| 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 0d2a8422352d2f1dc2b70d39bb473353aef01a90..82b64f1581de3bdfca28ddfc6e5d0b7e1ebb0dd9 100644
|
| --- a/cc/trees/layer_tree_host_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_unittest.cc
|
| @@ -943,12 +943,13 @@ class TestOpacityChangeLayerDelegate : public ContentLayerClient {
|
| void PaintContents(
|
| SkCanvas* canvas,
|
| const gfx::Rect& clip,
|
| + bool can_use_lcd_text,
|
| + bool contents_opaque,
|
| ContentLayerClient::GraphicsContextStatus gc_status) override {
|
| // Set layer opacity to 0.
|
| if (test_layer_)
|
| test_layer_->SetOpacity(0.f);
|
| }
|
| - void DidChangeLayerCanUseLCDText() override {}
|
| bool FillsBoundsCompletely() const override { return false; }
|
|
|
| private:
|
| @@ -2129,33 +2130,34 @@ class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
|
| SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
|
| LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted);
|
|
|
| -class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
|
| +class LayerTreeHostTestLCDText : public LayerTreeHostTest {
|
| public:
|
| - class NotificationClient : public ContentLayerClient {
|
| + class TextClient : public ContentLayerClient {
|
| public:
|
| - NotificationClient()
|
| - : layer_(0), paint_count_(0), lcd_notification_count_(0) {}
|
| + TextClient() : layer_(0), paint_count_(0), last_can_use_lcd_text_(false) {}
|
|
|
| void set_layer(Layer* layer) { layer_ = layer; }
|
| int paint_count() const { return paint_count_; }
|
| - int lcd_notification_count() const { return lcd_notification_count_; }
|
| + int last_can_use_lcd_text() const { return last_can_use_lcd_text_; }
|
| + gfx::Rect last_paint_rect() const { return last_paint_rect_; }
|
|
|
| void PaintContents(
|
| SkCanvas* canvas,
|
| - const gfx::Rect& clip,
|
| + const gfx::Rect& paint_rect,
|
| + bool can_use_lcd_text,
|
| + bool contents_opaque,
|
| ContentLayerClient::GraphicsContextStatus gc_status) override {
|
| ++paint_count_;
|
| - }
|
| - void DidChangeLayerCanUseLCDText() override {
|
| - ++lcd_notification_count_;
|
| - layer_->SetNeedsDisplay();
|
| + last_can_use_lcd_text_ = can_use_lcd_text;
|
| + last_paint_rect_ = paint_rect;
|
| }
|
| bool FillsBoundsCompletely() const override { return false; }
|
|
|
| private:
|
| Layer* layer_;
|
| int paint_count_;
|
| - int lcd_notification_count_;
|
| + bool last_can_use_lcd_text_;
|
| + gfx::Rect last_paint_rect_;
|
| };
|
|
|
| void SetupTree() override {
|
| @@ -2165,7 +2167,7 @@ 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());
|
| @@ -2184,44 +2186,48 @@ 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 was the whole layer, and with lcd text.
|
| EXPECT_EQ(1, client_.paint_count());
|
| + EXPECT_TRUE(client_.last_can_use_lcd_text());
|
| + 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();
|
| + layer_tree_host()->SetNeedsCommit();
|
| 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 on the
|
| + // second update.
|
| 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 notification, but would
|
| + // not normally invalidate causing a paint.
|
| layer_tree_host()->root_layer()->SetOpacity(.5f);
|
| // No need to request a commit - setting opacity will do it.
|
| break;
|
| - default:
|
| - // 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.
|
| + case 3:
|
| + // Paint count should be incremented due to the LCD change.
|
| EXPECT_EQ(2, client_.paint_count());
|
| + // The paint was not done with LCD text enabled.
|
| + EXPECT_FALSE(client_.last_can_use_lcd_text());
|
| + // And the whole layer was invalidated and repainted.
|
| + 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());
|
| EndTest();
|
| break;
|
| + case 4:
|
| + // Verify that there is no extra commit due to layer invalidation.
|
| + EXPECT_TRUE(false);
|
| + break;
|
| }
|
| }
|
|
|
| private:
|
| - NotificationClient client_;
|
| + TextClient client_;
|
| };
|
|
|
| -SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDNotification);
|
| +SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDText);
|
|
|
| // Verify that the BeginFrame notification is used to initiate rendering.
|
| class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest {
|
| @@ -2388,12 +2394,12 @@ class LayerTreeHostTestChangeLayerPropertiesInPaintContents
|
| void PaintContents(
|
| SkCanvas* canvas,
|
| const gfx::Rect& clip,
|
| + bool can_use_lcd_text,
|
| + bool contents_opaque,
|
| ContentLayerClient::GraphicsContextStatus gc_status) override {
|
| layer_->SetBounds(gfx::Size(2, 2));
|
| }
|
|
|
| - void DidChangeLayerCanUseLCDText() override {}
|
| -
|
| bool FillsBoundsCompletely() const override { return false; }
|
|
|
| private:
|
|
|