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

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

Issue 2438313002: Fixing color bleeding when the canvas is stretched. (Closed)
Patch Set: Addressing the color bleeding issue. 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 | « no previous file | 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..b87d3fb7f4ac373d4b0e7cb4fb155d772443c00d 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -323,12 +323,22 @@ 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 (FloatRect(ro->contentBoxRect()).contains(srcRect) &&
Justin Novosad 2016/10/21 15:56:03 "Contains" is not the right condition to determine
+ srcRect != FloatRect(ro->contentBoxRect())) {
+ m_dirtyRect.expand(FloatSize(0.5, 0.5));
Justin Novosad 2016/10/21 15:56:03 You should use inflate here.
+ m_dirtyRect.move(FloatSize(-0.25, -0.25));
+ }
+
+ m_dirtyRect.intersect(srcRect);
LayoutRect mappedDirtyRect(enclosingIntRect(
mapRect(m_dirtyRect, srcRect, FloatRect(ro->contentBoxRect()))));
// For querying PaintLayer::compositingState()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698