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

Side by Side Diff: tests/GpuRectanizerTest.cpp

Issue 319523003: Add bench for rectanizers (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Actually use bench loops parameter Created 6 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
« no previous file with comments | « gyp/bench.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #if SK_SUPPORT_GPU 8 #if SK_SUPPORT_GPU
9 9
10 #include "GrRectanizer_pow2.h" 10 #include "GrRectanizer_pow2.h"
11 #include "GrRectanizer_skyline.h" 11 #include "GrRectanizer_skyline.h"
12 #include "SkRandom.h" 12 #include "SkRandom.h"
13 #include "SkSize.h" 13 #include "SkSize.h"
14 #include "SkTDArray.h" 14 #include "SkTDArray.h"
15 #include "Test.h" 15 #include "Test.h"
16 16
17 static const int kWidth = 1000; 17 static const int kWidth = 1024;
18 static const int kHeight = 1000; 18 static const int kHeight = 1024;
19 19
20 // Basic test of a GrRectanizer-derived class' functionality 20 // Basic test of a GrRectanizer-derived class' functionality
21 static void test_rectanizer_basic(skiatest::Reporter* reporter, GrRectanizer* re ctanizer) { 21 static void test_rectanizer_basic(skiatest::Reporter* reporter, GrRectanizer* re ctanizer) {
22 REPORTER_ASSERT(reporter, kWidth == rectanizer->width()); 22 REPORTER_ASSERT(reporter, kWidth == rectanizer->width());
23 REPORTER_ASSERT(reporter, kHeight == rectanizer->height()); 23 REPORTER_ASSERT(reporter, kHeight == rectanizer->height());
24 24
25 SkIPoint16 loc; 25 SkIPoint16 loc;
26 26
27 REPORTER_ASSERT(reporter, rectanizer->addRect(50, 50, &loc)); 27 REPORTER_ASSERT(reporter, rectanizer->addRect(50, 50, &loc));
28 REPORTER_ASSERT(reporter, rectanizer->percentFull() > 0.0f); 28 REPORTER_ASSERT(reporter, rectanizer->percentFull() > 0.0f);
(...skipping 23 matching lines...) Expand all
52 } 52 }
53 53
54 static void test_pow2(skiatest::Reporter* reporter, const SkTDArray<SkISize>& re cts) { 54 static void test_pow2(skiatest::Reporter* reporter, const SkTDArray<SkISize>& re cts) {
55 GrRectanizerPow2 pow2Rectanizer(kWidth, kHeight); 55 GrRectanizerPow2 pow2Rectanizer(kWidth, kHeight);
56 56
57 test_rectanizer_basic(reporter, &pow2Rectanizer); 57 test_rectanizer_basic(reporter, &pow2Rectanizer);
58 test_rectanizer_inserts(reporter, &pow2Rectanizer, rects); 58 test_rectanizer_inserts(reporter, &pow2Rectanizer, rects);
59 } 59 }
60 60
61 DEF_GPUTEST(GpuRectanizer, reporter, factory) { 61 DEF_GPUTEST(GpuRectanizer, reporter, factory) {
62 SkTDArray<SkISize> fRects; 62 SkTDArray<SkISize> rects;
bsalomon 2014/06/05 14:02:01 why this change?
robertphillips 2014/06/05 14:07:06 It is just a method variable not a member variable
bsalomon 2014/06/05 14:07:47 Oh, right, duh. lgtm
63 SkRandom rand; 63 SkRandom rand;
64 64
65 for (int i = 0; i < 50; i++) { 65 for (int i = 0; i < 50; i++) {
66 fRects.push(SkISize::Make(rand.nextRangeU(1, kWidth / 2), 66 rects.push(SkISize::Make(rand.nextRangeU(1, kWidth / 2),
67 rand.nextRangeU(1, kHeight / 2))); 67 rand.nextRangeU(1, kHeight / 2)));
68 } 68 }
69 69
70 test_skyline(reporter, fRects); 70 test_skyline(reporter, rects);
71 test_pow2(reporter, fRects); 71 test_pow2(reporter, rects);
72 } 72 }
73 73
74 #endif 74 #endif
OLDNEW
« no previous file with comments | « gyp/bench.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698