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

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

Issue 2400223002: Add UMA metrics to OffscreenCanvas's commit type (Closed)
Patch Set: rebase + address comments 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/output/delegated_frame_data.h" 8 #include "cc/output/delegated_frame_data.h"
9 #include "cc/quads/render_pass.h" 9 #include "cc/quads/render_pass.h"
10 #include "cc/quads/shared_quad_state.h" 10 #include "cc/quads/shared_quad_state.h"
11 #include "cc/quads/solid_color_draw_quad.h" 11 #include "cc/quads/solid_color_draw_quad.h"
12 #include "cc/quads/texture_draw_quad.h" 12 #include "cc/quads/texture_draw_quad.h"
13 #include "cc/resources/returned_resource.h" 13 #include "cc/resources/returned_resource.h"
14 #include "gpu/command_buffer/client/gles2_interface.h" 14 #include "gpu/command_buffer/client/gles2_interface.h"
15 #include "platform/RuntimeEnabledFeatures.h" 15 #include "platform/Histogram.h"
16 #include "platform/graphics/gpu/SharedGpuContext.h" 16 #include "platform/graphics/gpu/SharedGpuContext.h"
17 #include "platform/RuntimeEnabledFeatures.h"
18 #include "public/platform/InterfaceProvider.h" 17 #include "public/platform/InterfaceProvider.h"
19 #include "public/platform/Platform.h" 18 #include "public/platform/Platform.h"
20 #include "public/platform/WebGraphicsContext3DProvider.h" 19 #include "public/platform/WebGraphicsContext3DProvider.h"
21 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom -blink.h" 20 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom -blink.h"
22 #include "third_party/khronos/GLES2/gl2.h" 21 #include "third_party/khronos/GLES2/gl2.h"
23 #include "third_party/khronos/GLES2/gl2ext.h" 22 #include "third_party/khronos/GLES2/gl2ext.h"
24 #include "third_party/skia/include/core/SkColor.h" 23 #include "third_party/skia/include/core/SkColor.h"
25 #include "third_party/skia/include/core/SkImage.h" 24 #include "third_party/skia/include/core/SkImage.h"
26 #include "third_party/skia/include/core/SkXfermode.h" 25 #include "third_party/skia/include/core/SkXfermode.h"
27 #include "ui/gfx/geometry/rect.h" 26 #include "ui/gfx/geometry/rect.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 cc::TransferableResource resource; 175 cc::TransferableResource resource;
177 resource.id = m_nextResourceId; 176 resource.id = m_nextResourceId;
178 resource.format = cc::ResourceFormat::RGBA_8888; 177 resource.format = cc::ResourceFormat::RGBA_8888;
179 // TODO(crbug.com/645590): filter should respect the image-rendering CSS 178 // TODO(crbug.com/645590): filter should respect the image-rendering CSS
180 // property of associated canvas element. 179 // property of associated canvas element.
181 resource.filter = GL_LINEAR; 180 resource.filter = GL_LINEAR;
182 resource.size = gfx::Size(m_width, m_height); 181 resource.size = gfx::Size(m_width, m_height);
183 // TODO(crbug.com/646022): making this overlay-able. 182 // TODO(crbug.com/646022): making this overlay-able.
184 resource.is_overlay_candidate = false; 183 resource.is_overlay_candidate = false;
185 184
186 if (image->isTextureBacked() && 185 DEFINE_THREAD_SAFE_STATIC_LOCAL(
187 Platform::current()->isGPUCompositingEnabled() && 186 EnumerationHistogram, commitTypeHistogram,
188 !isWebGLSoftwareRendering) { 187 new EnumerationHistogram("OffscreenCanvas.CommitType",
189 // Case 1: both canvas and compositor are gpu accelerated. 188 OffscreenCanvasCommitTypeCount));
190 setTransferableResourceToStaticBitmapImage(resource, image); 189 if (image->isTextureBacked()) {
191 } else if (!Platform::current()->isGPUCompositingEnabled() || 190 if (Platform::current()->isGPUCompositingEnabled() &&
192 isWebGLSoftwareRendering) { 191 !isWebGLSoftwareRendering) {
193 // Case 2: both canvas and compositor are not gpu accelerated, or canvas is 192 // Case 1: both canvas and compositor are gpu accelerated.
194 // accelerated but --disable-gpu-compositing is specified, or 193 commitTypeHistogram.count(CommitGPUCanvasGPUCompositing);
195 // WebGL's commit called with swiftshader. The last case is indicated by 194 setTransferableResourceToStaticBitmapImage(resource, image);
196 // WebGraphicsContext3DProvider::isSoftwareRendering. 195 } else {
197 setTransferableResourceToSharedBitmap(resource, image); 196 // Case 2: canvas is accelerated but --disable-gpu-compositing is
197 // specified, or WebGL's commit is called with SwiftShader. The latter
198 // case is indicated by
199 // WebGraphicsContext3DProvider::isSoftwareRendering.
200 commitTypeHistogram.count(CommitGPUCanvasSoftwareCompositing);
201 setTransferableResourceToSharedBitmap(resource, image);
202 }
198 } else { 203 } else {
199 // Case 3: canvas is not gpu-accelerated, but compositor is. 204 if (Platform::current()->isGPUCompositingEnabled() &&
200 setTransferableResourceToSharedGPUContext(resource, image); 205 !isWebGLSoftwareRendering) {
206 // Case 3: canvas is not gpu-accelerated, but compositor is
207 commitTypeHistogram.count(CommitSoftwareCanvasGPUCompositing);
208 setTransferableResourceToSharedGPUContext(resource, image);
209 } else {
210 // Case 4: both canvas and compositor are not gpu accelerated.
211 commitTypeHistogram.count(CommitSoftwareCanvasSoftwareCompositing);
212 setTransferableResourceToSharedBitmap(resource, image);
213 }
201 } 214 }
202 215
203 m_nextResourceId++; 216 m_nextResourceId++;
204 frame.delegated_frame_data->resource_list.push_back(std::move(resource)); 217 frame.delegated_frame_data->resource_list.push_back(std::move(resource));
205 218
206 cc::TextureDrawQuad* quad = 219 cc::TextureDrawQuad* quad =
207 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); 220 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
208 gfx::Size rectSize(m_width, m_height); 221 gfx::Size rectSize(m_width, m_height);
209 222
210 const bool needsBlending = true; 223 const bool needsBlending = true;
(...skipping 27 matching lines...) Expand all
238 } 251 }
239 252
240 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize( 253 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize(
241 const sk_sp<SkImage>& image) { 254 const sk_sp<SkImage>& image) {
242 if (image && image->width() == m_width && image->height() == m_height) 255 if (image && image->width() == m_width && image->height() == m_height)
243 return true; 256 return true;
244 return false; 257 return false;
245 } 258 }
246 259
247 } // namespace blink 260 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698