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

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

Issue 1903073002: cc : Fix sublayer scale bug when there is a transform node b/w targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_common_unittest.cc » ('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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 ResetIfHasNanCoordinate(&clip_node->data.clip); 466 ResetIfHasNanCoordinate(&clip_node->data.clip);
467 clip_node->data.clip_in_target_space = clip_node->data.clip; 467 clip_node->data.clip_in_target_space = clip_node->data.clip;
468 clip_node->data.combined_clip_in_target_space = clip_node->data.clip; 468 clip_node->data.combined_clip_in_target_space = clip_node->data.clip;
469 continue; 469 continue;
470 } 470 }
471 const TransformNode* transform_node = 471 const TransformNode* transform_node =
472 transform_tree.Node(clip_node->data.transform_id); 472 transform_tree.Node(clip_node->data.transform_id);
473 ClipNode* parent_clip_node = clip_tree->parent(clip_node); 473 ClipNode* parent_clip_node = clip_tree->parent(clip_node);
474 474
475 gfx::Transform parent_to_current; 475 gfx::Transform parent_to_current;
476 const TransformNode* parent_transform_node = 476 const TransformNode* parent_target_transform_node =
477 transform_tree.Node(parent_clip_node->data.transform_id); 477 transform_tree.Node(parent_clip_node->data.target_id);
478 bool success = true; 478 bool success = true;
479 479
480 // Clips must be combined in target space. We cannot, for example, combine 480 // Clips must be combined in target space. We cannot, for example, combine
481 // clips in the space of the child clip. The reason is non-affine 481 // clips in the space of the child clip. The reason is non-affine
482 // transforms. Say we have the following tree T->A->B->C, and B clips C, but 482 // transforms. Say we have the following tree T->A->B->C, and B clips C, but
483 // draw into target T. It may be the case that A applies a perspective 483 // draw into target T. It may be the case that A applies a perspective
484 // transform, and B and C are at different z positions. When projected into 484 // transform, and B and C are at different z positions. When projected into
485 // target space, the relative sizes and positions of B and C can shift. 485 // target space, the relative sizes and positions of B and C can shift.
486 // Since it's the relationship in target space that matters, that's where we 486 // Since it's the relationship in target space that matters, that's where we
487 // must combine clips. For each clip node, we save the clip rects in its 487 // must combine clips. For each clip node, we save the clip rects in its
488 // target space. So, we need to get the ancestor clip rect in the current 488 // target space. So, we need to get the ancestor clip rect in the current
489 // clip node's target space. 489 // clip node's target space.
490 gfx::RectF parent_combined_clip_in_target_space = 490 gfx::RectF parent_combined_clip_in_target_space =
491 parent_clip_node->data.combined_clip_in_target_space; 491 parent_clip_node->data.combined_clip_in_target_space;
492 gfx::RectF parent_clip_in_target_space = 492 gfx::RectF parent_clip_in_target_space =
493 parent_clip_node->data.clip_in_target_space; 493 parent_clip_node->data.clip_in_target_space;
494 if (parent_clip_node->data.target_id != clip_node->data.target_id && 494 if (parent_target_transform_node &&
495 parent_target_transform_node->id != clip_node->data.target_id &&
495 non_root_surfaces_enabled) { 496 non_root_surfaces_enabled) {
496 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( 497 success &= transform_tree.ComputeTransformWithDestinationSublayerScale(
497 parent_clip_node->data.target_id, clip_node->data.target_id, 498 parent_target_transform_node->id, clip_node->data.target_id,
498 &parent_to_current); 499 &parent_to_current);
499 if (parent_transform_node->data.sublayer_scale.x() > 0 && 500 if (parent_target_transform_node->data.sublayer_scale.x() > 0 &&
500 parent_transform_node->data.sublayer_scale.y() > 0) 501 parent_target_transform_node->data.sublayer_scale.y() > 0)
501 parent_to_current.Scale( 502 parent_to_current.Scale(
502 1.f / parent_transform_node->data.sublayer_scale.x(), 503 1.f / parent_target_transform_node->data.sublayer_scale.x(),
503 1.f / parent_transform_node->data.sublayer_scale.y()); 504 1.f / parent_target_transform_node->data.sublayer_scale.y());
504 // If we can't compute a transform, it's because we had to use the inverse 505 // If we can't compute a transform, it's because we had to use the inverse
505 // of a singular transform. We won't draw in this case, so there's no need 506 // of a singular transform. We won't draw in this case, so there's no need
506 // to compute clips. 507 // to compute clips.
507 if (!success) 508 if (!success)
508 continue; 509 continue;
509 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( 510 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect(
510 parent_to_current, 511 parent_to_current,
511 parent_clip_node->data.combined_clip_in_target_space); 512 parent_clip_node->data.combined_clip_in_target_space);
512 parent_clip_in_target_space = MathUtil::ProjectClippedRect( 513 parent_clip_in_target_space = MathUtil::ProjectClippedRect(
513 parent_to_current, parent_clip_node->data.clip_in_target_space); 514 parent_to_current, parent_clip_node->data.clip_in_target_space);
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 void UpdateElasticOverscroll(PropertyTrees* property_trees, 1113 void UpdateElasticOverscroll(PropertyTrees* property_trees,
1113 const Layer* overscroll_elasticity_layer, 1114 const Layer* overscroll_elasticity_layer,
1114 const gfx::Vector2dF& elastic_overscroll) { 1115 const gfx::Vector2dF& elastic_overscroll) {
1115 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, 1116 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer,
1116 elastic_overscroll); 1117 elastic_overscroll);
1117 } 1118 }
1118 1119
1119 } // namespace draw_property_utils 1120 } // namespace draw_property_utils
1120 1121
1121 } // namespace cc 1122 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698