| 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 "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
| 11 #include "core/events/EventTarget.h" | 11 #include "core/events/EventTarget.h" |
| 12 #include "core/html/HTMLCanvasElement.h" | 12 #include "core/html/HTMLCanvasElement.h" |
| 13 #include "core/html/canvas/CanvasImageSource.h" | 13 #include "core/html/canvas/CanvasImageSource.h" |
| 14 #include "core/offscreencanvas/ImageEncodeOptions.h" | 14 #include "core/offscreencanvas/ImageEncodeOptions.h" |
| 15 #include "platform/geometry/IntSize.h" | 15 #include "platform/geometry/IntSize.h" |
| 16 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h" | 16 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h" |
| 17 #include "platform/heap/Handle.h" | 17 #include "platform/heap/Handle.h" |
| 18 #include <memory> | 18 #include <memory> |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 | 21 |
| 22 class CanvasContextCreationAttributes; | 22 class CanvasContextCreationAttributes; |
| 23 class ImageBitmap; | 23 class ImageBitmap; |
| 24 class | 24 class |
| 25 OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingCon
text; | 25 OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingCon
text; |
| 26 typedef OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2Renderin
gContext | 26 typedef OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2Renderin
gContext |
| 27 OffscreenRenderingContext; | 27 OffscreenRenderingContext; |
| 28 | 28 |
| 29 class CORE_EXPORT OffscreenCanvas final : public EventTargetWithInlineData, | 29 class CORE_EXPORT OffscreenCanvas final : public EventTargetWithInlineData, |
| 30 public CanvasImageSource { | 30 public CanvasImageSource, |
| 31 public ImageBitmapSource { |
| 31 DEFINE_WRAPPERTYPEINFO(); | 32 DEFINE_WRAPPERTYPEINFO(); |
| 32 | 33 |
| 33 public: | 34 public: |
| 34 static OffscreenCanvas* create(unsigned width, unsigned height); | 35 static OffscreenCanvas* create(unsigned width, unsigned height); |
| 35 ~OffscreenCanvas() override {} | 36 ~OffscreenCanvas() override {} |
| 36 | 37 |
| 37 // IDL attributes | 38 // IDL attributes |
| 38 unsigned width() const { return m_size.width(); } | 39 unsigned width() const { return m_size.width(); } |
| 39 unsigned height() const { return m_size.height(); } | 40 unsigned height() const { return m_size.height(); } |
| 40 void setWidth(unsigned); | 41 void setWidth(unsigned); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } | 97 } |
| 97 | 98 |
| 98 // EventTarget implementation | 99 // EventTarget implementation |
| 99 const AtomicString& interfaceName() const final { | 100 const AtomicString& interfaceName() const final { |
| 100 return EventTargetNames::OffscreenCanvas; | 101 return EventTargetNames::OffscreenCanvas; |
| 101 } | 102 } |
| 102 ExecutionContext* getExecutionContext() const { | 103 ExecutionContext* getExecutionContext() const { |
| 103 return m_executionContext.get(); | 104 return m_executionContext.get(); |
| 104 } | 105 } |
| 105 | 106 |
| 107 // ImageBitmapSource implementation |
| 108 IntSize bitmapSourceSize() const final; |
| 109 ScriptPromise createImageBitmap(ScriptState*, |
| 110 EventTarget&, |
| 111 Optional<IntRect>, |
| 112 const ImageBitmapOptions&, |
| 113 ExceptionState&) final; |
| 114 |
| 106 // CanvasImageSource implementation | 115 // CanvasImageSource implementation |
| 107 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, | 116 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, |
| 108 AccelerationHint, | 117 AccelerationHint, |
| 109 SnapshotReason, | 118 SnapshotReason, |
| 110 const FloatSize&) const final; | 119 const FloatSize&) const final; |
| 111 bool wouldTaintOrigin(SecurityOrigin*) const final { return !m_originClean; } | 120 bool wouldTaintOrigin(SecurityOrigin*) const final { return !m_originClean; } |
| 112 bool isOffscreenCanvas() const final { return true; } | 121 bool isOffscreenCanvas() const final { return true; } |
| 113 FloatSize elementSize(const FloatSize& defaultObjectSize) const final { | 122 FloatSize elementSize(const FloatSize& defaultObjectSize) const final { |
| 114 return FloatSize(width(), height()); | 123 return FloatSize(width(), height()); |
| 115 } | 124 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 uint32_t m_clientId = 0; | 163 uint32_t m_clientId = 0; |
| 155 uint32_t m_sinkId = 0; | 164 uint32_t m_sinkId = 0; |
| 156 uint32_t m_localId = 0; | 165 uint32_t m_localId = 0; |
| 157 uint64_t m_nonceHigh = 0; | 166 uint64_t m_nonceHigh = 0; |
| 158 uint64_t m_nonceLow = 0; | 167 uint64_t m_nonceLow = 0; |
| 159 }; | 168 }; |
| 160 | 169 |
| 161 } // namespace blink | 170 } // namespace blink |
| 162 | 171 |
| 163 #endif // OffscreenCanvas_h | 172 #endif // OffscreenCanvas_h |
| OLD | NEW |