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 #include "core/offscreencanvas/OffscreenCanvas.h" | 5 #include "core/offscreencanvas/OffscreenCanvas.h" |
6 | 6 |
7 #include "core/dom/ExceptionCode.h" | 7 #include "core/dom/ExceptionCode.h" |
8 #include "core/fileapi/Blob.h" | 8 #include "core/fileapi/Blob.h" |
9 #include "core/html/ImageData.h" | 9 #include "core/html/ImageData.h" |
10 #include "core/html/canvas/CanvasAsyncBlobCreator.h" | 10 #include "core/html/canvas/CanvasAsyncBlobCreator.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 void OffscreenCanvas::setNeutered() { | 58 void OffscreenCanvas::setNeutered() { |
59 ASSERT(!m_context); | 59 ASSERT(!m_context); |
60 m_isNeutered = true; | 60 m_isNeutered = true; |
61 m_size.setWidth(0); | 61 m_size.setWidth(0); |
62 m_size.setHeight(0); | 62 m_size.setHeight(0); |
63 } | 63 } |
64 | 64 |
65 ImageBitmap* OffscreenCanvas::transferToImageBitmap( | 65 ImageBitmap* OffscreenCanvas::transferToImageBitmap( |
| 66 ScriptState* scriptState, |
66 ExceptionState& exceptionState) { | 67 ExceptionState& exceptionState) { |
67 if (m_isNeutered) { | 68 if (m_isNeutered) { |
68 exceptionState.throwDOMException( | 69 exceptionState.throwDOMException( |
69 InvalidStateError, | 70 InvalidStateError, |
70 "Cannot transfer an ImageBitmap from a detached OffscreenCanvas"); | 71 "Cannot transfer an ImageBitmap from a detached OffscreenCanvas"); |
71 return nullptr; | 72 return nullptr; |
72 } | 73 } |
73 if (!m_context) { | 74 if (!m_context) { |
74 exceptionState.throwDOMException(InvalidStateError, | 75 exceptionState.throwDOMException(InvalidStateError, |
75 "Cannot transfer an ImageBitmap from an " | 76 "Cannot transfer an ImageBitmap from an " |
76 "OffscreenCanvas with no context"); | 77 "OffscreenCanvas with no context"); |
77 return nullptr; | 78 return nullptr; |
78 } | 79 } |
79 ImageBitmap* image = m_context->transferToImageBitmap(); | 80 ImageBitmap* image = m_context->transferToImageBitmap(scriptState); |
80 if (!image) { | 81 if (!image) { |
81 // Undocumented exception (not in spec) | 82 // Undocumented exception (not in spec) |
82 exceptionState.throwDOMException(V8Error, "Out of memory"); | 83 exceptionState.throwDOMException(V8Error, "Out of memory"); |
83 } | 84 } |
84 return image; | 85 return image; |
85 } | 86 } |
86 | 87 |
87 PassRefPtr<Image> OffscreenCanvas::getSourceImageForCanvas( | 88 PassRefPtr<Image> OffscreenCanvas::getSourceImageForCanvas( |
88 SourceImageStatus* status, | 89 SourceImageStatus* status, |
89 AccelerationHint hint, | 90 AccelerationHint hint, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 asyncCreator->scheduleAsyncBlobCreation(options.quality()); | 234 asyncCreator->scheduleAsyncBlobCreation(options.quality()); |
234 | 235 |
235 return resolver->promise(); | 236 return resolver->promise(); |
236 } | 237 } |
237 | 238 |
238 DEFINE_TRACE(OffscreenCanvas) { | 239 DEFINE_TRACE(OffscreenCanvas) { |
239 visitor->trace(m_context); | 240 visitor->trace(m_context); |
240 } | 241 } |
241 | 242 |
242 } // namespace blink | 243 } // namespace blink |
OLD | NEW |