| Summary: | [CG] REGRESSION(r278863): The destination rectangle is truncated when the sub-image is used | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Said Abou-Hallawa <sabouhallawa> | ||||||||||||
| Component: | Images | Assignee: | Said Abou-Hallawa <sabouhallawa> | ||||||||||||
| Status: | RESOLVED FIXED | ||||||||||||||
| Severity: | Normal | CC: | simon.fraser, thorton, webkit-bug-importer | ||||||||||||
| Priority: | P2 | Keywords: | InRadar | ||||||||||||
| Version: | WebKit Nightly Build | ||||||||||||||
| Hardware: | Unspecified | ||||||||||||||
| OS: | Unspecified | ||||||||||||||
| See Also: |
https://bugs.webkit.org/show_bug.cgi?id=226916 https://bugs.webkit.org/show_bug.cgi?id=225377 |
||||||||||||||
| Attachments: |
|
||||||||||||||
|
Description
Said Abou-Hallawa
2021-07-02 02:39:14 PDT
Created attachment 432773 [details]
Patch
Created attachment 432827 [details]
Patch
Comment on attachment 432827 [details]
Patch
If we are drawing the whole image why do we hit the subimage codepath?
Consider the case of drawing the whole ImageBuffer through ImageBuffer::draw(). Assume this ImageBuffer has the following parameters:
logicalSize = { 392, 44 }
resolutionScale = 1.91326535
ImageBufferBackend::calculateBackendSize() gets the enclosing rectangle for the backend size:
backendSize = ceil(logicalSize * resolutionScale) = ceil({ 392 * 1.91326535, 44 * 1.91326535 }) = ceil({ 750, 84.1836754 }) = { 750, 85 }
The caller will pass the following arguments to ImageBuffer::draw():
destRect = { 0, 0, 392, 44 }
srcRect = { 0, 0, 392, 44 }
But ImageBufferCGBackend::draw() will pass the following arguments to GraphicsContextCG::drawNativeImage()
imageSize = { 750, 85 } // = backendSize
destRect = { 0, 0, 392, 44 }
srcRect = { 0, 0, 750, 84.1836754 } // = logicalSize * resolutionScale
The condition to use the subimage codepath is the following:
if (normalizedSrcRect != imageRect) // normalizedSrcRect is equal to srcRect in this case.
And this condition is true in this case because { 0, 0, 750, 84.1836754 } != { 0, 0, 750, 85 }
So yes in this case, we should not hit the subimage codepath. But I was trying to fix the regression and to put the calculation code back as it was before r278863.
Yes, my point was let's fix the rounding issues so we don't hit the subimage code path for every back buffer -> front buffer copy which will never benefit from the cache. Created attachment 432978 [details]
Patch
I fixed the issue of drawing the back ImageBuffer to the front ImageBuffer in RemoteLayerBackingStore::display(). Drawing the whole ImageBuffer should not go through the sub-image code path. But I had to adjust the calculation of the imageSize to match the logicalSize and the destRect to match the backendSize correctly. I think this bug is related to bug 225377 Created attachment 433074 [details]
Patch
Created attachment 433394 [details]
Patch
Comment on attachment 433394 [details] Patch Since this restores the behavior to shipping, r=me. However, we need to figure out how to avoid the sub image code path here (bug 227912). Committed r279885 (239637@main): <https://commits.webkit.org/239637@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 433394 [details]. |