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

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 295193002: Get rid of graphics layer anchor points, and replace with transform origin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 6 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
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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 virtual bool Update(ResourceUpdateQueue* queue, 994 virtual bool Update(ResourceUpdateQueue* queue,
995 const OcclusionTracker<Layer>* occlusion) OVERRIDE { 995 const OcclusionTracker<Layer>* occlusion) OVERRIDE {
996 bool updated = ContentLayer::Update(queue, occlusion); 996 bool updated = ContentLayer::Update(queue, occlusion);
997 paint_contents_count_++; 997 paint_contents_count_++;
998 return updated; 998 return updated;
999 } 999 }
1000 1000
1001 private: 1001 private:
1002 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client) 1002 explicit ContentLayerWithUpdateTracking(ContentLayerClient* client)
1003 : ContentLayer(client), paint_contents_count_(0) { 1003 : ContentLayer(client), paint_contents_count_(0) {
1004 SetAnchorPoint(gfx::PointF(0.f, 0.f));
1005 SetBounds(gfx::Size(10, 10)); 1004 SetBounds(gfx::Size(10, 10));
1006 SetIsDrawable(true); 1005 SetIsDrawable(true);
1007 } 1006 }
1008 virtual ~ContentLayerWithUpdateTracking() {} 1007 virtual ~ContentLayerWithUpdateTracking() {}
1009 1008
1010 int paint_contents_count_; 1009 int paint_contents_count_;
1011 }; 1010 };
1012 1011
1013 // Layer opacity change during paint should not prevent compositor resources 1012 // Layer opacity change during paint should not prevent compositor resources
1014 // from being updated during commit. 1013 // from being updated during commit.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 1083
1085 virtual void BeginTest() OVERRIDE { 1084 virtual void BeginTest() OVERRIDE {
1086 layer_tree_host()->SetViewportSize(gfx::Size(60, 60)); 1085 layer_tree_host()->SetViewportSize(gfx::Size(60, 60));
1087 layer_tree_host()->SetDeviceScaleFactor(1.5); 1086 layer_tree_host()->SetDeviceScaleFactor(1.5);
1088 EXPECT_EQ(gfx::Size(60, 60), layer_tree_host()->device_viewport_size()); 1087 EXPECT_EQ(gfx::Size(60, 60), layer_tree_host()->device_viewport_size());
1089 1088
1090 root_layer_->AddChild(child_layer_); 1089 root_layer_->AddChild(child_layer_);
1091 1090
1092 root_layer_->SetIsDrawable(true); 1091 root_layer_->SetIsDrawable(true);
1093 root_layer_->SetBounds(gfx::Size(30, 30)); 1092 root_layer_->SetBounds(gfx::Size(30, 30));
1094 root_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f));
1095 1093
1096 child_layer_->SetIsDrawable(true); 1094 child_layer_->SetIsDrawable(true);
1097 child_layer_->SetPosition(gfx::Point(2, 2)); 1095 child_layer_->SetPosition(gfx::Point(2, 2));
1098 child_layer_->SetBounds(gfx::Size(10, 10)); 1096 child_layer_->SetBounds(gfx::Size(10, 10));
1099 child_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f));
1100 1097
1101 layer_tree_host()->SetRootLayer(root_layer_); 1098 layer_tree_host()->SetRootLayer(root_layer_);
1102 1099
1103 PostSetNeedsCommitToMainThread(); 1100 PostSetNeedsCommitToMainThread();
1104 } 1101 }
1105 1102
1106 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1103 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1107 // Should only do one commit. 1104 // Should only do one commit.
1108 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); 1105 EXPECT_EQ(0, impl->active_tree()->source_frame_number());
1109 // Device scale factor should come over to impl. 1106 // Device scale factor should come over to impl.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 } 1330 }
1334 } 1331 }
1335 }; 1332 };
1336 1333
1337 MULTI_THREAD_DELEGATING_RENDERER_NOIMPL_TEST_F( 1334 MULTI_THREAD_DELEGATING_RENDERER_NOIMPL_TEST_F(
1338 LayerTreeHostTestDelegatingRendererAtomicCommit); 1335 LayerTreeHostTestDelegatingRendererAtomicCommit);
1339 1336
1340 static void SetLayerPropertiesForTesting(Layer* layer, 1337 static void SetLayerPropertiesForTesting(Layer* layer,
1341 Layer* parent, 1338 Layer* parent,
1342 const gfx::Transform& transform, 1339 const gfx::Transform& transform,
1343 const gfx::PointF& anchor, 1340 const gfx::Point3F& transform_origin,
1344 const gfx::PointF& position, 1341 const gfx::PointF& position,
1345 const gfx::Size& bounds, 1342 const gfx::Size& bounds,
1346 bool opaque) { 1343 bool opaque) {
1347 layer->RemoveAllChildren(); 1344 layer->RemoveAllChildren();
1348 if (parent) 1345 if (parent)
1349 parent->AddChild(layer); 1346 parent->AddChild(layer);
1350 layer->SetTransform(transform); 1347 layer->SetTransform(transform);
1351 layer->SetAnchorPoint(anchor); 1348 layer->SetTransformOrigin(transform_origin);
1352 layer->SetPosition(position); 1349 layer->SetPosition(position);
1353 layer->SetBounds(bounds); 1350 layer->SetBounds(bounds);
1354 layer->SetContentsOpaque(opaque); 1351 layer->SetContentsOpaque(opaque);
1355 } 1352 }
1356 1353
1357 class LayerTreeHostTestAtomicCommitWithPartialUpdate 1354 class LayerTreeHostTestAtomicCommitWithPartialUpdate
1358 : public LayerTreeHostTest { 1355 : public LayerTreeHostTest {
1359 public: 1356 public:
1360 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 1357 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
1361 settings->texture_id_allocation_chunk_size = 1; 1358 settings->texture_id_allocation_chunk_size = 1;
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 num_commits_(0) {} 1716 num_commits_(0) {}
1720 1717
1721 virtual void BeginTest() OVERRIDE { 1718 virtual void BeginTest() OVERRIDE {
1722 layer_tree_host()->SetRootLayer(layer_); 1719 layer_tree_host()->SetRootLayer(layer_);
1723 layer_tree_host()->SetViewportSize(gfx::Size(10, 20)); 1720 layer_tree_host()->SetViewportSize(gfx::Size(10, 20));
1724 1721
1725 gfx::Transform identity_matrix; 1722 gfx::Transform identity_matrix;
1726 SetLayerPropertiesForTesting(layer_.get(), 1723 SetLayerPropertiesForTesting(layer_.get(),
1727 0, 1724 0,
1728 identity_matrix, 1725 identity_matrix,
1729 gfx::PointF(0.f, 0.f), 1726 gfx::Point3F(0.f, 0.f, 0.f),
1730 gfx::PointF(0.f, 0.f), 1727 gfx::PointF(0.f, 0.f),
1731 gfx::Size(10, 20), 1728 gfx::Size(10, 20),
1732 true); 1729 true);
1733 1730
1734 PostSetNeedsCommitToMainThread(); 1731 PostSetNeedsCommitToMainThread();
1735 } 1732 }
1736 1733
1737 void PostEvictTextures() { 1734 void PostEvictTextures() {
1738 ImplThreadTaskRunner()->PostTask( 1735 ImplThreadTaskRunner()->PostTask(
1739 FROM_HERE, 1736 FROM_HERE,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 LayerTreeHostTestContinuousInvalidate() 1883 LayerTreeHostTestContinuousInvalidate()
1887 : num_commit_complete_(0), num_draw_layers_(0) {} 1884 : num_commit_complete_(0), num_draw_layers_(0) {}
1888 1885
1889 virtual void BeginTest() OVERRIDE { 1886 virtual void BeginTest() OVERRIDE {
1890 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); 1887 layer_tree_host()->SetViewportSize(gfx::Size(10, 10));
1891 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); 1888 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10));
1892 1889
1893 content_layer_ = ContentLayer::Create(&client_); 1890 content_layer_ = ContentLayer::Create(&client_);
1894 content_layer_->SetBounds(gfx::Size(10, 10)); 1891 content_layer_->SetBounds(gfx::Size(10, 10));
1895 content_layer_->SetPosition(gfx::PointF(0.f, 0.f)); 1892 content_layer_->SetPosition(gfx::PointF(0.f, 0.f));
1896 content_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f));
1897 content_layer_->SetIsDrawable(true); 1893 content_layer_->SetIsDrawable(true);
1898 layer_tree_host()->root_layer()->AddChild(content_layer_); 1894 layer_tree_host()->root_layer()->AddChild(content_layer_);
1899 1895
1900 PostSetNeedsCommitToMainThread(); 1896 PostSetNeedsCommitToMainThread();
1901 } 1897 }
1902 1898
1903 virtual void DidCommitAndDrawFrame() OVERRIDE { 1899 virtual void DidCommitAndDrawFrame() OVERRIDE {
1904 if (num_draw_layers_ == 2) 1900 if (num_draw_layers_ == 2)
1905 return; 1901 return;
1906 content_layer_->SetNeedsDisplay(); 1902 content_layer_->SetNeedsDisplay();
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
2538 virtual void SetupTree() OVERRIDE { 2534 virtual void SetupTree() OVERRIDE {
2539 LayerTreeHostTest::SetupTree(); 2535 LayerTreeHostTest::SetupTree();
2540 2536
2541 layer_tree_host()->root_layer()->SetIsDrawable(false); 2537 layer_tree_host()->root_layer()->SetIsDrawable(false);
2542 2538
2543 io_surface_id_ = 9; 2539 io_surface_id_ = 9;
2544 io_surface_size_ = gfx::Size(6, 7); 2540 io_surface_size_ = gfx::Size(6, 7);
2545 2541
2546 scoped_refptr<IOSurfaceLayer> io_surface_layer = IOSurfaceLayer::Create(); 2542 scoped_refptr<IOSurfaceLayer> io_surface_layer = IOSurfaceLayer::Create();
2547 io_surface_layer->SetBounds(gfx::Size(10, 10)); 2543 io_surface_layer->SetBounds(gfx::Size(10, 10));
2548 io_surface_layer->SetAnchorPoint(gfx::PointF());
2549 io_surface_layer->SetIsDrawable(true); 2544 io_surface_layer->SetIsDrawable(true);
2550 io_surface_layer->SetContentsOpaque(true); 2545 io_surface_layer->SetContentsOpaque(true);
2551 io_surface_layer->SetIOSurfaceProperties(io_surface_id_, io_surface_size_); 2546 io_surface_layer->SetIOSurfaceProperties(io_surface_id_, io_surface_size_);
2552 layer_tree_host()->root_layer()->AddChild(io_surface_layer); 2547 layer_tree_host()->root_layer()->AddChild(io_surface_layer);
2553 } 2548 }
2554 2549
2555 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2550 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
2556 2551
2557 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2552 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2558 EXPECT_EQ(0u, host_impl->resource_provider()->num_resources()); 2553 EXPECT_EQ(0u, host_impl->resource_provider()->num_resources());
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
2946 2941
2947 size_t push_properties_count() const { return push_properties_count_; } 2942 size_t push_properties_count() const { return push_properties_count_; }
2948 void reset_push_properties_count() { push_properties_count_ = 0; } 2943 void reset_push_properties_count() { push_properties_count_ = 0; }
2949 2944
2950 private: 2945 private:
2951 size_t push_properties_count_; 2946 size_t push_properties_count_;
2952 2947
2953 PushPropertiesCountingLayerImpl(LayerTreeImpl* tree_impl, int id) 2948 PushPropertiesCountingLayerImpl(LayerTreeImpl* tree_impl, int id)
2954 : LayerImpl(tree_impl, id), 2949 : LayerImpl(tree_impl, id),
2955 push_properties_count_(0) { 2950 push_properties_count_(0) {
2956 SetAnchorPoint(gfx::PointF());
2957 SetBounds(gfx::Size(1, 1)); 2951 SetBounds(gfx::Size(1, 1));
2958 } 2952 }
2959 }; 2953 };
2960 2954
2961 class PushPropertiesCountingLayer : public Layer { 2955 class PushPropertiesCountingLayer : public Layer {
2962 public: 2956 public:
2963 static scoped_refptr<PushPropertiesCountingLayer> Create() { 2957 static scoped_refptr<PushPropertiesCountingLayer> Create() {
2964 return new PushPropertiesCountingLayer(); 2958 return new PushPropertiesCountingLayer();
2965 } 2959 }
2966 2960
(...skipping 13 matching lines...) Expand all
2980 size_t push_properties_count() const { return push_properties_count_; } 2974 size_t push_properties_count() const { return push_properties_count_; }
2981 void reset_push_properties_count() { push_properties_count_ = 0; } 2975 void reset_push_properties_count() { push_properties_count_ = 0; }
2982 2976
2983 void set_persist_needs_push_properties(bool persist) { 2977 void set_persist_needs_push_properties(bool persist) {
2984 persist_needs_push_properties_ = persist; 2978 persist_needs_push_properties_ = persist;
2985 } 2979 }
2986 2980
2987 private: 2981 private:
2988 PushPropertiesCountingLayer() 2982 PushPropertiesCountingLayer()
2989 : push_properties_count_(0), persist_needs_push_properties_(false) { 2983 : push_properties_count_(0), persist_needs_push_properties_(false) {
2990 SetAnchorPoint(gfx::PointF());
2991 SetBounds(gfx::Size(1, 1)); 2984 SetBounds(gfx::Size(1, 1));
2992 SetIsDrawable(true); 2985 SetIsDrawable(true);
2993 } 2986 }
2994 virtual ~PushPropertiesCountingLayer() {} 2987 virtual ~PushPropertiesCountingLayer() {}
2995 2988
2996 size_t push_properties_count_; 2989 size_t push_properties_count_;
2997 bool persist_needs_push_properties_; 2990 bool persist_needs_push_properties_;
2998 }; 2991 };
2999 2992
3000 class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest { 2993 class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest {
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
4006 }; 3999 };
4007 4000
4008 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 4001 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335
4009 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 4002 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
4010 LayerTreeHostTestIOSurfaceLayerInvalidate); 4003 LayerTreeHostTestIOSurfaceLayerInvalidate);
4011 4004
4012 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { 4005 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest {
4013 protected: 4006 protected:
4014 virtual void SetupTree() OVERRIDE { 4007 virtual void SetupTree() OVERRIDE {
4015 root_layer_ = Layer::Create(); 4008 root_layer_ = Layer::Create();
4016 root_layer_->SetAnchorPoint(gfx::PointF());
4017 root_layer_->SetPosition(gfx::Point()); 4009 root_layer_->SetPosition(gfx::Point());
4018 root_layer_->SetBounds(gfx::Size(10, 10)); 4010 root_layer_->SetBounds(gfx::Size(10, 10));
4019 4011
4020 parent_layer_ = SolidColorLayer::Create(); 4012 parent_layer_ = SolidColorLayer::Create();
4021 parent_layer_->SetAnchorPoint(gfx::PointF());
4022 parent_layer_->SetPosition(gfx::Point()); 4013 parent_layer_->SetPosition(gfx::Point());
4023 parent_layer_->SetBounds(gfx::Size(10, 10)); 4014 parent_layer_->SetBounds(gfx::Size(10, 10));
4024 parent_layer_->SetIsDrawable(true); 4015 parent_layer_->SetIsDrawable(true);
4025 root_layer_->AddChild(parent_layer_); 4016 root_layer_->AddChild(parent_layer_);
4026 4017
4027 child_layer_ = SolidColorLayer::Create(); 4018 child_layer_ = SolidColorLayer::Create();
4028 child_layer_->SetAnchorPoint(gfx::PointF());
4029 child_layer_->SetPosition(gfx::Point()); 4019 child_layer_->SetPosition(gfx::Point());
4030 child_layer_->SetBounds(gfx::Size(10, 10)); 4020 child_layer_->SetBounds(gfx::Size(10, 10));
4031 child_layer_->SetIsDrawable(true); 4021 child_layer_->SetIsDrawable(true);
4032 parent_layer_->AddChild(child_layer_); 4022 parent_layer_->AddChild(child_layer_);
4033 4023
4034 layer_tree_host()->SetRootLayer(root_layer_); 4024 layer_tree_host()->SetRootLayer(root_layer_);
4035 LayerTreeHostTest::SetupTree(); 4025 LayerTreeHostTest::SetupTree();
4036 } 4026 }
4037 4027
4038 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4028 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
4079 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushHiddenLayer); 4069 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushHiddenLayer);
4080 4070
4081 class LayerTreeHostTestUpdateLayerInEmptyViewport : public LayerTreeHostTest { 4071 class LayerTreeHostTestUpdateLayerInEmptyViewport : public LayerTreeHostTest {
4082 protected: 4072 protected:
4083 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 4073 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
4084 settings->impl_side_painting = true; 4074 settings->impl_side_painting = true;
4085 } 4075 }
4086 4076
4087 virtual void SetupTree() OVERRIDE { 4077 virtual void SetupTree() OVERRIDE {
4088 root_layer_ = FakePictureLayer::Create(&client_); 4078 root_layer_ = FakePictureLayer::Create(&client_);
4089 root_layer_->SetAnchorPoint(gfx::PointF());
4090 root_layer_->SetBounds(gfx::Size(10, 10)); 4079 root_layer_->SetBounds(gfx::Size(10, 10));
4091 4080
4092 layer_tree_host()->SetRootLayer(root_layer_); 4081 layer_tree_host()->SetRootLayer(root_layer_);
4093 LayerTreeHostTest::SetupTree(); 4082 LayerTreeHostTest::SetupTree();
4094 } 4083 }
4095 4084
4096 virtual void BeginTest() OVERRIDE { 4085 virtual void BeginTest() OVERRIDE {
4097 // The viewport is empty, but we still need to update layers on the main 4086 // The viewport is empty, but we still need to update layers on the main
4098 // thread. 4087 // thread.
4099 layer_tree_host()->SetViewportSize(gfx::Size(0, 0)); 4088 layer_tree_host()->SetViewportSize(gfx::Size(0, 0));
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
4899 const gfx::Size bounds_; 4888 const gfx::Size bounds_;
4900 FakeContentLayerClient client_; 4889 FakeContentLayerClient client_;
4901 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; 4890 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_;
4902 scoped_refptr<FakePictureLayer> picture_layer_; 4891 scoped_refptr<FakePictureLayer> picture_layer_;
4903 Layer* child_layer_; 4892 Layer* child_layer_;
4904 }; 4893 };
4905 4894
4906 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); 4895 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
4907 4896
4908 } // namespace cc 4897 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698