Bug 48738

Summary: GraphicsContext: Don't do full save/restore when painting with low quality scaling
Product: WebKit Reporter: Andreas Kling <kling>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: dglazkov, webkit.review.bot
Priority: P2 Keywords: Performance
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Proposed patch
none
Proposed patch v2
none
Proposed patch v3 zimmermann: review+

Andreas Kling
Reported 2010-10-31 14:00:31 PDT
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 2010-10-31 14:08:48 PDT
Created attachment 72477 [details] Proposed patch
WebKit Review Bot
Comment 2 2010-10-31 14:11:18 PDT
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 2010-10-31 15:09:03 PDT
Andreas Kling
Comment 4 2010-11-01 05:16:39 PDT
Comment on attachment 72477 [details] Proposed patch This'll need some cleaning.
Andreas Kling
Comment 5 2010-11-01 06:13:50 PDT
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 2010-11-04 06:00:30 PDT
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 2010-11-04 07:18:13 PDT
Created attachment 72938 [details] Proposed patch v3 Updated wrt Niko's suggestion.
Nikolas Zimmermann
Comment 8 2010-11-04 07:46:49 PDT
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 2010-11-04 08:48:33 PDT
Note You need to log in before you can comment on or make changes to this bug.