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

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

Issue 2774903003: Fix the compositing of placeholder canvas backgrounds (Closed)
Patch Set: fix comments Created 3 years, 8 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/CrossThreadFunctional.h" 10 #include "platform/CrossThreadFunctional.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 return; 208 return;
209 } 209 }
210 cc::CompositorFrame frame; 210 cc::CompositorFrame frame;
211 // TODO(crbug.com/652931): update the device_scale_factor 211 // TODO(crbug.com/652931): update the device_scale_factor
212 frame.metadata.device_scale_factor = 1.0f; 212 frame.metadata.device_scale_factor = 1.0f;
213 213
214 const gfx::Rect bounds(m_width, m_height); 214 const gfx::Rect bounds(m_width, m_height);
215 const int renderPassId = 1; 215 const int renderPassId = 1;
216 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); 216 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
217 pass->SetNew(renderPassId, bounds, bounds, gfx::Transform()); 217 pass->SetNew(renderPassId, bounds, bounds, gfx::Transform());
218 pass->has_transparent_background = false;
219 218
220 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 219 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
221 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f, 220 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f,
222 SkBlendMode::kSrcOver, 0); 221 SkBlendMode::kSrcOver, 0);
223 222
224 cc::TransferableResource resource; 223 cc::TransferableResource resource;
225 resource.id = m_nextResourceId; 224 resource.id = m_nextResourceId;
226 resource.format = cc::ResourceFormat::RGBA_8888; 225 resource.format = cc::ResourceFormat::RGBA_8888;
227 resource.size = gfx::Size(m_width, m_height); 226 resource.size = gfx::Size(m_width, m_height);
228 // TODO(crbug.com/646022): making this overlay-able. 227 // TODO(crbug.com/646022): making this overlay-able.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 postImageToPlaceholder(std::move(image)); 264 postImageToPlaceholder(std::move(image));
266 commitTypeHistogram.count(commitType); 265 commitTypeHistogram.count(commitType);
267 266
268 m_nextResourceId++; 267 m_nextResourceId++;
269 frame.resource_list.push_back(std::move(resource)); 268 frame.resource_list.push_back(std::move(resource));
270 269
271 cc::TextureDrawQuad* quad = 270 cc::TextureDrawQuad* quad =
272 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); 271 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
273 gfx::Size rectSize(m_width, m_height); 272 gfx::Size rectSize(m_width, m_height);
274 273
274 // TODO(crbug.com/705019): optimize for contexts that have {alpha: false}
275 const bool needsBlending = true; 275 const bool needsBlending = true;
276 gfx::Rect opaqueRect(0, 0);
277
276 // TOOD(crbug.com/645993): this should be inherited from WebGL context's 278 // TOOD(crbug.com/645993): this should be inherited from WebGL context's
277 // creation settings. 279 // creation settings.
278 const bool premultipliedAlpha = true; 280 const bool premultipliedAlpha = true;
279 const gfx::PointF uvTopLeft(0.f, 0.f); 281 const gfx::PointF uvTopLeft(0.f, 0.f);
280 const gfx::PointF uvBottomRight(1.f, 1.f); 282 const gfx::PointF uvBottomRight(1.f, 1.f);
281 float vertexOpacity[4] = {1.f, 1.f, 1.f, 1.f}; 283 float vertexOpacity[4] = {1.f, 1.f, 1.f, 1.f};
282 // TODO(crbug.com/645994): this should be true when using style 284 // TODO(crbug.com/645994): this should be true when using style
283 // "image-rendering: pixelated". 285 // "image-rendering: pixelated".
284 // TODO(crbug.com/645590): filter should respect the image-rendering CSS 286 // TODO(crbug.com/645590): filter should respect the image-rendering CSS
285 // property of associated canvas element. 287 // property of associated canvas element.
286 const bool nearestNeighbor = false; 288 const bool nearestNeighbor = false;
287 quad->SetAll(sqs, bounds, bounds, bounds, needsBlending, resource.id, 289 quad->SetAll(sqs, bounds, opaqueRect, bounds, needsBlending, resource.id,
288 gfx::Size(), premultipliedAlpha, uvTopLeft, uvBottomRight, 290 gfx::Size(), premultipliedAlpha, uvTopLeft, uvBottomRight,
289 SK_ColorTRANSPARENT, vertexOpacity, yflipped, nearestNeighbor, 291 SK_ColorTRANSPARENT, vertexOpacity, yflipped, nearestNeighbor,
290 false); 292 false);
291 293
292 frame.render_pass_list.push_back(std::move(pass)); 294 frame.render_pass_list.push_back(std::move(pass));
293 295
294 double elapsedTime = WTF::monotonicallyIncreasingTime() - commitStartTime; 296 double elapsedTime = WTF::monotonicallyIncreasingTime() - commitStartTime;
295 297
296 switch (commitType) { 298 switch (commitType) {
297 case CommitGPUCanvasGPUCompositing: 299 case CommitGPUCanvasGPUCompositing:
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 453
452 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) { 454 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) {
453 if (m_width != width || m_height != height) { 455 if (m_width != width || m_height != height) {
454 m_width = width; 456 m_width = width;
455 m_height = height; 457 m_height = height;
456 m_changeSizeForNextCommit = true; 458 m_changeSizeForNextCommit = true;
457 } 459 }
458 } 460 }
459 461
460 } // namespace blink 462 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698