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/frame/ImageBitmap.h" | 9 #include "core/frame/ImageBitmap.h" |
10 #include "core/html/ImageData.h" | 10 #include "core/html/ImageData.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 m_frameDispatcher = WTF::wrapUnique(new OffscreenCanvasFrameDispatcherImpl( | 229 m_frameDispatcher = WTF::wrapUnique(new OffscreenCanvasFrameDispatcherImpl( |
230 this, m_clientId, m_sinkId, m_placeholderCanvasId, m_size.width(), | 230 this, m_clientId, m_sinkId, m_placeholderCanvasId, m_size.width(), |
231 m_size.height())); | 231 m_size.height())); |
232 } | 232 } |
233 return m_frameDispatcher.get(); | 233 return m_frameDispatcher.get(); |
234 } | 234 } |
235 | 235 |
236 ScriptPromise OffscreenCanvas::commit(RefPtr<StaticBitmapImage> image, | 236 ScriptPromise OffscreenCanvas::commit(RefPtr<StaticBitmapImage> image, |
237 bool isWebGLSoftwareRendering, | 237 bool isWebGLSoftwareRendering, |
238 ScriptState* scriptState) { | 238 ScriptState* scriptState) { |
239 getOrCreateFrameDispatcher()->setNeedsBeginFrame(true); | |
239 if (m_commitPromiseResolver) { | 240 if (m_commitPromiseResolver) { |
240 if (image) { | 241 if (image) { |
241 m_overdrawFrame = std::move(image); | 242 m_overdrawFrame = std::move(image); |
242 m_overdrawFrameIsWebGLSoftwareRendering = isWebGLSoftwareRendering; | 243 m_overdrawFrameIsWebGLSoftwareRendering = isWebGLSoftwareRendering; |
243 } | 244 } |
244 } else { | 245 } else { |
245 m_overdrawFrame = nullptr; | 246 m_overdrawFrame = nullptr; |
246 m_commitPromiseResolver = ScriptPromiseResolver::create(scriptState); | 247 m_commitPromiseResolver = ScriptPromiseResolver::create(scriptState); |
247 m_commitPromiseResolver->keepAliveWhilePending(); | 248 m_commitPromiseResolver->keepAliveWhilePending(); |
248 doCommit(std::move(image), isWebGLSoftwareRendering); | 249 doCommit(std::move(image), isWebGLSoftwareRendering); |
(...skipping 10 matching lines...) Expand all Loading... | |
259 | 260 |
260 void OffscreenCanvas::beginFrame() { | 261 void OffscreenCanvas::beginFrame() { |
261 if (m_overdrawFrame) { | 262 if (m_overdrawFrame) { |
262 // if we have an overdraw backlog, push the frame from the backlog | 263 // if we have an overdraw backlog, push the frame from the backlog |
263 // first and save the promise resolution for later. | 264 // first and save the promise resolution for later. |
264 doCommit(std::move(m_overdrawFrame), | 265 doCommit(std::move(m_overdrawFrame), |
265 m_overdrawFrameIsWebGLSoftwareRendering); | 266 m_overdrawFrameIsWebGLSoftwareRendering); |
266 } else if (m_commitPromiseResolver) { | 267 } else if (m_commitPromiseResolver) { |
267 m_commitPromiseResolver->resolve(); | 268 m_commitPromiseResolver->resolve(); |
268 m_commitPromiseResolver.clear(); | 269 m_commitPromiseResolver.clear(); |
270 getOrCreateFrameDispatcher()->setNeedsBeginFrame(false); | |
Justin Novosad
2017/01/19 18:06:49
Kudos for putting this in the right place. A comm
xlai (Olivia)
2017/01/19 19:14:34
Done.
| |
269 } | 271 } |
270 } | 272 } |
271 | 273 |
272 ScriptPromise OffscreenCanvas::convertToBlob(ScriptState* scriptState, | 274 ScriptPromise OffscreenCanvas::convertToBlob(ScriptState* scriptState, |
273 const ImageEncodeOptions& options, | 275 const ImageEncodeOptions& options, |
274 ExceptionState& exceptionState) { | 276 ExceptionState& exceptionState) { |
275 if (this->isNeutered()) { | 277 if (this->isNeutered()) { |
276 exceptionState.throwDOMException(InvalidStateError, | 278 exceptionState.throwDOMException(InvalidStateError, |
277 "OffscreenCanvas object is detached."); | 279 "OffscreenCanvas object is detached."); |
278 return exceptionState.reject(scriptState); | 280 return exceptionState.reject(scriptState); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 } | 321 } |
320 | 322 |
321 DEFINE_TRACE(OffscreenCanvas) { | 323 DEFINE_TRACE(OffscreenCanvas) { |
322 visitor->trace(m_context); | 324 visitor->trace(m_context); |
323 visitor->trace(m_executionContext); | 325 visitor->trace(m_executionContext); |
324 visitor->trace(m_commitPromiseResolver); | 326 visitor->trace(m_commitPromiseResolver); |
325 EventTargetWithInlineData::trace(visitor); | 327 EventTargetWithInlineData::trace(visitor); |
326 } | 328 } |
327 | 329 |
328 } // namespace blink | 330 } // namespace blink |
OLD | NEW |