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

Side by Side Diff: bench/subset/SubsetSingleBench.cpp

Issue 1531833002: Remove Subset*Benches (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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/subset/SubsetSingleBench.h ('k') | bench/subset/SubsetTranslateBench.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 "CodecBenchPriv.h"
9 #include "SubsetSingleBench.h"
10 #include "SubsetBenchPriv.h"
11 #include "SkData.h"
12 #include "SkCodec.h"
13 #include "SkImageDecoder.h"
14 #include "SkOSFile.h"
15 #include "SkStream.h"
16
17 /*
18 *
19 * This benchmark is designed to test the performance of subset decoding.
20 * It uses an input width, height, left, and top to decode a single subset.
21 *
22 */
23
24 SubsetSingleBench::SubsetSingleBench(const SkString& path,
25 SkColorType colorType,
26 uint32_t subsetWidth,
27 uint32_t subsetHeight,
28 uint32_t offsetLeft,
29 uint32_t offsetTop)
30 : fColorType(colorType)
31 , fSubsetWidth(subsetWidth)
32 , fSubsetHeight(subsetHeight)
33 , fOffsetLeft(offsetLeft)
34 , fOffsetTop(offsetTop)
35 {
36 // Parse the filename
37 SkString baseName = SkOSPath::Basename(path.c_str());
38
39 // Choose an informative color name
40 const char* colorName = color_type_to_str(fColorType);
41
42 fName.printf("CodecSubsetSingle_%dx%d +%d_+%d_%s_%s", fSubsetWidth,
43 fSubsetHeight, fOffsetLeft, fOffsetTop, baseName.c_str(), colorName) ;
44
45 // Perform the decode setup
46 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
47 fStream.reset(new SkMemoryStream(encoded));
48 }
49
50 const char* SubsetSingleBench::onGetName() {
51 return fName.c_str();
52 }
53
54 bool SubsetSingleBench::isSuitableFor(Backend backend) {
55 return kNonRendering_Backend == backend;
56 }
57
58 void SubsetSingleBench::onDraw(int n, SkCanvas* canvas) {
59 // When the color type is kIndex8, we will need to store the color table. I f it is
60 // used, it will be initialized by the codec.
61 int colorCount;
62 SkPMColor colors[256];
63 for (int count = 0; count < n; count++) {
64 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplicate() ));
65 SkASSERT(SkCodec::kOutOfOrder_SkScanlineOrder != codec->getScanlineOrder ());
66 const SkImageInfo info = codec->getInfo().makeColorType(fColorType);
67
68 // The scanline decoder will handle subsetting in the x-dimension.
69 SkIRect subset = SkIRect::MakeXYWH(fOffsetLeft, 0, fSubsetWidth,
70 codec->getInfo().height());
71 SkCodec::Options options;
72 options.fSubset = &subset;
73
74 SkDEBUGCODE(SkCodec::Result result =)
75 codec->startScanlineDecode(info, &options, colors, &colorCount);
76 SkASSERT(result == SkCodec::kSuccess);
77
78 SkBitmap bitmap;
79 SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight);
80 alloc_pixels(&bitmap, subsetInfo, colors, colorCount);
81
82 SkDEBUGCODE(bool success = ) codec->skipScanlines(fOffsetTop);
83 SkASSERT(success);
84
85 SkDEBUGCODE(uint32_t lines = ) codec->getScanlines(bitmap.getPixels(), f SubsetHeight,
86 bitmap.rowBytes());
87 SkASSERT(lines == fSubsetHeight);
88 }
89 }
OLDNEW
« no previous file with comments | « bench/subset/SubsetSingleBench.h ('k') | bench/subset/SubsetTranslateBench.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698