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

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

Issue 202763002: Switch to use SharedBitmapManager all the time in cc_unittests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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/heads_up_display_layer_impl_unittest.cc ('k') | cc/layers/layer_perftest.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"
11 #include "cc/test/fake_output_surface.h" 11 #include "cc/test/fake_output_surface.h"
12 #include "cc/test/geometry_test_utils.h" 12 #include "cc/test/geometry_test_utils.h"
13 #include "cc/test/test_shared_bitmap_manager.h"
13 #include "cc/trees/layer_tree_impl.h" 14 #include "cc/trees/layer_tree_impl.h"
14 #include "cc/trees/single_thread_proxy.h" 15 #include "cc/trees/single_thread_proxy.h"
15 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 18 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
18 19
19 namespace cc { 20 namespace cc {
20 namespace { 21 namespace {
21 22
22 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ 23 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); 76 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties());
76 77
77 TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { 78 TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) {
78 // 79 //
79 // This test checks that layerPropertyChanged() has the correct behavior. 80 // This test checks that layerPropertyChanged() has the correct behavior.
80 // 81 //
81 82
82 // The constructor on this will fake that we are on the correct thread. 83 // The constructor on this will fake that we are on the correct thread.
83 // Create a simple LayerImpl tree: 84 // Create a simple LayerImpl tree:
84 FakeImplProxy proxy; 85 FakeImplProxy proxy;
85 FakeLayerTreeHostImpl host_impl(&proxy); 86 TestSharedBitmapManager shared_bitmap_manager;
87 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
86 EXPECT_TRUE(host_impl.InitializeRenderer( 88 EXPECT_TRUE(host_impl.InitializeRenderer(
87 FakeOutputSurface::Create3d().PassAs<OutputSurface>())); 89 FakeOutputSurface::Create3d().PassAs<OutputSurface>()));
88 scoped_ptr<LayerImpl> root_clip = 90 scoped_ptr<LayerImpl> root_clip =
89 LayerImpl::Create(host_impl.active_tree(), 1); 91 LayerImpl::Create(host_impl.active_tree(), 1);
90 scoped_ptr<LayerImpl> root_ptr = 92 scoped_ptr<LayerImpl> root_ptr =
91 LayerImpl::Create(host_impl.active_tree(), 2); 93 LayerImpl::Create(host_impl.active_tree(), 2);
92 LayerImpl* root = root_ptr.get(); 94 LayerImpl* root = root_ptr.get();
93 root_clip->AddChild(root_ptr.Pass()); 95 root_clip->AddChild(root_ptr.Pass());
94 scoped_ptr<LayerImpl> scroll_parent = 96 scoped_ptr<LayerImpl> scroll_parent =
95 LayerImpl::Create(host_impl.active_tree(), 3); 97 LayerImpl::Create(host_impl.active_tree(), 3);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 236 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
235 root->SetScrollChildren(scroll_children)); 237 root->SetScrollChildren(scroll_children));
236 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 238 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
237 root->SetClipParent(clip_parent.get())); 239 root->SetClipParent(clip_parent.get()));
238 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 240 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
239 root->SetClipChildren(clip_children)); 241 root->SetClipChildren(clip_children));
240 } 242 }
241 243
242 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { 244 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {
243 FakeImplProxy proxy; 245 FakeImplProxy proxy;
244 FakeLayerTreeHostImpl host_impl(&proxy); 246 TestSharedBitmapManager shared_bitmap_manager;
247 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
245 EXPECT_TRUE(host_impl.InitializeRenderer( 248 EXPECT_TRUE(host_impl.InitializeRenderer(
246 FakeOutputSurface::Create3d().PassAs<OutputSurface>())); 249 FakeOutputSurface::Create3d().PassAs<OutputSurface>()));
247 host_impl.active_tree()->SetRootLayer( 250 host_impl.active_tree()->SetRootLayer(
248 LayerImpl::Create(host_impl.active_tree(), 1)); 251 LayerImpl::Create(host_impl.active_tree(), 1));
249 LayerImpl* root = host_impl.active_tree()->root_layer(); 252 LayerImpl* root = host_impl.active_tree()->root_layer();
250 scoped_ptr<LayerImpl> layer_ptr = 253 scoped_ptr<LayerImpl> layer_ptr =
251 LayerImpl::Create(host_impl.active_tree(), 2); 254 LayerImpl::Create(host_impl.active_tree(), 2);
252 LayerImpl* layer = layer_ptr.get(); 255 LayerImpl* layer = layer_ptr.get();
253 root->AddChild(layer_ptr.Pass()); 256 root->AddChild(layer_ptr.Pass());
254 layer->SetScrollClipLayer(root->id()); 257 layer->SetScrollClipLayer(root->id());
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 layer->SetBlendMode(arbitrary_blend_mode)); 349 layer->SetBlendMode(arbitrary_blend_mode));
347 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 350 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
348 layer->SetIsRootForIsolatedGroup(true)); 351 layer->SetIsRootForIsolatedGroup(true));
349 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 352 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
350 layer->SetTransform(arbitrary_transform)); 353 layer->SetTransform(arbitrary_transform));
351 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); 354 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size));
352 } 355 }
353 356
354 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { 357 TEST(LayerImplTest, SafeOpaqueBackgroundColor) {
355 FakeImplProxy proxy; 358 FakeImplProxy proxy;
356 FakeLayerTreeHostImpl host_impl(&proxy); 359 TestSharedBitmapManager shared_bitmap_manager;
360 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
357 EXPECT_TRUE(host_impl.InitializeRenderer( 361 EXPECT_TRUE(host_impl.InitializeRenderer(
358 FakeOutputSurface::Create3d().PassAs<OutputSurface>())); 362 FakeOutputSurface::Create3d().PassAs<OutputSurface>()));
359 scoped_ptr<LayerImpl> layer = LayerImpl::Create(host_impl.active_tree(), 1); 363 scoped_ptr<LayerImpl> layer = LayerImpl::Create(host_impl.active_tree(), 1);
360 364
361 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { 365 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) {
362 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { 366 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) {
363 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { 367 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) {
364 layer->SetContentsOpaque(!!contents_opaque); 368 layer->SetContentsOpaque(!!contents_opaque);
365 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED 369 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED
366 : SK_ColorTRANSPARENT); 370 : SK_ColorTRANSPARENT);
(...skipping 10 matching lines...) Expand all
377 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " 381 << "Flags: " << contents_opaque << ", " << layer_opaque << ", "
378 << host_opaque << "\n"; 382 << host_opaque << "\n";
379 } 383 }
380 } 384 }
381 } 385 }
382 } 386 }
383 } 387 }
384 388
385 class LayerImplScrollTest : public testing::Test { 389 class LayerImplScrollTest : public testing::Test {
386 public: 390 public:
387 LayerImplScrollTest() : host_impl_(&proxy_), root_id_(7) { 391 LayerImplScrollTest()
388 host_impl_.active_tree() 392 : host_impl_(&proxy_, &shared_bitmap_manager_), root_id_(7) {
389 ->SetRootLayer(LayerImpl::Create(host_impl_.active_tree(), root_id_)); 393 host_impl_.active_tree()->SetRootLayer(
394 LayerImpl::Create(host_impl_.active_tree(), root_id_));
390 host_impl_.active_tree()->root_layer()->AddChild( 395 host_impl_.active_tree()->root_layer()->AddChild(
391 LayerImpl::Create(host_impl_.active_tree(), root_id_ + 1)); 396 LayerImpl::Create(host_impl_.active_tree(), root_id_ + 1));
392 layer()->SetScrollClipLayer(root_id_); 397 layer()->SetScrollClipLayer(root_id_);
393 // Set the max scroll offset by noting that the root layer has bounds (1,1), 398 // Set the max scroll offset by noting that the root layer has bounds (1,1),
394 // thus whatever bounds are set for the layer will be the max scroll 399 // thus whatever bounds are set for the layer will be the max scroll
395 // offset plus 1 in each direction. 400 // offset plus 1 in each direction.
396 host_impl_.active_tree()->root_layer()->SetBounds(gfx::Size(1, 1)); 401 host_impl_.active_tree()->root_layer()->SetBounds(gfx::Size(1, 1));
397 gfx::Vector2d max_scroll_offset(51, 81); 402 gfx::Vector2d max_scroll_offset(51, 81);
398 layer()->SetBounds(gfx::Size(max_scroll_offset.x(), max_scroll_offset.y())); 403 layer()->SetBounds(gfx::Size(max_scroll_offset.x(), max_scroll_offset.y()));
399 } 404 }
400 405
401 LayerImpl* layer() { 406 LayerImpl* layer() {
402 return host_impl_.active_tree()->root_layer()->children()[0]; 407 return host_impl_.active_tree()->root_layer()->children()[0];
403 } 408 }
404 409
405 private: 410 private:
406 FakeImplProxy proxy_; 411 FakeImplProxy proxy_;
412 TestSharedBitmapManager shared_bitmap_manager_;
407 FakeLayerTreeHostImpl host_impl_; 413 FakeLayerTreeHostImpl host_impl_;
408 int root_id_; 414 int root_id_;
409 }; 415 };
410 416
411 TEST_F(LayerImplScrollTest, ScrollByWithZeroOffset) { 417 TEST_F(LayerImplScrollTest, ScrollByWithZeroOffset) {
412 // Test that LayerImpl::ScrollBy only affects ScrollDelta and total scroll 418 // Test that LayerImpl::ScrollBy only affects ScrollDelta and total scroll
413 // offset is bounded by the range [0, max scroll offset]. 419 // offset is bounded by the range [0, max scroll offset].
414 420
415 EXPECT_VECTOR_EQ(gfx::Vector2dF(), layer()->TotalScrollOffset()); 421 EXPECT_VECTOR_EQ(gfx::Vector2dF(), layer()->TotalScrollOffset());
416 EXPECT_VECTOR_EQ(gfx::Vector2dF(), layer()->scroll_offset()); 422 EXPECT_VECTOR_EQ(gfx::Vector2dF(), layer()->scroll_offset());
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 layer()->set_user_scrollable_vertical(false); 643 layer()->set_user_scrollable_vertical(false);
638 layer()->SetScrollOffset(scroll_offset); 644 layer()->SetScrollOffset(scroll_offset);
639 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta); 645 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta);
640 646
641 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 8.5f), unscrolled); 647 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 8.5f), unscrolled);
642 EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset()); 648 EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset());
643 } 649 }
644 650
645 } // namespace 651 } // namespace
646 } // namespace cc 652 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/heads_up_display_layer_impl_unittest.cc ('k') | cc/layers/layer_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698