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

Side by Side Diff: cc/trees/draw_property_utils.cc

Issue 1252313004: Add ClipNode when Render Surface Inherits Clip (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | cc/trees/property_tree.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/trees/draw_property_utils.h" 5 #include "cc/trees/draw_property_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 gfx::Transform clip_to_target; 410 gfx::Transform clip_to_target;
411 gfx::Transform target_to_clip; 411 gfx::Transform target_to_clip;
412 412
413 const bool target_is_root_surface = clip_node->data.target_id == 1; 413 const bool target_is_root_surface = clip_node->data.target_id == 1;
414 // When the target is the root surface, we need to include the root 414 // When the target is the root surface, we need to include the root
415 // transform by walking up to the root of the transform tree. 415 // transform by walking up to the root of the transform tree.
416 const int target_id = 416 const int target_id =
417 target_is_root_surface ? 0 : clip_node->data.target_id; 417 target_is_root_surface ? 0 : clip_node->data.target_id;
418 418
419 bool success = true; 419 bool success = true;
420 if (parent_transform_node->data.content_target_id == 420 if (clip_node->data.render_surface_applies_clip) {
421 clip_node->data.target_id) { 421 success &= transform_tree.ComputeTransform(transform_node->data.target_id,
422 target_id, &parent_to_target);
ajuma 2015/07/29 16:44:29 I'm having trouble following this. parent_to_targe
jaydasika 2015/07/30 19:43:10 Done.
423 } else if (parent_transform_node->data.content_target_id ==
424 clip_node->data.target_id) {
422 parent_to_target = parent_transform_node->data.to_target; 425 parent_to_target = parent_transform_node->data.to_target;
423 } else { 426 } else {
424 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( 427 success &= transform_tree.ComputeTransformWithDestinationSublayerScale(
425 parent_transform_node->id, target_id, &parent_to_target); 428 parent_transform_node->id, target_id, &parent_to_target);
426 } 429 }
427 430
428 if (transform_node->data.content_target_id == clip_node->data.target_id) { 431 if (transform_node->data.content_target_id == clip_node->data.target_id) {
429 clip_to_target = transform_node->data.to_target; 432 clip_to_target = transform_node->data.to_target;
430 } else { 433 } else {
431 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( 434 success &= transform_tree.ComputeTransformWithDestinationSublayerScale(
432 transform_node->id, target_id, &clip_to_target); 435 transform_node->id, target_id, &clip_to_target);
433 } 436 }
434 437
435 if (transform_node->data.content_target_id == clip_node->data.target_id && 438 if (transform_node->data.content_target_id == clip_node->data.target_id &&
436 transform_node->data.ancestors_are_invertible) { 439 transform_node->data.ancestors_are_invertible) {
437 target_to_clip = transform_node->data.from_target; 440 target_to_clip = transform_node->data.from_target;
438 } else { 441 } else {
439 success &= clip_to_target.GetInverse(&target_to_clip); 442 success &= clip_to_target.GetInverse(&target_to_clip);
440 } 443 }
441 444
442 // If we can't compute a transform, it's because we had to use the inverse 445 // If we can't compute a transform, it's because we had to use the inverse
443 // of a singular transform. We won't draw in this case, so there's no need 446 // of a singular transform. We won't draw in this case, so there's no need
444 // to compute clips. 447 // to compute clips.
445 if (!success) 448 if (!success)
446 continue; 449 continue;
447 450
448 // In order to intersect with as small a rect as possible, we do a 451 // In order to intersect with as small a rect as possible, we do a
449 // preliminary clip in target space so that when we project back, there's 452 // preliminary clip in target space so that when we project back, there's
450 // less likelihood of intersecting the view plane. 453 // less likelihood of intersecting the view plane.
451 gfx::RectF inherited_clip_in_target_space = MathUtil::MapClippedRect( 454 gfx::RectF inherited_clip_in_target_space;
452 parent_to_target, parent_clip_node->data.combined_clip); 455 if (parent_transform_node->id > target_id &&
ajuma 2015/07/29 16:44:29 We weren't previously handling the case where pare
jaydasika 2015/07/30 19:43:10 Add a unit test where render surface applies clip.
456 !clip_node->data.render_surface_applies_clip)
457 inherited_clip_in_target_space = MathUtil::MapClippedRect(
458 parent_to_target, parent_clip_node->data.combined_clip);
459 else
460 inherited_clip_in_target_space = MathUtil::ProjectClippedRect(
461 parent_to_target, parent_clip_node->data.combined_clip);
453 462
454 gfx::RectF clip_in_target_space = 463 gfx::RectF clip_in_target_space =
455 MathUtil::MapClippedRect(clip_to_target, clip_node->data.clip); 464 MathUtil::MapClippedRect(clip_to_target, clip_node->data.clip);
456 465
457 gfx::RectF intersected_in_target_space = gfx::IntersectRects( 466 gfx::RectF intersected_in_target_space = gfx::IntersectRects(
458 inherited_clip_in_target_space, clip_in_target_space); 467 inherited_clip_in_target_space, clip_in_target_space);
459 468
460 clip_node->data.combined_clip = MathUtil::ProjectClippedRect( 469 clip_node->data.combined_clip = MathUtil::ProjectClippedRect(
461 target_to_clip, intersected_in_target_space); 470 target_to_clip, intersected_in_target_space);
462 471
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 if (static_cast<int>(layer->offset_to_transform_parent().x()) != 696 if (static_cast<int>(layer->offset_to_transform_parent().x()) !=
688 layer->offset_to_transform_parent().x()) 697 layer->offset_to_transform_parent().x())
689 return false; 698 return false;
690 if (static_cast<int>(layer->offset_to_transform_parent().y()) != 699 if (static_cast<int>(layer->offset_to_transform_parent().y()) !=
691 layer->offset_to_transform_parent().y()) 700 layer->offset_to_transform_parent().y())
692 return false; 701 return false;
693 return true; 702 return true;
694 } 703 }
695 704
696 } // namespace cc 705 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/property_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698