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

Side by Side Diff: cc/layer_impl_unittest.cc

Issue 11529006: [cc] Fold more update calls into updateDrawProperties (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/layer_tree_host_impl.h » ('j') | cc/layer_tree_host_impl_unittest.cc » ('J')
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_impl.h" 5 #include "cc/layer_impl.h"
6 6
7 #include "cc/single_thread_proxy.h" 7 #include "cc/single_thread_proxy.h"
8 #include "cc/test/fake_impl_proxy.h" 8 #include "cc/test/fake_impl_proxy.h"
9 #include "cc/test/fake_layer_tree_host_impl.h" 9 #include "cc/test/fake_layer_tree_host_impl.h"
10 #include "cc/test/fake_output_surface.h"
10 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 13 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
13 #include <public/WebFilterOperation.h> 14 #include <public/WebFilterOperation.h>
14 #include <public/WebFilterOperations.h> 15 #include <public/WebFilterOperations.h>
15 16
16 using namespace WebKit; 17 using namespace WebKit;
17 18
18 namespace cc { 19 namespace cc {
19 namespace { 20 namespace {
(...skipping 26 matching lines...) Expand all
46 #define EXECUTE_AND_VERIFY_ONLY_SURFACE_CHANGED(codeToTest) \ 47 #define EXECUTE_AND_VERIFY_ONLY_SURFACE_CHANGED(codeToTest) \
47 root->resetAllChangeTrackingForSubtree(); \ 48 root->resetAllChangeTrackingForSubtree(); \
48 codeToTest; \ 49 codeToTest; \
49 EXPECT_FALSE(root->layerPropertyChanged()); \ 50 EXPECT_FALSE(root->layerPropertyChanged()); \
50 EXPECT_FALSE(child->layerPropertyChanged()); \ 51 EXPECT_FALSE(child->layerPropertyChanged()); \
51 EXPECT_FALSE(grandChild->layerPropertyChanged()); \ 52 EXPECT_FALSE(grandChild->layerPropertyChanged()); \
52 EXPECT_TRUE(root->layerSurfacePropertyChanged()) 53 EXPECT_TRUE(root->layerSurfacePropertyChanged())
53 54
54 #define VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(codeToTest) \ 55 #define VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(codeToTest) \
55 root->resetAllChangeTrackingForSubtree(); \ 56 root->resetAllChangeTrackingForSubtree(); \
56 hostImpl.resetNeedsUpdateDrawPropertiesForTesting(); \ 57 hostImpl.forcePrepareToDraw(); \
57 codeToTest; \ 58 codeToTest; \
58 EXPECT_TRUE(hostImpl.needsUpdateDrawProperties()); 59 EXPECT_TRUE(hostImpl.needsUpdateDrawProperties());
59 60
60 #define VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(codeToTest) \ 61 #define VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(codeToTest) \
61 root->resetAllChangeTrackingForSubtree(); \ 62 root->resetAllChangeTrackingForSubtree(); \
62 hostImpl.resetNeedsUpdateDrawPropertiesForTesting(); \ 63 hostImpl.forcePrepareToDraw(); \
63 codeToTest; \ 64 codeToTest; \
64 EXPECT_FALSE(hostImpl.needsUpdateDrawProperties()); 65 EXPECT_FALSE(hostImpl.needsUpdateDrawProperties());
65 66
66 TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly) 67 TEST(LayerImplTest, verifyLayerChangesAreTrackedProperly)
67 { 68 {
68 // 69 //
69 // This test checks that layerPropertyChanged() has the correct behavior. 70 // This test checks that layerPropertyChanged() has the correct behavior.
70 // 71 //
71 72
72 // The constructor on this will fake that we are on the correct thread. 73 // The constructor on this will fake that we are on the correct thread.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setOpacity(arbitraryNumber)) ; 164 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setOpacity(arbitraryNumber)) ;
164 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawsContent(true)); 165 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawsContent(true));
165 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setSublayerTransform(arbitra ryTransform)); 166 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setSublayerTransform(arbitra ryTransform));
166 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setBounds(arbitrarySize)); 167 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setBounds(arbitrarySize));
167 } 168 }
168 169
169 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) 170 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties)
170 { 171 {
171 FakeImplProxy proxy; 172 FakeImplProxy proxy;
172 FakeLayerTreeHostImpl hostImpl(&proxy); 173 FakeLayerTreeHostImpl hostImpl(&proxy);
174 hostImpl.initializeRenderer(createFakeOutputSurface());
173 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1); 175 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1);
174 176
175 gfx::PointF arbitraryPointF = gfx::PointF(0.125f, 0.25f); 177 gfx::PointF arbitraryPointF = gfx::PointF(0.125f, 0.25f);
176 float arbitraryNumber = 0.352f; 178 float arbitraryNumber = 0.352f;
177 gfx::Size arbitrarySize = gfx::Size(111, 222); 179 gfx::Size arbitrarySize = gfx::Size(111, 222);
178 gfx::Point arbitraryPoint = gfx::Point(333, 444); 180 gfx::Point arbitraryPoint = gfx::Point(333, 444);
179 gfx::Vector2d arbitraryVector2d = gfx::Vector2d(111, 222); 181 gfx::Vector2d arbitraryVector2d = gfx::Vector2d(111, 222);
180 gfx::Vector2d largeVector2d = gfx::Vector2d(1000, 1000); 182 gfx::Vector2d largeVector2d = gfx::Vector2d(1000, 1000);
181 gfx::Rect arbitraryRect = gfx::Rect(arbitraryPoint, arbitrarySize); 183 gfx::Rect arbitraryRect = gfx::Rect(arbitraryPoint, arbitrarySize);
182 gfx::RectF arbitraryRectF = gfx::RectF(arbitraryPointF, gfx::SizeF(1.234f, 5 .678f)); 184 gfx::RectF arbitraryRectF = gfx::RectF(arbitraryPointF, gfx::SizeF(1.234f, 5 .678f));
(...skipping 10 matching lines...) Expand all
193 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setFilters(WebFilterOperations())) ; 195 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setFilters(WebFilterOperations())) ;
194 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setFilter(arbitraryFilter)); 196 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setFilter(arbitraryFilter));
195 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setFilter(arbitraryFilter)); 197 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setFilter(arbitraryFilter));
196 198
197 // Related scrolling functions. 199 // Related scrolling functions.
198 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setMaxScrollOffset(largeVector2d)) ; 200 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setMaxScrollOffset(largeVector2d)) ;
199 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setMaxScrollOffset(largeVector2 d)); 201 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setMaxScrollOffset(largeVector2 d));
200 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->scrollBy(arbitraryVector2d)); 202 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->scrollBy(arbitraryVector2d));
201 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->scrollBy(gfx::Vector2d())); 203 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->scrollBy(gfx::Vector2d()));
202 root->setScrollDelta(gfx::Vector2d(0, 0)); 204 root->setScrollDelta(gfx::Vector2d(0, 0));
203 hostImpl.resetNeedsUpdateDrawPropertiesForTesting(); 205 hostImpl.forcePrepareToDraw();
204 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setScrollDelta(arbitraryVector2d)) ; 206 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setScrollDelta(arbitraryVector2d)) ;
205 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setScrollDelta(arbitraryVector2 d)); 207 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setScrollDelta(arbitraryVector2 d));
206 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setScrollOffset(arbitraryVector2d) ); 208 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setScrollOffset(arbitraryVector2d) );
207 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setScrollOffset(arbitraryVector 2d)); 209 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setScrollOffset(arbitraryVector 2d));
208 210
209 // Unrelated functions, always set to new values, always set needs update. 211 // Unrelated functions, always set to new values, always set needs update.
210 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setAnchorPointZ(arbitraryNumber)); 212 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setAnchorPointZ(arbitraryNumber));
211 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setMaskLayer(LayerImpl::create(hos tImpl.activeTree(), 4))); 213 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setMaskLayer(LayerImpl::create(hos tImpl.activeTree(), 4)));
212 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setMasksToBounds(true)); 214 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setMasksToBounds(true));
213 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setContentsOpaque(true)); 215 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(root->setContentsOpaque(true));
(...skipping 29 matching lines...) Expand all
243 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setBackgroundColor(SK_ColorGRAY )); 245 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setBackgroundColor(SK_ColorGRAY ));
244 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setBackgroundFilters(arbitraryF ilters)); 246 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setBackgroundFilters(arbitraryF ilters));
245 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setOpacity(arbitraryNumber)); 247 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setOpacity(arbitraryNumber));
246 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setTransform(arbitraryTransform )); 248 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setTransform(arbitraryTransform ));
247 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setSublayerTransform(arbitraryT ransform)); 249 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setSublayerTransform(arbitraryT ransform));
248 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setBounds(arbitrarySize)); 250 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(root->setBounds(arbitrarySize));
249 } 251 }
250 252
251 } // namespace 253 } // namespace
252 } // namespace cc 254 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layer_tree_host_impl.h » ('j') | cc/layer_tree_host_impl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698