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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkGradientShader.h" | 9 #include "SkGradientShader.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 // override this method to change the shader | 71 // override this method to change the shader |
72 virtual SkShader* createShader() { | 72 virtual SkShader* createShader() { |
73 const SkColor colors[] = { | 73 const SkColor colors[] = { |
74 SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, | 74 SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, |
75 SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW, | 75 SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW, |
76 }; | 76 }; |
77 const SkPoint pts[] = { { 200.f / 4.f, 0.f }, { 3.f * 200.f / 4, 200.f }
}; | 77 const SkPoint pts[] = { { 200.f / 4.f, 0.f }, { 3.f * 200.f / 4, 200.f }
}; |
78 | 78 |
79 return SkGradientShader::CreateLinear(pts, colors, NULL, | 79 return SkGradientShader::CreateLinear(pts, colors, nullptr, |
80 SK_ARRAY_COUNT(colors), | 80 SK_ARRAY_COUNT(colors), |
81 SkShader::kMirror_TileMode); | 81 SkShader::kMirror_TileMode); |
82 } | 82 } |
83 | 83 |
84 protected: | 84 protected: |
85 const char* onGetName() override { | 85 const char* onGetName() override { |
86 SkString vertexMode; | 86 SkString vertexMode; |
87 switch (fVertexMode) { | 87 switch (fVertexMode) { |
88 case kNone_VertexMode: | 88 case kNone_VertexMode: |
89 vertexMode.set("meshlines"); | 89 vertexMode.set("meshlines"); |
(...skipping 21 matching lines...) Expand all Loading... |
111 this->setCubics(); | 111 this->setCubics(); |
112 this->setColors(); | 112 this->setColors(); |
113 this->setTexCoords(); | 113 this->setTexCoords(); |
114 this->setupPaint(&fPaint); | 114 this->setupPaint(&fPaint); |
115 switch (fVertexMode) { | 115 switch (fVertexMode) { |
116 case kTexCoords_VertexMode: | 116 case kTexCoords_VertexMode: |
117 case kBoth_VertexMode: | 117 case kBoth_VertexMode: |
118 fPaint.setShader(this->createShader())->unref(); | 118 fPaint.setShader(this->createShader())->unref(); |
119 break; | 119 break; |
120 default: | 120 default: |
121 fPaint.setShader(NULL); | 121 fPaint.setShader(nullptr); |
122 break; | 122 break; |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 void onDraw(const int loops, SkCanvas* canvas) override { | 126 void onDraw(const int loops, SkCanvas* canvas) override { |
127 canvas->scale(fScale.x(), fScale.y()); | 127 canvas->scale(fScale.x(), fScale.y()); |
128 for (int i = 0; i < loops; i++) { | 128 for (int i = 0; i < loops; i++) { |
129 switch (fVertexMode) { | 129 switch (fVertexMode) { |
130 case kNone_VertexMode: | 130 case kNone_VertexMode: |
131 canvas->drawPatch(fCubics, NULL, NULL, NULL, fPaint); | 131 canvas->drawPatch(fCubics, nullptr, nullptr, nullptr, fPaint
); |
132 break; | 132 break; |
133 case kColors_VertexMode: | 133 case kColors_VertexMode: |
134 canvas->drawPatch(fCubics, fColors, NULL, NULL, fPaint); | 134 canvas->drawPatch(fCubics, fColors, nullptr, nullptr, fPaint
); |
135 break; | 135 break; |
136 case kTexCoords_VertexMode: | 136 case kTexCoords_VertexMode: |
137 canvas->drawPatch(fCubics, NULL, fTexCoords, NULL, fPaint); | 137 canvas->drawPatch(fCubics, nullptr, fTexCoords, nullptr, fPa
int); |
138 break; | 138 break; |
139 case kBoth_VertexMode: | 139 case kBoth_VertexMode: |
140 canvas->drawPatch(fCubics, fColors, fTexCoords, NULL, fPaint
); | 140 canvas->drawPatch(fCubics, fColors, fTexCoords, nullptr, fPa
int); |
141 break; | 141 break; |
142 default: | 142 default: |
143 break; | 143 break; |
144 } | 144 } |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 SkPaint fPaint; | 148 SkPaint fPaint; |
149 SkString fName; | 149 SkString fName; |
150 SkVector fScale; | 150 SkVector fScale; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 DEF_BENCH( return new LoopPatchBench(SkVector::Make(1.0f, 1.0f), | 316 DEF_BENCH( return new LoopPatchBench(SkVector::Make(1.0f, 1.0f), |
317 PatchBench::kBoth_VertexMode); ) | 317 PatchBench::kBoth_VertexMode); ) |
318 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), | 318 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), |
319 PatchBench::kNone_VertexMode); ) | 319 PatchBench::kNone_VertexMode); ) |
320 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), | 320 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), |
321 PatchBench::kColors_VertexMode); ) | 321 PatchBench::kColors_VertexMode); ) |
322 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), | 322 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), |
323 PatchBench::kTexCoords_VertexMode); ) | 323 PatchBench::kTexCoords_VertexMode); ) |
324 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), | 324 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), |
325 PatchBench::kBoth_VertexMode); ) | 325 PatchBench::kBoth_VertexMode); ) |
OLD | NEW |