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

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

Issue 2797543002: Fix unreliable MediaStream capture from WebGL canvases (Closed)
Patch Set: Created 3 years, 9 months 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/Source/core/html/HTMLCanvasElement.h ('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 63e6b6c1df0643300ef89950c14a23c6eba6add2..9c4e8a87ee3540c3c94eac9c1f67d86038472f71 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;
}
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());
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLCanvasElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698