| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 p.setColor(0xFF000000); | 137 p.setColor(0xFF000000); |
| 138 p.setFilterBitmap(true); | 138 p.setFilterBitmap(true); |
| 139 | 139 |
| 140 SkPaint p2; // for drawVertices path | 140 SkPaint p2; // for drawVertices path |
| 141 p2.setColor(0xFF000000); | 141 p2.setColor(0xFF000000); |
| 142 p2.setFilterBitmap(true); | 142 p2.setFilterBitmap(true); |
| 143 p2.setShader(SkShader::CreateBitmapShader(fAtlas, | 143 p2.setShader(SkShader::CreateBitmapShader(fAtlas, |
| 144 SkShader::kClamp_TileMode, | 144 SkShader::kClamp_TileMode, |
| 145 SkShader::kClamp_TileMode))->u
nref(); | 145 SkShader::kClamp_TileMode))->u
nref(); |
| 146 | 146 |
| 147 for (int i = 0; i < kNumRects; ++i, ++fNumSaved) { | 147 for (int i = 0; i < this->getLoops(); ++i, ++fNumSaved) { |
| 148 | |
| 149 if (0 == i % kNumBeforeClear) { | 148 if (0 == i % kNumBeforeClear) { |
| 150 if (kPartial_Clear == fClear) { | 149 if (kPartial_Clear == fClear) { |
| 151 for (int j = 0; j < fNumSaved; ++j) { | 150 for (int j = 0; j < fNumSaved; ++j) { |
| 152 canvas->setMatrix(SkMatrix::I()); | 151 canvas->setMatrix(SkMatrix::I()); |
| 153 mat.setTranslate(fSaved[j][0], fSaved[j][1]); | 152 mat.setTranslate(fSaved[j][0], fSaved[j][1]); |
| 154 | 153 |
| 155 if (kScale_Type == fType) { | 154 if (kScale_Type == fType) { |
| 156 mat.preScale(fSaved[j][2], fSaved[j][2]); | 155 mat.preScale(fSaved[j][2], fSaved[j][2]); |
| 157 } else if (kRotate_Type == fType) { | 156 } else if (kRotate_Type == fType) { |
| 158 mat.preRotate(fSaved[j][2]); | 157 mat.preRotate(fSaved[j][2]); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 221 |
| 223 static const int kAtlasCellWidth = 48; | 222 static const int kAtlasCellWidth = 48; |
| 224 static const int kAtlasCellHeight = 36; | 223 static const int kAtlasCellHeight = 36; |
| 225 static const int kNumAtlasedX = 5; | 224 static const int kNumAtlasedX = 5; |
| 226 static const int kNumAtlasedY = 5; | 225 static const int kNumAtlasedY = 5; |
| 227 static const int kAtlasSpacer = 2; | 226 static const int kAtlasSpacer = 2; |
| 228 static const int kTotAtlasWidth = kNumAtlasedX * kAtlasCellWidth + | 227 static const int kTotAtlasWidth = kNumAtlasedX * kAtlasCellWidth + |
| 229 (kNumAtlasedX+1) * kAtlasSpacer; | 228 (kNumAtlasedX+1) * kAtlasSpacer; |
| 230 static const int kTotAtlasHeight = kNumAtlasedY * kAtlasCellHeight + | 229 static const int kTotAtlasHeight = kNumAtlasedY * kAtlasCellHeight + |
| 231 (kNumAtlasedY+1) * kAtlasSpacer; | 230 (kNumAtlasedY+1) * kAtlasSpacer; |
| 232 | 231 static const int kNumBeforeClear = 100; |
| 233 #ifdef SK_DEBUG | |
| 234 static const int kNumRects = 100; | |
| 235 static const int kNumBeforeClear = 10; | |
| 236 #else | |
| 237 static const int kNumRects = 5000; | |
| 238 static const int kNumBeforeClear = 300; | |
| 239 #endif | |
| 240 | |
| 241 | 232 |
| 242 Type fType; | 233 Type fType; |
| 243 Clear fClear; | 234 Clear fClear; |
| 244 bool fAligned; | 235 bool fAligned; |
| 245 bool fUseAtlas; | 236 bool fUseAtlas; |
| 246 bool fUseDrawVertices; | 237 bool fUseDrawVertices; |
| 247 SkString fName; | 238 SkString fName; |
| 248 int fNumSaved; // num draws stored in 'fSaved' | 239 int fNumSaved; // num draws stored in 'fSaved' |
| 249 bool fInitialized; | 240 bool fInitialized; |
| 250 | 241 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 DEF_BENCH( return SkNEW_ARGS(GameBench, (p, GameBench::kTranslate_Type, | 330 DEF_BENCH( return SkNEW_ARGS(GameBench, (p, GameBench::kTranslate_Type, |
| 340 GameBench::kFull_Clear, true)); ) | 331 GameBench::kFull_Clear, true)); ) |
| 341 DEF_BENCH( return SkNEW_ARGS(GameBench, (p, GameBench::kRotate_Type, | 332 DEF_BENCH( return SkNEW_ARGS(GameBench, (p, GameBench::kRotate_Type, |
| 342 GameBench::kFull_Clear)); ) | 333 GameBench::kFull_Clear)); ) |
| 343 | 334 |
| 344 // Atlased | 335 // Atlased |
| 345 DEF_BENCH( return SkNEW_ARGS(GameBench, (p, GameBench::kTranslate_Type, | 336 DEF_BENCH( return SkNEW_ARGS(GameBench, (p, GameBench::kTranslate_Type, |
| 346 GameBench::kFull_Clear, false, true)
); ) | 337 GameBench::kFull_Clear, false, true)
); ) |
| 347 DEF_BENCH( return SkNEW_ARGS(GameBench, (p, GameBench::kTranslate_Type, | 338 DEF_BENCH( return SkNEW_ARGS(GameBench, (p, GameBench::kTranslate_Type, |
| 348 GameBench::kFull_Clear, false, true,
true)); ) | 339 GameBench::kFull_Clear, false, true,
true)); ) |
| OLD | NEW |