Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(940)

Side by Side Diff: bench/BitmapRegionDecoderBench.cpp

Issue 1990543002: Delete SkBitmapRegionCanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Preserve old name of tests Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « bench/BitmapRegionDecoderBench.h ('k') | bench/nanobench.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "BitmapRegionDecoderBench.h" 8 #include "BitmapRegionDecoderBench.h"
9 #include "CodecBenchPriv.h" 9 #include "CodecBenchPriv.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkOSFile.h" 11 #include "SkOSFile.h"
12 12
13 BitmapRegionDecoderBench::BitmapRegionDecoderBench(const char* baseName, SkData* encoded, 13 BitmapRegionDecoderBench::BitmapRegionDecoderBench(const char* baseName, SkData* encoded,
14 SkBitmapRegionDecoder::Strategy strategy, SkColorType colorType, 14 SkColorType colorType, uint32_t sampleSize, const SkIRect& subset)
15 uint32_t sampleSize, const SkIRect& subset)
16 : fBRD(nullptr) 15 : fBRD(nullptr)
17 , fData(SkRef(encoded)) 16 , fData(SkRef(encoded))
18 , fStrategy(strategy)
19 , fColorType(colorType) 17 , fColorType(colorType)
20 , fSampleSize(sampleSize) 18 , fSampleSize(sampleSize)
21 , fSubset(subset) 19 , fSubset(subset)
22 { 20 {
23 // Choose a useful name for the region decoding strategy
24 const char* strategyName;
25 switch (strategy) {
26 case SkBitmapRegionDecoder::kCanvas_Strategy:
27 strategyName = "Canvas";
28 break;
29 case SkBitmapRegionDecoder::kAndroidCodec_Strategy:
30 strategyName = "AndroidCodec";
31 break;
32 default:
33 SkASSERT(false);
34 strategyName = "";
35 break;
36 }
37
38 // Choose a useful name for the color type 21 // Choose a useful name for the color type
39 const char* colorName = color_type_to_str(colorType); 22 const char* colorName = color_type_to_str(colorType);
40 23
41 fName.printf("BRD_%s_%s_%s", baseName, strategyName, colorName); 24 fName.printf("BRD_%s_%s", baseName, colorName);
42 if (1 != sampleSize) { 25 if (1 != sampleSize) {
43 fName.appendf("_%.3f", 1.0f / (float) sampleSize); 26 fName.appendf("_%.3f", 1.0f / (float) sampleSize);
44 } 27 }
45 } 28 }
46 29
47 const char* BitmapRegionDecoderBench::onGetName() { 30 const char* BitmapRegionDecoderBench::onGetName() {
48 return fName.c_str(); 31 return fName.c_str();
49 } 32 }
50 33
51 bool BitmapRegionDecoderBench::isSuitableFor(Backend backend) { 34 bool BitmapRegionDecoderBench::isSuitableFor(Backend backend) {
52 return kNonRendering_Backend == backend; 35 return kNonRendering_Backend == backend;
53 } 36 }
54 37
55 void BitmapRegionDecoderBench::onDelayedSetup() { 38 void BitmapRegionDecoderBench::onDelayedSetup() {
56 fBRD.reset(SkBitmapRegionDecoder::Create(fData, fStrategy)); 39 fBRD.reset(SkBitmapRegionDecoder::Create(fData, SkBitmapRegionDecoder::kAndr oidCodec_Strategy));
57 } 40 }
58 41
59 void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) { 42 void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) {
60 for (int i = 0; i < n; i++) { 43 for (int i = 0; i < n; i++) {
61 SkBitmap bm; 44 SkBitmap bm;
62 SkAssertResult(fBRD->decodeRegion(&bm, nullptr, fSubset, fSampleSize, fC olorType, false)); 45 SkAssertResult(fBRD->decodeRegion(&bm, nullptr, fSubset, fSampleSize, fC olorType, false));
63 } 46 }
64 } 47 }
OLDNEW
« no previous file with comments | « bench/BitmapRegionDecoderBench.h ('k') | bench/nanobench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698