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

Side by Side Diff: bench/DecodingBench.cpp

Issue 918673002: Adding new benchmark to test image decoding performance. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Added include Created 5 years, 10 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/DecodingBench.h ('k') | bench/DecodingSubsetBench.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "DecodingBench.h"
9 #include "SkData.h"
10 #include "SkImageDecoder.h"
11 #include "SkOSFile.h"
12 #include "SkStream.h"
13
14 /*
15 *
16 * This benchmark is designed to test the performance of image decoding.
17 * It is invoked from the nanobench.cpp file.
18 *
19 */
20 DecodingBench::DecodingBench(SkString path, SkColorType colorType)
21 : fColorType(colorType)
22 {
23 // Parse filename and the color type to give the benchmark a useful name
24 SkString baseName = SkOSPath::Basename(path.c_str());
25 const char* colorName;
26 switch(colorType) {
27 case kN32_SkColorType:
28 colorName = "N32";
29 break;
30 case kRGB_565_SkColorType:
31 colorName = "565";
32 break;
33 case kAlpha_8_SkColorType:
34 colorName = "Alpha8";
35 break;
36 default:
37 colorName = "Unknown";
38 }
39 fName.printf("Decode_%s_%s", baseName.c_str(), colorName);
40
41 // Perform setup for the decode
42 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
43 fStream.reset(new SkMemoryStream(encoded));
44 fDecoder.reset(SkImageDecoder::Factory(fStream.get()));
45 }
46
47 const char* DecodingBench::onGetName() {
48 return fName.c_str();
49 }
50
51 bool DecodingBench::isSuitableFor(Backend backend) {
52 return kNonRendering_Backend == backend;
53 }
54
55 void DecodingBench::onDraw(const int n, SkCanvas* canvas) {
56 SkBitmap bitmap;
57 for (int i = 0; i < n; i++) {
58 fStream->rewind();
59 fDecoder->decode(fStream, &bitmap, fColorType,
60 SkImageDecoder::kDecodePixels_Mode);
61 }
62 }
OLDNEW
« no previous file with comments | « bench/DecodingBench.h ('k') | bench/DecodingSubsetBench.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698