Chromium Code Reviews| 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") |