OLD | NEW |
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 #include "Benchmark.h" | 7 #include "Benchmark.h" |
8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 default: | 97 default: |
98 break; | 98 break; |
99 } | 99 } |
100 SkString type; | 100 SkString type; |
101 this->appendName(&type); | 101 this->appendName(&type); |
102 fName.printf("patch_%s_%s_[%f,%f]", type.c_str(), vertexMode.c_str(), | 102 fName.printf("patch_%s_%s_[%f,%f]", type.c_str(), vertexMode.c_str(), |
103 fScale.x(), fScale.y()); | 103 fScale.x(), fScale.y()); |
104 return fName.c_str(); | 104 return fName.c_str(); |
105 } | 105 } |
106 | 106 |
107 virtual void preDraw() { | 107 virtual void onPreDraw() { |
108 | |
109 } | |
110 | |
111 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | |
112 | |
113 this->setCubics(); | 108 this->setCubics(); |
114 this->setColors(); | 109 this->setColors(); |
115 this->setTexCoords(); | 110 this->setTexCoords(); |
116 this->setupPaint(&fPaint); | 111 this->setupPaint(&fPaint); |
117 switch (fVertexMode) { | 112 switch (fVertexMode) { |
118 case kTexCoords_VertexMode: | 113 case kTexCoords_VertexMode: |
119 case kBoth_VertexMode: | 114 case kBoth_VertexMode: |
120 fPaint.setShader(this->createShader())->unref(); | 115 fPaint.setShader(this->createShader())->unref(); |
121 break; | 116 break; |
122 default: | 117 default: |
123 fPaint.setShader(NULL); | 118 fPaint.setShader(NULL); |
124 break; | 119 break; |
125 } | 120 } |
| 121 } |
126 | 122 |
| 123 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
127 canvas->scale(fScale.x(), fScale.y()); | 124 canvas->scale(fScale.x(), fScale.y()); |
128 for (int i = 0; i < loops; i++) { | 125 for (int i = 0; i < loops; i++) { |
129 switch (fVertexMode) { | 126 switch (fVertexMode) { |
130 case kNone_VertexMode: | 127 case kNone_VertexMode: |
131 canvas->drawPatch(fCubics, NULL, NULL, NULL, fPaint); | 128 canvas->drawPatch(fCubics, NULL, NULL, NULL, fPaint); |
132 break; | 129 break; |
133 case kColors_VertexMode: | 130 case kColors_VertexMode: |
134 canvas->drawPatch(fCubics, fColors, NULL, NULL, fPaint); | 131 canvas->drawPatch(fCubics, fColors, NULL, NULL, fPaint); |
135 break; | 132 break; |
136 case kTexCoords_VertexMode: | 133 case kTexCoords_VertexMode: |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 DEF_BENCH( return new LoopPatchBench(SkVector::Make(1.0f, 1.0f), | 313 DEF_BENCH( return new LoopPatchBench(SkVector::Make(1.0f, 1.0f), |
317 PatchBench::kBoth_VertexMode); ) | 314 PatchBench::kBoth_VertexMode); ) |
318 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), | 315 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), |
319 PatchBench::kNone_VertexMode); ) | 316 PatchBench::kNone_VertexMode); ) |
320 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), | 317 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), |
321 PatchBench::kColors_VertexMode); ) | 318 PatchBench::kColors_VertexMode); ) |
322 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), | 319 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), |
323 PatchBench::kTexCoords_VertexMode); ) | 320 PatchBench::kTexCoords_VertexMode); ) |
324 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), | 321 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), |
325 PatchBench::kBoth_VertexMode); ) | 322 PatchBench::kBoth_VertexMode); ) |
OLD | NEW |