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

Side by Side Diff: cc/layers/delegated_renderer_layer_impl.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl.h ('k') | cc/layers/draw_properties.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/layers/delegated_renderer_layer_impl.h" 5 #include "cc/layers/delegated_renderer_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 bool DelegatedRendererLayerImpl::WillDraw(DrawMode draw_mode, 249 bool DelegatedRendererLayerImpl::WillDraw(DrawMode draw_mode,
250 ResourceProvider* resource_provider) { 250 ResourceProvider* resource_provider) {
251 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) 251 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE)
252 return false; 252 return false;
253 return LayerImpl::WillDraw(draw_mode, resource_provider); 253 return LayerImpl::WillDraw(draw_mode, resource_provider);
254 } 254 }
255 255
256 void DelegatedRendererLayerImpl::AppendQuads( 256 void DelegatedRendererLayerImpl::AppendQuads(
257 RenderPass* render_pass, 257 RenderPass* render_pass,
258 const Occlusion& occlusion_in_content_space,
259 AppendQuadsData* append_quads_data) { 258 AppendQuadsData* append_quads_data) {
260 AppendRainbowDebugBorder(render_pass); 259 AppendRainbowDebugBorder(render_pass);
261 260
262 // This list will be empty after a lost context until a new frame arrives. 261 // This list will be empty after a lost context until a new frame arrives.
263 if (render_passes_in_draw_order_.empty()) 262 if (render_passes_in_draw_order_.empty())
264 return; 263 return;
265 264
266 RenderPassId target_render_pass_id = render_pass->id; 265 RenderPassId target_render_pass_id = render_pass->id;
267 266
268 const RenderPass* root_delegated_render_pass = 267 const RenderPass* root_delegated_render_pass =
269 render_passes_in_draw_order_.back(); 268 render_passes_in_draw_order_.back();
270 269
271 DCHECK(root_delegated_render_pass->output_rect.origin().IsOrigin()); 270 DCHECK(root_delegated_render_pass->output_rect.origin().IsOrigin());
272 gfx::Size frame_size = root_delegated_render_pass->output_rect.size(); 271 gfx::Size frame_size = root_delegated_render_pass->output_rect.size();
273 272
274 // If the index of the RenderPassId is 0, then it is a RenderPass generated 273 // If the index of the RenderPassId is 0, then it is a RenderPass generated
275 // for a layer in this compositor, not the delegating renderer. Then we want 274 // for a layer in this compositor, not the delegating renderer. Then we want
276 // to merge our root RenderPass with the target RenderPass. Otherwise, it is 275 // to merge our root RenderPass with the target RenderPass. Otherwise, it is
277 // some RenderPass which we added from the delegating renderer. 276 // some RenderPass which we added from the delegating renderer.
278 bool should_merge_root_render_pass_with_target = !target_render_pass_id.index; 277 bool should_merge_root_render_pass_with_target = !target_render_pass_id.index;
279 if (should_merge_root_render_pass_with_target) { 278 if (should_merge_root_render_pass_with_target) {
280 // Verify that the RenderPass we are appending to is created by our 279 // Verify that the RenderPass we are appending to is created by our
281 // render_target. 280 // render_target.
282 DCHECK(target_render_pass_id.layer_id == render_target()->id()); 281 DCHECK(target_render_pass_id.layer_id == render_target()->id());
283 282
284 AppendRenderPassQuads(render_pass, 283 AppendRenderPassQuads(render_pass,
285 occlusion_in_content_space,
286 root_delegated_render_pass, 284 root_delegated_render_pass,
287 frame_size); 285 frame_size);
288 } else { 286 } else {
289 // Verify that the RenderPass we are appending to was created by us. 287 // Verify that the RenderPass we are appending to was created by us.
290 DCHECK(target_render_pass_id.layer_id == id()); 288 DCHECK(target_render_pass_id.layer_id == id());
291 289
292 int render_pass_index = IdToIndex(target_render_pass_id.index); 290 int render_pass_index = IdToIndex(target_render_pass_id.index);
293 const RenderPass* delegated_render_pass = 291 const RenderPass* delegated_render_pass =
294 render_passes_in_draw_order_[render_pass_index]; 292 render_passes_in_draw_order_[render_pass_index];
295 AppendRenderPassQuads(render_pass, 293 AppendRenderPassQuads(render_pass,
296 occlusion_in_content_space,
297 delegated_render_pass, 294 delegated_render_pass,
298 frame_size); 295 frame_size);
299 } 296 }
300 } 297 }
301 298
302 void DelegatedRendererLayerImpl::AppendRainbowDebugBorder( 299 void DelegatedRendererLayerImpl::AppendRainbowDebugBorder(
303 RenderPass* render_pass) { 300 RenderPass* render_pass) {
304 if (!ShowDebugBorders()) 301 if (!ShowDebugBorders())
305 return; 302 return;
306 303
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 gfx::Rect left(0, y, border_width, height); 339 gfx::Rect left(0, y, border_width, height);
343 gfx::Rect right(content_bounds().width() - border_width, 340 gfx::Rect right(content_bounds().width() - border_width,
344 y, 341 y,
345 border_width, 342 border_width,
346 height); 343 height);
347 344
348 if (top.IsEmpty() && left.IsEmpty()) 345 if (top.IsEmpty() && left.IsEmpty())
349 break; 346 break;
350 347
351 if (!top.IsEmpty()) { 348 if (!top.IsEmpty()) {
349 bool force_anti_aliasing_off = false;
352 SolidColorDrawQuad* top_quad = 350 SolidColorDrawQuad* top_quad =
353 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 351 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
354 top_quad->SetNew( 352 top_quad->SetNew(shared_quad_state, top, top, colors[i % kNumColors],
355 shared_quad_state, top, top, colors[i % kNumColors], false); 353 force_anti_aliasing_off);
356 354
357 SolidColorDrawQuad* bottom_quad = 355 SolidColorDrawQuad* bottom_quad =
358 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 356 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
359 bottom_quad->SetNew(shared_quad_state, 357 bottom_quad->SetNew(shared_quad_state, bottom, bottom,
360 bottom,
361 bottom,
362 colors[kNumColors - 1 - (i % kNumColors)], 358 colors[kNumColors - 1 - (i % kNumColors)],
363 false); 359 force_anti_aliasing_off);
360
361 if (contents_opaque()) {
362 // Draws a stripe filling the layer vertically with the same color and
363 // width as the horizontal stipes along the layer's top border.
364 SolidColorDrawQuad* solid_quad =
365 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
366 // The inner fill is more transparent then the border.
367 static const float kFillOpacity = 0.1f;
368 SkColor fill_color = SkColorSetA(
369 colors[i % kNumColors],
370 static_cast<uint8_t>(SkColorGetA(colors[i % kNumColors]) *
371 kFillOpacity));
372 gfx::Rect fill_rect(x, 0, width, content_bounds().height());
373 solid_quad->SetNew(shared_quad_state, fill_rect, fill_rect, fill_color,
374 force_anti_aliasing_off);
375 }
364 } 376 }
365 if (!left.IsEmpty()) { 377 if (!left.IsEmpty()) {
378 bool force_anti_aliasing_off = false;
366 SolidColorDrawQuad* left_quad = 379 SolidColorDrawQuad* left_quad =
367 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 380 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
368 left_quad->SetNew(shared_quad_state, 381 left_quad->SetNew(shared_quad_state, left, left,
369 left,
370 left,
371 colors[kNumColors - 1 - (i % kNumColors)], 382 colors[kNumColors - 1 - (i % kNumColors)],
372 false); 383 force_anti_aliasing_off);
373 384
374 SolidColorDrawQuad* right_quad = 385 SolidColorDrawQuad* right_quad =
375 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 386 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
376 right_quad->SetNew( 387 right_quad->SetNew(shared_quad_state, right, right,
377 shared_quad_state, right, right, colors[i % kNumColors], false); 388 colors[i % kNumColors], force_anti_aliasing_off);
378 } 389 }
379 } 390 }
380 } 391 }
381 392
382 void DelegatedRendererLayerImpl::AppendRenderPassQuads( 393 void DelegatedRendererLayerImpl::AppendRenderPassQuads(
383 RenderPass* render_pass, 394 RenderPass* render_pass,
384 const Occlusion& occlusion_in_content_space,
385 const RenderPass* delegated_render_pass, 395 const RenderPass* delegated_render_pass,
386 const gfx::Size& frame_size) const { 396 const gfx::Size& frame_size) const {
387 const SharedQuadState* delegated_shared_quad_state = nullptr; 397 const SharedQuadState* delegated_shared_quad_state = nullptr;
388 SharedQuadState* output_shared_quad_state = nullptr; 398 SharedQuadState* output_shared_quad_state = nullptr;
389 399
390 for (const auto& delegated_quad : delegated_render_pass->quad_list) { 400 for (const auto& delegated_quad : delegated_render_pass->quad_list) {
391 bool is_root_delegated_render_pass = 401 bool is_root_delegated_render_pass =
392 delegated_render_pass == render_passes_in_draw_order_.back(); 402 delegated_render_pass == render_passes_in_draw_order_.back();
393 403
394 if (delegated_quad->shared_quad_state != delegated_shared_quad_state) { 404 if (delegated_quad->shared_quad_state != delegated_shared_quad_state) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 440
431 gfx::Transform quad_content_to_delegated_target_space = 441 gfx::Transform quad_content_to_delegated_target_space =
432 output_shared_quad_state->content_to_target_transform; 442 output_shared_quad_state->content_to_target_transform;
433 if (!is_root_delegated_render_pass) { 443 if (!is_root_delegated_render_pass) {
434 quad_content_to_delegated_target_space.ConcatTransform( 444 quad_content_to_delegated_target_space.ConcatTransform(
435 delegated_render_pass->transform_to_root_target); 445 delegated_render_pass->transform_to_root_target);
436 quad_content_to_delegated_target_space.ConcatTransform(draw_transform()); 446 quad_content_to_delegated_target_space.ConcatTransform(draw_transform());
437 } 447 }
438 448
439 Occlusion occlusion_in_quad_space = 449 Occlusion occlusion_in_quad_space =
440 occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( 450 draw_properties()
441 quad_content_to_delegated_target_space); 451 .occlusion_in_content_space.GetOcclusionWithGivenDrawTransform(
452 quad_content_to_delegated_target_space);
442 453
443 gfx::Rect quad_visible_rect = 454 gfx::Rect quad_visible_rect =
444 occlusion_in_quad_space.GetUnoccludedContentRect( 455 occlusion_in_quad_space.GetUnoccludedContentRect(
445 delegated_quad->visible_rect); 456 delegated_quad->visible_rect);
446 457
447 if (quad_visible_rect.IsEmpty()) 458 if (quad_visible_rect.IsEmpty())
448 continue; 459 continue;
449 460
450 if (delegated_quad->material != DrawQuad::RENDER_PASS) { 461 if (delegated_quad->material != DrawQuad::RENDER_PASS) {
451 DrawQuad* output_quad = render_pass->CopyFromAndAppendDrawQuad( 462 DrawQuad* output_quad = render_pass->CopyFromAndAppendDrawQuad(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 if (own_child_id_) { 498 if (own_child_id_) {
488 ResourceProvider* provider = layer_tree_impl()->resource_provider(); 499 ResourceProvider* provider = layer_tree_impl()->resource_provider();
489 provider->DestroyChild(child_id_); 500 provider->DestroyChild(child_id_);
490 } 501 }
491 502
492 resources_.clear(); 503 resources_.clear();
493 child_id_ = 0; 504 child_id_ = 0;
494 } 505 }
495 506
496 } // namespace cc 507 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl.h ('k') | cc/layers/draw_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698