Chromium Code Reviews| 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..d5d72e45859db3c36798d19e70f7023919c78a1c 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
| @@ -262,6 +262,16 @@ 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. |
|
Stephen White
2016/12/07 22:27:48
Nit: join this line with previous.
|
| + didDraw(FloatRect(0, 0, size().width(), size().height())); |
| + } |
| + |
| setNeedsCompositingUpdate(); |
| return m_context.get(); |
| @@ -338,7 +348,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 +393,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 +405,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()); |