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 | 7 |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkAAClip.h" | 9 #include "SkAAClip.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // jostle the clip regions each time to prevent caching | 52 // jostle the clip regions each time to prevent caching |
53 fClipRect.offset((i % 2) == 0 ? SkIntToScalar(10) : SkIntToScalar(-1
0), 0); | 53 fClipRect.offset((i % 2) == 0 ? SkIntToScalar(10) : SkIntToScalar(-1
0), 0); |
54 fClipPath.reset(); | 54 fClipPath.reset(); |
55 fClipPath.addRoundRect(fClipRect, | 55 fClipPath.addRoundRect(fClipRect, |
56 SkIntToScalar(5), SkIntToScalar(5)); | 56 SkIntToScalar(5), SkIntToScalar(5)); |
57 SkASSERT(fClipPath.isConvex()); | 57 SkASSERT(fClipPath.isConvex()); |
58 | 58 |
59 canvas->save(); | 59 canvas->save(); |
60 #if 1 | 60 #if 1 |
61 if (fDoPath) { | 61 if (fDoPath) { |
62 canvas->clipPath(fClipPath, SkRegion::kReplace_Op, fDoAA); | 62 canvas->clipPath(fClipPath, SkCanvas::kReplace_Op, fDoAA); |
63 } else { | 63 } else { |
64 canvas->clipRect(fClipRect, SkRegion::kReplace_Op, fDoAA); | 64 canvas->clipRect(fClipRect, SkCanvas::kReplace_Op, fDoAA); |
65 } | 65 } |
66 | 66 |
67 canvas->drawRect(fDrawRect, paint); | 67 canvas->drawRect(fDrawRect, paint); |
68 #else | 68 #else |
69 // this path tests out directly draw the clip primitive | 69 // this path tests out directly draw the clip primitive |
70 // use it to comparing just drawing the clip vs. drawing using | 70 // use it to comparing just drawing the clip vs. drawing using |
71 // the clip | 71 // the clip |
72 if (fDoPath) { | 72 if (fDoPath) { |
73 canvas->drawPath(fClipPath, paint); | 73 canvas->drawPath(fClipPath, paint); |
74 } else { | 74 } else { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 SkRect temp = SkRect::MakeLTRB(0, 0, | 124 SkRect temp = SkRect::MakeLTRB(0, 0, |
125 fSizes[depth].fX, fSizes[depth].fY); | 125 fSizes[depth].fX, fSizes[depth].fY); |
126 temp.offset(offset); | 126 temp.offset(offset); |
127 | 127 |
128 SkPath path; | 128 SkPath path; |
129 path.addRoundRect(temp, SkIntToScalar(3), SkIntToScalar(3)); | 129 path.addRoundRect(temp, SkIntToScalar(3), SkIntToScalar(3)); |
130 SkASSERT(path.isConvex()); | 130 SkASSERT(path.isConvex()); |
131 | 131 |
132 canvas->clipPath(path, | 132 canvas->clipPath(path, |
133 0 == depth ? SkRegion::kReplace_Op : | 133 0 == depth ? SkCanvas::kReplace_Op : |
134 SkRegion::kIntersect_Op, | 134 SkCanvas::kIntersect_Op, |
135 fDoAA); | 135 fDoAA); |
136 | 136 |
137 if (kNestingDepth == depth) { | 137 if (kNestingDepth == depth) { |
138 // we only draw the draw rect at the lowest nesting level | 138 // we only draw the draw rect at the lowest nesting level |
139 SkPaint paint; | 139 SkPaint paint; |
140 paint.setColor(0xff000000 | fRandom.nextU()); | 140 paint.setColor(0xff000000 | fRandom.nextU()); |
141 canvas->drawRect(fDrawRect, paint); | 141 canvas->drawRect(fDrawRect, paint); |
142 } else { | 142 } else { |
143 SkPoint childOffset = offset; | 143 SkPoint childOffset = offset; |
144 this->recurse(canvas, depth+1, childOffset); | 144 this->recurse(canvas, depth+1, childOffset); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 DEF_BENCH(return new AAClipBuilderBench(false, true);) | 248 DEF_BENCH(return new AAClipBuilderBench(false, true);) |
249 DEF_BENCH(return new AAClipBuilderBench(true, false);) | 249 DEF_BENCH(return new AAClipBuilderBench(true, false);) |
250 DEF_BENCH(return new AAClipBuilderBench(true, true);) | 250 DEF_BENCH(return new AAClipBuilderBench(true, true);) |
251 DEF_BENCH(return new AAClipRegionBench();) | 251 DEF_BENCH(return new AAClipRegionBench();) |
252 DEF_BENCH(return new AAClipBench(false, false);) | 252 DEF_BENCH(return new AAClipBench(false, false);) |
253 DEF_BENCH(return new AAClipBench(false, true);) | 253 DEF_BENCH(return new AAClipBench(false, true);) |
254 DEF_BENCH(return new AAClipBench(true, false);) | 254 DEF_BENCH(return new AAClipBench(true, false);) |
255 DEF_BENCH(return new AAClipBench(true, true);) | 255 DEF_BENCH(return new AAClipBench(true, true);) |
256 DEF_BENCH(return new NestedAAClipBench(false);) | 256 DEF_BENCH(return new NestedAAClipBench(false);) |
257 DEF_BENCH(return new NestedAAClipBench(true);) | 257 DEF_BENCH(return new NestedAAClipBench(true);) |
OLD | NEW |