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

Side by Side Diff: bench/BitmapRegionDecoderBench.cpp

Issue 1402863002: Implementation of SkBitmapRegionDecoder using SkAndroidCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@split1
Patch Set: Add AndroidCodec strategy to benchmark Created 5 years, 2 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 | « no previous file | 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"
(...skipping 12 matching lines...) Expand all
23 { 23 {
24 // Choose a useful name for the region decoding strategy 24 // Choose a useful name for the region decoding strategy
25 const char* strategyName; 25 const char* strategyName;
26 switch (strategy) { 26 switch (strategy) {
27 case SkBitmapRegionDecoderInterface::kOriginal_Strategy: 27 case SkBitmapRegionDecoderInterface::kOriginal_Strategy:
28 strategyName = "Original"; 28 strategyName = "Original";
29 break; 29 break;
30 case SkBitmapRegionDecoderInterface::kCanvas_Strategy: 30 case SkBitmapRegionDecoderInterface::kCanvas_Strategy:
31 strategyName = "Canvas"; 31 strategyName = "Canvas";
32 break; 32 break;
33 case SkBitmapRegionDecoderInterface::kAndroidCodec_Strategy:
34 strategyName = "AndroidCodec";
35 break;
33 default: 36 default:
34 SkASSERT(false); 37 SkASSERT(false);
35 strategyName = ""; 38 strategyName = "";
36 break; 39 break;
37 } 40 }
38 41
39 // Choose a useful name for the color type 42 // Choose a useful name for the color type
40 const char* colorName = color_type_to_str(colorType); 43 const char* colorName = color_type_to_str(colorType);
41 44
42 fName.printf("BRD_%s_%s_%s", baseName, strategyName, colorName); 45 fName.printf("BRD_%s_%s_%s", baseName, strategyName, colorName);
43 if (1 != sampleSize) { 46 if (1 != sampleSize) {
44 fName.appendf("_%.3f", get_scale_from_sample_size(sampleSize)); 47 fName.appendf("_%.3f", get_scale_from_sample_size(sampleSize));
45 } 48 }
46 } 49 }
47 50
48 const char* BitmapRegionDecoderBench::onGetName() { 51 const char* BitmapRegionDecoderBench::onGetName() {
49 return fName.c_str(); 52 return fName.c_str();
50 } 53 }
51 54
52 bool BitmapRegionDecoderBench::isSuitableFor(Backend backend) { 55 bool BitmapRegionDecoderBench::isSuitableFor(Backend backend) {
53 return kNonRendering_Backend == backend; 56 return kNonRendering_Backend == backend;
54 } 57 }
55 58
56 void BitmapRegionDecoderBench::onDelayedSetup() { 59 void BitmapRegionDecoderBench::onDelayedSetup() {
57 SkStreamRewindable* stream = new SkMemoryStream(fData); 60 fBRD.reset(SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(fData, fStrategy));
58 fBRD.reset(SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(stream, fStrategy));
59 } 61 }
60 62
61 void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) { 63 void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) {
62 SkAutoTDelete<SkBitmap> bitmap; 64 SkAutoTDelete<SkBitmap> bitmap;
63 for (int i = 0; i < n; i++) { 65 for (int i = 0; i < n; i++) {
64 bitmap.reset(fBRD->decodeRegion(fSubset.left(), fSubset.top(), fSubset.w idth(), 66 bitmap.reset(fBRD->decodeRegion(fSubset.left(), fSubset.top(), fSubset.w idth(),
65 fSubset.height(), fSampleSize, fColorType)); 67 fSubset.height(), fSampleSize, fColorType));
66 SkASSERT(nullptr != bitmap.get()); 68 SkASSERT(nullptr != bitmap.get());
67 } 69 }
68 } 70 }
OLDNEW
« no previous file with comments | « no previous file | bench/nanobench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698