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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 getOrCreateFrameDispatcher()->setNeedsBeginFrame(true); | 239 getOrCreateFrameDispatcher()->setNeedsBeginFrame(true); |
240 if (m_commitPromiseResolver) { | 240 if (m_commitPromiseResolver) { |
241 if (image) { | 241 if (image) { |
242 m_overdrawFrame = std::move(image); | 242 m_overdrawFrame = std::move(image); |
243 m_overdrawFrameIsWebGLSoftwareRendering = isWebGLSoftwareRendering; | 243 m_overdrawFrameIsWebGLSoftwareRendering = isWebGLSoftwareRendering; |
244 } | 244 } |
245 } else { | 245 } else { |
246 m_overdrawFrame = nullptr; | 246 m_overdrawFrame = nullptr; |
247 m_commitPromiseResolver = ScriptPromiseResolver::create(scriptState); | 247 m_commitPromiseResolver = ScriptPromiseResolver::create(scriptState); |
248 m_commitPromiseResolver->keepAliveWhilePending(); | 248 m_commitPromiseResolver->keepAliveWhilePending(); |
| 249 // TODO(eseckler): OffscreenCanvas shouldn't dispatch CompositorFrames |
| 250 // without a prior BeginFrame. |
249 doCommit(std::move(image), isWebGLSoftwareRendering); | 251 doCommit(std::move(image), isWebGLSoftwareRendering); |
250 } | 252 } |
251 return m_commitPromiseResolver->promise(); | 253 return m_commitPromiseResolver->promise(); |
252 } | 254 } |
253 | 255 |
254 void OffscreenCanvas::doCommit(RefPtr<StaticBitmapImage> image, | 256 void OffscreenCanvas::doCommit(RefPtr<StaticBitmapImage> image, |
255 bool isWebGLSoftwareRendering) { | 257 bool isWebGLSoftwareRendering) { |
256 double commitStartTime = WTF::monotonicallyIncreasingTime(); | 258 double commitStartTime = WTF::monotonicallyIncreasingTime(); |
257 getOrCreateFrameDispatcher()->dispatchFrame(std::move(image), commitStartTime, | 259 getOrCreateFrameDispatcher()->dispatchFrame(std::move(image), commitStartTime, |
258 isWebGLSoftwareRendering); | 260 isWebGLSoftwareRendering); |
259 } | 261 } |
260 | 262 |
261 void OffscreenCanvas::beginFrame() { | 263 void OffscreenCanvas::beginFrame() { |
| 264 // TODO(eseckler): beginFrame() shouldn't be used as confirmation of |
| 265 // CompositorFrame activation. |
262 if (m_overdrawFrame) { | 266 if (m_overdrawFrame) { |
263 // if we have an overdraw backlog, push the frame from the backlog | 267 // if we have an overdraw backlog, push the frame from the backlog |
264 // first and save the promise resolution for later. | 268 // first and save the promise resolution for later. |
265 doCommit(std::move(m_overdrawFrame), | 269 doCommit(std::move(m_overdrawFrame), |
266 m_overdrawFrameIsWebGLSoftwareRendering); | 270 m_overdrawFrameIsWebGLSoftwareRendering); |
267 } else if (m_commitPromiseResolver) { | 271 } else if (m_commitPromiseResolver) { |
268 m_commitPromiseResolver->resolve(); | 272 m_commitPromiseResolver->resolve(); |
269 m_commitPromiseResolver.clear(); | 273 m_commitPromiseResolver.clear(); |
270 // We need to tell parent frame to stop sending signals on begin frame to | 274 // We need to tell parent frame to stop sending signals on begin frame to |
271 // avoid overhead once we resolve the promise. | 275 // avoid overhead once we resolve the promise. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 } | 331 } |
328 | 332 |
329 DEFINE_TRACE(OffscreenCanvas) { | 333 DEFINE_TRACE(OffscreenCanvas) { |
330 visitor->trace(m_context); | 334 visitor->trace(m_context); |
331 visitor->trace(m_executionContext); | 335 visitor->trace(m_executionContext); |
332 visitor->trace(m_commitPromiseResolver); | 336 visitor->trace(m_commitPromiseResolver); |
333 EventTargetWithInlineData::trace(visitor); | 337 EventTargetWithInlineData::trace(visitor); |
334 } | 338 } |
335 | 339 |
336 } // namespace blink | 340 } // namespace blink |
OLD | NEW |