RESOLVED FIXED 48738
GraphicsContext: Don't do full save/restore when painting with low quality scaling
https://bugs.webkit.org/show_bug.cgi?id=48738
Summary GraphicsContext: Don't do full save/restore when painting with low quality sc...
Andreas Kling
Reported Sunday, October 31, 2010 10:00:31 PM UTC
When "useLowQualityScale" is true, GraphicsContext will currently save() and restore() in drawImage(), drawTiledImage() and drawImageBuffer(). This is unnecessary, we can just remember the current imageInterpolationQuality() and reset it after drawing.
Attachments
Proposed patch (4.17 KB, patch)
2010-10-31 14:08 PDT, Andreas Kling
no flags
Proposed patch v2 (6.55 KB, patch)
2010-11-01 06:13 PDT, Andreas Kling
no flags
Proposed patch v3 (7.10 KB, patch)
2010-11-04 07:18 PDT, Andreas Kling
zimmermann: review+
Andreas Kling
Comment 1 Sunday, October 31, 2010 10:08:48 PM UTC
Created attachment 72477 [details] Proposed patch
WebKit Review Bot
Comment 2 Sunday, October 31, 2010 10:11:18 PM UTC
Attachment 72477 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1 WebCore/platform/graphics/GraphicsContext.cpp:406: More than one command on the same line [whitespace/newline] [4] WebCore/platform/graphics/GraphicsContext.cpp:418: More than one command on the same line [whitespace/newline] [4] WebCore/platform/graphics/GraphicsContext.cpp:431: More than one command on the same line [whitespace/newline] [4] WebCore/platform/graphics/GraphicsContext.cpp:483: More than one command on the same line [whitespace/newline] [4] Total errors found: 4 in 2 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Review Bot
Comment 3 Sunday, October 31, 2010 11:09:03 PM UTC
Andreas Kling
Comment 4 Monday, November 1, 2010 1:16:39 PM UTC
Comment on attachment 72477 [details] Proposed patch This'll need some cleaning.
Andreas Kling
Comment 5 Monday, November 1, 2010 2:13:50 PM UTC
Created attachment 72500 [details] Proposed patch v2 Add missing GraphicsContext::imageInterpolationQuality() implementations to Skia, Haiku and WinCE. Also avoid the call to imageInterpolationQuality() if !useLowQualityScale.
Nikolas Zimmermann
Comment 6 Thursday, November 4, 2010 2:00:30 PM UTC
Comment on attachment 72500 [details] Proposed patch v2 View in context: https://bugs.webkit.org/attachment.cgi?id=72500&action=review > WebCore/platform/graphics/GraphicsContext.cpp:415 > + InterpolationQuality previousInterpolationQuality = InterpolationDefault; > if (useLowQualityScale) { > - save(); > + previousInterpolationQuality = imageInterpolationQuality(); > setImageInterpolationQuality(InterpolationNone); > } > + > image->draw(this, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), styleColorSpace, op); > + > if (useLowQualityScale) > - restore(); > + setImageInterpolationQuality(previousInterpolationQuality); Hm, I think we could do better, and avoid the temporary variable, if !useLowQualityScale is used: if (useLowQualityScale) { InterpolationQuality previousInterpolationQuality = imageInterpolationQuality(); setImageInterpolationQuality(InterpolationLow); // NOTE: The InterpolationNone looks wrong to me. image->draw(this, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), styleColorSpace, op); setImageInterpolationQuality(previousInterpolationQuality); } else image->draw(this, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), styleColorSpace, op); etc. What do you think?
Andreas Kling
Comment 7 Thursday, November 4, 2010 3:18:13 PM UTC
Created attachment 72938 [details] Proposed patch v3 Updated wrt Niko's suggestion.
Nikolas Zimmermann
Comment 8 Thursday, November 4, 2010 3:46:49 PM UTC
Comment on attachment 72938 [details] Proposed patch v3 View in context: https://bugs.webkit.org/attachment.cgi?id=72938&action=review > WebCore/platform/graphics/GraphicsContext.cpp:408 > setImageInterpolationQuality(InterpolationNone); Please add a FIXME here, that None is wrong.
Andreas Kling
Comment 9 Thursday, November 4, 2010 4:48:33 PM UTC
Note You need to log in before you can comment on or make changes to this bug.