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

Side by Side Diff: cc/quads/draw_quad_perftest.cc

Issue 1152473006: cc: Remove DrawQuad::IterateResoruces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mkwst review Created 5 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "cc/debug/lap_timer.h" 9 #include "cc/debug/lap_timer.h"
10 #include "cc/quads/draw_quad.h" 10 #include "cc/quads/draw_quad.h"
11 #include "cc/quads/render_pass.h" 11 #include "cc/quads/render_pass.h"
12 #include "cc/quads/texture_draw_quad.h" 12 #include "cc/quads/texture_draw_quad.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "testing/perf/perf_test.h" 14 #include "testing/perf/perf_test.h"
15 15
16 namespace cc { 16 namespace cc {
17 namespace { 17 namespace {
18 18
19 static const int kTimeLimitMillis = 2000; 19 static const int kTimeLimitMillis = 2000;
20 static const int kWarmupRuns = 5; 20 static const int kWarmupRuns = 5;
21 static const int kTimeCheckInterval = 10; 21 static const int kTimeCheckInterval = 10;
22 22
23 ResourceId Increment(ResourceId resource_id) {
24 return resource_id + 1;
25 }
26
27 SharedQuadState* CreateSharedQuadState(RenderPass* render_pass) { 23 SharedQuadState* CreateSharedQuadState(RenderPass* render_pass) {
28 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); 24 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0);
29 gfx::Size content_bounds(26, 28); 25 gfx::Size content_bounds(26, 28);
30 gfx::Rect visible_content_rect(10, 12, 14, 16); 26 gfx::Rect visible_content_rect(10, 12, 14, 16);
31 gfx::Rect clip_rect(19, 21, 23, 25); 27 gfx::Rect clip_rect(19, 21, 23, 25);
32 bool is_clipped = false; 28 bool is_clipped = false;
33 float opacity = 1.f; 29 float opacity = 1.f;
34 int sorting_context_id = 65536; 30 int sorting_context_id = 65536;
35 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; 31 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode;
36 32
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 quads->push_back(quad); 77 quads->push_back(quad);
82 } 78 }
83 } 79 }
84 80
85 void RunIterateResourceTest(const std::string& test_name, int quad_count) { 81 void RunIterateResourceTest(const std::string& test_name, int quad_count) {
86 CreateRenderPass(); 82 CreateRenderPass();
87 std::vector<DrawQuad*> quads; 83 std::vector<DrawQuad*> quads;
88 GenerateTextureDrawQuads(quad_count, &quads); 84 GenerateTextureDrawQuads(quad_count, &quads);
89 85
90 timer_.Reset(); 86 timer_.Reset();
91 DrawQuad::ResourceIteratorCallback callback = base::Bind(&Increment);
92 do { 87 do {
93 for (auto* quad : quads) 88 for (auto* quad : quads) {
94 quad->IterateResources(callback); 89 for (ResourceId& resource_id : quad->resources)
90 ++resource_id;
91 }
95 timer_.NextLap(); 92 timer_.NextLap();
96 } while (!timer_.HasTimeLimitExpired()); 93 } while (!timer_.HasTimeLimitExpired());
97 94
98 perf_test::PrintResult("draw_quad_iterate_resources", "", test_name, 95 perf_test::PrintResult("draw_quad_iterate_resources", "", test_name,
99 timer_.LapsPerSecond(), "runs/s", true); 96 timer_.LapsPerSecond(), "runs/s", true);
100 CleanUpRenderPass(); 97 CleanUpRenderPass();
101 } 98 }
102 99
103 private: 100 private:
104 scoped_ptr<RenderPass> render_pass_; 101 scoped_ptr<RenderPass> render_pass_;
105 SharedQuadState* shared_state_; 102 SharedQuadState* shared_state_;
106 LapTimer timer_; 103 LapTimer timer_;
107 }; 104 };
108 105
109 TEST_F(DrawQuadPerfTest, IterateResources) { 106 TEST_F(DrawQuadPerfTest, IterateResources) {
110 RunIterateResourceTest("10_quads", 10); 107 RunIterateResourceTest("10_quads", 10);
111 RunIterateResourceTest("100_quads", 100); 108 RunIterateResourceTest("100_quads", 100);
112 RunIterateResourceTest("500_quads", 500); 109 RunIterateResourceTest("500_quads", 500);
113 } 110 }
114 111
115 } // namespace 112 } // namespace
116 } // namespace cc 113 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698