| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/layer.h" | 7 #include "cc/layer.h" |
| 8 | 8 |
| 9 #include "cc/keyframed_animation_curve.h" | 9 #include "cc/keyframed_animation_curve.h" |
| 10 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
\ | 33 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
\ |
| 34 } while (0) | 34 } while (0) |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 class MockLayerImplTreeHost : public LayerTreeHost { | 38 class MockLayerImplTreeHost : public LayerTreeHost { |
| 39 public: | 39 public: |
| 40 MockLayerImplTreeHost() | 40 MockLayerImplTreeHost() |
| 41 : LayerTreeHost(&m_fakeClient, LayerTreeSettings()) | 41 : LayerTreeHost(&m_fakeClient, LayerTreeSettings()) |
| 42 { | 42 { |
| 43 initialize(); | 43 initialize(NULL); |
| 44 } | 44 } |
| 45 | 45 |
| 46 MOCK_METHOD0(setNeedsCommit, void()); | 46 MOCK_METHOD0(setNeedsCommit, void()); |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 FakeLayerImplTreeHostClient m_fakeClient; | 49 FakeLayerImplTreeHostClient m_fakeClient; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class MockLayerPainter : public LayerPainter { | 52 class MockLayerPainter : public LayerPainter { |
| 53 public: | 53 public: |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 // The above tests should not have caused a change to the needsDisplay flag. | 521 // The above tests should not have caused a change to the needsDisplay flag. |
| 522 EXPECT_FALSE(testLayer->needsDisplay()); | 522 EXPECT_FALSE(testLayer->needsDisplay()); |
| 523 | 523 |
| 524 // Test properties that should call setNeedsDisplay and setNeedsCommit | 524 // Test properties that should call setNeedsDisplay and setNeedsCommit |
| 525 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(IntSize
(5, 10))); | 525 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(IntSize
(5, 10))); |
| 526 EXPECT_TRUE(testLayer->needsDisplay()); | 526 EXPECT_TRUE(testLayer->needsDisplay()); |
| 527 } | 527 } |
| 528 | 528 |
| 529 TEST_F(LayerTest, verifyPushPropertiesAccumulatesUpdateRect) | 529 TEST_F(LayerTest, verifyPushPropertiesAccumulatesUpdateRect) |
| 530 { | 530 { |
| 531 DebugScopedSetImplThread setImplThread; | |
| 532 | |
| 533 scoped_refptr<Layer> testLayer = Layer::create(); | 531 scoped_refptr<Layer> testLayer = Layer::create(); |
| 534 scoped_ptr<LayerImpl> implLayer = LayerImpl::create(1); | 532 scoped_ptr<LayerImpl> implLayer = LayerImpl::create(1); |
| 535 | 533 |
| 536 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint::zero(), FloatSize(5, 5)
)); | 534 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint::zero(), FloatSize(5, 5)
)); |
| 537 testLayer->pushPropertiesTo(implLayer.get()); | 535 testLayer->pushPropertiesTo(implLayer.get()); |
| 538 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint::zero(), FloatSize(5, 5)), implLay
er->updateRect()); | 536 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint::zero(), FloatSize(5, 5)), implLay
er->updateRect()); |
| 539 | 537 |
| 540 // The LayerImpl's updateRect should be accumulated here, since we did not d
o anything to clear it. | 538 // The LayerImpl's updateRect should be accumulated here, since we did not d
o anything to clear it. |
| 541 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)
)); | 539 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)
)); |
| 542 testLayer->pushPropertiesTo(implLayer.get()); | 540 testLayer->pushPropertiesTo(implLayer.get()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 EXPECT_TRUE(testLayer->needsDisplay()); | 596 EXPECT_TRUE(testLayer->needsDisplay()); |
| 599 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 320, 240), testLayer->lastNeedsDisplayR
ect()); | 597 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 320, 240), testLayer->lastNeedsDisplayR
ect()); |
| 600 } | 598 } |
| 601 | 599 |
| 602 class FakeLayerImplTreeHost : public LayerTreeHost { | 600 class FakeLayerImplTreeHost : public LayerTreeHost { |
| 603 public: | 601 public: |
| 604 static scoped_ptr<FakeLayerImplTreeHost> create() | 602 static scoped_ptr<FakeLayerImplTreeHost> create() |
| 605 { | 603 { |
| 606 scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost); | 604 scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost); |
| 607 // The initialize call will fail, since our client doesn't provide a val
id GraphicsContext3D, but it doesn't matter in the tests that use this fake so i
gnore the return value. | 605 // The initialize call will fail, since our client doesn't provide a val
id GraphicsContext3D, but it doesn't matter in the tests that use this fake so i
gnore the return value. |
| 608 host->initialize(); | 606 host->initialize(NULL); |
| 609 return host.Pass(); | 607 return host.Pass(); |
| 610 } | 608 } |
| 611 | 609 |
| 612 private: | 610 private: |
| 613 FakeLayerImplTreeHost() | 611 FakeLayerImplTreeHost() |
| 614 : LayerTreeHost(&m_client, LayerTreeSettings()) | 612 : LayerTreeHost(&m_client, LayerTreeSettings()) |
| 615 { | 613 { |
| 616 } | 614 } |
| 617 | 615 |
| 618 FakeLayerImplTreeHostClient m_client; | 616 FakeLayerImplTreeHostClient m_client; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 scoped_refptr<MockLayer> layer(new MockLayer); | 841 scoped_refptr<MockLayer> layer(new MockLayer); |
| 844 EXPECT_FALSE(layer->needsDisplay()); | 842 EXPECT_FALSE(layer->needsDisplay()); |
| 845 layer->setBounds(IntSize(0, 10)); | 843 layer->setBounds(IntSize(0, 10)); |
| 846 EXPECT_FALSE(layer->needsDisplay()); | 844 EXPECT_FALSE(layer->needsDisplay()); |
| 847 layer->setBounds(IntSize(10, 10)); | 845 layer->setBounds(IntSize(10, 10)); |
| 848 EXPECT_TRUE(layer->needsDisplay()); | 846 EXPECT_TRUE(layer->needsDisplay()); |
| 849 } | 847 } |
| 850 | 848 |
| 851 | 849 |
| 852 } // namespace | 850 } // namespace |
| OLD | NEW |