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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 testLayer->pushPropertiesTo(implLayer.get()); | 542 testLayer->pushPropertiesTo(implLayer.get()); |
543 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint::zero(), FloatSize(15, 15)), implL
ayer->updateRect()); | 543 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint::zero(), FloatSize(15, 15)), implL
ayer->updateRect()); |
544 | 544 |
545 // If we do clear the LayerImpl side, then the next updateRect should be fre
sh without accumulation. | 545 // If we do clear the LayerImpl side, then the next updateRect should be fre
sh without accumulation. |
546 implLayer->resetAllChangeTrackingForSubtree(); | 546 implLayer->resetAllChangeTrackingForSubtree(); |
547 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)
)); | 547 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)
)); |
548 testLayer->pushPropertiesTo(implLayer.get()); | 548 testLayer->pushPropertiesTo(implLayer.get()); |
549 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)), implLay
er->updateRect()); | 549 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)), implLay
er->updateRect()); |
550 } | 550 } |
551 | 551 |
552 class LayerWithContentScaling : public Layer { | |
553 public: | |
554 explicit LayerWithContentScaling() | |
555 : Layer() | |
556 { | |
557 } | |
558 | |
559 virtual bool needsContentsScale() const OVERRIDE | |
560 { | |
561 return true; | |
562 } | |
563 | |
564 virtual void setNeedsDisplayRect(const FloatRect& dirtyRect) OVERRIDE | |
565 { | |
566 m_lastNeedsDisplayRect = dirtyRect; | |
567 Layer::setNeedsDisplayRect(dirtyRect); | |
568 } | |
569 | |
570 void resetNeedsDisplay() | |
571 { | |
572 m_needsDisplay = false; | |
573 } | |
574 | |
575 const FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsDisplayRec
t; } | |
576 | |
577 private: | |
578 virtual ~LayerWithContentScaling() | |
579 { | |
580 } | |
581 | |
582 FloatRect m_lastNeedsDisplayRect; | |
583 }; | |
584 | |
585 TEST_F(LayerTest, checkContentsScaleChangeTriggersNeedsDisplay) | |
586 { | |
587 scoped_refptr<LayerWithContentScaling> testLayer = make_scoped_refptr(new La
yerWithContentScaling()); | |
588 testLayer->setIsDrawable(true); | |
589 testLayer->setLayerTreeHost(m_layerTreeHost.get()); | |
590 | |
591 IntSize testBounds = IntSize(320, 240); | |
592 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBou
nds)); | |
593 | |
594 testLayer->resetNeedsDisplay(); | |
595 EXPECT_FALSE(testLayer->needsDisplay()); | |
596 | |
597 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setContentsScale(
testLayer->contentsScale() + 1.f)); | |
598 EXPECT_TRUE(testLayer->needsDisplay()); | |
599 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 320, 240), testLayer->lastNeedsDisplayR
ect()); | |
600 } | |
601 | |
602 class FakeLayerImplTreeHost : public LayerTreeHost { | 552 class FakeLayerImplTreeHost : public LayerTreeHost { |
603 public: | 553 public: |
604 static scoped_ptr<FakeLayerImplTreeHost> create() | 554 static scoped_ptr<FakeLayerImplTreeHost> create() |
605 { | 555 { |
606 scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost); | 556 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. | 557 // 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(); | 558 host->initialize(); |
609 return host.Pass(); | 559 return host.Pass(); |
610 } | 560 } |
611 | 561 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 scoped_refptr<MockLayer> layer(new MockLayer); | 793 scoped_refptr<MockLayer> layer(new MockLayer); |
844 EXPECT_FALSE(layer->needsDisplay()); | 794 EXPECT_FALSE(layer->needsDisplay()); |
845 layer->setBounds(IntSize(0, 10)); | 795 layer->setBounds(IntSize(0, 10)); |
846 EXPECT_FALSE(layer->needsDisplay()); | 796 EXPECT_FALSE(layer->needsDisplay()); |
847 layer->setBounds(IntSize(10, 10)); | 797 layer->setBounds(IntSize(10, 10)); |
848 EXPECT_TRUE(layer->needsDisplay()); | 798 EXPECT_TRUE(layer->needsDisplay()); |
849 } | 799 } |
850 | 800 |
851 | 801 |
852 } // namespace | 802 } // namespace |
OLD | NEW |