| 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/CrossThreadFunctional.h" | 10 #include "platform/CrossThreadFunctional.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 pass->SetNew(renderPassId, bounds, bounds, gfx::Transform()); | 202 pass->SetNew(renderPassId, bounds, bounds, gfx::Transform()); |
| 203 pass->has_transparent_background = false; | 203 pass->has_transparent_background = false; |
| 204 | 204 |
| 205 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 205 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| 206 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f, | 206 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f, |
| 207 SkBlendMode::kSrcOver, 0); | 207 SkBlendMode::kSrcOver, 0); |
| 208 | 208 |
| 209 cc::TransferableResource resource; | 209 cc::TransferableResource resource; |
| 210 resource.id = m_nextResourceId; | 210 resource.id = m_nextResourceId; |
| 211 resource.format = cc::ResourceFormat::RGBA_8888; | 211 resource.format = cc::ResourceFormat::RGBA_8888; |
| 212 // TODO(crbug.com/645590): filter should respect the image-rendering CSS | |
| 213 // property of associated canvas element. | |
| 214 resource.filter = GL_LINEAR; | |
| 215 resource.size = gfx::Size(m_width, m_height); | 212 resource.size = gfx::Size(m_width, m_height); |
| 216 // TODO(crbug.com/646022): making this overlay-able. | 213 // TODO(crbug.com/646022): making this overlay-able. |
| 217 resource.is_overlay_candidate = false; | 214 resource.is_overlay_candidate = false; |
| 218 | 215 |
| 219 bool yflipped = false; | 216 bool yflipped = false; |
| 220 OffscreenCanvasCommitType commitType; | 217 OffscreenCanvasCommitType commitType; |
| 221 DEFINE_THREAD_SAFE_STATIC_LOCAL( | 218 DEFINE_THREAD_SAFE_STATIC_LOCAL( |
| 222 EnumerationHistogram, commitTypeHistogram, | 219 EnumerationHistogram, commitTypeHistogram, |
| 223 new EnumerationHistogram("OffscreenCanvas.CommitType", | 220 new EnumerationHistogram("OffscreenCanvas.CommitType", |
| 224 OffscreenCanvasCommitTypeCount)); | 221 OffscreenCanvasCommitTypeCount)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 271 |
| 275 const bool needsBlending = true; | 272 const bool needsBlending = true; |
| 276 // TOOD(crbug.com/645993): this should be inherited from WebGL context's | 273 // TOOD(crbug.com/645993): this should be inherited from WebGL context's |
| 277 // creation settings. | 274 // creation settings. |
| 278 const bool premultipliedAlpha = true; | 275 const bool premultipliedAlpha = true; |
| 279 const gfx::PointF uvTopLeft(0.f, 0.f); | 276 const gfx::PointF uvTopLeft(0.f, 0.f); |
| 280 const gfx::PointF uvBottomRight(1.f, 1.f); | 277 const gfx::PointF uvBottomRight(1.f, 1.f); |
| 281 float vertexOpacity[4] = {1.f, 1.f, 1.f, 1.f}; | 278 float vertexOpacity[4] = {1.f, 1.f, 1.f, 1.f}; |
| 282 // TODO(crbug.com/645994): this should be true when using style | 279 // TODO(crbug.com/645994): this should be true when using style |
| 283 // "image-rendering: pixelated". | 280 // "image-rendering: pixelated". |
| 281 // TODO(crbug.com/645590): filter should respect the image-rendering CSS |
| 282 // property of associated canvas element. |
| 284 const bool nearestNeighbor = false; | 283 const bool nearestNeighbor = false; |
| 285 quad->SetAll(sqs, bounds, bounds, bounds, needsBlending, resource.id, | 284 quad->SetAll(sqs, bounds, bounds, bounds, needsBlending, resource.id, |
| 286 gfx::Size(), premultipliedAlpha, uvTopLeft, uvBottomRight, | 285 gfx::Size(), premultipliedAlpha, uvTopLeft, uvBottomRight, |
| 287 SK_ColorTRANSPARENT, vertexOpacity, yflipped, nearestNeighbor, | 286 SK_ColorTRANSPARENT, vertexOpacity, yflipped, nearestNeighbor, |
| 288 false); | 287 false); |
| 289 | 288 |
| 290 frame.render_pass_list.push_back(std::move(pass)); | 289 frame.render_pass_list.push_back(std::move(pass)); |
| 291 | 290 |
| 292 double elapsedTime = WTF::monotonicallyIncreasingTime() - commitStartTime; | 291 double elapsedTime = WTF::monotonicallyIncreasingTime() - commitStartTime; |
| 293 | 292 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 450 |
| 452 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) { | 451 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) { |
| 453 if (m_width != width || m_height != height) { | 452 if (m_width != width || m_height != height) { |
| 454 m_width = width; | 453 m_width = width; |
| 455 m_height = height; | 454 m_height = height; |
| 456 m_changeSizeForNextCommit = true; | 455 m_changeSizeForNextCommit = true; |
| 457 } | 456 } |
| 458 } | 457 } |
| 459 | 458 |
| 460 } // namespace blink | 459 } // namespace blink |
| OLD | NEW |