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" |
(...skipping 28 matching lines...) Expand all Loading... |
39 int getAssociatedCanvasId() const { return m_canvasId; } | 39 int getAssociatedCanvasId() const { return m_canvasId; } |
40 bool isNeutered() const { return m_isNeutered; } | 40 bool isNeutered() const { return m_isNeutered; } |
41 void setNeutered(); | 41 void setNeutered(); |
42 CanvasRenderingContext* getCanvasRenderingContext(ScriptState*, const String
&, const CanvasContextCreationAttributes&); | 42 CanvasRenderingContext* getCanvasRenderingContext(ScriptState*, const String
&, const CanvasContextCreationAttributes&); |
43 CanvasRenderingContext* renderingContext() { return m_context; } | 43 CanvasRenderingContext* renderingContext() { return m_context; } |
44 | 44 |
45 static void registerRenderingContextFactory(std::unique_ptr<CanvasRenderingC
ontextFactory>); | 45 static void registerRenderingContextFactory(std::unique_ptr<CanvasRenderingC
ontextFactory>); |
46 | 46 |
47 bool originClean() const; | 47 bool originClean() const; |
48 void setOriginTainted() { m_originClean = false; } | 48 void setOriginTainted() { m_originClean = false; } |
| 49 // TODO(crbug.com/630356): apply the flag to WebGL context as well |
| 50 void setDisableReadingFromCanvasTrue() { m_disableReadingFromCanvas = true;
} |
49 | 51 |
50 void setSurfaceId(uint32_t clientId, uint32_t localId, uint64_t nonce) | 52 void setSurfaceId(uint32_t clientId, uint32_t localId, uint64_t nonce) |
51 { | 53 { |
52 m_clientId = clientId; | 54 m_clientId = clientId; |
53 m_localId = localId; | 55 m_localId = localId; |
54 m_nonce = nonce; | 56 m_nonce = nonce; |
55 } | 57 } |
56 uint32_t clientId() const { return m_clientId; } | 58 uint32_t clientId() const { return m_clientId; } |
57 uint32_t localId() const { return m_localId; } | 59 uint32_t localId() const { return m_localId; } |
58 uint64_t nonce() const { return m_nonce; } | 60 uint64_t nonce() const { return m_nonce; } |
59 | 61 |
60 DECLARE_VIRTUAL_TRACE(); | 62 DECLARE_VIRTUAL_TRACE(); |
61 | 63 |
62 private: | 64 private: |
63 explicit OffscreenCanvas(const IntSize&); | 65 explicit OffscreenCanvas(const IntSize&); |
64 | 66 |
65 using ContextFactoryVector = Vector<std::unique_ptr<CanvasRenderingContextFa
ctory>>; | 67 using ContextFactoryVector = Vector<std::unique_ptr<CanvasRenderingContextFa
ctory>>; |
66 static ContextFactoryVector& renderingContextFactories(); | 68 static ContextFactoryVector& renderingContextFactories(); |
67 static CanvasRenderingContextFactory* getRenderingContextFactory(int); | 69 static CanvasRenderingContextFactory* getRenderingContextFactory(int); |
68 | 70 |
69 Member<CanvasRenderingContext> m_context; | 71 Member<CanvasRenderingContext> m_context; |
70 int m_canvasId = -1; // DOMNodeIds starts from 0, using -1 to indicate no as
sociated canvas element. | 72 int m_canvasId = -1; // DOMNodeIds starts from 0, using -1 to indicate no as
sociated canvas element. |
71 IntSize m_size; | 73 IntSize m_size; |
72 bool m_isNeutered = false; | 74 bool m_isNeutered = false; |
73 | 75 |
74 bool m_originClean; | 76 bool m_originClean; |
| 77 bool m_disableReadingFromCanvas = false; |
75 | 78 |
76 // cc::SurfaceId is broken into three integer components as this can be used | 79 // cc::SurfaceId is broken into three integer components as this can be used |
77 // in transfer of OffscreenCanvas across threads | 80 // in transfer of OffscreenCanvas across threads |
78 // If this object is not created via HTMLCanvasElement.transferControlToOffs
creen(), | 81 // If this object is not created via HTMLCanvasElement.transferControlToOffs
creen(), |
79 // then the following members would remain as initialized zero values. | 82 // then the following members would remain as initialized zero values. |
80 uint32_t m_clientId = 0; | 83 uint32_t m_clientId = 0; |
81 uint32_t m_localId = 0; | 84 uint32_t m_localId = 0; |
82 uint64_t m_nonce = 0; | 85 uint64_t m_nonce = 0; |
83 }; | 86 }; |
84 | 87 |
85 } // namespace blink | 88 } // namespace blink |
86 | 89 |
87 #endif // OffscreenCanvas_h | 90 #endif // OffscreenCanvas_h |
OLD | NEW |