diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-07 00:16:16 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-07 00:16:16 +0000 |
commit | d993e033fecdb11e600dfb2e6770c5cf76fd4b72 (patch) | |
tree | 1a5b15ce198c0b8f151aae4a42d1ca968e6cf8d6 /cc | |
parent | 0dd13cb7686e3b5500bc15a3ac876ae65eb9b484 (diff) | |
download | chromium_src-d993e033fecdb11e600dfb2e6770c5cf76fd4b72.zip chromium_src-d993e033fecdb11e600dfb2e6770c5cf76fd4b72.tar.gz chromium_src-d993e033fecdb11e600dfb2e6770c5cf76fd4b72.tar.bz2 |
cc: Add page scale zooming perf test
R=danakj@chromium.org
BUG=none
Review URL: https://chromiumcodereview.appspot.com/16352005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204672 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/layer_impl.cc | 3 | ||||
-rw-r--r-- | cc/test/data/heavy_layer_tree.json | 1 | ||||
-rw-r--r-- | cc/test/layer_tree_json_parser.cc | 4 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.h | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_perftest.cc | 82 |
5 files changed, 86 insertions, 5 deletions
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index 2aaaee2..60e3fe7 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -502,6 +502,9 @@ base::DictionaryValue* LayerImpl::LayerTreeAsJson() const { result->SetBoolean("DrawsContent", draws_content_); result->SetDouble("Opacity", opacity()); + if (scrollable_) + result->SetBoolean("Scrollable", scrollable_); + list = new base::ListValue; for (size_t i = 0; i < children_.size(); ++i) list->Append(children_[i]->LayerTreeAsJson()); diff --git a/cc/test/data/heavy_layer_tree.json b/cc/test/data/heavy_layer_tree.json index b4a4737..789fdec 100644 --- a/cc/test/data/heavy_layer_tree.json +++ b/cc/test/data/heavy_layer_tree.json @@ -4,6 +4,7 @@ "Bounds": [ 384, 519 ], "Children": [ { "Bounds": [ 1251, 31876 ], + "Scrollable": true, "Children": [ { "Bounds": [ 1251, 31876 ], "Children": [ ], diff --git a/cc/test/layer_tree_json_parser.cc b/cc/test/layer_tree_json_parser.cc index de7fc70..669010e 100644 --- a/cc/test/layer_tree_json_parser.cc +++ b/cc/test/layer_tree_json_parser.cc @@ -77,6 +77,10 @@ scoped_refptr<Layer> ParseTreeFromValue(base::Value* val, if (dict->GetDouble("Opacity", &opacity)) new_layer->SetOpacity(opacity); + bool scrollable; + if (dict->GetBoolean("Scrollable", &scrollable)) + new_layer->SetScrollable(scrollable); + success &= dict->GetList("DrawTransform", &list); double transform[16]; for (int i = 0; i < 16; ++i) diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 4e14b11..35a97c7 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -194,6 +194,7 @@ class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { void SetPageScaleFactorAndLimits(float page_scale_factor, float min_page_scale_factor, float max_page_scale_factor); + float page_scale_factor() const { return page_scale_factor_; } SkColor background_color() const { return background_color_; } void set_background_color(SkColor color) { background_color_ = color; } diff --git a/cc/trees/layer_tree_host_perftest.cc b/cc/trees/layer_tree_host_perftest.cc index 73c0540..1f76126 100644 --- a/cc/trees/layer_tree_host_perftest.cc +++ b/cc/trees/layer_tree_host_perftest.cc @@ -15,6 +15,7 @@ #include "cc/test/layer_tree_json_parser.h" #include "cc/test/layer_tree_test.h" #include "cc/test/paths.h" +#include "cc/trees/layer_tree_impl.h" namespace cc { namespace { @@ -27,6 +28,7 @@ class LayerTreeHostPerfTest : public LayerTreeTest { public: LayerTreeHostPerfTest() : num_draws_(0), + num_commits_(0), full_damage_each_frame_(false), animation_driven_drawing_(false), measure_commit_cost_(false) { @@ -49,8 +51,10 @@ class LayerTreeHostPerfTest : public LayerTreeTest { } virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { - if (measure_commit_cost_ && num_draws_ >= kWarmupRuns) + if (measure_commit_cost_ && num_draws_ >= kWarmupRuns) { total_commit_time_ += base::TimeTicks::HighResNow() - commit_start_time_; + ++num_commits_; + } } virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { @@ -75,20 +79,25 @@ class LayerTreeHostPerfTest : public LayerTreeTest { virtual void BuildTree() {} virtual void AfterTest() OVERRIDE { + num_draws_ -= kWarmupRuns; + // Format matches chrome/test/perf/perf_test.h:PrintResult - printf("*RESULT %s: frames= %.2f runs/s\n", + printf("*RESULT %s: frames: %d, %.2f ms/frame\n", test_name_.c_str(), - num_draws_ / elapsed_.InSecondsF()); + num_draws_, + elapsed_.InMillisecondsF() / num_draws_); if (measure_commit_cost_) { - printf("*RESULT %s: commit_cost= %.2f ms/commit\n", + printf("*RESULT %s: commits: %d, %.2f ms/commit\n", test_name_.c_str(), - total_commit_time_.InMillisecondsF() / num_draws_); + num_commits_, + total_commit_time_.InMillisecondsF() / num_commits_); } } protected: base::TimeTicks start_time_; int num_draws_; + int num_commits_; std::string test_name_; base::TimeDelta elapsed_; FakeContentLayerClient fake_content_layer_client_; @@ -183,5 +192,68 @@ TEST_F(ImplSidePaintingPerfTest, HeavyPage) { RunTestWithImplSidePainting(); } +class PageScaleImplSidePaintingPerfTest : public ImplSidePaintingPerfTest { + public: + PageScaleImplSidePaintingPerfTest() + : max_scale_(16.f), min_scale_(1.f / max_scale_) {} + + virtual void SetupTree() OVERRIDE { + layer_tree_host()->SetPageScaleFactorAndLimits(1.f, min_scale_, max_scale_); + } + + virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, + float scale_delta) OVERRIDE { + float page_scale_factor = layer_tree_host()->page_scale_factor(); + page_scale_factor *= scale_delta; + layer_tree_host()->SetPageScaleFactorAndLimits( + page_scale_factor, min_scale_, max_scale_); + } + + virtual void AnimateLayers(LayerTreeHostImpl* host_impl, + base::TimeTicks monotonic_time) OVERRIDE { + if (!host_impl->pinch_gesture_active()) { + host_impl->PinchGestureBegin(); + start_time_ = monotonic_time; + } + gfx::Point anchor(200, 200); + + float seconds = (monotonic_time - start_time_).InSecondsF(); + + // Every half second, zoom from min scale to max scale. + float interval = 0.5f; + + // Start time in the middle of the interval when zoom = 1. + seconds += interval / 2.f; + + // Stack two ranges together to go up from min to max and down from + // max to min in the next so as not to have a zoom discrepancy. + float time_in_two_intervals = fmod(seconds, 2.f * interval) / interval; + + // Map everything to go from min to max between 0 and 1. + float time_in_one_interval = + time_in_two_intervals > 1.f ? 2.f - time_in_two_intervals + : time_in_two_intervals; + // Normalize time to -1..1. + float normalized = 2.f * time_in_one_interval - 1.f; + float scale_factor = std::fabs(normalized) * (max_scale_ - 1.f) + 1.f; + float total_scale = normalized < 0.f ? 1.f / scale_factor : scale_factor; + + float desired_delta = + total_scale / host_impl->active_tree()->total_page_scale_factor(); + host_impl->PinchGestureUpdate(desired_delta, anchor); + } + + private: + float max_scale_; + float min_scale_; + base::TimeTicks start_time_; +}; + +TEST_F(PageScaleImplSidePaintingPerfTest, HeavyPage) { + measure_commit_cost_ = true; + ReadTestFile("heavy_layer_tree"); + RunTestWithImplSidePainting(); +} + } // namespace } // namespace cc |