| 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/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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 cc::TransferableResource resource; | 180 cc::TransferableResource resource; |
| 182 resource.id = m_nextResourceId; | 181 resource.id = m_nextResourceId; |
| 183 resource.format = cc::ResourceFormat::RGBA_8888; | 182 resource.format = cc::ResourceFormat::RGBA_8888; |
| 184 // TODO(crbug.com/645590): filter should respect the image-rendering CSS | 183 // TODO(crbug.com/645590): filter should respect the image-rendering CSS |
| 185 // property of associated canvas element. | 184 // property of associated canvas element. |
| 186 resource.filter = GL_LINEAR; | 185 resource.filter = GL_LINEAR; |
| 187 resource.size = gfx::Size(m_width, m_height); | 186 resource.size = gfx::Size(m_width, m_height); |
| 188 // TODO(crbug.com/646022): making this overlay-able. | 187 // TODO(crbug.com/646022): making this overlay-able. |
| 189 resource.is_overlay_candidate = false; | 188 resource.is_overlay_candidate = false; |
| 190 | 189 |
| 190 DEFINE_THREAD_SAFE_STATIC_LOCAL( |
| 191 EnumerationHistogram, commitTypeHistogram, |
| 192 new EnumerationHistogram("OffscreenCanvas.CommitType", |
| 193 OffscreenCanvasCommitTypeCount)); |
| 191 if (!image->isTextureBacked() && | 194 if (!image->isTextureBacked() && |
| 192 !Platform::current()->isGPUCompositingEnabled()) | 195 !Platform::current()->isGPUCompositingEnabled()) { |
| 196 commitTypeHistogram.count(CommitSoftwareCanvasSoftwareCompositing); |
| 193 setTransferableResourceInMemory(resource, image); | 197 setTransferableResourceInMemory(resource, image); |
| 194 else if (!image->isTextureBacked() && | 198 } else if (!image->isTextureBacked() && |
| 195 Platform::current()->isGPUCompositingEnabled()) | 199 Platform::current()->isGPUCompositingEnabled()) { |
| 200 commitTypeHistogram.count(CommitSoftwareCanvasGPUCompositing); |
| 196 setTransferableResourceMemoryToTexture(resource, image); | 201 setTransferableResourceMemoryToTexture(resource, image); |
| 197 else if (image->isTextureBacked() && | 202 } else if (image->isTextureBacked() && |
| 198 (!Platform::current()->isGPUCompositingEnabled() || | 203 (!Platform::current()->isGPUCompositingEnabled() || |
| 199 isWebGLSoftwareRendering)) | 204 isWebGLSoftwareRendering)) { |
| 205 commitTypeHistogram.count(CommitGPUCanvasSoftwareCompositing); |
| 200 setTransferableResourceInMemory(resource, image); | 206 setTransferableResourceInMemory(resource, image); |
| 201 else | 207 } else { |
| 208 commitTypeHistogram.count(CommitGPUCanvasGPUCompositing); |
| 202 setTransferableResourceInTexture(resource, image); | 209 setTransferableResourceInTexture(resource, image); |
| 210 } |
| 203 | 211 |
| 204 m_nextResourceId++; | 212 m_nextResourceId++; |
| 205 frame.delegated_frame_data->resource_list.push_back(std::move(resource)); | 213 frame.delegated_frame_data->resource_list.push_back(std::move(resource)); |
| 206 | 214 |
| 207 cc::TextureDrawQuad* quad = | 215 cc::TextureDrawQuad* quad = |
| 208 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); | 216 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); |
| 209 gfx::Size rectSize(m_width, m_height); | 217 gfx::Size rectSize(m_width, m_height); |
| 210 | 218 |
| 211 const bool needsBlending = true; | 219 const bool needsBlending = true; |
| 212 // TOOD(crbug.com/645993): this should be inherited from WebGL context's | 220 // TOOD(crbug.com/645993): this should be inherited from WebGL context's |
| (...skipping 26 matching lines...) Expand all Loading... |
| 239 } | 247 } |
| 240 | 248 |
| 241 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize( | 249 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize( |
| 242 const sk_sp<SkImage>& image) { | 250 const sk_sp<SkImage>& image) { |
| 243 if (image && image->width() == m_width && image->height() == m_height) | 251 if (image && image->width() == m_width && image->height() == m_height) |
| 244 return true; | 252 return true; |
| 245 return false; | 253 return false; |
| 246 } | 254 } |
| 247 | 255 |
| 248 } // namespace blink | 256 } // namespace blink |
| OLD | NEW |