RESOLVED FIXED Bug 169547
REGRESSION (r213764): Background image from sprite sheet incorrectly scaled
https://bugs.webkit.org/show_bug.cgi?id=169547
Summary REGRESSION (r213764): Background image from sprite sheet incorrectly scaled
Jamie White
Reported 2017-03-13 03:04:05 PDT
Created attachment 304246 [details] Minimal HTML demonstrating the bug The reproduction is extracted from Slack, which uses a large sprite sheet for its emojis. On the current nightly, the sprites in question appear to be scaled much larger than is intended. To demonstrate the effect: load the sample page and resize the browser window.
Attachments
Minimal HTML demonstrating the bug (284 bytes, text/html)
2017-03-13 03:04 PDT, Jamie White
no flags
Demo video (45.97 KB, image/gif)
2017-03-13 03:04 PDT, Jamie White
no flags
Patch (19.66 KB, patch)
2017-03-13 14:27 PDT, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews116 for mac-elcapitan (1.80 MB, application/zip)
2017-03-13 15:49 PDT, Build Bot
no flags
Archive of layout-test-results from ews103 for mac-elcapitan (1.09 MB, application/zip)
2017-03-13 16:06 PDT, Build Bot
no flags
Patch (19.65 KB, patch)
2017-03-13 16:49 PDT, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews113 for mac-elcapitan (1.62 MB, application/zip)
2017-03-13 17:57 PDT, Build Bot
no flags
Archive of layout-test-results from ews102 for mac-elcapitan (911.90 KB, application/zip)
2017-03-13 18:05 PDT, Build Bot
no flags
Patch (15.80 KB, patch)
2017-03-14 09:42 PDT, Said Abou-Hallawa
no flags
Patch (15.87 KB, patch)
2017-03-14 10:51 PDT, Said Abou-Hallawa
no flags
Patch (15.87 KB, patch)
2017-03-14 11:23 PDT, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews101 for mac-elcapitan (753.67 KB, application/zip)
2017-03-14 12:37 PDT, Build Bot
no flags
Archive of layout-test-results from ews116 for mac-elcapitan (1.67 MB, application/zip)
2017-03-14 17:05 PDT, Build Bot
no flags
Patch (16.27 KB, patch)
2017-03-14 22:14 PDT, Said Abou-Hallawa
no flags
Patch (16.73 KB, patch)
2017-03-14 23:11 PDT, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews101 for mac-elcapitan (970.94 KB, application/zip)
2017-03-15 00:26 PDT, Build Bot
no flags
Archive of layout-test-results from ews114 for mac-elcapitan (1.67 MB, application/zip)
2017-03-15 00:34 PDT, Build Bot
no flags
Patch (12.78 KB, patch)
2017-03-15 08:44 PDT, Said Abou-Hallawa
no flags
Patch (19.14 KB, patch)
2017-03-28 15:25 PDT, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews100 for mac-elcapitan (989.93 KB, application/zip)
2017-03-28 16:41 PDT, Build Bot
no flags
Patch (21.06 KB, patch)
2017-03-28 16:42 PDT, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews115 for mac-elcapitan (1.80 MB, application/zip)
2017-03-28 18:14 PDT, Build Bot
no flags
Archive of layout-test-results from ews102 for mac-elcapitan (929.12 KB, application/zip)
2017-03-28 18:17 PDT, Build Bot
no flags
Archive of layout-test-results from ews122 for ios-simulator-wk2 (1.03 MB, application/zip)
2017-03-28 18:39 PDT, Build Bot
no flags
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 (1.03 MB, application/zip)
2017-03-28 18:45 PDT, Build Bot
no flags
Patch (25.63 KB, patch)
2017-03-29 10:17 PDT, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 (1000.96 KB, application/zip)
2017-03-29 11:25 PDT, Build Bot
no flags
Patch (25.62 KB, patch)
2017-03-29 11:31 PDT, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews117 for mac-elcapitan (1.85 MB, application/zip)
2017-03-29 12:51 PDT, Build Bot
no flags
Archive of layout-test-results from ews100 for mac-elcapitan (1.04 MB, application/zip)
2017-03-29 12:51 PDT, Build Bot
no flags
Patch (26.46 KB, patch)
2017-03-29 13:14 PDT, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews102 for mac-elcapitan (1.04 MB, application/zip)
2017-03-29 14:09 PDT, Build Bot
no flags
Archive of layout-test-results from ews113 for mac-elcapitan (1.90 MB, application/zip)
2017-03-29 14:21 PDT, Build Bot
no flags
Patch (27.78 KB, patch)
2017-03-29 14:47 PDT, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews126 for ios-simulator-wk2 (2.69 MB, application/zip)
2017-03-29 16:16 PDT, Build Bot
no flags
Patch (29.27 KB, patch)
2017-03-29 18:08 PDT, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews102 for mac-elcapitan (1.16 MB, application/zip)
2017-03-29 19:19 PDT, Build Bot
no flags
Archive of layout-test-results from ews115 for mac-elcapitan (1.84 MB, application/zip)
2017-03-29 19:26 PDT, Build Bot
no flags
Patch (31.79 KB, patch)
2017-03-30 12:03 PDT, Said Abou-Hallawa
no flags
Patch (31.91 KB, patch)
2017-03-30 14:57 PDT, Said Abou-Hallawa
no flags
Jamie White
Comment 1 2017-03-13 03:04:48 PDT
Created attachment 304247 [details] Demo video
Radar WebKit Bug Importer
Comment 2 2017-03-13 09:39:09 PDT
Said Abou-Hallawa
Comment 3 2017-03-13 14:27:13 PDT
Said Abou-Hallawa
Comment 4 2017-03-13 14:27:47 PDT
Comment on attachment 304302 [details] Patch This patch is for EWS.
Build Bot
Comment 5 2017-03-13 15:49:45 PDT
Comment on attachment 304302 [details] Patch Attachment 304302 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/3310670 New failing tests: fast/images/sprite-sheet-image-draw.html
Build Bot
Comment 6 2017-03-13 15:49:48 PDT
Created attachment 304315 [details] Archive of layout-test-results from ews116 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews116 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 7 2017-03-13 16:06:07 PDT
Comment on attachment 304302 [details] Patch Attachment 304302 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/3310856 New failing tests: fast/images/sprite-sheet-image-draw.html
Build Bot
Comment 8 2017-03-13 16:06:11 PDT
Created attachment 304316 [details] Archive of layout-test-results from ews103 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews103 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Said Abou-Hallawa
Comment 9 2017-03-13 16:49:31 PDT
Build Bot
Comment 10 2017-03-13 17:57:18 PDT
Comment on attachment 304324 [details] Patch Attachment 304324 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/3311648 New failing tests: fast/images/sprite-sheet-image-draw.html
Build Bot
Comment 11 2017-03-13 17:57:22 PDT
Created attachment 304326 [details] Archive of layout-test-results from ews113 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews113 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 12 2017-03-13 18:05:29 PDT
Comment on attachment 304324 [details] Patch Attachment 304324 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/3311784 New failing tests: fast/images/sprite-sheet-image-draw.html
Build Bot
Comment 13 2017-03-13 18:05:33 PDT
Created attachment 304328 [details] Archive of layout-test-results from ews102 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews102 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Said Abou-Hallawa
Comment 14 2017-03-14 09:42:21 PDT
Said Abou-Hallawa
Comment 15 2017-03-14 10:51:39 PDT
Said Abou-Hallawa
Comment 16 2017-03-14 11:23:13 PDT
Build Bot
Comment 17 2017-03-14 12:37:22 PDT
Comment on attachment 304400 [details] Patch Attachment 304400 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/3322956 New failing tests: fast/images/sprite-sheet-image-draw.html
Build Bot
Comment 18 2017-03-14 12:37:28 PDT
Created attachment 304413 [details] Archive of layout-test-results from ews101 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 19 2017-03-14 17:04:55 PDT
Comment on attachment 304400 [details] Patch Attachment 304400 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/3324962 New failing tests: fast/images/sprite-sheet-image-draw.html
Build Bot
Comment 20 2017-03-14 17:05:00 PDT
Created attachment 304446 [details] Archive of layout-test-results from ews116 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews116 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Said Abou-Hallawa
Comment 21 2017-03-14 22:14:34 PDT
Said Abou-Hallawa
Comment 22 2017-03-14 23:11:48 PDT
Build Bot
Comment 23 2017-03-15 00:26:19 PDT
Comment on attachment 304479 [details] Patch Attachment 304479 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/3327922 New failing tests: fast/images/sprite-sheet-image-draw.html
Build Bot
Comment 24 2017-03-15 00:26:24 PDT
Created attachment 304484 [details] Archive of layout-test-results from ews101 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 25 2017-03-15 00:34:16 PDT
Comment on attachment 304479 [details] Patch Attachment 304479 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/3327909 New failing tests: fast/images/sprite-sheet-image-draw.html
Build Bot
Comment 26 2017-03-15 00:34:21 PDT
Created attachment 304485 [details] Archive of layout-test-results from ews114 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews114 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Said Abou-Hallawa
Comment 27 2017-03-15 08:44:25 PDT
Said Abou-Hallawa
Comment 28 2017-03-15 08:48:44 PDT
I gave up adding a test to this patch. The test runs all the times locally even with --repeat-each=100. But it's never passed on the mac bots. The bots refused to show the image when it is included as an <img> element or as a css background-image.
Said Abou-Hallawa
Comment 29 2017-03-16 12:11:58 PDT
Comment on attachment 304503 [details] Patch The tests may not be showing the images because of https://bugs.webkit.org/show_bug.cgi?id=169771.
Said Abou-Hallawa
Comment 30 2017-03-28 15:25:55 PDT
Simon Fraser (smfr)
Comment 31 2017-03-28 15:34:25 PDT
Comment on attachment 305651 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=305651&action=review > LayoutTests/fast/images/sprite-sheet-image-draw.html:19 > + }, 50); Are you racing with image decode? This could be flakey on the bots.
Build Bot
Comment 32 2017-03-28 16:41:44 PDT
Comment on attachment 305651 [details] Patch Attachment 305651 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/3429832 New failing tests: fast/images/sprite-sheet-image-draw.html fast/images/async-image-background-image.html
Build Bot
Comment 33 2017-03-28 16:41:48 PDT
Created attachment 305667 [details] Archive of layout-test-results from ews100 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews100 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Said Abou-Hallawa
Comment 34 2017-03-28 16:42:38 PDT
Build Bot
Comment 35 2017-03-28 18:14:04 PDT
Comment on attachment 305668 [details] Patch Attachment 305668 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/3430402 New failing tests: fast/images/sprite-sheet-image-draw.html fast/images/async-image-background-image.html
Build Bot
Comment 36 2017-03-28 18:14:08 PDT
Created attachment 305687 [details] Archive of layout-test-results from ews115 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews115 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 37 2017-03-28 18:17:44 PDT
Comment on attachment 305668 [details] Patch Attachment 305668 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/3430473 New failing tests: fast/images/sprite-sheet-image-draw.html fast/images/async-image-background-image.html
Build Bot
Comment 38 2017-03-28 18:17:47 PDT
Created attachment 305689 [details] Archive of layout-test-results from ews102 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews102 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 39 2017-03-28 18:39:38 PDT
Comment on attachment 305668 [details] Patch Attachment 305668 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/3430420 New failing tests: fast/images/sprite-sheet-image-draw.html
Build Bot
Comment 40 2017-03-28 18:39:41 PDT
Created attachment 305691 [details] Archive of layout-test-results from ews122 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews122 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Build Bot
Comment 41 2017-03-28 18:45:56 PDT
Comment on attachment 305668 [details] Patch Attachment 305668 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/3430594 New failing tests: fast/images/sprite-sheet-image-draw.html
Build Bot
Comment 42 2017-03-28 18:45:59 PDT
Created attachment 305693 [details] Archive of layout-test-results from ews104 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Said Abou-Hallawa
Comment 43 2017-03-29 10:17:40 PDT
Build Bot
Comment 44 2017-03-29 11:25:33 PDT
Comment on attachment 305754 [details] Patch Attachment 305754 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/3434740 New failing tests: fast/images/sprite-sheet-image-draw.html
Build Bot
Comment 45 2017-03-29 11:25:37 PDT
Created attachment 305761 [details] Archive of layout-test-results from ews104 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Said Abou-Hallawa
Comment 46 2017-03-29 11:31:44 PDT
Build Bot
Comment 47 2017-03-29 12:51:08 PDT
Comment on attachment 305764 [details] Patch Attachment 305764 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/3435105 New failing tests: fast/images/sprite-sheet-image-draw.html fast/images/async-image-background-image.html
Build Bot
Comment 48 2017-03-29 12:51:11 PDT
Created attachment 305772 [details] Archive of layout-test-results from ews117 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews117 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 49 2017-03-29 12:51:48 PDT
Comment on attachment 305764 [details] Patch Attachment 305764 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/3435135 New failing tests: fast/images/sprite-sheet-image-draw.html fast/images/async-image-background-image.html
Build Bot
Comment 50 2017-03-29 12:51:52 PDT
Created attachment 305773 [details] Archive of layout-test-results from ews100 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews100 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Said Abou-Hallawa
Comment 51 2017-03-29 13:14:33 PDT
Build Bot
Comment 52 2017-03-29 14:09:43 PDT
Comment on attachment 305775 [details] Patch Attachment 305775 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/3435536 New failing tests: fast/images/sprite-sheet-image-draw.html fast/images/async-image-background-image.html
Build Bot
Comment 53 2017-03-29 14:09:47 PDT
Created attachment 305784 [details] Archive of layout-test-results from ews102 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews102 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 54 2017-03-29 14:21:41 PDT
Comment on attachment 305775 [details] Patch Attachment 305775 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/3435558 New failing tests: fast/images/sprite-sheet-image-draw.html fast/images/async-image-background-image.html
Build Bot
Comment 55 2017-03-29 14:21:44 PDT
Created attachment 305789 [details] Archive of layout-test-results from ews113 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews113 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Said Abou-Hallawa
Comment 56 2017-03-29 14:47:06 PDT
Build Bot
Comment 57 2017-03-29 16:16:54 PDT
Comment on attachment 305796 [details] Patch Attachment 305796 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/3436145 New failing tests: fast/images/sprite-sheet-image-draw.html
Build Bot
Comment 58 2017-03-29 16:16:58 PDT
Created attachment 305804 [details] Archive of layout-test-results from ews126 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews126 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Said Abou-Hallawa
Comment 59 2017-03-29 18:08:19 PDT
Build Bot
Comment 60 2017-03-29 19:18:55 PDT
Comment on attachment 305818 [details] Patch Attachment 305818 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/3437057 New failing tests: fast/images/sprite-sheet-image-draw.html fast/images/async-image-background-image.html
Build Bot
Comment 61 2017-03-29 19:19:00 PDT
Created attachment 305821 [details] Archive of layout-test-results from ews102 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews102 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 62 2017-03-29 19:26:45 PDT
Comment on attachment 305818 [details] Patch Attachment 305818 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/3437055 New failing tests: fast/images/sprite-sheet-image-draw.html fast/images/async-image-background-image.html
Build Bot
Comment 63 2017-03-29 19:26:50 PDT
Created attachment 305822 [details] Archive of layout-test-results from ews115 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews115 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Said Abou-Hallawa
Comment 64 2017-03-30 12:03:31 PDT
Said Abou-Hallawa
Comment 65 2017-03-30 12:22:02 PDT
There were three issues with the test: 1. There was a bug in the code. BitmapImage::stopAnimation() was stopping the decoding thread for all images. This is not needed for large images since the decoding thread will stop automatically once the frame is decoded. The fix is to make BitmapImage::stopAnimation() stops the decoding thread for the animated images only. 2. There was a problem with the test when running it on 2x display. The width of the <div> element was created with the same width as the background image. But on 2x display, the number of pixels of the <div> element are doubled for each dimension. And this was causing the image to be resized and the pixels on the edges get blurred. The solution was use @media css rules for the 2x display. 3. In the test I using document.body.offsetHeight to force redraw. It turns out this is not sufficient since offsetHeight is now optimized such that it won't cause layout/redraw unless the element is dirty. The fix was to change the element properties temporarily, call offsetHeight and then reset the element properties back.
Simon Fraser (smfr)
Comment 66 2017-03-30 13:34:01 PDT
Comment on attachment 305870 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=305870&action=review > Source/WebCore/ChangeLog:15 > + To fix this issue, we must use the size of the image and not destRect.size(). You say "size of the image", but the srcRect parameter to nativeImageDrawingScale() isn't necessarily the bounds of the whole image. We may be drawing a subsection of the image. > Source/WebCore/platform/graphics/cg/NativeImageCG.cpp:83 > -float subsamplingScale(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect) > +FloatSize nativeImageDrawingScale(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect) > { > // Never use subsampled images for drawing into PDF contexts. > if (wkCGContextIsPDFContext(context.platformContext())) > - return 1; > + return { 1, 1 }; > > CGRect transformedDestinationRect = CGRectApplyAffineTransform(destRect, CGContextGetCTM(context.platformContext())); > - return std::min<float>(1, std::max(transformedDestinationRect.size.width / srcRect.width(), transformedDestinationRect.size.height / srcRect.height())); > + return { static_cast<float>(transformedDestinationRect.size.width / srcRect.width()), static_cast<float>(transformedDestinationRect.size.height / srcRect.height()) }; It's weird to have this bare function for each platform, but it's mostly cross platform code (you can call getCTM on the GraphicsContext). This should become a function on maybe GraphicsContext at some point.
Said Abou-Hallawa
Comment 67 2017-03-30 14:00:44 PDT
*** Bug 169574 has been marked as a duplicate of this bug. ***
Said Abou-Hallawa
Comment 68 2017-03-30 14:57:35 PDT
Said Abou-Hallawa
Comment 69 2017-03-30 15:00:54 PDT
(In reply to Simon Fraser (smfr) from comment #66) > Comment on attachment 305870 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=305870&action=review > > > Source/WebCore/ChangeLog:15 > > + To fix this issue, we must use the size of the image and not destRect.size(). > > You say "size of the image", but the srcRect parameter to > nativeImageDrawingScale() isn't necessarily the bounds of the whole image. > We may be drawing a subsection of the image. > I changed the ChangeLog to include the following description for the fix: To fix this issue, first the base size has to be size of the image and not destRect.size(). Secondly, we need to scale this base size with the context transformation multiplied by the ratio destRect / srcRect. This scaling is exactly the same scaling which is calculated in subsamplingScale(). Finally we use this scaled size as the sizeForDrawing to send to the ImageDecoder. > > Source/WebCore/platform/graphics/cg/NativeImageCG.cpp:83 > > -float subsamplingScale(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect) > > +FloatSize nativeImageDrawingScale(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect) > > { > > // Never use subsampled images for drawing into PDF contexts. > > if (wkCGContextIsPDFContext(context.platformContext())) > > - return 1; > > + return { 1, 1 }; > > > > CGRect transformedDestinationRect = CGRectApplyAffineTransform(destRect, CGContextGetCTM(context.platformContext())); > > - return std::min<float>(1, std::max(transformedDestinationRect.size.width / srcRect.width(), transformedDestinationRect.size.height / srcRect.height())); > > + return { static_cast<float>(transformedDestinationRect.size.width / srcRect.width()), static_cast<float>(transformedDestinationRect.size.height / srcRect.height()) }; > > It's weird to have this bare function for each platform, but it's mostly > cross platform code (you can call getCTM on the GraphicsContext). This > should become a function on maybe GraphicsContext at some point. Will do.
WebKit Commit Bot
Comment 70 2017-03-30 15:41:17 PDT
Comment on attachment 305910 [details] Patch Clearing flags on attachment: 305910 Committed r214635: <http://trac.webkit.org/changeset/214635>
WebKit Commit Bot
Comment 71 2017-03-30 15:41:20 PDT
All reviewed patches have been landed. Closing bug.
Said Abou-Hallawa
Comment 72 2017-03-31 12:26:04 PDT
I logged https://bugs.webkit.org/show_bug.cgi?id=170353 to track making nativeImageDrawingScale() a cross platform function.
Note You need to log in before you can comment on or make changes to this bug.