| 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());
|
|
|