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

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

Issue 2558973002: Add missing paint invalidation when creating canvas 2d context with no alpha (Closed)
Patch Set: senorblanco feedback Created 4 years 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/LayoutTests/fast/canvas/canvas-no-alpha-invalidation-expected.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 142aeed0e4480d3f0133ad2a143ae2408516d452..c97c3e0653c246d09c918d9fcd823ef065375433 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -262,6 +262,15 @@ CanvasRenderingContext* HTMLCanvasElement::getCanvasRenderingContext(
if (m_context->is3d()) {
updateExternallyAllocatedMemory();
}
+
+ LayoutObject* layoutObject = this->layoutObject();
+ if (layoutObject && m_context->is2d() &&
+ !m_context->creationAttributes().alpha()) {
+ // In the alpha false case, canvas is initially opaque even though there is
+ // no ImageBuffer, so we need to trigger an invalidation.
+ didDraw(FloatRect(0, 0, size().width(), size().height()));
+ }
+
setNeedsCompositingUpdate();
return m_context.get();
@@ -338,7 +347,7 @@ void HTMLCanvasElement::didFinalizeFrame() {
if (RuntimeEnabledFeatures::
enableCanvas2dDynamicRenderingModeSwitchingEnabled() &&
!RuntimeEnabledFeatures::canvas2dFixedRenderingModeEnabled()) {
- if (m_context->is2d() && buffer() && buffer()->isAccelerated() &&
+ if (m_context->is2d() && hasImageBuffer() && buffer()->isAccelerated() &&
m_numFramesSinceLastRenderingModeSwitch >=
ExpensiveCanvasHeuristicParameters::MinFramesBeforeSwitch &&
!m_pendingRenderingModeSwitch) {
@@ -383,10 +392,10 @@ void HTMLCanvasElement::doDeferredPaintInvalidation() {
if (!m_context->is2d()) {
didFinalizeFrame();
} else {
- DCHECK(hasImageBuffer());
FloatRect srcRect(0, 0, size().width(), size().height());
m_dirtyRect.intersect(srcRect);
LayoutBox* lb = layoutBox();
+ FloatRect invalidationRect;
if (lb) {
FloatRect mappedDirtyRect =
mapRect(m_dirtyRect, srcRect, FloatRect(lb->contentBoxRect()));
@@ -395,9 +404,14 @@ void HTMLCanvasElement::doDeferredPaintInvalidation() {
// to the content box, as opposed to the layout box.
mappedDirtyRect.move(-lb->contentBoxOffset());
}
- m_imageBuffer->finalizeFrame(mappedDirtyRect);
+ invalidationRect = mappedDirtyRect;
+ } else {
+ invalidationRect = m_dirtyRect;
+ }
+ if (hasImageBuffer()) {
+ m_imageBuffer->finalizeFrame(invalidationRect);
} else {
- m_imageBuffer->finalizeFrame(m_dirtyRect);
+ didFinalizeFrame();
}
}
DCHECK(m_dirtyRect.isEmpty());
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/canvas/canvas-no-alpha-invalidation-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698