| 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 e39a76dc0a9c738e6f69da33c2ff2d138a407227..72a5b451e59d74351d14c33f100956ccd163562c 100644
|
| --- a/cc/trees/layer_tree_host_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_unittest.cc
|
| @@ -1112,7 +1112,6 @@ class TestOpacityChangeLayerDelegate : public ContentLayerClient {
|
| if (test_layer_)
|
| test_layer_->SetOpacity(0.f);
|
| }
|
| - void DidChangeLayerCanUseLCDText() override {}
|
| bool FillsBoundsCompletely() const override { return false; }
|
|
|
| private:
|
| @@ -2306,46 +2305,42 @@ class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
|
| SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
|
| LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted);
|
|
|
| -class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
|
| +class LayerTreeHostTestLCDChange : public LayerTreeHostTest {
|
| public:
|
| - class NotificationClient : public ContentLayerClient {
|
| + class PaintClient : public FakeContentLayerClient {
|
| public:
|
| - NotificationClient()
|
| - : layer_(0), paint_count_(0), lcd_notification_count_(0) {}
|
| + PaintClient() : 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_; }
|
|
|
| void PaintContents(
|
| SkCanvas* canvas,
|
| const gfx::Rect& clip,
|
| ContentLayerClient::GraphicsContextStatus gc_status) override {
|
| + FakeContentLayerClient::PaintContents(canvas, clip, gc_status);
|
| ++paint_count_;
|
| }
|
| - void DidChangeLayerCanUseLCDText() override {
|
| - ++lcd_notification_count_;
|
| - layer_->SetNeedsDisplay();
|
| - }
|
| +
|
| bool FillsBoundsCompletely() const override { return false; }
|
|
|
| private:
|
| - Layer* layer_;
|
| int paint_count_;
|
| - int lcd_notification_count_;
|
| };
|
|
|
| void SetupTree() override {
|
| + num_tiles_rastered_ = 0;
|
| +
|
| scoped_refptr<Layer> root_layer;
|
| if (layer_tree_host()->settings().impl_side_painting)
|
| root_layer = PictureLayer::Create(&client_);
|
| else
|
| root_layer = ContentLayer::Create(&client_);
|
| + client_.set_fill_with_nonsolid_color(true);
|
| root_layer->SetIsDrawable(true);
|
| - root_layer->SetBounds(gfx::Size(1, 1));
|
| + root_layer->SetBounds(gfx::Size(10, 10));
|
| + root_layer->SetContentsOpaque(true);
|
|
|
| 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:
|
| @@ -2356,49 +2351,76 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
|
| }
|
|
|
| void BeginTest() override { PostSetNeedsCommitToMainThread(); }
|
| - void AfterTest() override {}
|
|
|
| - void DidCommit() override {
|
| + void DidCommitAndDrawFrame() 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());
|
| // 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:
|
| - // 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.
|
| - EXPECT_EQ(2, client_.paint_count());
|
| + case 3:
|
| + // LCD text doesn't require re-recording, so no painting should occur.
|
| + EXPECT_EQ(1, 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());
|
| + // Change layer opacity that should not trigger lcd change.
|
| + layer_tree_host()->root_layer()->SetOpacity(1.f);
|
| + break;
|
| + case 4:
|
| + // LCD text doesn't require re-recording, so no painting should occur.
|
| + EXPECT_EQ(1, client_.paint_count());
|
| + // Even though LCD text could be allowed.
|
| + EXPECT_TRUE(layer_tree_host()->root_layer()->can_use_lcd_text());
|
| EndTest();
|
| break;
|
| }
|
| }
|
|
|
| + void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl,
|
| + const Tile* tile) override {
|
| + ++num_tiles_rastered_;
|
| + }
|
| +
|
| + void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
|
| + switch (host_impl->active_tree()->source_frame_number()) {
|
| + case 0:
|
| + // The first draw.
|
| + EXPECT_EQ(1, num_tiles_rastered_);
|
| + break;
|
| + case 1:
|
| + // Nothing changed on the layer.
|
| + EXPECT_EQ(1, num_tiles_rastered_);
|
| + break;
|
| + case 2:
|
| + // LCD text was disabled, it should be re-rastered with LCD text off.
|
| + EXPECT_EQ(2, num_tiles_rastered_);
|
| + break;
|
| + case 3:
|
| + // LCD text was enabled but it's sticky and stays off.
|
| + EXPECT_EQ(2, num_tiles_rastered_);
|
| + break;
|
| + }
|
| + }
|
| +
|
| + void AfterTest() override {}
|
| +
|
| private:
|
| - NotificationClient client_;
|
| + PaintClient client_;
|
| + int num_tiles_rastered_;
|
| };
|
|
|
| -SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDNotification);
|
| +SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestLCDChange);
|
|
|
| // Verify that the BeginFrame notification is used to initiate rendering.
|
| class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest {
|
| @@ -2569,8 +2591,6 @@ class LayerTreeHostTestChangeLayerPropertiesInPaintContents
|
| layer_->SetBounds(gfx::Size(2, 2));
|
| }
|
|
|
| - void DidChangeLayerCanUseLCDText() override {}
|
| -
|
| bool FillsBoundsCompletely() const override { return false; }
|
|
|
| private:
|
| @@ -5387,6 +5407,9 @@ class LayerTreeHostTestCrispUpAfterPinchEnds : public LayerTreeHostTest {
|
| FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass());
|
| layer->SetBounds(gfx::Size(500, 500));
|
| layer->SetContentsOpaque(true);
|
| + // Avoid LCD text on the layer so we don't cause extra commits when we
|
| + // pinch.
|
| + layer->disable_lcd_text();
|
| pinch->AddChild(layer);
|
|
|
| layer_tree_host()->RegisterViewportLayers(root, pinch, pinch);
|
| @@ -5433,11 +5456,6 @@ class LayerTreeHostTestCrispUpAfterPinchEnds : public LayerTreeHostTest {
|
| PostNextAfterDraw(host_impl);
|
| break;
|
| case 2:
|
| - // Wait for any activations that need to occur due to starting a pinch,
|
| - // and drawing with a non-identity transform (for eg. LCD text being
|
| - // disabled).
|
| - if (host_impl->pending_tree())
|
| - break;
|
| if (quad_scale_delta != 1.f)
|
| break;
|
| // Drew at page scale 1.5 after pinching in.
|
| @@ -5582,7 +5600,6 @@ class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles
|
| void SetupTree() override {
|
| step_ = 1;
|
| continuous_draws_ = 0;
|
| - expect_draw_ = false;
|
| client_.set_fill_with_nonsolid_color(true);
|
|
|
| scoped_refptr<Layer> root = Layer::Create();
|
| @@ -5600,6 +5617,9 @@ class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles
|
| FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass());
|
| layer->SetBounds(gfx::Size(500, 500));
|
| layer->SetContentsOpaque(true);
|
| + // Avoid LCD text on the layer so we don't cause extra commits when we
|
| + // pinch.
|
| + layer->disable_lcd_text();
|
| pinch->AddChild(layer);
|
|
|
| layer_tree_host()->RegisterViewportLayers(root, pinch, pinch);
|
| @@ -5662,18 +5682,17 @@ class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles
|
| EXPECT_EQ(1.f, quad_scale_delta);
|
| break;
|
| case 5:
|
| - // TODO(danakj): We may get one more draw because the NotifyReadyToDraw
|
| - // is asynchronous from the previous draw and happens late.
|
| + // TODO(danakj): We get more draws before the NotifyReadyToDraw
|
| + // because it is asynchronous from the previous draw and happens late.
|
| break;
|
| case 6:
|
| - // We may get another draw if we activate due to the pinch (eg LCD text
|
| - // gets disabled).
|
| - if (expect_draw_)
|
| - break;
|
| + // NotifyReadyToDraw happened. If we were already inside a frame, we may
|
| + // try to draw once more.
|
| + break;
|
| + case 7:
|
| NOTREACHED() << "No draws should happen once we have a complete frame.";
|
| break;
|
| }
|
| - expect_draw_ = false;
|
| return draw_result;
|
| }
|
|
|
| @@ -5701,8 +5720,13 @@ class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles
|
| }
|
| break;
|
| case 4:
|
| - // TODO(danakj): Now we wait for NotifyReadyToDraw to avoid flakiness
|
| - // since it happens asynchronously.
|
| + ++step_;
|
| + break;
|
| + case 5:
|
| + // Waiting for NotifyReadyToDraw.
|
| + break;
|
| + case 6:
|
| + // NotifyReadyToDraw happened.
|
| ++step_;
|
| break;
|
| }
|
| @@ -5710,21 +5734,17 @@ class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles
|
|
|
| void NotifyReadyToDrawOnThread(LayerTreeHostImpl* host_impl) override {
|
| if (step_ == 5) {
|
| - // We should not continue to draw any more. End the test after a timeout
|
| - // to watch for any extraneous draws.
|
| + ++step_;
|
| + // NotifyReadyToDraw has happened, we may draw once more, but should not
|
| + // get any more draws after that. End the test after a timeout to watch
|
| + // for any extraneous draws.
|
| // TODO(brianderson): We could remove this delay and instead wait until
|
| // the BeginFrameSource decides it doesn't need to send frames anymore,
|
| // or test that it already doesn't here.
|
| EndTestAfterDelayMs(16 * 4);
|
| - ++step_;
|
| - expect_draw_ = true;
|
| }
|
| }
|
|
|
| - void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
|
| - expect_draw_ = true;
|
| - }
|
| -
|
| void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl,
|
| const Tile* tile) override {
|
| // On step_ == 2, we are preventing texture uploads from completing,
|
| @@ -5739,7 +5759,6 @@ class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles
|
| FakeContentLayerClient client_;
|
| int step_;
|
| int continuous_draws_;
|
| - bool expect_draw_;
|
| base::WaitableEvent playback_allowed_event_;
|
| };
|
|
|
|
|