Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp

Issue 2430653002: Mus+Ash: Towards Unifying CompositorFrameSink terminology (Closed)
Patch Set: Fix bitmap_uploader Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 image->isPremultiplied() ? kPremul_SkAlphaType : kUnpremul_SkAlphaType); 61 image->isPremultiplied() ? kPremul_SkAlphaType : kUnpremul_SkAlphaType);
62 // TODO(xlai): Optimize to avoid copying pixels. See crbug.com/651456. 62 // TODO(xlai): Optimize to avoid copying pixels. See crbug.com/651456.
63 // However, in the case when |image| is texture backed, this function call 63 // However, in the case when |image| is texture backed, this function call
64 // does a GPU readback which is required. 64 // does a GPU readback which is required.
65 image->imageForCurrentFrame()->readPixels(imageInfo, pixels, 65 image->imageForCurrentFrame()->readPixels(imageInfo, pixels,
66 imageInfo.minRowBytes(), 0, 0); 66 imageInfo.minRowBytes(), 0, 0);
67 resource.mailbox_holder.mailbox = bitmap->id(); 67 resource.mailbox_holder.mailbox = bitmap->id();
68 resource.mailbox_holder.texture_target = 0; 68 resource.mailbox_holder.texture_target = 0;
69 resource.is_software = true; 69 resource.is_software = true;
70 70
71 // Hold ref to |bitmap|, to keep it alive until the browser ReturnResources. 71 // Hold ref to |bitmap|, to keep it alive until the browser ReclaimResources.
72 // It guarantees that the shared bitmap is not re-used or deleted. 72 // It guarantees that the shared bitmap is not re-used or deleted.
73 m_sharedBitmaps.add(m_nextResourceId, std::move(bitmap)); 73 m_sharedBitmaps.add(m_nextResourceId, std::move(bitmap));
74 } 74 }
75 75
76 void OffscreenCanvasFrameDispatcherImpl:: 76 void OffscreenCanvasFrameDispatcherImpl::
77 setTransferableResourceToSharedGPUContext( 77 setTransferableResourceToSharedGPUContext(
78 cc::TransferableResource& resource, 78 cc::TransferableResource& resource,
79 RefPtr<StaticBitmapImage> image) { 79 RefPtr<StaticBitmapImage> image) {
80 // TODO(crbug.com/652707): When committing the first frame, there is no 80 // TODO(crbug.com/652707): When committing the first frame, there is no
81 // instance of SharedGpuContext yet, calling SharedGpuContext::gl() will 81 // instance of SharedGpuContext yet, calling SharedGpuContext::gl() will
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 gl->ShallowFlushCHROMIUM(); 119 gl->ShallowFlushCHROMIUM();
120 gpu::SyncToken syncToken; 120 gpu::SyncToken syncToken;
121 gl->GenSyncTokenCHROMIUM(fenceSync, syncToken.GetData()); 121 gl->GenSyncTokenCHROMIUM(fenceSync, syncToken.GetData());
122 122
123 resource.mailbox_holder = 123 resource.mailbox_holder =
124 gpu::MailboxHolder(mailbox, syncToken, GL_TEXTURE_2D); 124 gpu::MailboxHolder(mailbox, syncToken, GL_TEXTURE_2D);
125 resource.read_lock_fences_enabled = false; 125 resource.read_lock_fences_enabled = false;
126 resource.is_software = false; 126 resource.is_software = false;
127 127
128 // Hold ref to |textureId| for the piece of GPU memory where the pixel data 128 // Hold ref to |textureId| for the piece of GPU memory where the pixel data
129 // is uploaded to, to keep it alive until the browser ReturnResources. 129 // is uploaded to, to keep it alive until the browser ReclaimResources.
130 m_cachedTextureIds.add(m_nextResourceId, textureId); 130 m_cachedTextureIds.add(m_nextResourceId, textureId);
131 } 131 }
132 132
133 void OffscreenCanvasFrameDispatcherImpl:: 133 void OffscreenCanvasFrameDispatcherImpl::
134 setTransferableResourceToStaticBitmapImage( 134 setTransferableResourceToStaticBitmapImage(
135 cc::TransferableResource& resource, 135 cc::TransferableResource& resource,
136 RefPtr<StaticBitmapImage> image) { 136 RefPtr<StaticBitmapImage> image) {
137 image->ensureMailbox(); 137 image->ensureMailbox();
138 resource.mailbox_holder = gpu::MailboxHolder( 138 resource.mailbox_holder = gpu::MailboxHolder(
139 image->getMailbox(), image->getSyncToken(), GL_TEXTURE_2D); 139 image->getMailbox(), image->getSyncToken(), GL_TEXTURE_2D);
140 resource.read_lock_fences_enabled = false; 140 resource.read_lock_fences_enabled = false;
141 resource.is_software = false; 141 resource.is_software = false;
142 142
143 // Hold ref to |image|, to keep it alive until the browser ReturnResources. 143 // Hold ref to |image|, to keep it alive until the browser ReclaimResources.
144 // It guarantees that the resource is not re-used or deleted. 144 // It guarantees that the resource is not re-used or deleted.
145 m_cachedImages.add(m_nextResourceId, std::move(image)); 145 m_cachedImages.add(m_nextResourceId, std::move(image));
146 } 146 }
147 147
148 void OffscreenCanvasFrameDispatcherImpl::dispatchFrame( 148 void OffscreenCanvasFrameDispatcherImpl::dispatchFrame(
149 RefPtr<StaticBitmapImage> image, 149 RefPtr<StaticBitmapImage> image,
150 double commitStartTime, 150 double commitStartTime,
151 bool isWebGLSoftwareRendering /* This flag is true when WebGL's commit is 151 bool isWebGLSoftwareRendering /* This flag is true when WebGL's commit is
152 called on SwiftShader. */) { 152 called on SwiftShader. */) {
153 if (!image) 153 if (!image)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 "SoftwareCanvasSoftwareCompositingWorker", 305 "SoftwareCanvasSoftwareCompositingWorker",
306 0, 10000000, 50)); 306 0, 10000000, 50));
307 commitSoftwareCanvasSoftwareCompositingWorkerTimer.count(elapsedTime * 307 commitSoftwareCanvasSoftwareCompositingWorkerTimer.count(elapsedTime *
308 1000000.0); 308 1000000.0);
309 } 309 }
310 break; 310 break;
311 case OffscreenCanvasCommitTypeCount: 311 case OffscreenCanvasCommitTypeCount:
312 NOTREACHED(); 312 NOTREACHED();
313 } 313 }
314 314
315 m_sink->SubmitCompositorFrame(std::move(frame), base::Closure()); 315 m_sink->SubmitCompositorFrame(std::move(frame));
316 } 316 }
317 317
318 void OffscreenCanvasFrameDispatcherImpl::ReturnResources( 318 void OffscreenCanvasFrameDispatcherImpl::DidReceiveCompositorFrameAck() {
319 // FIXME: Implement this.
rjkroege 2016/10/20 21:33:18 TODO(fsamuel)
Fady Samuel 2016/10/20 23:04:10 Done.
320 }
321
322 void OffscreenCanvasFrameDispatcherImpl::ReclaimResources(
319 const cc::ReturnedResourceArray& resources) { 323 const cc::ReturnedResourceArray& resources) {
320 for (const auto& resource : resources) { 324 for (const auto& resource : resources) {
321 m_cachedImages.remove(resource.id); 325 m_cachedImages.remove(resource.id);
322 m_sharedBitmaps.remove(resource.id); 326 m_sharedBitmaps.remove(resource.id);
323 m_cachedTextureIds.remove(resource.id); 327 m_cachedTextureIds.remove(resource.id);
324 } 328 }
325 } 329 }
326 330
327 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize( 331 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize(
328 const sk_sp<SkImage>& image) { 332 const sk_sp<SkImage>& image) {
329 if (image && image->width() == m_width && image->height() == m_height) 333 if (image && image->width() == m_width && image->height() == m_height)
330 return true; 334 return true;
331 return false; 335 return false;
332 } 336 }
333 337
334 } // namespace blink 338 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698