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

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

Powered by Google App Engine
This is Rietveld 408576698