OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SkBenchmark.h" | 7 #include "SkBenchmark.h" |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkPathUtils.h" | 9 #include "SkPathUtils.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 } | 34 } |
35 | 35 |
36 /// Emulates the mix of rects blitted by gmail during scrolling | 36 /// Emulates the mix of rects blitted by gmail during scrolling |
37 class PathUtilsBench : public SkBenchmark { | 37 class PathUtilsBench : public SkBenchmark { |
38 typedef void (*Proc)(char*, SkPath*); | 38 typedef void (*Proc)(char*, SkPath*); |
39 | 39 |
40 Proc fProc; | 40 Proc fProc; |
41 SkString fName; | 41 SkString fName; |
42 char* bits[H * STRIDE]; | 42 char* bits[H * STRIDE]; |
43 | 43 |
44 enum { N = SkBENCHLOOP(20) }; | |
45 | |
46 public: | 44 public: |
47 PathUtilsBench(void* param, Proc proc, const char name[]) : INHERITED(param)
{ | 45 PathUtilsBench(void* param, Proc proc, const char name[]) : INHERITED(param)
{ |
48 fProc = proc; | 46 fProc = proc; |
49 fName.printf("pathUtils_%s", name); | 47 fName.printf("pathUtils_%s", name); |
50 | 48 |
51 | 49 |
52 } | 50 } |
53 | 51 |
54 protected: | 52 protected: |
55 virtual const char* onGetName() { return fName.c_str(); } | 53 virtual const char* onGetName() { return fName.c_str(); } |
56 | 54 |
57 virtual void onDraw(SkCanvas* canvas) { | 55 virtual void onDraw(SkCanvas* canvas) { |
58 | 56 |
59 for (int i = 0; i < N; ++i){ | 57 for (int i = 0; i < this->getLoops(); ++i){ |
60 //create a random 16x16 bitmap | 58 //create a random 16x16 bitmap |
61 fillRandomBits(H * STRIDE, (char*) &bits); | 59 fillRandomBits(H * STRIDE, (char*) &bits); |
62 | 60 |
63 //use passed function pointer to handle it | 61 //use passed function pointer to handle it |
64 SkPath path; | 62 SkPath path; |
65 fProc( (char*) &bits, &path); | 63 fProc( (char*) &bits, &path); |
66 } | 64 } |
67 } | 65 } |
68 | 66 |
69 private: | 67 private: |
70 typedef SkBenchmark INHERITED; | 68 typedef SkBenchmark INHERITED; |
71 }; | 69 }; |
72 | 70 |
73 static SkBenchmark* PU_path(void* p) { return SkNEW_ARGS(PathUtilsBench, (p, pat
h_proc, "path")); } | 71 static SkBenchmark* PU_path(void* p) { return SkNEW_ARGS(PathUtilsBench, (p, pat
h_proc, "path")); } |
74 static SkBenchmark* PU_region(void* p) { return SkNEW_ARGS(PathUtilsBench, (p, r
egion_proc, "region")); } | 72 static SkBenchmark* PU_region(void* p) { return SkNEW_ARGS(PathUtilsBench, (p, r
egion_proc, "region")); } |
75 | 73 |
76 static BenchRegistry PU_Path(PU_path); | 74 static BenchRegistry PU_Path(PU_path); |
77 static BenchRegistry PU_Region(PU_region); | 75 static BenchRegistry PU_Region(PU_region); |
OLD | NEW |