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

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

Issue 1057283003: Remove parts of //cc we aren't using (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 8 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 picture_layer_tiling_client_.set_tree(PENDING_TREE);
51 scoped_refptr<FakePicturePileImpl> pile =
52 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(
53 gfx::Size(256 * 50, 256 * 50));
54 picture_layer_tiling_ = PictureLayerTiling::Create(
55 1, pile, &picture_layer_tiling_client_,
56 defaults.max_tiles_for_interest_area,
57 defaults.skewport_target_time_in_seconds,
58 defaults.skewport_extrapolation_limit_in_content_pixels);
59 picture_layer_tiling_->CreateAllTilesForTesting();
60 }
61
62 void TearDown() override { picture_layer_tiling_.reset(NULL); }
63
64 void RunInvalidateTest(const std::string& test_name, const Region& region) {
65 timer_.Reset();
66 do {
67 picture_layer_tiling_->Invalidate(region);
68 timer_.NextLap();
69 } while (!timer_.HasTimeLimitExpired());
70
71 perf_test::PrintResult(
72 "invalidation", "", test_name, timer_.LapsPerSecond(), "runs/s", true);
73 }
74
75 void RunComputeTilePriorityRectsStationaryTest(
76 const std::string& test_name,
77 const gfx::Transform& transform) {
78 gfx::Rect viewport_rect(0, 0, 1024, 768);
79
80 timer_.Reset();
81 do {
82 picture_layer_tiling_->ComputeTilePriorityRects(
83 viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion());
84 timer_.NextLap();
85 } while (!timer_.HasTimeLimitExpired());
86
87 perf_test::PrintResult("compute_tile_priority_rects_stationary",
88 "",
89 test_name,
90 timer_.LapsPerSecond(),
91 "runs/s",
92 true);
93 }
94
95 void RunComputeTilePriorityRectsScrollingTest(
96 const std::string& test_name,
97 const gfx::Transform& transform) {
98 gfx::Size viewport_size(1024, 768);
99 gfx::Rect viewport_rect(viewport_size);
100 int xoffsets[] = {10, 0, -10, 0};
101 int yoffsets[] = {0, 10, 0, -10};
102 int offsetIndex = 0;
103 int offsetCount = 0;
104 const int maxOffsetCount = 1000;
105
106 timer_.Reset();
107 do {
108 picture_layer_tiling_->ComputeTilePriorityRects(
109 viewport_rect, 1.f, timer_.NumLaps() + 1, Occlusion());
110
111 viewport_rect = gfx::Rect(viewport_rect.x() + xoffsets[offsetIndex],
112 viewport_rect.y() + yoffsets[offsetIndex],
113 viewport_rect.width(),
114 viewport_rect.height());
115
116 if (++offsetCount > maxOffsetCount) {
117 offsetCount = 0;
118 offsetIndex = (offsetIndex + 1) % 4;
119 }
120 timer_.NextLap();
121 } while (!timer_.HasTimeLimitExpired());
122
123 perf_test::PrintResult("compute_tile_priority_rects_scrolling",
124 "",
125 test_name,
126 timer_.LapsPerSecond(),
127 "runs/s",
128 true);
129 }
130
131 private:
132 FakePictureLayerTilingClient picture_layer_tiling_client_;
133 scoped_ptr<PictureLayerTiling> picture_layer_tiling_;
134
135 LapTimer timer_;
136
137 scoped_refptr<ContextProvider> context_provider_;
138 FakeOutputSurfaceClient output_surface_client_;
139 scoped_ptr<FakeOutputSurface> output_surface_;
140 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
141 scoped_ptr<ResourceProvider> resource_provider_;
142 };
143
144 TEST_F(PictureLayerTilingPerfTest, Invalidate) {
145 Region one_tile(gfx::Rect(256, 256));
146 RunInvalidateTest("1x1", one_tile);
147
148 Region half_region(gfx::Rect(25 * 256, 50 * 256));
149 RunInvalidateTest("25x50", half_region);
150
151 Region full_region(gfx::Rect(50 * 256, 50 * 256));
152 RunInvalidateTest("50x50", full_region);
153 }
154
155 #if defined(OS_ANDROID)
156 // TODO(vmpstr): Investigate why this is noisy (crbug.com/310220).
157 TEST_F(PictureLayerTilingPerfTest, DISABLED_ComputeTilePriorityRects) {
158 #else
159 TEST_F(PictureLayerTilingPerfTest, ComputeTilePriorityRects) {
160 #endif // defined(OS_ANDROID)
161 gfx::Transform transform;
162
163 RunComputeTilePriorityRectsStationaryTest("no_transform", transform);
164 RunComputeTilePriorityRectsScrollingTest("no_transform", transform);
165
166 transform.Rotate(10);
167 RunComputeTilePriorityRectsStationaryTest("rotation", transform);
168 RunComputeTilePriorityRectsScrollingTest("rotation", transform);
169
170 transform.ApplyPerspectiveDepth(10);
171 RunComputeTilePriorityRectsStationaryTest("perspective", transform);
172 RunComputeTilePriorityRectsScrollingTest("perspective", transform);
173 }
174
175 } // namespace
176 } // 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