| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 void OffscreenCanvas::setSize(const IntSize& size) { | 44 void OffscreenCanvas::setSize(const IntSize& size) { |
| 45 if (m_context) { | 45 if (m_context) { |
| 46 if (m_context->is3d()) { | 46 if (m_context->is3d()) { |
| 47 if (size != m_size) | 47 if (size != m_size) |
| 48 m_context->reshape(size.width(), size.height()); | 48 m_context->reshape(size.width(), size.height()); |
| 49 } else if (m_context->is2d()) { | 49 } else if (m_context->is2d()) { |
| 50 m_context->reset(); | 50 m_context->reset(); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 m_size = size; | 53 m_size = size; |
| 54 if (m_frameDispatcher) { |
| 55 m_frameDispatcher->reshape(m_size.width(), m_size.height()); |
| 56 } |
| 54 } | 57 } |
| 55 | 58 |
| 56 void OffscreenCanvas::setNeutered() { | 59 void OffscreenCanvas::setNeutered() { |
| 57 ASSERT(!m_context); | 60 ASSERT(!m_context); |
| 58 m_isNeutered = true; | 61 m_isNeutered = true; |
| 59 m_size.setWidth(0); | 62 m_size.setWidth(0); |
| 60 m_size.setHeight(0); | 63 m_size.setHeight(0); |
| 61 } | 64 } |
| 62 | 65 |
| 63 ImageBitmap* OffscreenCanvas::transferToImageBitmap( | 66 ImageBitmap* OffscreenCanvas::transferToImageBitmap( |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return m_context && m_context->isAccelerated(); | 179 return m_context && m_context->isAccelerated(); |
| 177 } | 180 } |
| 178 | 181 |
| 179 OffscreenCanvasFrameDispatcher* OffscreenCanvas::getOrCreateFrameDispatcher() { | 182 OffscreenCanvasFrameDispatcher* OffscreenCanvas::getOrCreateFrameDispatcher() { |
| 180 if (!m_frameDispatcher) { | 183 if (!m_frameDispatcher) { |
| 181 // The frame dispatcher connects the current thread of OffscreenCanvas | 184 // The frame dispatcher connects the current thread of OffscreenCanvas |
| 182 // (either main or worker) to the browser process and remains unchanged | 185 // (either main or worker) to the browser process and remains unchanged |
| 183 // throughout the lifetime of this OffscreenCanvas. | 186 // throughout the lifetime of this OffscreenCanvas. |
| 184 m_frameDispatcher = wrapUnique(new OffscreenCanvasFrameDispatcherImpl( | 187 m_frameDispatcher = wrapUnique(new OffscreenCanvasFrameDispatcherImpl( |
| 185 m_clientId, m_sinkId, m_localId, m_nonceHigh, m_nonceLow, | 188 m_clientId, m_sinkId, m_localId, m_nonceHigh, m_nonceLow, |
| 186 m_placeholderCanvasId, width(), height())); | 189 m_placeholderCanvasId, m_size.width(), m_size.height())); |
| 187 } | 190 } |
| 188 return m_frameDispatcher.get(); | 191 return m_frameDispatcher.get(); |
| 189 } | 192 } |
| 190 | 193 |
| 191 ScriptPromise OffscreenCanvas::convertToBlob(ScriptState* scriptState, | 194 ScriptPromise OffscreenCanvas::convertToBlob(ScriptState* scriptState, |
| 192 const ImageEncodeOptions& options, | 195 const ImageEncodeOptions& options, |
| 193 ExceptionState& exceptionState) { | 196 ExceptionState& exceptionState) { |
| 194 if (this->isNeutered()) { | 197 if (this->isNeutered()) { |
| 195 exceptionState.throwDOMException(InvalidStateError, | 198 exceptionState.throwDOMException(InvalidStateError, |
| 196 "OffscreenCanvas object is detached."); | 199 "OffscreenCanvas object is detached."); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 return resolver->promise(); | 240 return resolver->promise(); |
| 238 } | 241 } |
| 239 | 242 |
| 240 DEFINE_TRACE(OffscreenCanvas) { | 243 DEFINE_TRACE(OffscreenCanvas) { |
| 241 visitor->trace(m_context); | 244 visitor->trace(m_context); |
| 242 visitor->trace(m_executionContext); | 245 visitor->trace(m_executionContext); |
| 243 EventTarget::trace(visitor); | 246 EventTarget::trace(visitor); |
| 244 } | 247 } |
| 245 | 248 |
| 246 } // namespace blink | 249 } // namespace blink |
| OLD | NEW |