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

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

Issue 2449853004: Getting rid of DelegatedFrameData (Closed)
Patch Set: Dana's comment rebase Created 4 years, 1 month 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 double commitStartTime, 152 double commitStartTime,
153 bool isWebGLSoftwareRendering /* This flag is true when WebGL's commit is 153 bool isWebGLSoftwareRendering /* This flag is true when WebGL's commit is
154 called on SwiftShader. */) { 154 called on SwiftShader. */) {
155 if (!image) 155 if (!image)
156 return; 156 return;
157 if (!verifyImageSize(image->imageForCurrentFrame())) 157 if (!verifyImageSize(image->imageForCurrentFrame()))
158 return; 158 return;
159 cc::CompositorFrame frame; 159 cc::CompositorFrame frame;
160 // TODO(crbug.com/652931): update the device_scale_factor 160 // TODO(crbug.com/652931): update the device_scale_factor
161 frame.metadata.device_scale_factor = 1.0f; 161 frame.metadata.device_scale_factor = 1.0f;
162 frame.delegated_frame_data.reset(new cc::DelegatedFrameData);
163 162
164 const gfx::Rect bounds(m_width, m_height); 163 const gfx::Rect bounds(m_width, m_height);
165 const cc::RenderPassId renderPassId(1, 1); 164 const cc::RenderPassId renderPassId(1, 1);
166 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); 165 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
167 pass->SetAll(renderPassId, bounds, bounds, gfx::Transform(), false); 166 pass->SetAll(renderPassId, bounds, bounds, gfx::Transform(), false);
168 167
169 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 168 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
170 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f, 169 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f,
171 SkXfermode::kSrcOver_Mode, 0); 170 SkXfermode::kSrcOver_Mode, 0);
172 171
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 setTransferableResourceToSharedGPUContext(resource, image); 208 setTransferableResourceToSharedGPUContext(resource, image);
210 } else { 209 } else {
211 // Case 4: both canvas and compositor are not gpu accelerated. 210 // Case 4: both canvas and compositor are not gpu accelerated.
212 commitType = CommitSoftwareCanvasSoftwareCompositing; 211 commitType = CommitSoftwareCanvasSoftwareCompositing;
213 setTransferableResourceToSharedBitmap(resource, image); 212 setTransferableResourceToSharedBitmap(resource, image);
214 } 213 }
215 } 214 }
216 commitTypeHistogram.count(commitType); 215 commitTypeHistogram.count(commitType);
217 216
218 m_nextResourceId++; 217 m_nextResourceId++;
219 frame.delegated_frame_data->resource_list.push_back(std::move(resource)); 218 frame.resource_list.push_back(std::move(resource));
220 219
221 cc::TextureDrawQuad* quad = 220 cc::TextureDrawQuad* quad =
222 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); 221 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
223 gfx::Size rectSize(m_width, m_height); 222 gfx::Size rectSize(m_width, m_height);
224 223
225 const bool needsBlending = true; 224 const bool needsBlending = true;
226 // TOOD(crbug.com/645993): this should be inherited from WebGL context's 225 // TOOD(crbug.com/645993): this should be inherited from WebGL context's
227 // creation settings. 226 // creation settings.
228 const bool premultipliedAlpha = true; 227 const bool premultipliedAlpha = true;
229 const gfx::PointF uvTopLeft(0.f, 0.f); 228 const gfx::PointF uvTopLeft(0.f, 0.f);
230 const gfx::PointF uvBottomRight(1.f, 1.f); 229 const gfx::PointF uvBottomRight(1.f, 1.f);
231 float vertexOpacity[4] = {1.f, 1.f, 1.f, 1.f}; 230 float vertexOpacity[4] = {1.f, 1.f, 1.f, 1.f};
232 // TODO(crbug.com/645994): this should be true when using style 231 // TODO(crbug.com/645994): this should be true when using style
233 // "image-rendering: pixelated". 232 // "image-rendering: pixelated".
234 const bool nearestNeighbor = false; 233 const bool nearestNeighbor = false;
235 quad->SetAll(sqs, bounds, bounds, bounds, needsBlending, resource.id, 234 quad->SetAll(sqs, bounds, bounds, bounds, needsBlending, resource.id,
236 gfx::Size(), premultipliedAlpha, uvTopLeft, uvBottomRight, 235 gfx::Size(), premultipliedAlpha, uvTopLeft, uvBottomRight,
237 SK_ColorTRANSPARENT, vertexOpacity, yflipped, nearestNeighbor, 236 SK_ColorTRANSPARENT, vertexOpacity, yflipped, nearestNeighbor,
238 false); 237 false);
239 238
240 frame.delegated_frame_data->render_pass_list.push_back(std::move(pass)); 239 frame.render_pass_list.push_back(std::move(pass));
241 240
242 double elapsedTime = WTF::monotonicallyIncreasingTime() - commitStartTime; 241 double elapsedTime = WTF::monotonicallyIncreasingTime() - commitStartTime;
243 switch (commitType) { 242 switch (commitType) {
244 case CommitGPUCanvasGPUCompositing: 243 case CommitGPUCanvasGPUCompositing:
245 if (isMainThread()) { 244 if (isMainThread()) {
246 DEFINE_STATIC_LOCAL( 245 DEFINE_STATIC_LOCAL(
247 CustomCountHistogram, commitGPUCanvasGPUCompositingMainTimer, 246 CustomCountHistogram, commitGPUCanvasGPUCompositingMainTimer,
248 ("Blink.Canvas.OffscreenCommit.GPUCanvasGPUCompositingMain", 0, 247 ("Blink.Canvas.OffscreenCommit.GPUCanvasGPUCompositingMain", 0,
249 10000000, 50)); 248 10000000, 50));
250 commitGPUCanvasGPUCompositingMainTimer.count(elapsedTime * 1000000.0); 249 commitGPUCanvasGPUCompositingMainTimer.count(elapsedTime * 1000000.0);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 329 }
331 330
332 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize( 331 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize(
333 const sk_sp<SkImage>& image) { 332 const sk_sp<SkImage>& image) {
334 if (image && image->width() == m_width && image->height() == m_height) 333 if (image && image->width() == m_width && image->height() == m_height)
335 return true; 334 return true;
336 return false; 335 return false;
337 } 336 }
338 337
339 } // namespace blink 338 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698