| OLD | NEW |
| 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.h" | 5 #include "cc/layers/layer.h" |
| 6 | 6 |
| 7 #include "cc/animation/keyframed_animation_curve.h" | 7 #include "cc/animation/keyframed_animation_curve.h" |
| 8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
| 9 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
| 10 #include "cc/resources/layer_painter.h" | 10 #include "cc/resources/layer_painter.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 InitializeSingleThreaded(client, base::MessageLoopProxy::current()); | 44 InitializeSingleThreaded(client, base::MessageLoopProxy::current()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 MOCK_METHOD0(SetNeedsCommit, void()); | 47 MOCK_METHOD0(SetNeedsCommit, void()); |
| 48 MOCK_METHOD0(SetNeedsUpdateLayers, void()); | 48 MOCK_METHOD0(SetNeedsUpdateLayers, void()); |
| 49 MOCK_METHOD0(SetNeedsFullTreeSync, void()); | 49 MOCK_METHOD0(SetNeedsFullTreeSync, void()); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class MockLayerPainter : public LayerPainter { | 52 class MockLayerPainter : public LayerPainter { |
| 53 public: | 53 public: |
| 54 virtual void Paint(SkCanvas* canvas, const gfx::Rect& content_rect) OVERRIDE { | 54 virtual void Paint(SkCanvas* canvas, const gfx::Rect& content_rect) override { |
| 55 } | 55 } |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class LayerTest : public testing::Test { | 58 class LayerTest : public testing::Test { |
| 59 public: | 59 public: |
| 60 LayerTest() | 60 LayerTest() |
| 61 : host_impl_(&proxy_, &shared_bitmap_manager_), | 61 : host_impl_(&proxy_, &shared_bitmap_manager_), |
| 62 fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} | 62 fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} |
| 63 | 63 |
| 64 protected: | 64 protected: |
| 65 virtual void SetUp() OVERRIDE { | 65 virtual void SetUp() override { |
| 66 layer_tree_host_.reset(new StrictMock<MockLayerTreeHost>(&fake_client_)); | 66 layer_tree_host_.reset(new StrictMock<MockLayerTreeHost>(&fake_client_)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 virtual void TearDown() OVERRIDE { | 69 virtual void TearDown() override { |
| 70 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 70 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 71 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); | 71 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); |
| 72 parent_ = NULL; | 72 parent_ = NULL; |
| 73 child1_ = NULL; | 73 child1_ = NULL; |
| 74 child2_ = NULL; | 74 child2_ = NULL; |
| 75 child3_ = NULL; | 75 child3_ = NULL; |
| 76 grand_child1_ = NULL; | 76 grand_child1_ = NULL; |
| 77 grand_child2_ = NULL; | 77 grand_child2_ = NULL; |
| 78 grand_child3_ = NULL; | 78 grand_child3_ = NULL; |
| 79 | 79 |
| (...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 } | 1204 } |
| 1205 } | 1205 } |
| 1206 } | 1206 } |
| 1207 | 1207 |
| 1208 class DrawsContentChangeLayer : public Layer { | 1208 class DrawsContentChangeLayer : public Layer { |
| 1209 public: | 1209 public: |
| 1210 static scoped_refptr<DrawsContentChangeLayer> Create() { | 1210 static scoped_refptr<DrawsContentChangeLayer> Create() { |
| 1211 return make_scoped_refptr(new DrawsContentChangeLayer()); | 1211 return make_scoped_refptr(new DrawsContentChangeLayer()); |
| 1212 } | 1212 } |
| 1213 | 1213 |
| 1214 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE { | 1214 virtual void SetLayerTreeHost(LayerTreeHost* host) override { |
| 1215 Layer::SetLayerTreeHost(host); | 1215 Layer::SetLayerTreeHost(host); |
| 1216 SetFakeDrawsContent(!fake_draws_content_); | 1216 SetFakeDrawsContent(!fake_draws_content_); |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 virtual bool HasDrawableContent() const OVERRIDE { | 1219 virtual bool HasDrawableContent() const override { |
| 1220 return fake_draws_content_ && Layer::HasDrawableContent(); | 1220 return fake_draws_content_ && Layer::HasDrawableContent(); |
| 1221 } | 1221 } |
| 1222 | 1222 |
| 1223 void SetFakeDrawsContent(bool fake_draws_content) { | 1223 void SetFakeDrawsContent(bool fake_draws_content) { |
| 1224 fake_draws_content_ = fake_draws_content; | 1224 fake_draws_content_ = fake_draws_content; |
| 1225 UpdateDrawsContent(HasDrawableContent()); | 1225 UpdateDrawsContent(HasDrawableContent()); |
| 1226 } | 1226 } |
| 1227 | 1227 |
| 1228 private: | 1228 private: |
| 1229 DrawsContentChangeLayer() : Layer(), fake_draws_content_(false) {} | 1229 DrawsContentChangeLayer() : Layer(), fake_draws_content_(false) {} |
| 1230 virtual ~DrawsContentChangeLayer() OVERRIDE {} | 1230 virtual ~DrawsContentChangeLayer() override {} |
| 1231 | 1231 |
| 1232 bool fake_draws_content_; | 1232 bool fake_draws_content_; |
| 1233 }; | 1233 }; |
| 1234 | 1234 |
| 1235 TEST_F(LayerTest, DrawsContentChangedInSetLayerTreeHost) { | 1235 TEST_F(LayerTest, DrawsContentChangedInSetLayerTreeHost) { |
| 1236 scoped_refptr<Layer> root_layer = Layer::Create(); | 1236 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 1237 scoped_refptr<DrawsContentChangeLayer> becomes_not_draws_content = | 1237 scoped_refptr<DrawsContentChangeLayer> becomes_not_draws_content = |
| 1238 DrawsContentChangeLayer::Create(); | 1238 DrawsContentChangeLayer::Create(); |
| 1239 scoped_refptr<DrawsContentChangeLayer> becomes_draws_content = | 1239 scoped_refptr<DrawsContentChangeLayer> becomes_draws_content = |
| 1240 DrawsContentChangeLayer::Create(); | 1240 DrawsContentChangeLayer::Create(); |
| 1241 root_layer->SetIsDrawable(true); | 1241 root_layer->SetIsDrawable(true); |
| 1242 becomes_not_draws_content->SetIsDrawable(true); | 1242 becomes_not_draws_content->SetIsDrawable(true); |
| 1243 becomes_not_draws_content->SetFakeDrawsContent(true); | 1243 becomes_not_draws_content->SetFakeDrawsContent(true); |
| 1244 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 1244 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
| 1245 root_layer->AddChild(becomes_not_draws_content); | 1245 root_layer->AddChild(becomes_not_draws_content); |
| 1246 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 1246 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
| 1247 | 1247 |
| 1248 becomes_draws_content->SetIsDrawable(true); | 1248 becomes_draws_content->SetIsDrawable(true); |
| 1249 root_layer->AddChild(becomes_draws_content); | 1249 root_layer->AddChild(becomes_draws_content); |
| 1250 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); | 1250 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); |
| 1251 } | 1251 } |
| 1252 | 1252 |
| 1253 } // namespace | 1253 } // namespace |
| 1254 } // namespace cc | 1254 } // namespace cc |
| OLD | NEW |