Bug 45792 - Drawing an image outside the bounds of a canvas still causes repaints
Summary: Drawing an image outside the bounds of a canvas still causes repaints
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Simon Fraser (smfr)
URL: http://www.phoboslab.org/biolab/
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-14 17:34 PDT by Simon Fraser (smfr)
Modified: 2010-09-14 18:55 PDT (History)
1 user (show)

See Also:


Attachments
Patch (1.89 KB, patch)
2010-09-14 18:38 PDT, Simon Fraser (smfr)
oliver: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2010-09-14 17:34:31 PDT
http://www.phoboslab.org/biolab/ seems to draw all the tiles in the game on every frame, even ones that are far outside the bounds of the canvas. Stupidly, we still turn these into repaints.
Comment 1 Simon Fraser (smfr) 2010-09-14 18:11:13 PDT
diff --git a/WebCore/html/HTMLCanvasElement.cpp b/WebCore/html/HTMLCanvasElement.cpp
index 3838f14..6f46ab4 100644
--- a/WebCore/html/HTMLCanvasElement.cpp
+++ b/WebCore/html/HTMLCanvasElement.cpp
@@ -193,7 +193,7 @@ void HTMLCanvasElement::didDraw(const FloatRect& rect)
         FloatRect destRect = ro->contentBoxRect();
         FloatRect r = mapRect(rect, FloatRect(0, 0, size().width(), size().height()), destRect);
         r.intersect(destRect);
-        if (m_dirtyRect.contains(r))
+        if (r.isEmpty() || m_dirtyRect.contains(r))
             return;
 
         m_dirtyRect.unite(r);

I'll make some tests.
Comment 2 Simon Fraser (smfr) 2010-09-14 18:38:38 PDT
Created attachment 67630 [details]
Patch
Comment 3 Oliver Hunt 2010-09-14 18:46:07 PDT
Comment on attachment 67630 [details]
Patch

r=me
Comment 4 Simon Fraser (smfr) 2010-09-14 18:55:29 PDT
http://trac.webkit.org/changeset/67526