| Index: cc/trees/layer_tree_host_unittest.cc
|
| diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
|
| index aedd0d937a43a69ffce015ea7507f522556a406a..39996512bf9e34bb69aee8258f375bd572455e87 100644
|
| --- a/cc/trees/layer_tree_host_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_unittest.cc
|
| @@ -948,7 +948,6 @@ class TestOpacityChangeLayerDelegate : public ContentLayerClient {
|
| if (test_layer_)
|
| test_layer_->SetOpacity(0.f);
|
| }
|
| - void DidChangeLayerCanUseLCDText() override {}
|
| bool FillsBoundsCompletely() const override { return false; }
|
|
|
| private:
|
| @@ -2129,33 +2128,28 @@ class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
|
| SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
|
| LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted);
|
|
|
| -class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
|
| +class LayerTreeHostTestLCDInvalidation : public LayerTreeHostTest {
|
| public:
|
| - class NotificationClient : public ContentLayerClient {
|
| + class InvalidationClient : public ContentLayerClient {
|
| public:
|
| - NotificationClient()
|
| - : layer_(0), paint_count_(0), lcd_notification_count_(0) {}
|
| + InvalidationClient() : paint_count_(0) {}
|
|
|
| - void set_layer(Layer* layer) { layer_ = layer; }
|
| int paint_count() const { return paint_count_; }
|
| - int lcd_notification_count() const { return lcd_notification_count_; }
|
| + gfx::Rect last_paint_rect() const { return last_paint_rect_; }
|
|
|
| void PaintContents(
|
| SkCanvas* canvas,
|
| const gfx::Rect& clip,
|
| ContentLayerClient::GraphicsContextStatus gc_status) override {
|
| ++paint_count_;
|
| + last_paint_rect_ = clip;
|
| }
|
| - void DidChangeLayerCanUseLCDText() override {
|
| - ++lcd_notification_count_;
|
| - layer_->SetNeedsDisplay();
|
| - }
|
| +
|
| bool FillsBoundsCompletely() const override { return false; }
|
|
|
| private:
|
| - Layer* layer_;
|
| int paint_count_;
|
| - int lcd_notification_count_;
|
| + gfx::Rect last_paint_rect_;
|
| };
|
|
|
| void SetupTree() override {
|
| @@ -2165,10 +2159,9 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
|
| else
|
| root_layer = ContentLayer::Create(&client_);
|
| root_layer->SetIsDrawable(true);
|
| - root_layer->SetBounds(gfx::Size(1, 1));
|
| + root_layer->SetBounds(gfx::Size(10, 10));
|
|
|
| layer_tree_host()->SetRootLayer(root_layer);
|
| - client_.set_layer(root_layer.get());
|
|
|
| // The expecations are based on the assumption that the default
|
| // LCD settings are:
|
| @@ -2184,44 +2177,95 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
|
| void DidCommit() override {
|
| switch (layer_tree_host()->source_frame_number()) {
|
| case 1:
|
| - // The first update consists of one LCD notification and one paint.
|
| - EXPECT_EQ(1, client_.lcd_notification_count());
|
| + // The first update consists of a paint of the whole layer.
|
| EXPECT_EQ(1, client_.paint_count());
|
| + EXPECT_TRUE(client_.last_paint_rect().Contains(gfx::Rect(10, 10)));
|
| // LCD text must have been enabled on the layer.
|
| EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text());
|
| PostSetNeedsCommitToMainThread();
|
| break;
|
| case 2:
|
| - // Since nothing changed on layer, there should be no notification
|
| - // or paint on the second update.
|
| - EXPECT_EQ(1, client_.lcd_notification_count());
|
| + // Since nothing changed on layer, there should be no paint.
|
| EXPECT_EQ(1, client_.paint_count());
|
| // LCD text must not have changed.
|
| EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text());
|
| - // Change layer opacity that should trigger lcd notification.
|
| + // Change layer opacity that should trigger lcd change.
|
| layer_tree_host()->root_layer()->SetOpacity(.5f);
|
| - // No need to request a commit - setting opacity will do it.
|
| break;
|
| - default:
|
| + case 3:
|
| // Verify that there is no extra commit due to layer invalidation.
|
| EXPECT_EQ(3, layer_tree_host()->source_frame_number());
|
| - // LCD notification count should have incremented due to
|
| - // change in layer opacity.
|
| - EXPECT_EQ(2, client_.lcd_notification_count());
|
| - // Paint count should be incremented due to invalidation.
|
| + // Paint count should be incremented due to invalidation, and the paint
|
| + // should cover the whole layer.
|
| EXPECT_EQ(2, client_.paint_count());
|
| + EXPECT_TRUE(client_.last_paint_rect().Contains(gfx::Rect(10, 10)));
|
| // LCD text must have been disabled on the layer due to opacity.
|
| EXPECT_FALSE(layer_tree_host()->root_layer()->can_use_lcd_text());
|
| + // Change layer opacity that should not trigger lcd change.
|
| + layer_tree_host()->root_layer()->SetOpacity(1.f);
|
| + break;
|
| + case 4:
|
| + // Since nothing changed on layer, there should be no paint.
|
| + EXPECT_EQ(2, client_.paint_count());
|
| + // Even though LCD text could be allowed.
|
| + EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text());
|
| + EndTest();
|
| + break;
|
| + }
|
| + }
|
| +
|
| + private:
|
| + InvalidationClient client_;
|
| +};
|
| +
|
| +SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDInvalidation);
|
| +
|
| +class LayerTreeHostTestLCDInvalidationNoExtraCommit : public LayerTreeHostTest {
|
| + public:
|
| + void SetupTree() override {
|
| + scoped_refptr<Layer> root_layer;
|
| + if (layer_tree_host()->settings().impl_side_painting)
|
| + root_layer = PictureLayer::Create(&client_);
|
| + else
|
| + root_layer = ContentLayer::Create(&client_);
|
| + root_layer->SetIsDrawable(true);
|
| + root_layer->SetBounds(gfx::Size(1, 1));
|
| +
|
| + layer_tree_host()->SetRootLayer(root_layer);
|
| +
|
| + // The expecations are based on the assumption that the default
|
| + // LCD settings are:
|
| + EXPECT_TRUE(layer_tree_host()->settings().can_use_lcd_text);
|
| + EXPECT_FALSE(root_layer->can_use_lcd_text());
|
| +
|
| + LayerTreeHostTest::SetupTree();
|
| + }
|
| +
|
| + void BeginTest() override { PostSetNeedsCommitToMainThread(); }
|
| + void AfterTest() override {}
|
| +
|
| + void DidCommit() override {
|
| + switch (layer_tree_host()->source_frame_number()) {
|
| + case 1:
|
| + EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text());
|
| + layer_tree_host()->root_layer()->SetOpacity(.5f);
|
| + break;
|
| + case 2:
|
| + EXPECT_FALSE(layer_tree_host()->root_layer()->can_use_lcd_text());
|
| EndTest();
|
| break;
|
| + case 3:
|
| + // Verify that there is no extra commit due to layer invalidation.
|
| + ADD_FAILURE() << "Extra commit happened due to LCD text change";
|
| + break;
|
| }
|
| }
|
|
|
| private:
|
| - NotificationClient client_;
|
| + FakeContentLayerClient client_;
|
| };
|
|
|
| -SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDNotification);
|
| +SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDInvalidationNoExtraCommit);
|
|
|
| // Verify that the BeginFrame notification is used to initiate rendering.
|
| class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest {
|
| @@ -2392,8 +2436,6 @@ class LayerTreeHostTestChangeLayerPropertiesInPaintContents
|
| layer_->SetBounds(gfx::Size(2, 2));
|
| }
|
|
|
| - void DidChangeLayerCanUseLCDText() override {}
|
| -
|
| bool FillsBoundsCompletely() const override { return false; }
|
|
|
| private:
|
|
|