| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" | 5 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" |
| 6 | 6 |
| 7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
| 8 #include "cc/quads/texture_draw_quad.h" | 8 #include "cc/quads/texture_draw_quad.h" |
| 9 #include "gpu/command_buffer/client/gles2_interface.h" | 9 #include "gpu/command_buffer/client/gles2_interface.h" |
| 10 #include "platform/CrossThreadFunctional.h" | 10 #include "platform/CrossThreadFunctional.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 resource.is_software = false; | 151 resource.is_software = false; |
| 152 | 152 |
| 153 // Hold ref to |image|, to keep it alive until the browser ReclaimResources. | 153 // Hold ref to |image|, to keep it alive until the browser ReclaimResources. |
| 154 // It guarantees that the resource is not re-used or deleted. | 154 // It guarantees that the resource is not re-used or deleted. |
| 155 m_cachedImages.add(m_nextResourceId, std::move(image)); | 155 m_cachedImages.add(m_nextResourceId, std::move(image)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 namespace { | 158 namespace { |
| 159 | 159 |
| 160 void updatePlaceholderImage(WeakPtr<OffscreenCanvasFrameDispatcher> dispatcher, | 160 void updatePlaceholderImage(WeakPtr<OffscreenCanvasFrameDispatcher> dispatcher, |
| 161 std::unique_ptr<WebTaskRunner> taskRunner, | 161 RefPtr<WebTaskRunner> taskRunner, |
| 162 int placeholderCanvasId, | 162 int placeholderCanvasId, |
| 163 RefPtr<blink::Image> image, | 163 RefPtr<blink::Image> image, |
| 164 unsigned resourceId) { | 164 unsigned resourceId) { |
| 165 DCHECK(isMainThread()); | 165 DCHECK(isMainThread()); |
| 166 OffscreenCanvasPlaceholder* placeholderCanvas = | 166 OffscreenCanvasPlaceholder* placeholderCanvas = |
| 167 OffscreenCanvasPlaceholder::getPlaceholderById(placeholderCanvasId); | 167 OffscreenCanvasPlaceholder::getPlaceholderById(placeholderCanvasId); |
| 168 if (placeholderCanvas) { | 168 if (placeholderCanvas) { |
| 169 placeholderCanvas->setPlaceholderFrame(std::move(image), | 169 placeholderCanvas->setPlaceholderFrame(std::move(image), |
| 170 std::move(dispatcher), | 170 std::move(dispatcher), |
| 171 std::move(taskRunner), resourceId); | 171 std::move(taskRunner), resourceId); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } else { | 236 } else { |
| 237 // Case 4: both canvas and compositor are not gpu accelerated. | 237 // Case 4: both canvas and compositor are not gpu accelerated. |
| 238 commitType = CommitSoftwareCanvasSoftwareCompositing; | 238 commitType = CommitSoftwareCanvasSoftwareCompositing; |
| 239 setTransferableResourceToSharedBitmap(resource, image); | 239 setTransferableResourceToSharedBitmap(resource, image); |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 | 242 |
| 243 // After this point, |image| can only be used on the main thread, until | 243 // After this point, |image| can only be used on the main thread, until |
| 244 // it is returned. | 244 // it is returned. |
| 245 image->transfer(); | 245 image->transfer(); |
| 246 std::unique_ptr<WebTaskRunner> dispatcherTaskRunner = | 246 RefPtr<WebTaskRunner> dispatcherTaskRunner = |
| 247 Platform::current()->currentThread()->getWebTaskRunner()->clone(); | 247 Platform::current()->currentThread()->getWebTaskRunner(); |
| 248 | 248 |
| 249 Platform::current()->mainThread()->getWebTaskRunner()->postTask( | 249 Platform::current()->mainThread()->getWebTaskRunner()->postTask( |
| 250 BLINK_FROM_HERE, | 250 BLINK_FROM_HERE, |
| 251 crossThreadBind(updatePlaceholderImage, this->createWeakPtr(), | 251 crossThreadBind(updatePlaceholderImage, this->createWeakPtr(), |
| 252 passed(std::move(dispatcherTaskRunner)), | 252 passed(std::move(dispatcherTaskRunner)), |
| 253 m_placeholderCanvasId, std::move(image), resource.id)); | 253 m_placeholderCanvasId, std::move(image), resource.id)); |
| 254 m_spareResourceLocks.add(m_nextResourceId); | 254 m_spareResourceLocks.add(m_nextResourceId); |
| 255 | 255 |
| 256 commitTypeHistogram.count(commitType); | 256 commitTypeHistogram.count(commitType); |
| 257 | 257 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 return true; | 405 return true; |
| 406 return false; | 406 return false; |
| 407 } | 407 } |
| 408 | 408 |
| 409 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) { | 409 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) { |
| 410 m_width = width; | 410 m_width = width; |
| 411 m_height = height; | 411 m_height = height; |
| 412 } | 412 } |
| 413 | 413 |
| 414 } // namespace blink | 414 } // namespace blink |
| OLD | NEW |