OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" | 5 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" |
6 | 6 |
7 #include "bindings/modules/v8/OffscreenCanvasRenderingContext2DOrWebGLRenderingC
ontextOrWebGL2RenderingContext.h" | 7 #include "bindings/modules/v8/OffscreenCanvasRenderingContext2DOrWebGLRenderingC
ontextOrWebGL2RenderingContext.h" |
| 8 #include "core/dom/ExecutionContext.h" |
8 #include "core/frame/ImageBitmap.h" | 9 #include "core/frame/ImageBitmap.h" |
9 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
10 #include "core/workers/WorkerGlobalScope.h" | 11 #include "core/workers/WorkerGlobalScope.h" |
11 #include "core/workers/WorkerSettings.h" | 12 #include "core/workers/WorkerSettings.h" |
12 #include "platform/graphics/ImageBuffer.h" | 13 #include "platform/graphics/ImageBuffer.h" |
13 #include "platform/graphics/StaticBitmapImage.h" | 14 #include "platform/graphics/StaticBitmapImage.h" |
14 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 15 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
15 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" | 16 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" |
16 #include "wtf/Assertions.h" | 17 #include "wtf/Assertions.h" |
17 #include "wtf/CurrentTime.h" | 18 #include "wtf/CurrentTime.h" |
18 | 19 |
19 #define UNIMPLEMENTED ASSERT_NOT_REACHED | 20 #define UNIMPLEMENTED ASSERT_NOT_REACHED |
20 | 21 |
21 namespace blink { | 22 namespace blink { |
22 | 23 |
23 OffscreenCanvasRenderingContext2D::~OffscreenCanvasRenderingContext2D() {} | 24 OffscreenCanvasRenderingContext2D::~OffscreenCanvasRenderingContext2D() {} |
24 | 25 |
25 OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D( | 26 OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D( |
26 ScriptState* scriptState, | 27 ScriptState* scriptState, |
27 OffscreenCanvas* canvas, | 28 OffscreenCanvas* canvas, |
28 const CanvasContextCreationAttributes& attrs) | 29 const CanvasContextCreationAttributes& attrs) |
29 : CanvasRenderingContext(nullptr, canvas, attrs) { | 30 : CanvasRenderingContext(nullptr, canvas, attrs) { |
30 ExecutionContext* executionContext = scriptState->getExecutionContext(); | 31 m_executionContext = scriptState->getExecutionContext(); |
31 if (executionContext->isDocument()) { | 32 if (m_executionContext.get()->isDocument()) { |
32 if (toDocument(executionContext)->settings()->disableReadingFromCanvas()) | 33 if (toDocument(m_executionContext.get()) |
| 34 ->settings() |
| 35 ->disableReadingFromCanvas()) |
33 canvas->setDisableReadingFromCanvasTrue(); | 36 canvas->setDisableReadingFromCanvasTrue(); |
34 return; | 37 return; |
35 } | 38 } |
36 | 39 |
37 WorkerSettings* workerSettings = | 40 WorkerSettings* workerSettings = |
38 toWorkerGlobalScope(executionContext)->workerSettings(); | 41 toWorkerGlobalScope(m_executionContext.get())->workerSettings(); |
39 if (workerSettings && workerSettings->disableReadingFromCanvas()) | 42 if (workerSettings && workerSettings->disableReadingFromCanvas()) |
40 canvas->setDisableReadingFromCanvasTrue(); | 43 canvas->setDisableReadingFromCanvasTrue(); |
41 } | 44 } |
42 | 45 |
43 DEFINE_TRACE(OffscreenCanvasRenderingContext2D) { | 46 DEFINE_TRACE(OffscreenCanvasRenderingContext2D) { |
| 47 visitor->trace(m_executionContext); |
44 CanvasRenderingContext::trace(visitor); | 48 CanvasRenderingContext::trace(visitor); |
45 BaseRenderingContext2D::trace(visitor); | 49 BaseRenderingContext2D::trace(visitor); |
46 } | 50 } |
47 | 51 |
48 void OffscreenCanvasRenderingContext2D::commit(ScriptState* scriptState, | 52 void OffscreenCanvasRenderingContext2D::commit(ScriptState* scriptState, |
49 ExceptionState& exceptionState) { | 53 ExceptionState& exceptionState) { |
50 UseCounter::Feature feature = UseCounter::OffscreenCanvasCommit2D; | 54 UseCounter::Feature feature = UseCounter::OffscreenCanvasCommit2D; |
51 UseCounter::count(scriptState->getExecutionContext(), feature); | 55 UseCounter::count(scriptState->getExecutionContext(), feature); |
52 if (getOffscreenCanvas()->getAssociatedCanvasId() < 0) { | 56 if (getOffscreenCanvas()->getAssociatedCanvasId() < 0) { |
53 // If an OffscreenCanvas has no associated canvas Id, it indicates that | 57 // If an OffscreenCanvas has no associated canvas Id, it indicates that |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 245 } |
242 | 246 |
243 bool OffscreenCanvasRenderingContext2D::isContextLost() const { | 247 bool OffscreenCanvasRenderingContext2D::isContextLost() const { |
244 return false; | 248 return false; |
245 } | 249 } |
246 | 250 |
247 bool OffscreenCanvasRenderingContext2D::isPaintable() const { | 251 bool OffscreenCanvasRenderingContext2D::isPaintable() const { |
248 return this->imageBuffer(); | 252 return this->imageBuffer(); |
249 } | 253 } |
250 } | 254 } |
OLD | NEW |