| 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_ != kNoPlaceholderCanvas; |
| 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_; } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 enum { |
| 170 kNoPlaceholderCanvas = -1, // DOMNodeIds starts from 0, using -1 to | 171 kNoPlaceholderCanvas = 0, // DOMNodeIds starts from 1, using 0 to |
| 171 // indicate no associated canvas element. | 172 // indicate no associated canvas element. |
| 172 }; | 173 }; |
| 173 int placeholder_canvas_id_ = kNoPlaceholderCanvas; | 174 DOMNodeId placeholder_canvas_id_ = kNoPlaceholderCanvas; |
| 174 | 175 |
| 175 IntSize size_; | 176 IntSize size_; |
| 176 bool is_neutered_ = false; | 177 bool is_neutered_ = false; |
| 177 | 178 |
| 178 bool origin_clean_ = true; | 179 bool origin_clean_ = true; |
| 179 bool disable_reading_from_canvas_ = false; | 180 bool disable_reading_from_canvas_ = false; |
| 180 | 181 |
| 181 bool IsPaintable() const; | 182 bool IsPaintable() const; |
| 182 | 183 |
| 183 std::unique_ptr<OffscreenCanvasFrameDispatcher> frame_dispatcher_; | 184 std::unique_ptr<OffscreenCanvasFrameDispatcher> frame_dispatcher_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 194 // If this object is not created via | 195 // If this object is not created via |
| 195 // HTMLCanvasElement.transferControlToOffscreen(), | 196 // HTMLCanvasElement.transferControlToOffscreen(), |
| 196 // then the following members would remain as initialized zero values. | 197 // then the following members would remain as initialized zero values. |
| 197 uint32_t client_id_ = 0; | 198 uint32_t client_id_ = 0; |
| 198 uint32_t sink_id_ = 0; | 199 uint32_t sink_id_ = 0; |
| 199 }; | 200 }; |
| 200 | 201 |
| 201 } // namespace blink | 202 } // namespace blink |
| 202 | 203 |
| 203 #endif // OffscreenCanvas_h | 204 #endif // OffscreenCanvas_h |
| OLD | NEW |