| 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/Histogram.h" | 10 #include "platform/Histogram.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // Hold ref to |textureId| for the piece of GPU memory where the pixel data | 129 // Hold ref to |textureId| for the piece of GPU memory where the pixel data |
| 130 // is uploaded to, to keep it alive until the browser ReclaimResources. | 130 // is uploaded to, to keep it alive until the browser ReclaimResources. |
| 131 m_cachedTextureIds.add(m_nextResourceId, textureId); | 131 m_cachedTextureIds.add(m_nextResourceId, textureId); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void OffscreenCanvasFrameDispatcherImpl:: | 134 void OffscreenCanvasFrameDispatcherImpl:: |
| 135 setTransferableResourceToStaticBitmapImage( | 135 setTransferableResourceToStaticBitmapImage( |
| 136 cc::TransferableResource& resource, | 136 cc::TransferableResource& resource, |
| 137 RefPtr<StaticBitmapImage> image) { | 137 RefPtr<StaticBitmapImage> image) { |
| 138 image->ensureMailbox(); | 138 image->ensureMailbox(); |
| 139 resource.mailbox_holder = gpu::MailboxHolder( | 139 resource.mailbox_holder = |
| 140 image->getMailbox(), image->getSyncToken(), GL_TEXTURE_2D); | 140 gpu::MailboxHolder(image->mailbox(), image->syncToken(), GL_TEXTURE_2D); |
| 141 resource.read_lock_fences_enabled = false; | 141 resource.read_lock_fences_enabled = false; |
| 142 resource.is_software = false; | 142 resource.is_software = false; |
| 143 | 143 |
| 144 // Hold ref to |image|, to keep it alive until the browser ReclaimResources. | 144 // Hold ref to |image|, to keep it alive until the browser ReclaimResources. |
| 145 // It guarantees that the resource is not re-used or deleted. | 145 // It guarantees that the resource is not re-used or deleted. |
| 146 m_cachedImages.add(m_nextResourceId, std::move(image)); | 146 m_cachedImages.add(m_nextResourceId, std::move(image)); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void OffscreenCanvasFrameDispatcherImpl::dispatchFrame( | 149 void OffscreenCanvasFrameDispatcherImpl::dispatchFrame( |
| 150 RefPtr<StaticBitmapImage> image, | 150 RefPtr<StaticBitmapImage> image, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 m_sink->SubmitCompositorFrame(std::move(frame)); | 314 m_sink->SubmitCompositorFrame(std::move(frame)); |
| 315 } | 315 } |
| 316 | 316 |
| 317 void OffscreenCanvasFrameDispatcherImpl::DidReceiveCompositorFrameAck() { | 317 void OffscreenCanvasFrameDispatcherImpl::DidReceiveCompositorFrameAck() { |
| 318 // TODO(fsamuel): Implement this. | 318 // TODO(fsamuel): Implement this. |
| 319 } | 319 } |
| 320 | 320 |
| 321 void OffscreenCanvasFrameDispatcherImpl::ReclaimResources( | 321 void OffscreenCanvasFrameDispatcherImpl::ReclaimResources( |
| 322 const cc::ReturnedResourceArray& resources) { | 322 const cc::ReturnedResourceArray& resources) { |
| 323 for (const auto& resource : resources) { | 323 for (const auto& resource : resources) { |
| 324 RefPtr<StaticBitmapImage> image = m_cachedImages.get(resource.id); |
| 325 if (image) |
| 326 image->updateSyncToken(resource.sync_token); |
| 324 m_cachedImages.remove(resource.id); | 327 m_cachedImages.remove(resource.id); |
| 325 m_sharedBitmaps.remove(resource.id); | 328 m_sharedBitmaps.remove(resource.id); |
| 326 m_cachedTextureIds.remove(resource.id); | 329 m_cachedTextureIds.remove(resource.id); |
| 327 } | 330 } |
| 328 } | 331 } |
| 329 | 332 |
| 330 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize( | 333 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize( |
| 331 const sk_sp<SkImage>& image) { | 334 const sk_sp<SkImage>& image) { |
| 332 if (image && image->width() == m_width && image->height() == m_height) | 335 if (image && image->width() == m_width && image->height() == m_height) |
| 333 return true; | 336 return true; |
| 334 return false; | 337 return false; |
| 335 } | 338 } |
| 336 | 339 |
| 337 } // namespace blink | 340 } // namespace blink |
| OLD | NEW |