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

Unified Diff: third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.cpp

Issue 2653933003: Make stream captures work on canvases that are not in the DOM. (Closed)
Patch Set: Created 3 years, 11 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
Index: third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.cpp
diff --git a/third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.cpp b/third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.cpp
index 2ddfe27b909e4759d15e29fcb0e0e4f3733a9a88..0ff852d8634d8ba61173c0e18c5e2b6bac6fad1b 100644
--- a/third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.cpp
+++ b/third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.cpp
@@ -29,6 +29,7 @@
#include "core/html/canvas/CanvasImageSource.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/weborigin/SecurityOrigin.h"
+#include "public/platform/Platform.h"
const char* const kLinearRGBCanvasColorSpaceName = "linear-rgb";
const char* const kSRGBCanvasColorSpaceName = "srgb";
@@ -108,6 +109,10 @@ SkColorType CanvasRenderingContext::colorType() const {
}
void CanvasRenderingContext::dispose() {
+ if (m_finalizeFrameScheduled) {
+ Platform::current()->currentThread()->removeTaskObserver(this);
+ }
+
// HTMLCanvasElement and CanvasRenderingContext have a circular reference.
// When the pair is no longer reachable, their destruction order is non-
// deterministic, so the first of the two to be destroyed needs to notify
@@ -124,6 +129,24 @@ void CanvasRenderingContext::dispose() {
}
}
+void CanvasRenderingContext::didDraw(const SkIRect& dirtyRect) {
+ canvas()->didDraw(SkRect::Make(dirtyRect));
+ if (!m_finalizeFrameScheduled) {
+ m_finalizeFrameScheduled = true;
+ Platform::current()->currentThread()->addTaskObserver(this);
+ }
+}
+
+void CanvasRenderingContext::didProcessTask() {
+ Platform::current()->currentThread()->removeTaskObserver(this);
+ m_finalizeFrameScheduled = false;
+
+ if (!canvas())
+ return;
+
+ canvas()->finalizeFrame();
xlai (Olivia) 2017/01/27 22:23:25 Can you add a comment here explaining why you call
Justin Novosad 2017/02/07 21:52:29 Done.
+}
+
CanvasRenderingContext::ContextType CanvasRenderingContext::contextTypeFromId(
const String& id) {
if (id == "2d")

Powered by Google App Engine
This is Rietveld 408576698