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

Side by Side Diff: cc/layer_impl_unittest.cc

Issue 11275113: Remove most remaining references to IntRect and FloatRect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compositor bindings Created 8 years, 1 month 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 | « cc/layer_impl.cc ('k') | cc/layer_sorter.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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer_impl.h" 7 #include "cc/layer_impl.h"
8 8
9 #include "cc/single_thread_proxy.h" 9 #include "cc/single_thread_proxy.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 root->addChild(LayerImpl::create(2)); 63 root->addChild(LayerImpl::create(2));
64 LayerImpl* child = root->children()[0]; 64 LayerImpl* child = root->children()[0];
65 child->addChild(LayerImpl::create(3)); 65 child->addChild(LayerImpl::create(3));
66 LayerImpl* grandChild = child->children()[0]; 66 LayerImpl* grandChild = child->children()[0];
67 67
68 // Adding children is an internal operation and should not mark layers as ch anged. 68 // Adding children is an internal operation and should not mark layers as ch anged.
69 EXPECT_FALSE(root->layerPropertyChanged()); 69 EXPECT_FALSE(root->layerPropertyChanged());
70 EXPECT_FALSE(child->layerPropertyChanged()); 70 EXPECT_FALSE(child->layerPropertyChanged());
71 EXPECT_FALSE(grandChild->layerPropertyChanged()); 71 EXPECT_FALSE(grandChild->layerPropertyChanged());
72 72
73 FloatPoint arbitraryFloatPoint = FloatPoint(0.125f, 0.25f); 73 gfx::PointF arbitraryPointF = gfx::PointF(0.125f, 0.25f);
74 float arbitraryNumber = 0.352f; 74 float arbitraryNumber = 0.352f;
75 IntSize arbitraryIntSize = IntSize(111, 222); 75 gfx::Size arbitrarySize = gfx::Size(111, 222);
76 IntPoint arbitraryIntPoint = IntPoint(333, 444); 76 gfx::Point arbitraryPoint = gfx::Point(333, 444);
77 IntRect arbitraryIntRect = IntRect(arbitraryIntPoint, arbitraryIntSize); 77 gfx::Rect arbitraryRect = gfx::Rect(arbitraryPoint, arbitrarySize);
78 FloatRect arbitraryFloatRect = FloatRect(arbitraryFloatPoint, FloatSize(1.23 4f, 5.678f)); 78 gfx::RectF arbitraryRectF = gfx::RectF(arbitraryPointF, gfx::SizeF(1.234f, 5 .678f));
79 SkColor arbitraryColor = SkColorSetRGB(10, 20, 30); 79 SkColor arbitraryColor = SkColorSetRGB(10, 20, 30);
80 WebTransformationMatrix arbitraryTransform; 80 WebTransformationMatrix arbitraryTransform;
81 arbitraryTransform.scale3d(0.1, 0.2, 0.3); 81 arbitraryTransform.scale3d(0.1, 0.2, 0.3);
82 WebFilterOperations arbitraryFilters; 82 WebFilterOperations arbitraryFilters;
83 arbitraryFilters.append(WebFilterOperation::createOpacityFilter(0.5)); 83 arbitraryFilters.append(WebFilterOperation::createOpacityFilter(0.5));
84 SkAutoTUnref<SkImageFilter> arbitraryFilter(new SkBlurImageFilter(SK_Scalar1 , SK_Scalar1)); 84 SkAutoTUnref<SkImageFilter> arbitraryFilter(new SkBlurImageFilter(SK_Scalar1 , SK_Scalar1));
85 85
86 // These properties are internal, and should not be considered "change" when they are used. 86 // These properties are internal, and should not be considered "change" when they are used.
87 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setUseLCDText(true)); 87 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setUseLCDText(true));
88 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawOpacity(arbitraryNumb er)); 88 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawOpacity(arbitraryNumb er));
89 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setRenderTarget(0)); 89 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setRenderTarget(0));
90 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawTransform(arbitraryTr ansform)); 90 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawTransform(arbitraryTr ansform));
91 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScreenSpaceTransform(arbi traryTransform)); 91 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScreenSpaceTransform(arbi traryTransform));
92 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawableContentRect(arbit raryIntRect)); 92 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawableContentRect(arbit raryRect));
93 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setUpdateRect(arbitraryFloat Rect)); 93 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setUpdateRect(arbitraryRectF ));
94 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setVisibleContentRect(arbitr aryIntRect)); 94 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setVisibleContentRect(arbitr aryRect));
95 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMaxScrollPosition(arbitra ryIntSize)); 95 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMaxScrollPosition(cc::Int Size(arbitrarySize)));
96 96
97 // Changing these properties affects the entire subtree of layers. 97 // Changing these properties affects the entire subtree of layers.
98 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPoint(arbitraryFloatPoint) ); 98 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPoint(arbitraryPointF));
99 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPointZ(arbitraryNumber)); 99 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPointZ(arbitraryNumber));
100 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setFilters(arbitraryFilters)); 100 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setFilters(arbitraryFilters));
101 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setFilters(WebFilterOperations())); 101 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setFilters(WebFilterOperations()));
102 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setFilter(arbitraryFilter)); 102 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setFilter(arbitraryFilter));
103 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setMaskLayer(LayerImpl::create(4))) ; 103 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setMaskLayer(LayerImpl::create(4))) ;
104 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setMasksToBounds(true)); 104 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setMasksToBounds(true));
105 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setContentsOpaque(true)); 105 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setContentsOpaque(true));
106 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setReplicaLayer(LayerImpl::create(5 ))); 106 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setReplicaLayer(LayerImpl::create(5 )));
107 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPosition(arbitraryFloatPoint)); 107 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPosition(arbitraryPointF));
108 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPreserves3D(true)); 108 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPreserves3D(true));
109 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setDoubleSided(false)); // construc tor initializes it to "true". 109 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setDoubleSided(false)); // construc tor initializes it to "true".
110 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->scrollBy(arbitraryIntSize)); 110 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->scrollBy(cc::IntSize(arbitrarySize) ));
111 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollDelta(IntSize())); 111 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollDelta(cc::IntSize()));
112 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollPosition(arbitraryIntPoint )); 112 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setScrollPosition(cc::IntPoint(arbi traryPoint)));
113 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setImplTransform(arbitraryTransform )); 113 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setImplTransform(arbitraryTransform ));
114 114
115 // Changing these properties only affects the layer itself. 115 // Changing these properties only affects the layer itself.
116 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setContentBounds(arbitraryIntSiz e)); 116 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setContentBounds(arbitrarySize)) ;
117 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setContentsScale(arbitraryNumber , arbitraryNumber)); 117 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setContentsScale(arbitraryNumber , arbitraryNumber));
118 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setDebugBorderColor(arbitraryCol or)); 118 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setDebugBorderColor(arbitraryCol or));
119 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setDebugBorderWidth(arbitraryNum ber)); 119 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setDebugBorderWidth(arbitraryNum ber));
120 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setDrawsContent(true)); 120 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setDrawsContent(true));
121 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setBackgroundColor(SK_ColorGRAY) ); 121 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setBackgroundColor(SK_ColorGRAY) );
122 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setBackgroundFilters(arbitraryFi lters)); 122 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setBackgroundFilters(arbitraryFi lters));
123 123
124 // Changing these properties only affects how render surface is drawn 124 // Changing these properties only affects how render surface is drawn
125 EXECUTE_AND_VERIFY_ONLY_SURFACE_CHANGED(root->setOpacity(arbitraryNumber)); 125 EXECUTE_AND_VERIFY_ONLY_SURFACE_CHANGED(root->setOpacity(arbitraryNumber));
126 EXECUTE_AND_VERIFY_ONLY_SURFACE_CHANGED(root->setTransform(arbitraryTransfor m)); 126 EXECUTE_AND_VERIFY_ONLY_SURFACE_CHANGED(root->setTransform(arbitraryTransfor m));
127 127
128 // Special case: check that sublayer transform changes all layer's descendan ts, but not the layer itself. 128 // Special case: check that sublayer transform changes all layer's descendan ts, but not the layer itself.
129 root->resetAllChangeTrackingForSubtree(); 129 root->resetAllChangeTrackingForSubtree();
130 root->setSublayerTransform(arbitraryTransform); 130 root->setSublayerTransform(arbitraryTransform);
131 EXPECT_FALSE(root->layerPropertyChanged()); 131 EXPECT_FALSE(root->layerPropertyChanged());
132 EXPECT_TRUE(child->layerPropertyChanged()); 132 EXPECT_TRUE(child->layerPropertyChanged());
133 EXPECT_TRUE(grandChild->layerPropertyChanged()); 133 EXPECT_TRUE(grandChild->layerPropertyChanged());
134 134
135 // Special case: check that setBounds changes behavior depending on masksToB ounds. 135 // Special case: check that setBounds changes behavior depending on masksToB ounds.
136 root->setMasksToBounds(false); 136 root->setMasksToBounds(false);
137 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setBounds(IntSize(135, 246))); 137 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setBounds(gfx::Size(135, 246)));
138 root->setMasksToBounds(true); 138 root->setMasksToBounds(true);
139 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setBounds(arbitraryIntSize)); // sh ould be a different size than previous call, to ensure it marks tree changed. 139 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setBounds(arbitrarySize)); // shoul d be a different size than previous call, to ensure it marks tree changed.
140 140
141 // After setting all these properties already, setting to the exact same val ues again should 141 // After setting all these properties already, setting to the exact same val ues again should
142 // not cause any change. 142 // not cause any change.
143 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setAnchorPoint(arbitraryFloa tPoint)); 143 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setAnchorPoint(arbitraryPoin tF));
144 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setAnchorPointZ(arbitraryNum ber)); 144 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setAnchorPointZ(arbitraryNum ber));
145 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMasksToBounds(true)); 145 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMasksToBounds(true));
146 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPosition(arbitraryFloatPo int)); 146 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPosition(arbitraryPointF) );
147 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPreserves3D(true)); 147 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPreserves3D(true));
148 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setTransform(arbitraryTransf orm)); 148 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setTransform(arbitraryTransf orm));
149 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDoubleSided(false)); // c onstructor initializes it to "true". 149 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDoubleSided(false)); // c onstructor initializes it to "true".
150 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollDelta(IntSize())); 150 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollDelta(cc::IntSize() ));
151 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollPosition(arbitraryI ntPoint)); 151 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScrollPosition(cc::IntPoi nt(arbitraryPoint)));
152 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setImplTransform(arbitraryTr ansform)); 152 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setImplTransform(arbitraryTr ansform));
153 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentBounds(arbitraryIn tSize)); 153 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentBounds(arbitrarySi ze));
154 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentsScale(arbitraryNu mber, arbitraryNumber)); 154 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentsScale(arbitraryNu mber, arbitraryNumber));
155 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentsOpaque(true)); 155 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setContentsOpaque(true));
156 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setOpacity(arbitraryNumber)) ; 156 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setOpacity(arbitraryNumber)) ;
157 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDebugBorderColor(arbitrar yColor)); 157 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDebugBorderColor(arbitrar yColor));
158 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDebugBorderWidth(arbitrar yNumber)); 158 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDebugBorderWidth(arbitrar yNumber));
159 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawsContent(true)); 159 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawsContent(true));
160 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setSublayerTransform(arbitra ryTransform)); 160 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setSublayerTransform(arbitra ryTransform));
161 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setBounds(arbitraryIntSize)) ; 161 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setBounds(arbitrarySize));
162 } 162 }
163 163
164 } // namespace 164 } // namespace
OLDNEW
« no previous file with comments | « cc/layer_impl.cc ('k') | cc/layer_sorter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698