summaryrefslogtreecommitdiffstats
path: root/cc/test
diff options
context:
space:
mode:
authordanakj <danakj@chromium.org>2014-11-13 18:05:04 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-14 02:05:39 +0000
commita819c2552ffe135e2e15fb0eb64341882a7d4912 (patch)
tree7a75706f340f7d8fd069a9f43d9452ab1bfc9220 /cc/test
parentbf14bb992d8111b6cc6e380aa0ab3030d4ec3b05 (diff)
downloadchromium_src-a819c2552ffe135e2e15fb0eb64341882a7d4912.zip
chromium_src-a819c2552ffe135e2e15fb0eb64341882a7d4912.tar.gz
chromium_src-a819c2552ffe135e2e15fb0eb64341882a7d4912.tar.bz2
SetNeedsRedraw directly when updating a visible tile.
Removes the UpdateVisibleTiles scheduler state, instead if the current set of raster tasks starts with a visible tile, we optimistically call SetNeedsRedraw() at the start of each impl frame to cause us to try and draw. At draw time we UpdateVisibleTiles in the tile manager to collect any completed tasks. To handle other cases, whenever a visible tile is completed, we call SetNeedsRedraw() in addition to setting damage on the layer. Last, when NotifyReadyToDraw() happens, we have a complete frame, so we can stop optimistically calling SetNeedsRedraw() at the start of each impl frame. This allows us to remove the full viewport damage when ending a pinch gesture. This change adds 2 integration unit tests for pinch zoom. The first ensures that when a pinch ends we don't leave blurry tiles on the screen, but update them to ideal. The second ensures we continuously try to draw while we have an incomplete frame. BUG=427423 Review URL: https://codereview.chromium.org/671653005 Cr-Commit-Position: refs/heads/master@{#304147}
Diffstat (limited to 'cc/test')
-rw-r--r--cc/test/fake_layer_tree_host_impl_client.h1
-rw-r--r--cc/test/fake_picture_layer.cc15
-rw-r--r--cc/test/fake_picture_layer.h12
-rw-r--r--cc/test/fake_picture_pile.cc15
-rw-r--r--cc/test/fake_picture_pile.h16
-rw-r--r--cc/test/fake_picture_pile_impl.cc32
-rw-r--r--cc/test/fake_picture_pile_impl.h16
-rw-r--r--cc/test/layer_tree_test.cc16
-rw-r--r--cc/test/layer_tree_test.h5
9 files changed, 106 insertions, 22 deletions
diff --git a/cc/test/fake_layer_tree_host_impl_client.h b/cc/test/fake_layer_tree_host_impl_client.h
index 3c44994..ced02a6 100644
--- a/cc/test/fake_layer_tree_host_impl_client.h
+++ b/cc/test/fake_layer_tree_host_impl_client.h
@@ -27,7 +27,6 @@ class FakeLayerTreeHostImplClient : public LayerTreeHostImplClient {
void SetNeedsRedrawOnImplThread() override {}
void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) override {}
void SetNeedsAnimateOnImplThread() override {}
- void DidInitializeVisibleTileOnImplThread() override {}
void SetNeedsCommitOnImplThread() override {}
void SetNeedsManageTilesOnImplThread() override {}
void PostAnimationEventsToMainThreadOnImplThread(
diff --git a/cc/test/fake_picture_layer.cc b/cc/test/fake_picture_layer.cc
index bd169ba..1a19bc7 100644
--- a/cc/test/fake_picture_layer.cc
+++ b/cc/test/fake_picture_layer.cc
@@ -12,8 +12,19 @@ FakePictureLayer::FakePictureLayer(ContentLayerClient* client)
: PictureLayer(client),
update_count_(0),
push_properties_count_(0),
- always_update_resources_(false),
- output_surface_created_count_(0) {
+ output_surface_created_count_(0),
+ always_update_resources_(false) {
+ SetBounds(gfx::Size(1, 1));
+ SetIsDrawable(true);
+}
+
+FakePictureLayer::FakePictureLayer(ContentLayerClient* client,
+ scoped_ptr<RecordingSource> source)
+ : PictureLayer(client, source.Pass()),
+ update_count_(0),
+ push_properties_count_(0),
+ output_surface_created_count_(0),
+ always_update_resources_(false) {
SetBounds(gfx::Size(1, 1));
SetIsDrawable(true);
}
diff --git a/cc/test/fake_picture_layer.h b/cc/test/fake_picture_layer.h
index 7aa155e..f42a14d 100644
--- a/cc/test/fake_picture_layer.h
+++ b/cc/test/fake_picture_layer.h
@@ -8,15 +8,21 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "cc/layers/picture_layer.h"
+#include "cc/resources/recording_source.h"
namespace cc {
-
class FakePictureLayer : public PictureLayer {
public:
static scoped_refptr<FakePictureLayer> Create(ContentLayerClient* client) {
return make_scoped_refptr(new FakePictureLayer(client));
}
+ static scoped_refptr<FakePictureLayer> CreateWithRecordingSource(
+ ContentLayerClient* client,
+ scoped_ptr<RecordingSource> source) {
+ return make_scoped_refptr(new FakePictureLayer(client, source.Pass()));
+ }
+
scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
size_t update_count() const { return update_count_; }
@@ -41,12 +47,14 @@ class FakePictureLayer : public PictureLayer {
private:
explicit FakePictureLayer(ContentLayerClient* client);
+ FakePictureLayer(ContentLayerClient* client,
+ scoped_ptr<RecordingSource> source);
~FakePictureLayer() override;
size_t update_count_;
size_t push_properties_count_;
- bool always_update_resources_;
size_t output_surface_created_count_;
+ bool always_update_resources_;
};
} // namespace cc
diff --git a/cc/test/fake_picture_pile.cc b/cc/test/fake_picture_pile.cc
new file mode 100644
index 0000000..912ec06
--- /dev/null
+++ b/cc/test/fake_picture_pile.cc
@@ -0,0 +1,15 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/test/fake_picture_pile.h"
+
+#include "cc/test/fake_picture_pile_impl.h"
+
+namespace cc {
+
+scoped_refptr<RasterSource> FakePicturePile::CreateRasterSource() const {
+ return FakePicturePileImpl::CreateFromPile(this, playback_allowed_event_);
+}
+
+} // namespace cc
diff --git a/cc/test/fake_picture_pile.h b/cc/test/fake_picture_pile.h
index e486e3b..2d8f4bf 100644
--- a/cc/test/fake_picture_pile.h
+++ b/cc/test/fake_picture_pile.h
@@ -7,12 +7,20 @@
#include "cc/resources/picture_pile.h"
+namespace base {
+class WaitableEvent;
+}
+
namespace cc {
class FakePicturePile : public PicturePile {
public:
+ FakePicturePile() : playback_allowed_event_(nullptr) {}
~FakePicturePile() override {}
+ // PicturePile overrides.
+ scoped_refptr<RasterSource> CreateRasterSource() const override;
+
using PicturePile::buffer_pixels;
using PicturePile::CanRasterSlowTileCheck;
using PicturePile::Clear;
@@ -37,6 +45,10 @@ class FakePicturePile : public PicturePile {
has_any_recordings_ = has_recordings;
}
+ void SetPlaybackAllowedEvent(base::WaitableEvent* event) {
+ playback_allowed_event_ = event;
+ }
+
TilingData& tiling() { return tiling_; }
bool is_solid_color() const { return is_solid_color_; }
@@ -47,7 +59,11 @@ class FakePicturePile : public PicturePile {
typedef PicturePile::PictureInfo PictureInfo;
typedef PicturePile::PictureMapKey PictureMapKey;
typedef PicturePile::PictureMap PictureMap;
+
+ private:
+ base::WaitableEvent* playback_allowed_event_;
};
+
} // namespace cc
#endif // CC_TEST_FAKE_PICTURE_PILE_H_
diff --git a/cc/test/fake_picture_pile_impl.cc b/cc/test/fake_picture_pile_impl.cc
index 3d31c12..cb68e87 100644
--- a/cc/test/fake_picture_pile_impl.cc
+++ b/cc/test/fake_picture_pile_impl.cc
@@ -8,6 +8,7 @@
#include <limits>
#include <utility>
+#include "base/synchronization/waitable_event.h"
#include "cc/resources/picture_pile.h"
#include "cc/test/fake_picture_pile.h"
#include "cc/test/impl_side_painting_settings.h"
@@ -15,10 +16,14 @@
namespace cc {
-FakePicturePileImpl::FakePicturePileImpl() {}
+FakePicturePileImpl::FakePicturePileImpl() : playback_allowed_event_(nullptr) {
+}
-FakePicturePileImpl::FakePicturePileImpl(const PicturePile* other)
+FakePicturePileImpl::FakePicturePileImpl(
+ const PicturePile* other,
+ base::WaitableEvent* playback_allowed_event)
: PicturePileImpl(other),
+ playback_allowed_event_(playback_allowed_event),
tile_grid_info_(other->GetTileGridInfoForTesting()) {
}
@@ -34,7 +39,7 @@ scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFilledPile(
pile.SetRecordedViewport(gfx::Rect(layer_bounds));
pile.SetHasAnyRecordings(true);
- auto pile_impl = make_scoped_refptr(new FakePicturePileImpl(&pile));
+ auto pile_impl = make_scoped_refptr(new FakePicturePileImpl(&pile, nullptr));
for (int x = 0; x < pile_impl->tiling().num_tiles_x(); ++x) {
for (int y = 0; y < pile_impl->tiling().num_tiles_y(); ++y)
pile_impl->AddRecordingAt(x, y);
@@ -51,7 +56,7 @@ scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateEmptyPile(
pile.SetTileGridSize(ImplSidePaintingSettings().default_tile_grid_size);
pile.SetRecordedViewport(gfx::Rect());
pile.SetHasAnyRecordings(false);
- return make_scoped_refptr(new FakePicturePileImpl(&pile));
+ return make_scoped_refptr(new FakePicturePileImpl(&pile, nullptr));
}
scoped_refptr<FakePicturePileImpl>
@@ -65,7 +70,7 @@ FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings(
// This simulates a false positive for this flag.
pile.SetRecordedViewport(gfx::Rect());
pile.SetHasAnyRecordings(true);
- return make_scoped_refptr(new FakePicturePileImpl(&pile));
+ return make_scoped_refptr(new FakePicturePileImpl(&pile, nullptr));
}
scoped_refptr<FakePicturePileImpl>
@@ -79,11 +84,26 @@ FakePicturePileImpl::CreateInfiniteFilledPile() {
pile.SetRecordedViewport(gfx::Rect(size));
pile.SetHasAnyRecordings(true);
- auto pile_impl = make_scoped_refptr(new FakePicturePileImpl(&pile));
+ auto pile_impl = make_scoped_refptr(new FakePicturePileImpl(&pile, nullptr));
pile_impl->AddRecordingAt(0, 0);
return pile_impl;
}
+scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFromPile(
+ const PicturePile* other,
+ base::WaitableEvent* playback_allowed_event) {
+ return make_scoped_refptr(
+ new FakePicturePileImpl(other, playback_allowed_event));
+}
+
+void FakePicturePileImpl::PlaybackToCanvas(SkCanvas* canvas,
+ const gfx::Rect& canvas_rect,
+ float contents_scale) const {
+ if (playback_allowed_event_)
+ playback_allowed_event_->Wait();
+ PicturePileImpl::PlaybackToCanvas(canvas, canvas_rect, contents_scale);
+}
+
void FakePicturePileImpl::AddRecordingAt(int x, int y) {
EXPECT_GE(x, 0);
EXPECT_GE(y, 0);
diff --git a/cc/test/fake_picture_pile_impl.h b/cc/test/fake_picture_pile_impl.h
index f1a9d31..c32684c 100644
--- a/cc/test/fake_picture_pile_impl.h
+++ b/cc/test/fake_picture_pile_impl.h
@@ -9,6 +9,10 @@
#include "cc/resources/picture_pile_impl.h"
#include "cc/test/fake_content_layer_client.h"
+namespace base {
+class WaitableEvent;
+}
+
namespace cc {
class FakePicturePileImpl : public PicturePileImpl {
@@ -23,6 +27,14 @@ class FakePicturePileImpl : public PicturePileImpl {
CreateEmptyPileThatThinksItHasRecordings(const gfx::Size& tile_size,
const gfx::Size& layer_bounds);
static scoped_refptr<FakePicturePileImpl> CreateInfiniteFilledPile();
+ static scoped_refptr<FakePicturePileImpl> CreateFromPile(
+ const PicturePile* other,
+ base::WaitableEvent* playback_allowed_event);
+
+ // Hi-jack the PlaybackToCanvas method to delay its completion.
+ void PlaybackToCanvas(SkCanvas* canvas,
+ const gfx::Rect& canvas_rect,
+ float contents_scale) const override;
TilingData& tiling() { return tiling_; }
@@ -84,11 +96,13 @@ class FakePicturePileImpl : public PicturePileImpl {
protected:
FakePicturePileImpl();
- explicit FakePicturePileImpl(const PicturePile* other);
+ FakePicturePileImpl(const PicturePile* other,
+ base::WaitableEvent* playback_allowed_event);
~FakePicturePileImpl() override;
FakeContentLayerClient client_;
SkPaint default_paint_;
+ base::WaitableEvent* playback_allowed_event_;
SkTileGridFactory::TileGridInfo tile_grid_info_;
};
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc
index 2dd86f7..89cc554 100644
--- a/cc/test/layer_tree_test.cc
+++ b/cc/test/layer_tree_test.cc
@@ -259,22 +259,17 @@ class LayerTreeHostImplForTesting : public LayerTreeHostImpl {
LayerTreeHostImpl::ReclaimResources(ack);
}
- void UpdateVisibleTiles() override {
- LayerTreeHostImpl::UpdateVisibleTiles();
- test_hooks_->UpdateVisibleTilesOnThread(this);
- }
-
void NotifyReadyToActivate() override {
if (block_notify_ready_to_activate_for_testing_) {
notify_ready_to_activate_was_blocked_ = true;
} else {
- client_->NotifyReadyToActivate();
+ LayerTreeHostImpl::NotifyReadyToActivate();
test_hooks_->NotifyReadyToActivateOnThread(this);
}
}
void NotifyReadyToDraw() override {
- client_->NotifyReadyToDraw();
+ LayerTreeHostImpl::NotifyReadyToDraw();
test_hooks_->NotifyReadyToDrawOnThread(this);
}
@@ -327,6 +322,11 @@ class LayerTreeHostImplForTesting : public LayerTreeHostImpl {
test_hooks_->UpdateAnimationState(this, has_unfinished_animation);
}
+ void NotifyTileStateChanged(const Tile* tile) override {
+ LayerTreeHostImpl::NotifyTileStateChanged(tile);
+ test_hooks_->NotifyTileStateChangedOnThread(this, tile);
+ }
+
private:
TestHooks* test_hooks_;
bool block_notify_ready_to_activate_for_testing_;
@@ -513,7 +513,7 @@ void LayerTreeTest::EndTest() {
}
}
-void LayerTreeTest::EndTestAfterDelay(int delay_milliseconds) {
+void LayerTreeTest::EndTestAfterDelayMs(int delay_milliseconds) {
main_task_runner_->PostDelayedTask(
FROM_HERE,
base::Bind(&LayerTreeTest::EndTest, main_thread_weak_ptr_),
diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h
index 531e28d..b801d94 100644
--- a/cc/test/layer_tree_test.h
+++ b/cc/test/layer_tree_test.h
@@ -57,9 +57,10 @@ class TestHooks : public AnimationDelegate {
virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) {}
virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) {}
virtual void SwapBuffersCompleteOnThread(LayerTreeHostImpl* host_impl) {}
- virtual void UpdateVisibleTilesOnThread(LayerTreeHostImpl* host_impl) {}
virtual void NotifyReadyToActivateOnThread(LayerTreeHostImpl* host_impl) {}
virtual void NotifyReadyToDrawOnThread(LayerTreeHostImpl* host_impl) {}
+ virtual void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl,
+ const Tile* tile) {}
virtual void AnimateLayers(LayerTreeHostImpl* host_impl,
base::TimeTicks monotonic_time) {}
virtual void UpdateAnimationState(LayerTreeHostImpl* host_impl,
@@ -130,7 +131,7 @@ class LayerTreeTest : public testing::Test, public TestHooks {
virtual ~LayerTreeTest();
virtual void EndTest();
- void EndTestAfterDelay(int delay_milliseconds);
+ void EndTestAfterDelayMs(int delay_milliseconds);
void PostAddAnimationToMainThread(Layer* layer_to_receive_animation);
void PostAddInstantAnimationToMainThread(Layer* layer_to_receive_animation);