| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 InitializeSingleThreaded(client, base::MessageLoopProxy::current()); | 45 InitializeSingleThreaded(client, base::MessageLoopProxy::current()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 MOCK_METHOD0(SetNeedsCommit, void()); | 48 MOCK_METHOD0(SetNeedsCommit, void()); |
| 49 MOCK_METHOD0(SetNeedsUpdateLayers, void()); | 49 MOCK_METHOD0(SetNeedsUpdateLayers, void()); |
| 50 MOCK_METHOD0(SetNeedsFullTreeSync, void()); | 50 MOCK_METHOD0(SetNeedsFullTreeSync, void()); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 class MockLayerPainter : public LayerPainter { | 53 class MockLayerPainter : public LayerPainter { |
| 54 public: | 54 public: |
| 55 virtual void Paint(SkCanvas* canvas, const gfx::Rect& content_rect) override { | 55 void Paint(SkCanvas* canvas, const gfx::Rect& content_rect) override {} |
| 56 } | |
| 57 }; | 56 }; |
| 58 | 57 |
| 59 class LayerTest : public testing::Test { | 58 class LayerTest : public testing::Test { |
| 60 public: | 59 public: |
| 61 LayerTest() | 60 LayerTest() |
| 62 : host_impl_(&proxy_, &shared_bitmap_manager_), | 61 : host_impl_(&proxy_, &shared_bitmap_manager_), |
| 63 fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} | 62 fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} |
| 64 | 63 |
| 65 protected: | 64 protected: |
| 66 virtual void SetUp() override { | 65 virtual void SetUp() override { |
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 } | 1203 } |
| 1205 } | 1204 } |
| 1206 } | 1205 } |
| 1207 | 1206 |
| 1208 class DrawsContentChangeLayer : public Layer { | 1207 class DrawsContentChangeLayer : public Layer { |
| 1209 public: | 1208 public: |
| 1210 static scoped_refptr<DrawsContentChangeLayer> Create() { | 1209 static scoped_refptr<DrawsContentChangeLayer> Create() { |
| 1211 return make_scoped_refptr(new DrawsContentChangeLayer()); | 1210 return make_scoped_refptr(new DrawsContentChangeLayer()); |
| 1212 } | 1211 } |
| 1213 | 1212 |
| 1214 virtual void SetLayerTreeHost(LayerTreeHost* host) override { | 1213 void SetLayerTreeHost(LayerTreeHost* host) override { |
| 1215 Layer::SetLayerTreeHost(host); | 1214 Layer::SetLayerTreeHost(host); |
| 1216 SetFakeDrawsContent(!fake_draws_content_); | 1215 SetFakeDrawsContent(!fake_draws_content_); |
| 1217 } | 1216 } |
| 1218 | 1217 |
| 1219 virtual bool HasDrawableContent() const override { | 1218 bool HasDrawableContent() const override { |
| 1220 return fake_draws_content_ && Layer::HasDrawableContent(); | 1219 return fake_draws_content_ && Layer::HasDrawableContent(); |
| 1221 } | 1220 } |
| 1222 | 1221 |
| 1223 void SetFakeDrawsContent(bool fake_draws_content) { | 1222 void SetFakeDrawsContent(bool fake_draws_content) { |
| 1224 fake_draws_content_ = fake_draws_content; | 1223 fake_draws_content_ = fake_draws_content; |
| 1225 UpdateDrawsContent(HasDrawableContent()); | 1224 UpdateDrawsContent(HasDrawableContent()); |
| 1226 } | 1225 } |
| 1227 | 1226 |
| 1228 private: | 1227 private: |
| 1229 DrawsContentChangeLayer() : Layer(), fake_draws_content_(false) {} | 1228 DrawsContentChangeLayer() : Layer(), fake_draws_content_(false) {} |
| 1230 virtual ~DrawsContentChangeLayer() override {} | 1229 ~DrawsContentChangeLayer() override {} |
| 1231 | 1230 |
| 1232 bool fake_draws_content_; | 1231 bool fake_draws_content_; |
| 1233 }; | 1232 }; |
| 1234 | 1233 |
| 1235 TEST_F(LayerTest, DrawsContentChangedInSetLayerTreeHost) { | 1234 TEST_F(LayerTest, DrawsContentChangedInSetLayerTreeHost) { |
| 1236 scoped_refptr<Layer> root_layer = Layer::Create(); | 1235 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 1237 scoped_refptr<DrawsContentChangeLayer> becomes_not_draws_content = | 1236 scoped_refptr<DrawsContentChangeLayer> becomes_not_draws_content = |
| 1238 DrawsContentChangeLayer::Create(); | 1237 DrawsContentChangeLayer::Create(); |
| 1239 scoped_refptr<DrawsContentChangeLayer> becomes_draws_content = | 1238 scoped_refptr<DrawsContentChangeLayer> becomes_draws_content = |
| 1240 DrawsContentChangeLayer::Create(); | 1239 DrawsContentChangeLayer::Create(); |
| 1241 root_layer->SetIsDrawable(true); | 1240 root_layer->SetIsDrawable(true); |
| 1242 becomes_not_draws_content->SetIsDrawable(true); | 1241 becomes_not_draws_content->SetIsDrawable(true); |
| 1243 becomes_not_draws_content->SetFakeDrawsContent(true); | 1242 becomes_not_draws_content->SetFakeDrawsContent(true); |
| 1244 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 1243 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
| 1245 root_layer->AddChild(becomes_not_draws_content); | 1244 root_layer->AddChild(becomes_not_draws_content); |
| 1246 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 1245 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
| 1247 | 1246 |
| 1248 becomes_draws_content->SetIsDrawable(true); | 1247 becomes_draws_content->SetIsDrawable(true); |
| 1249 root_layer->AddChild(becomes_draws_content); | 1248 root_layer->AddChild(becomes_draws_content); |
| 1250 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); | 1249 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); |
| 1251 } | 1250 } |
| 1252 | 1251 |
| 1253 } // namespace | 1252 } // namespace |
| 1254 } // namespace cc | 1253 } // namespace cc |
| OLD | NEW |