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

Side by Side Diff: bench/DecodingSubsetBench.cpp

Issue 918673002: Adding new benchmark to test image decoding performance. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Build tile failing is not an error 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
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 "DecodingSubsetBench.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 subset decoding.
17 * It is invoked from the nanobench.cpp file.
18 *
19 */
20 DecodingSubsetBench::DecodingSubsetBench(SkString path, SkColorType colorType,
21 const int divisor)
22 : fColorType(colorType)
23 , fDivisor(divisor)
24 {
25 // Parse filename and the color type to give the benchmark a useful name
26 SkString baseName = SkOSPath::Basename(path.c_str());
27 const char* colorName;
28 switch(colorType) {
29 case kN32_SkColorType:
30 colorName = "N32";
31 break;
32 case kRGB_565_SkColorType:
33 colorName = "565";
34 break;
35 case kAlpha_8_SkColorType:
36 colorName = "Alpha8";
37 break;
38 default:
39 colorName = "Unknown";
40 }
41 fName.printf("DecodeSubset_%dx%d_%s_%s", fDivisor, fDivisor,
42 baseName.c_str(), colorName);
43
44 // Perform the decode setup
45 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
46 fStream = new SkMemoryStream(encoded);
47 fDecoder.reset(SkImageDecoder::Factory(fStream));
48 }
49
50 const char* DecodingSubsetBench::onGetName() {
51 return fName.c_str();
52 }
53
54 bool DecodingSubsetBench::isSuitableFor(Backend backend) {
55 return kNonRendering_Backend == backend;
56 }
57
58 void DecodingSubsetBench::onDraw(const int n, SkCanvas* canvas) {
59 for (int i = 0; i < n; i++) {
60 fStream->rewind();
61 int w, h;
62 fDecoder->buildTileIndex(fStream, &w, &h);
scroggo 2015/02/13 13:41:31 At this point, buildTileIndex takes ownership of t
msarett 2015/02/13 14:20:02 That explains a few bugs I was running into. Than
63 // Divide the image into subsets and decode each subset
64 const int sW = w / fDivisor;
65 const int sH = h / fDivisor;
66 for (int y = 0; y < h; y += sH) {
67 for (int x = 0; x < w; x += sW) {
68 SkBitmap bitmap;
69 SkIRect rect = SkIRect::MakeXYWH(x, y, sW, sH);
70 fDecoder->decodeSubset(&bitmap, rect, fColorType);
71 }
72 }
73 }
74 }
OLDNEW
« no previous file with comments | « bench/DecodingSubsetBench.h ('k') | bench/ImageDecodeBench.cpp » ('j') | bench/nanobench.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698