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

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

Issue 16968002: Move implementation of WebFilterOperations into cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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/output/filter_operation.h » ('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"
8 #include "cc/output/filter_operations.h"
7 #include "cc/test/fake_impl_proxy.h" 9 #include "cc/test/fake_impl_proxy.h"
8 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
9 #include "cc/test/fake_output_surface.h" 11 #include "cc/test/fake_output_surface.h"
10 #include "cc/trees/layer_tree_impl.h" 12 #include "cc/trees/layer_tree_impl.h"
11 #include "cc/trees/single_thread_proxy.h" 13 #include "cc/trees/single_thread_proxy.h"
12 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/WebKit/public/platform/WebFilterOperation.h"
15 #include "third_party/WebKit/public/platform/WebFilterOperations.h"
16 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 16 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
17 17
18 using WebKit::WebFilterOperation;
19 using WebKit::WebFilterOperations;
20
21 namespace cc { 18 namespace cc {
22 namespace { 19 namespace {
23 20
24 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ 21 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \
25 root->ResetAllChangeTrackingForSubtree(); \ 22 root->ResetAllChangeTrackingForSubtree(); \
26 code_to_test; \ 23 code_to_test; \
27 EXPECT_TRUE(root->LayerPropertyChanged()); \ 24 EXPECT_TRUE(root->LayerPropertyChanged()); \
28 EXPECT_TRUE(child->LayerPropertyChanged()); \ 25 EXPECT_TRUE(child->LayerPropertyChanged()); \
29 EXPECT_TRUE(grand_child->LayerPropertyChanged()); \ 26 EXPECT_TRUE(grand_child->LayerPropertyChanged()); \
30 EXPECT_FALSE(root->LayerSurfacePropertyChanged()) 27 EXPECT_FALSE(root->LayerSurfacePropertyChanged())
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 float arbitrary_number = 0.352f; 90 float arbitrary_number = 0.352f;
94 gfx::Size arbitrary_size = gfx::Size(111, 222); 91 gfx::Size arbitrary_size = gfx::Size(111, 222);
95 gfx::Point arbitrary_point = gfx::Point(333, 444); 92 gfx::Point arbitrary_point = gfx::Point(333, 444);
96 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); 93 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222);
97 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size); 94 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size);
98 gfx::RectF arbitrary_rect_f = 95 gfx::RectF arbitrary_rect_f =
99 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f)); 96 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f));
100 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); 97 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30);
101 gfx::Transform arbitrary_transform; 98 gfx::Transform arbitrary_transform;
102 arbitrary_transform.Scale3d(0.1, 0.2, 0.3); 99 arbitrary_transform.Scale3d(0.1, 0.2, 0.3);
103 WebFilterOperations arbitrary_filters; 100 FilterOperations arbitrary_filters;
104 arbitrary_filters.append(WebFilterOperation::createOpacityFilter(0.5f)); 101 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f));
105 skia::RefPtr<SkImageFilter> arbitrary_filter = 102 skia::RefPtr<SkImageFilter> arbitrary_filter =
106 skia::AdoptRef(new SkBlurImageFilter(SK_Scalar1, SK_Scalar1)); 103 skia::AdoptRef(new SkBlurImageFilter(SK_Scalar1, SK_Scalar1));
107 104
108 // These properties are internal, and should not be considered "change" when 105 // These properties are internal, and should not be considered "change" when
109 // they are used. 106 // they are used.
110 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 107 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
111 root->set_update_rect(arbitrary_rect_f)); 108 root->set_update_rect(arbitrary_rect_f));
112 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 109 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
113 root->SetMaxScrollOffset(arbitrary_vector2d)); 110 root->SetMaxScrollOffset(arbitrary_vector2d));
114 111
115 // Changing these properties affects the entire subtree of layers. 112 // Changing these properties affects the entire subtree of layers.
116 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetAnchorPoint(arbitrary_point_f)); 113 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetAnchorPoint(arbitrary_point_f));
117 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetAnchorPointZ(arbitrary_number)); 114 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetAnchorPointZ(arbitrary_number));
118 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters)); 115 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters));
119 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(WebFilterOperations())); 116 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(FilterOperations()));
120 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilter(arbitrary_filter)); 117 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(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 gfx::Size arbitrary_size = gfx::Size(111, 222); 202 gfx::Size arbitrary_size = gfx::Size(111, 222);
206 gfx::Point arbitrary_point = gfx::Point(333, 444); 203 gfx::Point arbitrary_point = gfx::Point(333, 444);
207 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); 204 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222);
208 gfx::Vector2d large_vector2d = gfx::Vector2d(1000, 1000); 205 gfx::Vector2d large_vector2d = gfx::Vector2d(1000, 1000);
209 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size); 206 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size);
210 gfx::RectF arbitrary_rect_f = 207 gfx::RectF arbitrary_rect_f =
211 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f)); 208 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f));
212 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); 209 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30);
213 gfx::Transform arbitrary_transform; 210 gfx::Transform arbitrary_transform;
214 arbitrary_transform.Scale3d(0.1, 0.2, 0.3); 211 arbitrary_transform.Scale3d(0.1, 0.2, 0.3);
215 WebFilterOperations arbitrary_filters; 212 FilterOperations arbitrary_filters;
216 arbitrary_filters.append(WebFilterOperation::createOpacityFilter(0.5f)); 213 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f));
217 skia::RefPtr<SkImageFilter> arbitrary_filter = 214 skia::RefPtr<SkImageFilter> arbitrary_filter =
218 skia::AdoptRef(new SkBlurImageFilter(SK_Scalar1, SK_Scalar1)); 215 skia::AdoptRef(new SkBlurImageFilter(SK_Scalar1, SK_Scalar1));
219 216
220 // Related filter functions. 217 // Related filter functions.
221 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(arbitrary_filters)); 218 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(arbitrary_filters));
222 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(arbitrary_filters)); 219 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(arbitrary_filters));
223 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(WebFilterOperations())); 220 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilters(FilterOperations()));
224 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilter(arbitrary_filter)); 221 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilter(arbitrary_filter));
225 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilter(arbitrary_filter)); 222 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetFilter(arbitrary_filter));
226 223
227 // Related scrolling functions. 224 // Related scrolling functions.
228 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetMaxScrollOffset(large_vector2d)); 225 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->SetMaxScrollOffset(large_vector2d));
229 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 226 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
230 root->SetMaxScrollOffset(large_vector2d)); 227 root->SetMaxScrollOffset(large_vector2d));
231 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->ScrollBy(arbitrary_vector2d)); 228 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->ScrollBy(arbitrary_vector2d));
232 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->ScrollBy(gfx::Vector2d())); 229 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->ScrollBy(gfx::Vector2d()));
233 root->SetScrollDelta(gfx::Vector2d(0, 0)); 230 root->SetScrollDelta(gfx::Vector2d(0, 0));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " 315 << "Flags: " << contents_opaque << ", " << layer_opaque << ", "
319 << host_opaque << "\n"; 316 << host_opaque << "\n";
320 } 317 }
321 } 318 }
322 } 319 }
323 } 320 }
324 } 321 }
325 322
326 } // namespace 323 } // namespace
327 } // namespace cc 324 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/output/filter_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698