OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBenchmark.h" | 8 #include "SkBenchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 | 80 |
81 virtual void onPreDraw() SK_OVERRIDE { | 81 virtual void onPreDraw() SK_OVERRIDE { |
82 if (!fInitialized) { | 82 if (!fInitialized) { |
83 this->makeCheckerboard(); | 83 this->makeCheckerboard(); |
84 this->makeAtlas(); | 84 this->makeAtlas(); |
85 fInitialized = true; | 85 fInitialized = true; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 89 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
90 SkRandom scaleRand; | 90 SkRandom scaleRand; |
91 SkRandom transRand; | 91 SkRandom transRand; |
92 SkRandom rotRand; | 92 SkRandom rotRand; |
93 | 93 |
94 int width, height; | 94 int width, height; |
95 if (fUseAtlas) { | 95 if (fUseAtlas) { |
96 width = kAtlasCellWidth; | 96 width = kAtlasCellWidth; |
97 height = kAtlasCellHeight; | 97 height = kAtlasCellHeight; |
98 } else { | 98 } else { |
99 width = kCheckerboardWidth; | 99 width = kCheckerboardWidth; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 p.setColor(0xFF000000); | 136 p.setColor(0xFF000000); |
137 p.setFilterLevel(SkPaint::kLow_FilterLevel); | 137 p.setFilterLevel(SkPaint::kLow_FilterLevel); |
138 | 138 |
139 SkPaint p2; // for drawVertices path | 139 SkPaint p2; // for drawVertices path |
140 p2.setColor(0xFF000000); | 140 p2.setColor(0xFF000000); |
141 p2.setFilterLevel(SkPaint::kLow_FilterLevel); | 141 p2.setFilterLevel(SkPaint::kLow_FilterLevel); |
142 p2.setShader(SkShader::CreateBitmapShader(fAtlas, | 142 p2.setShader(SkShader::CreateBitmapShader(fAtlas, |
143 SkShader::kClamp_TileMode, | 143 SkShader::kClamp_TileMode, |
144 SkShader::kClamp_TileMode))->u
nref(); | 144 SkShader::kClamp_TileMode))->u
nref(); |
145 | 145 |
146 for (int i = 0; i < this->getLoops(); ++i, ++fNumSaved) { | 146 for (int i = 0; i < loops; ++i, ++fNumSaved) { |
147 if (0 == i % kNumBeforeClear) { | 147 if (0 == i % kNumBeforeClear) { |
148 if (kPartial_Clear == fClear) { | 148 if (kPartial_Clear == fClear) { |
149 for (int j = 0; j < fNumSaved; ++j) { | 149 for (int j = 0; j < fNumSaved; ++j) { |
150 canvas->setMatrix(SkMatrix::I()); | 150 canvas->setMatrix(SkMatrix::I()); |
151 mat.setTranslate(fSaved[j][0], fSaved[j][1]); | 151 mat.setTranslate(fSaved[j][0], fSaved[j][1]); |
152 | 152 |
153 if (kScale_Type == fType) { | 153 if (kScale_Type == fType) { |
154 mat.preScale(fSaved[j][2], fSaved[j][2]); | 154 mat.preScale(fSaved[j][2], fSaved[j][2]); |
155 } else if (kRotate_Type == fType) { | 155 } else if (kRotate_Type == fType) { |
156 mat.preRotate(fSaved[j][2]); | 156 mat.preRotate(fSaved[j][2]); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type, | 329 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type, |
330 GameBench::kFull_Clear, true)); ) | 330 GameBench::kFull_Clear, true)); ) |
331 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kRotate_Type, | 331 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kRotate_Type, |
332 GameBench::kFull_Clear)); ) | 332 GameBench::kFull_Clear)); ) |
333 | 333 |
334 // Atlased | 334 // Atlased |
335 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type, | 335 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type, |
336 GameBench::kFull_Clear, false, true)
); ) | 336 GameBench::kFull_Clear, false, true)
); ) |
337 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type, | 337 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type, |
338 GameBench::kFull_Clear, false, true,
true)); ) | 338 GameBench::kFull_Clear, false, true,
true)); ) |
OLD | NEW |