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 413841dd2ab3079a3dab294718cf741890dad911..355af9166312627ab05f91701b37b7ad17fb0d44 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
| @@ -329,7 +329,17 @@ void HTMLCanvasElement::didDraw(const FloatRect& rect) { |
| void HTMLCanvasElement::finalizeFrame() { |
| if (hasImageBuffer()) |
| m_imageBuffer->finalizeFrame(); |
| - notifyListenersCanvasChanged(); |
| + |
| + // If the canvas is visible, notifying listeners is taken |
| + // care of in the in doDeferredPaintInvalidation, which allows |
| + // the frame to be grabbed prior to compositing, which is |
| + // critically important because compositing may clear the canvas's |
| + // image. (e.g. WebGL context with preserveDrawingBuffer=false). |
| + // If the canvas is not visible, doDeferredPaintInvalidation |
| + // will not get called, so we need to take care of business here. |
| + if (!m_didNotifyListenersForCurrentFrame) |
| + notifyListenersCanvasChanged(); |
| + m_didNotifyListenersForCurrentFrame = false; |
|
xlai (Olivia)
2017/03/22 17:06:21
I'm thinking of a scenario when the canvas is visi
|
| } |
| void HTMLCanvasElement::didDisableAcceleration() { |
| @@ -371,6 +381,9 @@ void HTMLCanvasElement::doDeferredPaintInvalidation() { |
| if (m_dirtyRect.isEmpty()) |
| return; |
| + notifyListenersCanvasChanged(); |
| + m_didNotifyListenersForCurrentFrame = true; |
| + |
| // 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()); |