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

Side by Side Diff: cc/layer_tree_host_common.cc

Issue 12278010: Merge 181957 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1410/src/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/layer_tree_host_common.h" 5 #include "cc/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/layer.h" 10 #include "cc/layer.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 return calculateVisibleRectWithCachedLayerRect(visibleRectInTargetSurfaceSpa ce, gfx::Rect(gfx::Point(), layer->contentBounds()), layerRectInTargetSpace, lay er->drawTransform()); 162 return calculateVisibleRectWithCachedLayerRect(visibleRectInTargetSurfaceSpa ce, gfx::Rect(gfx::Point(), layer->contentBounds()), layerRectInTargetSpace, lay er->drawTransform());
163 } 163 }
164 164
165 static inline bool transformToParentIsKnown(LayerImpl*) 165 static inline bool transformToParentIsKnown(LayerImpl*)
166 { 166 {
167 return true; 167 return true;
168 } 168 }
169 169
170 static inline bool transformToParentIsKnown(Layer* layer) 170 static inline bool transformToParentIsKnown(Layer* layer)
171 { 171 {
172
172 return !layer->transformIsAnimating(); 173 return !layer->transformIsAnimating();
173 } 174 }
174 175
175 static inline bool transformToScreenIsKnown(LayerImpl*) 176 static inline bool transformToScreenIsKnown(LayerImpl*)
176 { 177 {
177 return true; 178 return true;
178 } 179 }
179 180
180 static inline bool transformToScreenIsKnown(Layer* layer) 181 static inline bool transformToScreenIsKnown(Layer* layer)
181 { 182 {
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 // the transform to the anchor point is specified in "layer space", where the bounds 564 // the transform to the anchor point is specified in "layer space", where the bounds
564 // of the layer map to [bounds.width(), bounds.height()]. 565 // of the layer map to [bounds.width(), bounds.height()].
565 // 566 //
566 // 3. Definition of various transforms used: 567 // 3. Definition of various transforms used:
567 // M[parent] is the parent matrix, with respect to the nearest render surface, passed down recursively. 568 // M[parent] is the parent matrix, with respect to the nearest render surface, passed down recursively.
568 // M[root] is the full hierarchy, with respect to the root, passed do wn recursively. 569 // M[root] is the full hierarchy, with respect to the root, passed do wn recursively.
569 // Tr[origin] is the translation matrix from the parent's origin to t his layer's origin. 570 // Tr[origin] is the translation matrix from the parent's origin to t his layer's origin.
570 // Tr[origin2anchor] is the translation from the layer's origin to it s anchor point 571 // Tr[origin2anchor] is the translation from the layer's origin to it s anchor point
571 // Tr[origin2center] is the translation from the layer's origin to it s center 572 // Tr[origin2center] is the translation from the layer's origin to it s center
572 // M[layer] is the layer's matrix (applied at the anchor point) 573 // M[layer] is the layer's matrix (applied at the anchor point)
573 // M[sublayer] is the layer's sublayer transform (applied at the laye r's center) 574 // M[sublayer] is the layer's sublayer transform (also applied at the layer's anchor point)
574 // S[layer2content] is the ratio of a layer's contentBounds() to its bounds(). 575 // S[layer2content] is the ratio of a layer's contentBounds() to its bounds().
575 // 576 //
576 // Some composite transforms can help in understanding the sequence of tr ansforms: 577 // Some composite transforms can help in understanding the sequence of tr ansforms:
577 // compositeLayerTransform = Tr[origin2anchor] * M[layer] * Tr[origin 2anchor].inverse() 578 // compositeLayerTransform = Tr[origin2anchor] * M[layer] * Tr[origin 2anchor].inverse()
578 // compositeSublayerTransform = Tr[origin2center] * M[sublayer] * Tr[ origin2center].inverse() 579 // compositeSublayerTransform = Tr[origin2anchor] * M[sublayer] * Tr[ origin2anchor].inverse()
579 //
580 // In words, the layer transform is applied about the anchor point, and t he sublayer transform is
581 // applied about the center of the layer.
582 // 580 //
583 // 4. When a layer (or render surface) is drawn, it is drawn into a "target render surface". Therefore the draw 581 // 4. When a layer (or render surface) is drawn, it is drawn into a "target render surface". Therefore the draw
584 // transform does not necessarily transform from screen space to local la yer space. Instead, the draw transform 582 // transform does not necessarily transform from screen space to local la yer space. Instead, the draw transform
585 // is the transform between the "target render surface space" and local l ayer space. Note that render surfaces, 583 // is the transform between the "target render surface space" and local l ayer space. Note that render surfaces,
586 // except for the root, also draw themselves into a different target rend er surface, and so their draw 584 // except for the root, also draw themselves into a different target rend er surface, and so their draw
587 // transform and origin transforms are also described with respect to the target. 585 // transform and origin transforms are also described with respect to the target.
588 // 586 //
589 // Using these definitions, then: 587 // Using these definitions, then:
590 // 588 //
591 // The draw transform for the layer is: 589 // The draw transform for the layer is:
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 // scale factor that accounts for the surface's pixel dimensions. 745 // scale factor that accounts for the surface's pixel dimensions.
748 combinedTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSu rfaceSublayerScale.y()); 746 combinedTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSu rfaceSublayerScale.y());
749 renderSurface->setDrawTransform(combinedTransform); 747 renderSurface->setDrawTransform(combinedTransform);
750 748
751 // The owning layer's transform was re-parented by the surface, so the l ayer's new drawTransform 749 // The owning layer's transform was re-parented by the surface, so the l ayer's new drawTransform
752 // only needs to scale the layer to surface space. 750 // only needs to scale the layer to surface space.
753 layerDrawProperties.target_space_transform.MakeIdentity(); 751 layerDrawProperties.target_space_transform.MakeIdentity();
754 layerDrawProperties.target_space_transform.Scale(renderSurfaceSublayerSc ale.x() / layer->contentsScaleX(), renderSurfaceSublayerScale.y() / layer->conte ntsScaleY()); 752 layerDrawProperties.target_space_transform.Scale(renderSurfaceSublayerSc ale.x() / layer->contentsScaleX(), renderSurfaceSublayerScale.y() / layer->conte ntsScaleY());
755 753
756 // Inside the surface's subtree, we scale everything to the owning layer 's scale. 754 // Inside the surface's subtree, we scale everything to the owning layer 's scale.
757 // The sublayer matrix transforms centered layer rects into target 755 // The sublayer matrix transforms layer rects into target
758 // surface content space. 756 // surface content space.
759 DCHECK(sublayerMatrix.IsIdentity()); 757 DCHECK(sublayerMatrix.IsIdentity());
760 sublayerMatrix.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublay erScale.y()); 758 sublayerMatrix.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublay erScale.y());
761 759
762 // The opacity value is moved from the layer to its surface, so that the entire subtree properly inherits opacity. 760 // The opacity value is moved from the layer to its surface, so that the entire subtree properly inherits opacity.
763 renderSurface->setDrawOpacity(accumulatedDrawOpacity); 761 renderSurface->setDrawOpacity(accumulatedDrawOpacity);
764 renderSurface->setDrawOpacityIsAnimating(animatingOpacityToTarget); 762 renderSurface->setDrawOpacityIsAnimating(animatingOpacityToTarget);
765 animatingOpacityToTarget = false; 763 animatingOpacityToTarget = false;
766 layerDrawProperties.opacity = 1; 764 layerDrawProperties.opacity = 1;
767 layerDrawProperties.opacity_is_animating = animatingOpacityToTarget; 765 layerDrawProperties.opacity_is_animating = animatingOpacityToTarget;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 clipRectForSubtree = clipRectFromAncestor; 858 clipRectForSubtree = clipRectFromAncestor;
861 clipRectForSubtree.Intersect(rectInTargetSpace); 859 clipRectForSubtree.Intersect(rectInTargetSpace);
862 } else 860 } else
863 clipRectForSubtree = rectInTargetSpace; 861 clipRectForSubtree = rectInTargetSpace;
864 } 862 }
865 863
866 // Flatten to 2D if the layer doesn't preserve 3D. 864 // Flatten to 2D if the layer doesn't preserve 3D.
867 if (!layer->preserves3D()) 865 if (!layer->preserves3D())
868 sublayerMatrix.FlattenTo2d(); 866 sublayerMatrix.FlattenTo2d();
869 867
870 // Apply the sublayer transform at the center of the layer. 868 // Apply the sublayer transform at the anchor point of the layer.
871 if (!layer->sublayerTransform().IsIdentity()) { 869 if (!layer->sublayerTransform().IsIdentity()) {
872 sublayerMatrix.Translate(0.5 * bounds.width(), 0.5 * bounds.height()); 870 sublayerMatrix.Translate(layer->anchorPoint().x() * bounds.width(), laye r->anchorPoint().y() * bounds.height());
873 sublayerMatrix.PreconcatTransform(layer->sublayerTransform()); 871 sublayerMatrix.PreconcatTransform(layer->sublayerTransform());
874 sublayerMatrix.Translate(-0.5 * bounds.width(), -0.5 * bounds.height()); 872 sublayerMatrix.Translate(-layer->anchorPoint().x() * bounds.width(), -la yer->anchorPoint().y() * bounds.height());
875 } 873 }
876 874
877 LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->l ayerList() : layerList); 875 LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->l ayerList() : layerList);
878 876
879 // Any layers that are appended after this point are in the layer's subtree and should be included in the sorting process. 877 // Any layers that are appended after this point are in the layer's subtree and should be included in the sorting process.
880 unsigned sortingStartIndex = descendants.size(); 878 unsigned sortingStartIndex = descendants.size();
881 879
882 if (!layerShouldBeSkipped(layer)) 880 if (!layerShouldBeSkipped(layer))
883 descendants.push_back(layer); 881 descendants.push_back(layer);
884 882
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 1196
1199 // At this point, we think the point does hit the touch event handler region o n the layer, but we need to walk up 1197 // At this point, we think the point does hit the touch event handler region o n the layer, but we need to walk up
1200 // the parents to ensure that the layer was not clipped in such a way that the 1198 // the parents to ensure that the layer was not clipped in such a way that the
1201 // hit point actually should not hit the layer. 1199 // hit point actually should not hit the layer.
1202 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) 1200 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl))
1203 return false; 1201 return false;
1204 1202
1205 return true; 1203 return true;
1206 } 1204 }
1207 } // namespace cc 1205 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698