Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Unified Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2438313002: Fixing color bleeding when the canvas is stretched. (Closed)
Patch Set: Addressing comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/ManualTests/canvas-stretch-color-bleeding.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
index 2a5a8ff5939da3b58adbbd60f3f5670202277781..cf0428a28fbdfa2ecc6aee249390666a701c0299 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -323,12 +323,21 @@ void HTMLCanvasElement::didFinalizeFrame() {
// Propagate the m_dirtyRect accumulated so far to the compositor
// before restarting with a blank dirty rect.
FloatRect srcRect(0, 0, size().width(), size().height());
- m_dirtyRect.intersect(srcRect);
+
LayoutBox* ro = layoutBox();
// Canvas content updates do not need to be propagated as
// paint invalidations if the canvas is accelerated, since
// the canvas contents are sent separately through a texture layer.
if (ro && (!m_context || !m_context->isAccelerated())) {
+ // If ro->contentBoxRect() is larger than srcRect the canvas's image is
+ // being stretched, so we need to account for color bleeding caused by the
+ // interpollation filter.
+ if (ro->contentBoxRect().width() > srcRect.width() ||
+ ro->contentBoxRect().height() > srcRect.height()) {
+ m_dirtyRect.inflate(0.5);
+ }
+
+ m_dirtyRect.intersect(srcRect);
LayoutRect mappedDirtyRect(enclosingIntRect(
mapRect(m_dirtyRect, srcRect, FloatRect(ro->contentBoxRect()))));
// For querying PaintLayer::compositingState()
« no previous file with comments | « third_party/WebKit/ManualTests/canvas-stretch-color-bleeding.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698