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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 bool OffscreenCanvas::isAccelerated() const { | 177 bool OffscreenCanvas::isAccelerated() const { |
178 return m_context && m_context->isAccelerated(); | 178 return m_context && m_context->isAccelerated(); |
179 } | 179 } |
180 | 180 |
181 OffscreenCanvasFrameDispatcher* OffscreenCanvas::getOrCreateFrameDispatcher() { | 181 OffscreenCanvasFrameDispatcher* OffscreenCanvas::getOrCreateFrameDispatcher() { |
182 if (!m_frameDispatcher) { | 182 if (!m_frameDispatcher) { |
183 // The frame dispatcher connects the current thread of OffscreenCanvas | 183 // The frame dispatcher connects the current thread of OffscreenCanvas |
184 // (either main or worker) to the browser process and remains unchanged | 184 // (either main or worker) to the browser process and remains unchanged |
185 // throughout the lifetime of this OffscreenCanvas. | 185 // throughout the lifetime of this OffscreenCanvas. |
| 186 DCHECK_NE(m_canvasId, -1); |
186 m_frameDispatcher = wrapUnique(new OffscreenCanvasFrameDispatcherImpl( | 187 m_frameDispatcher = wrapUnique(new OffscreenCanvasFrameDispatcherImpl( |
187 m_clientId, m_sinkId, m_localId, m_nonce, width(), height())); | 188 m_canvasId, m_clientId, m_sinkId, m_localId, m_nonce, width(), |
| 189 height())); |
188 } | 190 } |
189 return m_frameDispatcher.get(); | 191 return m_frameDispatcher.get(); |
190 } | 192 } |
191 | 193 |
192 ScriptPromise OffscreenCanvas::convertToBlob(ScriptState* scriptState, | 194 ScriptPromise OffscreenCanvas::convertToBlob(ScriptState* scriptState, |
193 const ImageEncodeOptions& options, | 195 const ImageEncodeOptions& options, |
194 ExceptionState& exceptionState) { | 196 ExceptionState& exceptionState) { |
195 if (this->isNeutered()) { | 197 if (this->isNeutered()) { |
196 exceptionState.throwDOMException(InvalidStateError, | 198 exceptionState.throwDOMException(InvalidStateError, |
197 "OffscreenCanvas object is detached."); | 199 "OffscreenCanvas object is detached."); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 asyncCreator->scheduleAsyncBlobCreation(options.quality()); | 236 asyncCreator->scheduleAsyncBlobCreation(options.quality()); |
235 | 237 |
236 return resolver->promise(); | 238 return resolver->promise(); |
237 } | 239 } |
238 | 240 |
239 DEFINE_TRACE(OffscreenCanvas) { | 241 DEFINE_TRACE(OffscreenCanvas) { |
240 visitor->trace(m_context); | 242 visitor->trace(m_context); |
241 } | 243 } |
242 | 244 |
243 } // namespace blink | 245 } // namespace blink |
OLD | NEW |