| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef OffscreenCanvas_h | 5 #ifndef OffscreenCanvas_h |
| 6 #define OffscreenCanvas_h | 6 #define OffscreenCanvas_h |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "core/dom/DOMNodeIds.h" |
| 10 #include "core/events/EventTarget.h" | 11 #include "core/events/EventTarget.h" |
| 11 #include "core/html/HTMLCanvasElement.h" | 12 #include "core/html/HTMLCanvasElement.h" |
| 12 #include "core/html/canvas/CanvasImageSource.h" | 13 #include "core/html/canvas/CanvasImageSource.h" |
| 13 #include "core/html/canvas/CanvasRenderingContextHost.h" | 14 #include "core/html/canvas/CanvasRenderingContextHost.h" |
| 14 #include "core/imagebitmap/ImageBitmapSource.h" | 15 #include "core/imagebitmap/ImageBitmapSource.h" |
| 15 #include "core/offscreencanvas/ImageEncodeOptions.h" | 16 #include "core/offscreencanvas/ImageEncodeOptions.h" |
| 16 #include "platform/bindings/ScriptState.h" | 17 #include "platform/bindings/ScriptState.h" |
| 17 #include "platform/bindings/ScriptWrappable.h" | 18 #include "platform/bindings/ScriptWrappable.h" |
| 18 #include "platform/geometry/IntSize.h" | 19 #include "platform/geometry/IntSize.h" |
| 19 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h" | 20 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 53 |
| 53 // API Methods | 54 // API Methods |
| 54 ImageBitmap* transferToImageBitmap(ScriptState*, ExceptionState&); | 55 ImageBitmap* transferToImageBitmap(ScriptState*, ExceptionState&); |
| 55 ScriptPromise convertToBlob(ScriptState*, | 56 ScriptPromise convertToBlob(ScriptState*, |
| 56 const ImageEncodeOptions&, | 57 const ImageEncodeOptions&, |
| 57 ExceptionState&); | 58 ExceptionState&); |
| 58 | 59 |
| 59 const IntSize& Size() const override { return size_; } | 60 const IntSize& Size() const override { return size_; } |
| 60 void SetSize(const IntSize&); | 61 void SetSize(const IntSize&); |
| 61 | 62 |
| 62 void SetPlaceholderCanvasId(int canvas_id) { | 63 void SetPlaceholderCanvasId(DOMNodeId canvas_id) { |
| 63 placeholder_canvas_id_ = canvas_id; | 64 placeholder_canvas_id_ = canvas_id; |
| 64 } | 65 } |
| 65 int PlaceholderCanvasId() const { return placeholder_canvas_id_; } | 66 DOMNodeId PlaceholderCanvasId() const { return placeholder_canvas_id_; } |
| 66 bool HasPlaceholderCanvas() { | 67 bool HasPlaceholderCanvas() { |
| 67 return placeholder_canvas_id_ != kNoPlaceholderCanvas; | 68 return placeholder_canvas_id_ != kInvalidDOMNodeId; |
| 68 } | 69 } |
| 69 bool IsNeutered() const { return is_neutered_; } | 70 bool IsNeutered() const { return is_neutered_; } |
| 70 void SetNeutered(); | 71 void SetNeutered(); |
| 71 CanvasRenderingContext* GetCanvasRenderingContext( | 72 CanvasRenderingContext* GetCanvasRenderingContext( |
| 72 ScriptState*, | 73 ScriptState*, |
| 73 const String&, | 74 const String&, |
| 74 const CanvasContextCreationAttributes&); | 75 const CanvasContextCreationAttributes&); |
| 75 CanvasRenderingContext* RenderingContext() { return context_; } | 76 CanvasRenderingContext* RenderingContext() { return context_; } |
| 76 | 77 |
| 77 static void RegisterRenderingContextFactory( | 78 static void RegisterRenderingContextFactory( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 OffscreenCanvasFrameDispatcher* GetOrCreateFrameDispatcher(); | 160 OffscreenCanvasFrameDispatcher* GetOrCreateFrameDispatcher(); |
| 160 void DoCommit(RefPtr<StaticBitmapImage>, bool is_web_gl_software_rendering); | 161 void DoCommit(RefPtr<StaticBitmapImage>, bool is_web_gl_software_rendering); |
| 161 using ContextFactoryVector = | 162 using ContextFactoryVector = |
| 162 Vector<std::unique_ptr<CanvasRenderingContextFactory>>; | 163 Vector<std::unique_ptr<CanvasRenderingContextFactory>>; |
| 163 static ContextFactoryVector& RenderingContextFactories(); | 164 static ContextFactoryVector& RenderingContextFactories(); |
| 164 static CanvasRenderingContextFactory* GetRenderingContextFactory(int); | 165 static CanvasRenderingContextFactory* GetRenderingContextFactory(int); |
| 165 | 166 |
| 166 Member<CanvasRenderingContext> context_; | 167 Member<CanvasRenderingContext> context_; |
| 167 WeakMember<ExecutionContext> execution_context_; | 168 WeakMember<ExecutionContext> execution_context_; |
| 168 | 169 |
| 169 enum { | 170 DOMNodeId placeholder_canvas_id_ = kInvalidDOMNodeId; |
| 170 kNoPlaceholderCanvas = -1, // DOMNodeIds starts from 0, using -1 to | |
| 171 // indicate no associated canvas element. | |
| 172 }; | |
| 173 int placeholder_canvas_id_ = kNoPlaceholderCanvas; | |
| 174 | 171 |
| 175 IntSize size_; | 172 IntSize size_; |
| 176 bool is_neutered_ = false; | 173 bool is_neutered_ = false; |
| 177 | 174 |
| 178 bool origin_clean_ = true; | 175 bool origin_clean_ = true; |
| 179 bool disable_reading_from_canvas_ = false; | 176 bool disable_reading_from_canvas_ = false; |
| 180 | 177 |
| 181 bool IsPaintable() const; | 178 bool IsPaintable() const; |
| 182 | 179 |
| 183 std::unique_ptr<OffscreenCanvasFrameDispatcher> frame_dispatcher_; | 180 std::unique_ptr<OffscreenCanvasFrameDispatcher> frame_dispatcher_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 194 // If this object is not created via | 191 // If this object is not created via |
| 195 // HTMLCanvasElement.transferControlToOffscreen(), | 192 // HTMLCanvasElement.transferControlToOffscreen(), |
| 196 // then the following members would remain as initialized zero values. | 193 // then the following members would remain as initialized zero values. |
| 197 uint32_t client_id_ = 0; | 194 uint32_t client_id_ = 0; |
| 198 uint32_t sink_id_ = 0; | 195 uint32_t sink_id_ = 0; |
| 199 }; | 196 }; |
| 200 | 197 |
| 201 } // namespace blink | 198 } // namespace blink |
| 202 | 199 |
| 203 #endif // OffscreenCanvas_h | 200 #endif // OffscreenCanvas_h |
| OLD | NEW |