| 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/frame/ImageBitmap.h" | 8 #include "core/frame/ImageBitmap.h" |
| 9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
| 10 #include "core/workers/WorkerGlobalScope.h" | 10 #include "core/workers/WorkerGlobalScope.h" |
| 11 #include "core/workers/WorkerSettings.h" | 11 #include "core/workers/WorkerSettings.h" |
| 12 #include "platform/graphics/ImageBuffer.h" | 12 #include "platform/graphics/ImageBuffer.h" |
| 13 #include "platform/graphics/StaticBitmapImage.h" | 13 #include "platform/graphics/StaticBitmapImage.h" |
| 14 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 14 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 15 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" | 15 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" |
| 16 #include "wtf/Assertions.h" | 16 #include "wtf/Assertions.h" |
| 17 #include "wtf/CurrentTime.h" |
| 17 | 18 |
| 18 #define UNIMPLEMENTED ASSERT_NOT_REACHED | 19 #define UNIMPLEMENTED ASSERT_NOT_REACHED |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| 22 OffscreenCanvasRenderingContext2D::~OffscreenCanvasRenderingContext2D() {} | 23 OffscreenCanvasRenderingContext2D::~OffscreenCanvasRenderingContext2D() {} |
| 23 | 24 |
| 24 OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D( | 25 OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D( |
| 25 ScriptState* scriptState, | 26 ScriptState* scriptState, |
| 26 OffscreenCanvas* canvas, | 27 OffscreenCanvas* canvas, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 if (getOffscreenCanvas()->getAssociatedCanvasId() < 0) { | 49 if (getOffscreenCanvas()->getAssociatedCanvasId() < 0) { |
| 49 // If an OffscreenCanvas has no associated canvas Id, it indicates that | 50 // If an OffscreenCanvas has no associated canvas Id, it indicates that |
| 50 // it is not an OffscreenCanvas created by transfering control from html | 51 // it is not an OffscreenCanvas created by transfering control from html |
| 51 // canvas. | 52 // canvas. |
| 52 exceptionState.throwDOMException(InvalidStateError, | 53 exceptionState.throwDOMException(InvalidStateError, |
| 53 "Commit() was called on a context whose " | 54 "Commit() was called on a context whose " |
| 54 "OffscreenCanvas is not associated with a " | 55 "OffscreenCanvas is not associated with a " |
| 55 "canvas element."); | 56 "canvas element."); |
| 56 return; | 57 return; |
| 57 } | 58 } |
| 59 double commitStartTime = WTF::monotonicallyIncreasingTime(); |
| 58 RefPtr<StaticBitmapImage> image = this->transferToStaticBitmapImage(); | 60 RefPtr<StaticBitmapImage> image = this->transferToStaticBitmapImage(); |
| 59 getOffscreenCanvas()->getOrCreateFrameDispatcher()->dispatchFrame( | 61 getOffscreenCanvas()->getOrCreateFrameDispatcher()->dispatchFrame( |
| 60 std::move(image)); | 62 std::move(image), commitStartTime); |
| 61 } | 63 } |
| 62 | 64 |
| 63 // BaseRenderingContext2D implementation | 65 // BaseRenderingContext2D implementation |
| 64 bool OffscreenCanvasRenderingContext2D::originClean() const { | 66 bool OffscreenCanvasRenderingContext2D::originClean() const { |
| 65 return getOffscreenCanvas()->originClean(); | 67 return getOffscreenCanvas()->originClean(); |
| 66 } | 68 } |
| 67 | 69 |
| 68 void OffscreenCanvasRenderingContext2D::setOriginTainted() { | 70 void OffscreenCanvasRenderingContext2D::setOriginTainted() { |
| 69 return getOffscreenCanvas()->setOriginTainted(); | 71 return getOffscreenCanvas()->setOriginTainted(); |
| 70 } | 72 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 217 } |
| 216 | 218 |
| 217 bool OffscreenCanvasRenderingContext2D::isContextLost() const { | 219 bool OffscreenCanvasRenderingContext2D::isContextLost() const { |
| 218 return false; | 220 return false; |
| 219 } | 221 } |
| 220 | 222 |
| 221 bool OffscreenCanvasRenderingContext2D::isPaintable() const { | 223 bool OffscreenCanvasRenderingContext2D::isPaintable() const { |
| 222 return this->imageBuffer(); | 224 return this->imageBuffer(); |
| 223 } | 225 } |
| 224 } | 226 } |
| OLD | NEW |