Bug 227614 - [CG] REGRESSION(r278863): The destination rectangle is truncated when the sub-image is used
Summary: [CG] REGRESSION(r278863): The destination rectangle is truncated when the sub...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-07-02 02:39 PDT by Said Abou-Hallawa
Modified: 2021-07-13 12:38 PDT (History)
3 users (show)

See Also:


Attachments
Patch (1.83 KB, patch)
2021-07-02 02:41 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (2.12 KB, patch)
2021-07-02 15:06 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (6.58 KB, patch)
2021-07-06 15:01 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (10.83 KB, patch)
2021-07-07 14:14 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (5.76 KB, patch)
2021-07-13 00:37 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2021-07-02 02:39:14 PDT
This was overlooked when GraphicsContextCG::drawNativeImage() was re-factored in r278863.
Comment 1 Said Abou-Hallawa 2021-07-02 02:40:38 PDT
<rdar://79840643>
Comment 2 Said Abou-Hallawa 2021-07-02 02:41:06 PDT
Created attachment 432773 [details]
Patch
Comment 3 Said Abou-Hallawa 2021-07-02 15:06:37 PDT
Created attachment 432827 [details]
Patch
Comment 4 Simon Fraser (smfr) 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?
Comment 5 Said Abou-Hallawa 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.
Comment 6 Simon Fraser (smfr) 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.
Comment 7 Said Abou-Hallawa 2021-07-06 15:01:12 PDT
Created attachment 432978 [details]
Patch
Comment 8 Said Abou-Hallawa 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.
Comment 9 Said Abou-Hallawa 2021-07-06 15:13:55 PDT
I think this bug is related to bug 225377
Comment 10 Said Abou-Hallawa 2021-07-07 14:14:41 PDT
Created attachment 433074 [details]
Patch
Comment 11 Said Abou-Hallawa 2021-07-13 00:37:45 PDT
Created attachment 433394 [details]
Patch
Comment 12 Simon Fraser (smfr) 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).
Comment 13 EWS 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].