 Chromium Code Reviews
 Chromium Code Reviews Issue 2594843002:
  Implementing promise-based commit for driving OffscreenCanvas animations  (Closed)
    
  
    Issue 2594843002:
  Implementing promise-based commit for driving OffscreenCanvas animations  (Closed) 
  | Index: third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.h | 
| diff --git a/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.h b/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.h | 
| index e3f175ad4e58cfa3b8be7c47300784bd4838327a..165a2ab39daba4968acebb3673d5847a08961808 100644 | 
| --- a/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.h | 
| +++ b/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.h | 
| @@ -26,14 +26,18 @@ class | 
| typedef OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext | 
| OffscreenRenderingContext; | 
| -class CORE_EXPORT OffscreenCanvas final : public EventTargetWithInlineData, | 
| - public CanvasImageSource, | 
| - public ImageBitmapSource { | 
| +class CORE_EXPORT OffscreenCanvas final | 
| + : public EventTargetWithInlineData, | 
| + public CanvasImageSource, | 
| + public ImageBitmapSource, | 
| + public OffscreenCanvasFrameDispatcherClient { | 
| DEFINE_WRAPPERTYPEINFO(); | 
| + USING_PRE_FINALIZER(OffscreenCanvas, dispose); | 
| public: | 
| static OffscreenCanvas* create(unsigned width, unsigned height); | 
| - ~OffscreenCanvas() override {} | 
| + ~OffscreenCanvas() override; | 
| + void dispose(); | 
| // IDL attributes | 
| unsigned width() const { return m_size.width(); } | 
| @@ -73,8 +77,6 @@ class CORE_EXPORT OffscreenCanvas final : public EventTargetWithInlineData, | 
| // TODO(crbug.com/630356): apply the flag to WebGL context as well | 
| void setDisableReadingFromCanvasTrue() { m_disableReadingFromCanvas = true; } | 
| - OffscreenCanvasFrameDispatcher* getOrCreateFrameDispatcher(); | 
| - | 
| void setFrameSinkId(uint32_t clientId, uint32_t sinkId) { | 
| m_clientId = clientId; | 
| m_sinkId = sinkId; | 
| @@ -86,6 +88,15 @@ class CORE_EXPORT OffscreenCanvas final : public EventTargetWithInlineData, | 
| m_executionContext = context; | 
| } | 
| + ScriptPromise commit(RefPtr<StaticBitmapImage>, | 
| + bool isWebGLSoftwareRendering, | 
| + ScriptState*); | 
| + | 
| + void detachContext() { m_context = nullptr; } | 
| + | 
| + // OffscreenCanvasFrameDispatcherClient implementation | 
| + void beginFrame() final; | 
| + | 
| // EventTarget implementation | 
| const AtomicString& interfaceName() const final { | 
| return EventTargetNames::OffscreenCanvas; | 
| @@ -121,7 +132,8 @@ class CORE_EXPORT OffscreenCanvas final : public EventTargetWithInlineData, | 
| private: | 
| explicit OffscreenCanvas(const IntSize&); | 
| - | 
| + OffscreenCanvasFrameDispatcher* getOrCreateFrameDispatcher(); | 
| + void doCommit(RefPtr<StaticBitmapImage>, bool isWebGLSoftwareRendering); | 
| using ContextFactoryVector = | 
| Vector<std::unique_ptr<CanvasRenderingContextFactory>>; | 
| static ContextFactoryVector& renderingContextFactories(); | 
| @@ -139,13 +151,16 @@ class CORE_EXPORT OffscreenCanvas final : public EventTargetWithInlineData, | 
| IntSize m_size; | 
| bool m_isNeutered = false; | 
| - bool m_originClean; | 
| + bool m_originClean = true; | 
| bool m_disableReadingFromCanvas = false; | 
| bool isPaintable() const; | 
| std::unique_ptr<OffscreenCanvasFrameDispatcher> m_frameDispatcher; | 
| // cc::FrameSinkId is broken into two integer components as this can be used | 
| 
xlai (Olivia)
2016/12/21 19:54:25
This comment for uint32_t m_clientId is broken int
 
Justin Novosad
2016/12/21 21:15:40
Oop. Bad rebase.  Done.
 | 
| + Member<ScriptPromiseResolver> m_commitPromiseResolver; | 
| + RefPtr<StaticBitmapImage> m_overdrawFrame; | 
| + bool m_overdrawFrameIsWebGLSoftwareRendering = false; | 
| // in transfer of OffscreenCanvas across threads | 
| // If this object is not created via | 
| // HTMLCanvasElement.transferControlToOffscreen(), |