Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: cc/resources/picture_layer_tiling_perftest.cc

Issue 1144693002: cc: Move files out of cc/resources/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resources: android Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/picture_layer_tiling.cc ('k') | cc/resources/picture_layer_tiling_set.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/debug/lap_timer.h"
6 #include "cc/resources/picture_layer_tiling.h"
7 #include "cc/resources/resource_provider.h"
8 #include "cc/resources/scoped_resource.h"
9 #include "cc/test/fake_output_surface.h"
10 #include "cc/test/fake_output_surface_client.h"
11 #include "cc/test/fake_picture_layer_tiling_client.h"
12 #include "cc/test/fake_picture_pile_impl.h"
13 #include "cc/test/test_context_provider.h"
14 #include "cc/test/test_shared_bitmap_manager.h"
15
16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "testing/perf/perf_test.h"
18
19 namespace cc {
20
21 namespace {
22
23 static const int kTimeLimitMillis = 2000;
24 static const int kWarmupRuns = 5;
25 static const int kTimeCheckInterval = 10;
26
27 class PictureLayerTilingPerfTest : public testing::Test {
28 public:
29 PictureLayerTilingPerfTest()
30 : timer_(kWarmupRuns,
31 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
32 kTimeCheckInterval),
33 context_provider_(TestContextProvider::Create()) {
34 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass();
35 CHECK(output_surface_->BindToClient(&output_surface_client_));
36
37 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
38 resource_provider_ = ResourceProvider::Create(output_surface_.get(),
39 shared_bitmap_manager_.get(),
40 NULL,
41 NULL,
42 0,
43 false,
44 1).Pass();
45 }
46
47 void SetUp() override {
48 LayerTreeSettings defaults;
49 picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256));
50 scoped_refptr<FakePicturePileImpl> pile =
51 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(
52 gfx::Size(256 * 50, 256 * 50));
53 picture_layer_tiling_ = PictureLayerTiling::Create(
54 PENDING_TREE, 1.f, pile, &picture_layer_tiling_client_,
55 defaults.tiling_interest_area_viewport_multiplier,
56 defaults.skewport_target_time_in_seconds,
57 defaults.skewport_extrapolation_limit_in_content_pixels);
58 picture_layer_tiling_->CreateAllTilesForTesting();
59 }
60
61 void TearDown() override { picture_layer_tiling_.reset(NULL); }
62
63 void RunInvalidateTest(const std::string& test_name, const Region& region) {
64 timer_.Reset();
65 do {
66 picture_layer_tiling_->Invalidate(region);
67 timer_.NextLap();
68 } while (!timer_.HasTimeLimitExpired());
69
70 perf_test::PrintResult(
71 "invalidation", "", test_name, timer_.LapsPerSecond(), "runs/s", true);
72 }
73
74 void RunComputeTilePriorityRectsStationaryTest(
75 const std::string& test_name,
76 const gfx::Transform& transform) {
77 gfx::Rect viewport_rect(0, 0, 1024, 768);
78
79 timer_.Reset();
80 do {
81 picture_layer_tiling_->ComputeTilePriorityRects(
82 viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion());
83 timer_.NextLap();
84 } while (!timer_.HasTimeLimitExpired());
85
86 perf_test::PrintResult("compute_tile_priority_rects_stationary",
87 "",
88 test_name,
89 timer_.LapsPerSecond(),
90 "runs/s",
91 true);
92 }
93
94 void RunComputeTilePriorityRectsScrollingTest(
95 const std::string& test_name,
96 const gfx::Transform& transform) {
97 gfx::Size viewport_size(1024, 768);
98 gfx::Rect viewport_rect(viewport_size);
99 int xoffsets[] = {10, 0, -10, 0};
100 int yoffsets[] = {0, 10, 0, -10};
101 int offset_index = 0;
102 int offset_count = 0;
103 const int max_offset_count = 1000;
104
105 timer_.Reset();
106 do {
107 picture_layer_tiling_->ComputeTilePriorityRects(
108 viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion());
109
110 viewport_rect = gfx::Rect(viewport_rect.x() + xoffsets[offset_index],
111 viewport_rect.y() + yoffsets[offset_index],
112 viewport_rect.width(), viewport_rect.height());
113
114 if (++offset_count > max_offset_count) {
115 offset_count = 0;
116 offset_index = (offset_index + 1) % 4;
117 }
118 timer_.NextLap();
119 } while (!timer_.HasTimeLimitExpired());
120
121 perf_test::PrintResult("compute_tile_priority_rects_scrolling",
122 "",
123 test_name,
124 timer_.LapsPerSecond(),
125 "runs/s",
126 true);
127 }
128
129 private:
130 FakePictureLayerTilingClient picture_layer_tiling_client_;
131 scoped_ptr<PictureLayerTiling> picture_layer_tiling_;
132
133 LapTimer timer_;
134
135 scoped_refptr<ContextProvider> context_provider_;
136 FakeOutputSurfaceClient output_surface_client_;
137 scoped_ptr<FakeOutputSurface> output_surface_;
138 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
139 scoped_ptr<ResourceProvider> resource_provider_;
140 };
141
142 TEST_F(PictureLayerTilingPerfTest, Invalidate) {
143 Region one_tile(gfx::Rect(256, 256));
144 RunInvalidateTest("1x1", one_tile);
145
146 Region half_region(gfx::Rect(25 * 256, 50 * 256));
147 RunInvalidateTest("25x50", half_region);
148
149 Region full_region(gfx::Rect(50 * 256, 50 * 256));
150 RunInvalidateTest("50x50", full_region);
151 }
152
153 #if defined(OS_ANDROID)
154 // TODO(vmpstr): Investigate why this is noisy (crbug.com/310220).
155 TEST_F(PictureLayerTilingPerfTest, DISABLED_ComputeTilePriorityRects) {
156 #else
157 TEST_F(PictureLayerTilingPerfTest, ComputeTilePriorityRects) {
158 #endif // defined(OS_ANDROID)
159 gfx::Transform transform;
160
161 RunComputeTilePriorityRectsStationaryTest("no_transform", transform);
162 RunComputeTilePriorityRectsScrollingTest("no_transform", transform);
163
164 transform.Rotate(10);
165 RunComputeTilePriorityRectsStationaryTest("rotation", transform);
166 RunComputeTilePriorityRectsScrollingTest("rotation", transform);
167
168 transform.ApplyPerspectiveDepth(10);
169 RunComputeTilePriorityRectsStationaryTest("perspective", transform);
170 RunComputeTilePriorityRectsScrollingTest("perspective", transform);
171 }
172
173 } // namespace
174 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.cc ('k') | cc/resources/picture_layer_tiling_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698