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

Side by Side 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, 1 month 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 316
317 void HTMLCanvasElement::didFinalizeFrame() { 317 void HTMLCanvasElement::didFinalizeFrame() {
318 notifyListenersCanvasChanged(); 318 notifyListenersCanvasChanged();
319 319
320 if (m_dirtyRect.isEmpty()) 320 if (m_dirtyRect.isEmpty())
321 return; 321 return;
322 322
323 // Propagate the m_dirtyRect accumulated so far to the compositor 323 // Propagate the m_dirtyRect accumulated so far to the compositor
324 // before restarting with a blank dirty rect. 324 // before restarting with a blank dirty rect.
325 FloatRect srcRect(0, 0, size().width(), size().height()); 325 FloatRect srcRect(0, 0, size().width(), size().height());
326 m_dirtyRect.intersect(srcRect); 326
327 LayoutBox* ro = layoutBox(); 327 LayoutBox* ro = layoutBox();
328 // Canvas content updates do not need to be propagated as 328 // Canvas content updates do not need to be propagated as
329 // paint invalidations if the canvas is accelerated, since 329 // paint invalidations if the canvas is accelerated, since
330 // the canvas contents are sent separately through a texture layer. 330 // the canvas contents are sent separately through a texture layer.
331 if (ro && (!m_context || !m_context->isAccelerated())) { 331 if (ro && (!m_context || !m_context->isAccelerated())) {
332 // If ro->contentBoxRect() is larger than srcRect the canvas's image is
333 // being stretched, so we need to account for color bleeding caused by the
334 // interpollation filter.
335 if (ro->contentBoxRect().width() > srcRect.width() ||
336 ro->contentBoxRect().height() > srcRect.height()) {
337 m_dirtyRect.expand(FloatSize(0.5, 0.5));
Justin Novosad 2016/10/24 17:53:10 Just use inflate
zakerinasab 2016/10/24 18:14:35 Done.
338 m_dirtyRect.move(FloatSize(-0.25, -0.25));
339 }
340
341 m_dirtyRect.intersect(srcRect);
332 LayoutRect mappedDirtyRect(enclosingIntRect( 342 LayoutRect mappedDirtyRect(enclosingIntRect(
333 mapRect(m_dirtyRect, srcRect, FloatRect(ro->contentBoxRect())))); 343 mapRect(m_dirtyRect, srcRect, FloatRect(ro->contentBoxRect()))));
334 // For querying PaintLayer::compositingState() 344 // For querying PaintLayer::compositingState()
335 // FIXME: is this invalidation using the correct compositing state? 345 // FIXME: is this invalidation using the correct compositing state?
336 DisableCompositingQueryAsserts disabler; 346 DisableCompositingQueryAsserts disabler;
337 ro->invalidatePaintRectangle(mappedDirtyRect); 347 ro->invalidatePaintRectangle(mappedDirtyRect);
338 } 348 }
339 m_dirtyRect = FloatRect(); 349 m_dirtyRect = FloatRect();
340 350
341 m_numFramesSinceLastRenderingModeSwitch++; 351 m_numFramesSinceLastRenderingModeSwitch++;
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 mojom::blink::OffscreenCanvasSurfacePtr service; 1355 mojom::blink::OffscreenCanvasSurfacePtr service;
1346 Platform::current()->interfaceProvider()->getInterface( 1356 Platform::current()->interfaceProvider()->getInterface(
1347 mojo::GetProxy(&service)); 1357 mojo::GetProxy(&service));
1348 m_surfaceLayerBridge = 1358 m_surfaceLayerBridge =
1349 wrapUnique(new CanvasSurfaceLayerBridge(std::move(service))); 1359 wrapUnique(new CanvasSurfaceLayerBridge(std::move(service)));
1350 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), 1360 return m_surfaceLayerBridge->createSurfaceLayer(this->width(),
1351 this->height()); 1361 this->height());
1352 } 1362 }
1353 1363
1354 } // namespace blink 1364 } // namespace blink
OLDNEW
« 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