| 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 763de5d7ddbd0085b1728df3dc2aadecf5137a22..322dd0668636bedd2ab8e2e2a88a4c0db8509211 100644
|
| --- a/cc/trees/layer_tree_host_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_unittest.cc
|
| @@ -968,13 +968,14 @@ class TestOpacityChangeLayerDelegate : public ContentLayerClient {
|
| virtual void PaintContents(
|
| SkCanvas* canvas,
|
| const gfx::Rect& clip,
|
| + bool can_paint_lcd_text,
|
| gfx::RectF* opaque,
|
| ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE {
|
| // Set layer opacity to 0.
|
| if (test_layer_)
|
| test_layer_->SetOpacity(0.f);
|
| }
|
| - virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
|
| + virtual bool PaintsLCDText() const OVERRIDE { return false; }
|
| virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
|
|
|
| private:
|
| @@ -2183,43 +2184,41 @@ class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
|
| SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
|
| LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted);
|
|
|
| -class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
|
| +class LayerTreeHostTestLCDText : public LayerTreeHostTest {
|
| public:
|
| - class NotificationClient : public ContentLayerClient {
|
| + class PaintTracker : public ContentLayerClient {
|
| public:
|
| - NotificationClient()
|
| - : layer_(0), paint_count_(0), lcd_notification_count_(0) {}
|
| + PaintTracker() : paint_count_(0), did_paint_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 did_paint_lcd_text() const { return did_paint_lcd_text_; }
|
|
|
| virtual void PaintContents(
|
| SkCanvas* canvas,
|
| const gfx::Rect& clip,
|
| + bool can_paint_lcd_text,
|
| gfx::RectF* opaque,
|
| ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE {
|
| ++paint_count_;
|
| + did_paint_lcd_text_ = can_paint_lcd_text;
|
| }
|
| - virtual void DidChangeLayerCanUseLCDText() OVERRIDE {
|
| - ++lcd_notification_count_;
|
| - layer_->SetNeedsDisplay();
|
| - }
|
| + virtual bool PaintsLCDText() const OVERRIDE { return true; }
|
| virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
|
|
|
| private:
|
| - Layer* layer_;
|
| int paint_count_;
|
| - int lcd_notification_count_;
|
| + bool did_paint_lcd_text_;
|
| };
|
|
|
| virtual void SetupTree() OVERRIDE {
|
| - scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_);
|
| + 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);
|
| - client_.set_layer(root_layer.get());
|
|
|
| // The expecations are based on the assumption that the default
|
| // LCD settings are:
|
| @@ -2235,44 +2234,42 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
|
| virtual void DidCommit() OVERRIDE {
|
| switch (layer_tree_host()->source_frame_number()) {
|
| case 1:
|
| - // The first update consists one LCD notification and one paint.
|
| - EXPECT_EQ(1, client_.lcd_notification_count());
|
| - EXPECT_EQ(1, client_.paint_count());
|
| // LCD text must have been enabled on the layer.
|
| EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text());
|
| + // LCD text must be painted on the first paint.
|
| + EXPECT_EQ(1, client_.paint_count());
|
| + EXPECT_TRUE(client_.did_paint_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 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 change.
|
| layer_tree_host()->root_layer()->SetOpacity(.5f);
|
| // No need to request a commit - setting opacity will do it.
|
| break;
|
| default:
|
| // Verify that there is not 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.
|
| - EXPECT_EQ(2, client_.paint_count());
|
| // LCD text must have been disabled on the layer due to opacity.
|
| EXPECT_FALSE(layer_tree_host()->root_layer()->can_use_lcd_text());
|
| + // Paint count should be incremented due to invalidation.
|
| + EXPECT_EQ(2, client_.paint_count());
|
| + // Last paint should be without LCD text.
|
| + EXPECT_FALSE(client_.did_paint_lcd_text());
|
| EndTest();
|
| break;
|
| }
|
| }
|
|
|
| private:
|
| - NotificationClient client_;
|
| + PaintTracker client_;
|
| };
|
|
|
| -SINGLE_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 {
|
| @@ -2440,12 +2437,13 @@ class LayerTreeHostTestChangeLayerPropertiesInPaintContents
|
| virtual void PaintContents(
|
| SkCanvas* canvas,
|
| const gfx::Rect& clip,
|
| + bool can_paint_lcd_text,
|
| gfx::RectF* opaque,
|
| ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE {
|
| layer_->SetBounds(gfx::Size(2, 2));
|
| }
|
|
|
| - virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
|
| + virtual bool PaintsLCDText() const OVERRIDE { return false; }
|
|
|
| virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
|
|
|
|
|