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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 testLayer->pushPropertiesTo(implLayer.get()); | 545 testLayer->pushPropertiesTo(implLayer.get()); |
546 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint::zero(), FloatSize(15, 15)), implL
ayer->updateRect()); | 546 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint::zero(), FloatSize(15, 15)), implL
ayer->updateRect()); |
547 | 547 |
548 // If we do clear the LayerImpl side, then the next updateRect should be fre
sh without accumulation. | 548 // If we do clear the LayerImpl side, then the next updateRect should be fre
sh without accumulation. |
549 implLayer->resetAllChangeTrackingForSubtree(); | 549 implLayer->resetAllChangeTrackingForSubtree(); |
550 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)
)); | 550 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)
)); |
551 testLayer->pushPropertiesTo(implLayer.get()); | 551 testLayer->pushPropertiesTo(implLayer.get()); |
552 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)), implLay
er->updateRect()); | 552 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)), implLay
er->updateRect()); |
553 } | 553 } |
554 | 554 |
555 class LayerWithContentScaling : public Layer { | |
556 public: | |
557 explicit LayerWithContentScaling() | |
558 : Layer() | |
559 { | |
560 } | |
561 | |
562 virtual bool needsContentsScale() const OVERRIDE | |
563 { | |
564 return true; | |
565 } | |
566 | |
567 virtual void setNeedsDisplayRect(const FloatRect& dirtyRect) OVERRIDE | |
568 { | |
569 m_lastNeedsDisplayRect = dirtyRect; | |
570 Layer::setNeedsDisplayRect(dirtyRect); | |
571 } | |
572 | |
573 void resetNeedsDisplay() | |
574 { | |
575 m_needsDisplay = false; | |
576 } | |
577 | |
578 const FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsDisplayRec
t; } | |
579 | |
580 private: | |
581 virtual ~LayerWithContentScaling() | |
582 { | |
583 } | |
584 | |
585 FloatRect m_lastNeedsDisplayRect; | |
586 }; | |
587 | |
588 TEST_F(LayerTest, checkContentsScaleChangeTriggersNeedsDisplay) | |
589 { | |
590 scoped_refptr<LayerWithContentScaling> testLayer = make_scoped_refptr(new La
yerWithContentScaling()); | |
591 testLayer->setIsDrawable(true); | |
592 testLayer->setLayerTreeHost(m_layerTreeHost.get()); | |
593 | |
594 IntSize testBounds = IntSize(320, 240); | |
595 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBou
nds)); | |
596 | |
597 testLayer->resetNeedsDisplay(); | |
598 EXPECT_FALSE(testLayer->needsDisplay()); | |
599 | |
600 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setContentsScale(
testLayer->contentsScale() + 1.f)); | |
601 EXPECT_TRUE(testLayer->needsDisplay()); | |
602 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 320, 240), testLayer->lastNeedsDisplayR
ect()); | |
603 } | |
604 | |
605 class FakeLayerImplTreeHost : public LayerTreeHost { | 555 class FakeLayerImplTreeHost : public LayerTreeHost { |
606 public: | 556 public: |
607 static scoped_ptr<FakeLayerImplTreeHost> create() | 557 static scoped_ptr<FakeLayerImplTreeHost> create() |
608 { | 558 { |
609 scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost); | 559 scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost); |
610 // 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. | 560 // 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. |
611 host->initialize(); | 561 host->initialize(); |
612 return host.Pass(); | 562 return host.Pass(); |
613 } | 563 } |
614 | 564 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 scoped_refptr<MockLayer> layer(new MockLayer); | 803 scoped_refptr<MockLayer> layer(new MockLayer); |
854 EXPECT_FALSE(layer->needsDisplay()); | 804 EXPECT_FALSE(layer->needsDisplay()); |
855 layer->setBounds(IntSize(0, 10)); | 805 layer->setBounds(IntSize(0, 10)); |
856 EXPECT_FALSE(layer->needsDisplay()); | 806 EXPECT_FALSE(layer->needsDisplay()); |
857 layer->setBounds(IntSize(10, 10)); | 807 layer->setBounds(IntSize(10, 10)); |
858 EXPECT_TRUE(layer->needsDisplay()); | 808 EXPECT_TRUE(layer->needsDisplay()); |
859 } | 809 } |
860 | 810 |
861 | 811 |
862 } // namespace | 812 } // namespace |
OLD | NEW |