Bug 227614

Summary: [CG] REGRESSION(r278863): The destination rectangle is truncated when the sub-image is used
Product: WebKit Reporter: Said Abou-Hallawa <sabouhallawa>
Component: ImagesAssignee: 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 Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Said Abou-Hallawa
Reported 2021-07-02 02:39:14 PDT
This was overlooked when GraphicsContextCG::drawNativeImage() was re-factored in r278863.
Attachments
Patch (1.83 KB, patch)
2021-07-02 02:41 PDT, Said Abou-Hallawa
no flags
Patch (2.12 KB, patch)
2021-07-02 15:06 PDT, Said Abou-Hallawa
no flags
Patch (6.58 KB, patch)
2021-07-06 15:01 PDT, Said Abou-Hallawa
no flags
Patch (10.83 KB, patch)
2021-07-07 14:14 PDT, Said Abou-Hallawa
no flags
Patch (5.76 KB, patch)
2021-07-13 00:37 PDT, Said Abou-Hallawa
no flags
Said Abou-Hallawa
Comment 1 2021-07-02 02:40:38 PDT
Said Abou-Hallawa
Comment 2 2021-07-02 02:41:06 PDT
Said Abou-Hallawa
Comment 3 2021-07-02 15:06:37 PDT
Simon Fraser (smfr)
Comment 4 2021-07-02 19:09:01 PDT
Comment on attachment 432827 [details] Patch If we are drawing the whole image why do we hit the subimage codepath?
Said Abou-Hallawa
Comment 5 2021-07-02 20:02:43 PDT
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.
Simon Fraser (smfr)
Comment 6 2021-07-06 09:36:23 PDT
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.
Said Abou-Hallawa
Comment 7 2021-07-06 15:01:12 PDT
Said Abou-Hallawa
Comment 8 2021-07-06 15:10:27 PDT
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.
Said Abou-Hallawa
Comment 9 2021-07-06 15:13:55 PDT
I think this bug is related to bug 225377
Said Abou-Hallawa
Comment 10 2021-07-07 14:14:41 PDT
Said Abou-Hallawa
Comment 11 2021-07-13 00:37:45 PDT
Simon Fraser (smfr)
Comment 12 2021-07-13 11:21:15 PDT
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).
EWS
Comment 13 2021-07-13 12:38:41 PDT
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].
Note You need to log in before you can comment on or make changes to this bug.