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

Side by Side Diff: cc/layer_tree_host_common.cc

Issue 11418197: Move temporary MathUtil wrappers to permanent home in gfx::Transform (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years 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 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 "cc/layer.h" 9 #include "cc/layer.h"
10 #include "cc/layer_impl.h" 10 #include "cc/layer_impl.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 template<typename LayerType> 79 template<typename LayerType>
80 static bool isLayerBackFaceVisible(LayerType* layer) 80 static bool isLayerBackFaceVisible(LayerType* layer)
81 { 81 {
82 // The current W3C spec on CSS transforms says that backface visibility shou ld be 82 // The current W3C spec on CSS transforms says that backface visibility shou ld be
83 // determined differently depending on whether the layer is in a "3d renderi ng 83 // determined differently depending on whether the layer is in a "3d renderi ng
84 // context" or not. For Chromium code, we can determine whether we are in a 3d 84 // context" or not. For Chromium code, we can determine whether we are in a 3d
85 // rendering context by checking if the parent preserves 3d. 85 // rendering context by checking if the parent preserves 3d.
86 86
87 if (layerIsInExisting3DRenderingContext(layer)) 87 if (layerIsInExisting3DRenderingContext(layer))
88 return MathUtil::isBackFaceVisible(layer->drawTransform()); 88 return layer->drawTransform().IsBackFaceVisible();
89 89
90 // In this case, either the layer establishes a new 3d rendering context, or is not in 90 // In this case, either the layer establishes a new 3d rendering context, or is not in
91 // a 3d rendering context at all. 91 // a 3d rendering context at all.
92 return MathUtil::isBackFaceVisible(layer->transform()); 92 return layer->transform().IsBackFaceVisible();
93 } 93 }
94 94
95 template<typename LayerType> 95 template<typename LayerType>
96 static bool isSurfaceBackFaceVisible(LayerType* layer, const gfx::Transform& dra wTransform) 96 static bool isSurfaceBackFaceVisible(LayerType* layer, const gfx::Transform& dra wTransform)
97 { 97 {
98 if (layerIsInExisting3DRenderingContext(layer)) 98 if (layerIsInExisting3DRenderingContext(layer))
99 return MathUtil::isBackFaceVisible(drawTransform); 99 return drawTransform.IsBackFaceVisible();
100 100
101 if (isRootLayerOfNewRenderingContext(layer)) 101 if (isRootLayerOfNewRenderingContext(layer))
102 return MathUtil::isBackFaceVisible(layer->transform()); 102 return layer->transform().IsBackFaceVisible();
103 103
104 // If the renderSurface is not part of a new or existing rendering context, then the 104 // If the renderSurface is not part of a new or existing rendering context, then the
105 // layers that contribute to this surface will decide back-face visibility f or themselves. 105 // layers that contribute to this surface will decide back-face visibility f or themselves.
106 return false; 106 return false;
107 } 107 }
108 108
109 template<typename LayerType> 109 template<typename LayerType>
110 static inline bool layerClipsSubtree(LayerType* layer) 110 static inline bool layerClipsSubtree(LayerType* layer)
111 { 111 {
112 return layer->masksToBounds() || layer->maskLayer(); 112 return layer->masksToBounds() || layer->maskLayer();
(...skipping 20 matching lines...) Expand all
133 targetSurfaceClipRect = gfx::ToEnclosingRect(MathUtil::projectClippedRec t(MathUtil::inverse(layer->renderTarget()->renderSurface()->drawTransform()), la yer->renderTarget()->renderSurface()->clipRect())); 133 targetSurfaceClipRect = gfx::ToEnclosingRect(MathUtil::projectClippedRec t(MathUtil::inverse(layer->renderTarget()->renderSurface()->drawTransform()), la yer->renderTarget()->renderSurface()->clipRect()));
134 targetSurfaceClipRect.Intersect(layer->drawableContentRect()); 134 targetSurfaceClipRect.Intersect(layer->drawableContentRect());
135 } 135 }
136 136
137 if (targetSurfaceClipRect.IsEmpty()) 137 if (targetSurfaceClipRect.IsEmpty())
138 return gfx::Rect(); 138 return gfx::Rect();
139 139
140 return LayerTreeHostCommon::calculateVisibleRect(targetSurfaceClipRect, gfx: :Rect(gfx::Point(), layer->contentBounds()), layer->drawTransform()); 140 return LayerTreeHostCommon::calculateVisibleRect(targetSurfaceClipRect, gfx: :Rect(gfx::Point(), layer->contentBounds()), layer->drawTransform());
141 } 141 }
142 142
143 static bool isScaleOrTranslation(const gfx::Transform& m)
144 {
145 return !m.matrix().getDouble(1, 0) && !m.matrix().getDouble(2, 0) && !m.matr ix().getDouble(3, 0)
146 && !m.matrix().getDouble(0, 1) && !m.matrix().getDouble(2, 1) && !m.m atrix().getDouble(3, 1)
147 && !m.matrix().getDouble(0, 2) && !m.matrix().getDouble(1, 2) && !m.m atrix().getDouble(2, 3)
148 && m.matrix().getDouble(3, 3);
149 }
150
151 static inline bool transformToParentIsKnown(LayerImpl*) 143 static inline bool transformToParentIsKnown(LayerImpl*)
152 { 144 {
153 return true; 145 return true;
154 } 146 }
155 147
156 static inline bool transformToParentIsKnown(Layer* layer) 148 static inline bool transformToParentIsKnown(Layer* layer)
157 { 149 {
158 return !layer->transformIsAnimating(); 150 return !layer->transformIsAnimating();
159 } 151 }
160 152
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 535
544 gfx::RectF contentRect(gfx::PointF(), layer->contentBounds()); 536 gfx::RectF contentRect(gfx::PointF(), layer->contentBounds());
545 537
546 // fullHierarchyMatrix is the matrix that transforms objects between screen space (except projection matrix) and the most recent RenderSurfaceImpl's space. 538 // fullHierarchyMatrix is the matrix that transforms objects between screen space (except projection matrix) and the most recent RenderSurfaceImpl's space.
547 // nextHierarchyMatrix will only change if this layer uses a new RenderSurfa ceImpl, otherwise remains the same. 539 // nextHierarchyMatrix will only change if this layer uses a new RenderSurfa ceImpl, otherwise remains the same.
548 gfx::Transform nextHierarchyMatrix = fullHierarchyMatrix; 540 gfx::Transform nextHierarchyMatrix = fullHierarchyMatrix;
549 gfx::Transform sublayerMatrix; 541 gfx::Transform sublayerMatrix;
550 542
551 gfx::Vector2dF renderSurfaceSublayerScale = MathUtil::computeTransform2dScal eComponents(combinedTransform); 543 gfx::Vector2dF renderSurfaceSublayerScale = MathUtil::computeTransform2dScal eComponents(combinedTransform);
552 544
553 if (subtreeShouldRenderToSeparateSurface(layer, isScaleOrTranslation(combine dTransform))) { 545 if (subtreeShouldRenderToSeparateSurface(layer, combinedTransform.IsScaleOrT ranslation())) {
554 // Check back-face visibility before continuing with this surface and it s subtree 546 // Check back-face visibility before continuing with this surface and it s subtree
555 if (!layer->doubleSided() && transformToParentIsKnown(layer) && isSurfac eBackFaceVisible(layer, combinedTransform)) 547 if (!layer->doubleSided() && transformToParentIsKnown(layer) && isSurfac eBackFaceVisible(layer, combinedTransform))
556 return; 548 return;
557 549
558 if (!layer->renderSurface()) 550 if (!layer->renderSurface())
559 layer->createRenderSurface(); 551 layer->createRenderSurface();
560 552
561 RenderSurfaceType* renderSurface = layer->renderSurface(); 553 RenderSurfaceType* renderSurface = layer->renderSurface();
562 renderSurface->clearLayerLists(); 554 renderSurface->clearLayerLists();
563 555
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 978
987 foundLayer = currentLayer; 979 foundLayer = currentLayer;
988 break; 980 break;
989 } 981 }
990 982
991 // This can potentially return 0, which means the screenSpacePoint did not s uccessfully hit test any layers, not even the root layer. 983 // This can potentially return 0, which means the screenSpacePoint did not s uccessfully hit test any layers, not even the root layer.
992 return foundLayer; 984 return foundLayer;
993 } 985 }
994 986
995 } // namespace cc 987 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698