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

Side by Side Diff: cc/layers/layer_impl_unittest.cc

Issue 21154002: Add support for converting cc::FilterOperations into an SkImageFilter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 3 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 | « cc/layers/layer_impl.cc ('k') | cc/layers/render_surface_impl.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/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "cc/output/filter_operation.h" 7 #include "cc/output/filter_operation.h"
8 #include "cc/output/filter_operations.h" 8 #include "cc/output/filter_operations.h"
9 #include "cc/test/fake_impl_proxy.h" 9 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 gfx::Point arbitrary_point = gfx::Point(333, 444); 95 gfx::Point arbitrary_point = gfx::Point(333, 444);
96 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); 96 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222);
97 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size); 97 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size);
98 gfx::RectF arbitrary_rect_f = 98 gfx::RectF arbitrary_rect_f =
99 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f)); 99 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f));
100 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); 100 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30);
101 gfx::Transform arbitrary_transform; 101 gfx::Transform arbitrary_transform;
102 arbitrary_transform.Scale3d(0.1, 0.2, 0.3); 102 arbitrary_transform.Scale3d(0.1, 0.2, 0.3);
103 FilterOperations arbitrary_filters; 103 FilterOperations arbitrary_filters;
104 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); 104 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f));
105 skia::RefPtr<SkImageFilter> arbitrary_filter =
106 skia::AdoptRef(new SkBlurImageFilter(SK_Scalar1, SK_Scalar1));
107 105
108 // These properties are internal, and should not be considered "change" when 106 // These properties are internal, and should not be considered "change" when
109 // they are used. 107 // they are used.
110 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 108 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
111 root->set_update_rect(arbitrary_rect_f)); 109 root->set_update_rect(arbitrary_rect_f));
112 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 110 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
113 root->SetMaxScrollOffset(arbitrary_vector2d)); 111 root->SetMaxScrollOffset(arbitrary_vector2d));
114 112
115 // Changing these properties affects the entire subtree of layers. 113 // Changing these properties affects the entire subtree of layers.
116 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetAnchorPoint(arbitrary_point_f)); 114 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetAnchorPoint(arbitrary_point_f));
117 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetAnchorPointZ(arbitrary_number)); 115 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetAnchorPointZ(arbitrary_number));
118 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters)); 116 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters));
119 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(FilterOperations())); 117 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(FilterOperations()));
120 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilter(arbitrary_filter));
121 EXECUTE_AND_VERIFY_SUBTREE_CHANGED( 118 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
122 root->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4))); 119 root->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4)));
123 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true)); 120 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true));
124 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true)); 121 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true));
125 EXECUTE_AND_VERIFY_SUBTREE_CHANGED( 122 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
126 root->SetReplicaLayer(LayerImpl::Create(host_impl.active_tree(), 5))); 123 root->SetReplicaLayer(LayerImpl::Create(host_impl.active_tree(), 5)));
127 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetPosition(arbitrary_point_f)); 124 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetPosition(arbitrary_point_f));
128 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetPreserves3d(true)); 125 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetPreserves3d(true));
129 EXECUTE_AND_VERIFY_SUBTREE_CHANGED( 126 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
130 root->SetDoubleSided(false)); // constructor initializes it to "true". 127 root->SetDoubleSided(false)); // constructor initializes it to "true".
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); 206 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222);
210 gfx::Vector2d large_vector2d = gfx::Vector2d(1000, 1000); 207 gfx::Vector2d large_vector2d = gfx::Vector2d(1000, 1000);
211 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size); 208 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size);
212 gfx::RectF arbitrary_rect_f = 209 gfx::RectF arbitrary_rect_f =
213 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f)); 210 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f));
214 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); 211 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30);
215 gfx::Transform arbitrary_transform; 212 gfx::Transform arbitrary_transform;
216 arbitrary_transform.Scale3d(0.1, 0.2, 0.3); 213 arbitrary_transform.Scale3d(0.1, 0.2, 0.3);
217 FilterOperations arbitrary_filters; 214 FilterOperations arbitrary_filters;
218 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); 215 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f));
219 skia::RefPtr<SkImageFilter> arbitrary_filter =
220 skia::AdoptRef(new SkBlurImageFilter(SK_Scalar1, SK_Scalar1));
221 216
222 // Related filter functions. 217 // Related filter functions.
223 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(arbitrary_filters)); 218 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(arbitrary_filters));
224 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(arbitrary_filters)); 219 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(arbitrary_filters));
225 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(FilterOperations())); 220 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(FilterOperations()));
226 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilter(arbitrary_filter)); 221 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(arbitrary_filters));
227 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilter(arbitrary_filter));
228 222
229 // Related scrolling functions. 223 // Related scrolling functions.
230 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetMaxScrollOffset(large_vector2d)); 224 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetMaxScrollOffset(large_vector2d));
231 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 225 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
232 root->SetMaxScrollOffset(large_vector2d)); 226 root->SetMaxScrollOffset(large_vector2d));
233 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->ScrollBy(arbitrary_vector2d)); 227 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->ScrollBy(arbitrary_vector2d));
234 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->ScrollBy(gfx::Vector2d())); 228 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->ScrollBy(gfx::Vector2d()));
235 root->SetScrollDelta(gfx::Vector2d(0, 0)); 229 root->SetScrollDelta(gfx::Vector2d(0, 0));
236 host_impl.ForcePrepareToDraw(); 230 host_impl.ForcePrepareToDraw();
237 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetScrollDelta(arbitrary_vector2d)); 231 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetScrollDelta(arbitrary_vector2d));
(...skipping 26 matching lines...) Expand all
264 root->SetBackgroundFilters(arbitrary_filters)); 258 root->SetBackgroundFilters(arbitrary_filters));
265 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetOpacity(arbitrary_number)); 259 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetOpacity(arbitrary_number));
266 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetTransform(arbitrary_transform)); 260 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetTransform(arbitrary_transform));
267 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 261 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
268 root->SetSublayerTransform(arbitrary_transform)); 262 root->SetSublayerTransform(arbitrary_transform));
269 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetBounds(arbitrary_size)); 263 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetBounds(arbitrary_size));
270 264
271 // Unrelated functions, set to the same values, no needs update. 265 // Unrelated functions, set to the same values, no needs update.
272 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 266 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
273 root->SetAnchorPointZ(arbitrary_number)); 267 root->SetAnchorPointZ(arbitrary_number));
274 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilter(arbitrary_filter)); 268 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(arbitrary_filters));
275 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetMasksToBounds(true)); 269 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetMasksToBounds(true));
276 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetContentsOpaque(true)); 270 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetContentsOpaque(true));
277 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetPosition(arbitrary_point_f)); 271 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetPosition(arbitrary_point_f));
278 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetPreserves3d(true)); 272 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetPreserves3d(true));
279 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 273 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
280 root->SetDoubleSided(false)); // constructor initializes it to "true". 274 root->SetDoubleSided(false)); // constructor initializes it to "true".
281 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 275 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
282 root->SetContentBounds(arbitrary_size)); 276 root->SetContentBounds(arbitrary_size));
283 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 277 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
284 root->SetContentsScale(arbitrary_number, arbitrary_number)); 278 root->SetContentsScale(arbitrary_number, arbitrary_number));
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 547
554 layer()->ApplySentScrollDeltasFromAbortedCommit(); 548 layer()->ApplySentScrollDeltasFromAbortedCommit();
555 549
556 EXPECT_VECTOR_EQ(scroll_offset + scroll_delta, layer()->TotalScrollOffset()); 550 EXPECT_VECTOR_EQ(scroll_offset + scroll_delta, layer()->TotalScrollOffset());
557 EXPECT_VECTOR_EQ(scroll_offset + sent_scroll_delta, layer()->scroll_offset()); 551 EXPECT_VECTOR_EQ(scroll_offset + sent_scroll_delta, layer()->scroll_offset());
558 EXPECT_VECTOR_EQ(gfx::Vector2d(), layer()->sent_scroll_delta()); 552 EXPECT_VECTOR_EQ(gfx::Vector2d(), layer()->sent_scroll_delta());
559 } 553 }
560 554
561 } // namespace 555 } // namespace
562 } // namespace cc 556 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/layers/render_surface_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698