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

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

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 years, 3 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/subset/SubsetSingleBench.cpp ('k') | bench/subset/SubsetZoomBench.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 "SubsetTranslateBench.h" 8 #include "SubsetTranslateBench.h"
9 #include "SubsetBenchPriv.h" 9 #include "SubsetBenchPriv.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 void SubsetTranslateBench::onDraw(const int n, SkCanvas* canvas) { 56 void SubsetTranslateBench::onDraw(const int n, SkCanvas* canvas) {
57 // When the color type is kIndex8, we will need to store the color table. I f it is 57 // When the color type is kIndex8, we will need to store the color table. I f it is
58 // used, it will be initialized by the codec. 58 // used, it will be initialized by the codec.
59 int colorCount; 59 int colorCount;
60 SkPMColor colors[256]; 60 SkPMColor colors[256];
61 if (fUseCodec) { 61 if (fUseCodec) {
62 for (int count = 0; count < n; count++) { 62 for (int count = 0; count < n; count++) {
63 SkAutoTDelete<SkScanlineDecoder> scanlineDecoder( 63 SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(
64 SkScanlineDecoder::NewFromStream(fStream->duplicate())); 64 SkScanlineDecoder::NewFromStream(fStream->duplicate()));
65 const SkImageInfo info = scanlineDecoder->getInfo().makeColorType(fC olorType); 65 const SkImageInfo info = scanlineDecoder->getInfo().makeColorType(fC olorType);
66 SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowByte s())); 66 SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]);
67 scanlineDecoder->start(info, NULL, colors, &colorCount); 67 scanlineDecoder->start(info, NULL, colors, &colorCount);
68 68
69 SkBitmap bitmap; 69 SkBitmap bitmap;
70 // Note that we use the same bitmap for all of the subsets. 70 // Note that we use the same bitmap for all of the subsets.
71 // It might be larger than necessary for the end subsets. 71 // It might be larger than necessary for the end subsets.
72 SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight); 72 SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight);
73 alloc_pixels(&bitmap, subsetInfo, colors, colorCount); 73 alloc_pixels(&bitmap, subsetInfo, colors, colorCount);
74 74
75 for (int x = 0; x < info.width(); x += fSubsetWidth) { 75 for (int x = 0; x < info.width(); x += fSubsetWidth) {
76 for (int y = 0; y < info.height(); y += fSubsetHeight) { 76 for (int y = 0; y < info.height(); y += fSubsetHeight) {
(...skipping 10 matching lines...) Expand all
87 memcpy(bitmap.getAddr(0, y), row.get() + x * bpp, 87 memcpy(bitmap.getAddr(0, y), row.get() + x * bpp,
88 currSubsetWidth * bpp); 88 currSubsetWidth * bpp);
89 } 89 }
90 } 90 }
91 } 91 }
92 } 92 }
93 } else { 93 } else {
94 // We create a color table here to satisfy allocPixels() when the output 94 // We create a color table here to satisfy allocPixels() when the output
95 // type is kIndex8. It's okay that this is uninitialized since we never 95 // type is kIndex8. It's okay that this is uninitialized since we never
96 // use it. 96 // use it.
97 SkColorTable* colorTable = SkNEW_ARGS(SkColorTable, (colors, 0)); 97 SkColorTable* colorTable = new SkColorTable(colors, 0);
98 for (int count = 0; count < n; count++) { 98 for (int count = 0; count < n; count++) {
99 int width, height; 99 int width, height;
100 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStrea m)); 100 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStrea m));
101 decoder->buildTileIndex(fStream->duplicate(), &width, &height); 101 decoder->buildTileIndex(fStream->duplicate(), &width, &height);
102 SkBitmap bitmap; 102 SkBitmap bitmap;
103 // Note that we use the same bitmap for all of the subsets. 103 // Note that we use the same bitmap for all of the subsets.
104 // It might be larger than necessary for the end subsets. 104 // It might be larger than necessary for the end subsets.
105 // If we do not include this step, decodeSubset() would allocate spa ce 105 // If we do not include this step, decodeSubset() would allocate spa ce
106 // for the pixels automatically, but this would not allow us to reus e the 106 // for the pixels automatically, but this would not allow us to reus e the
107 // same bitmap as the other subsets. We want to reuse the same bitm ap 107 // same bitmap as the other subsets. We want to reuse the same bitm ap
108 // because it gives a more fair comparison with SkCodec and is a com mon 108 // because it gives a more fair comparison with SkCodec and is a com mon
109 // use case of BitmapRegionDecoder. 109 // use case of BitmapRegionDecoder.
110 bitmap.allocPixels(SkImageInfo::Make(fSubsetWidth, fSubsetHeight, 110 bitmap.allocPixels(SkImageInfo::Make(fSubsetWidth, fSubsetHeight,
111 fColorType, kOpaque_SkAlphaType), NULL, colorTable); 111 fColorType, kOpaque_SkAlphaType), NULL, colorTable);
112 112
113 for (int x = 0; x < width; x += fSubsetWidth) { 113 for (int x = 0; x < width; x += fSubsetWidth) {
114 for (int y = 0; y < height; y += fSubsetHeight) { 114 for (int y = 0; y < height; y += fSubsetHeight) {
115 const uint32_t currSubsetWidth = x + (int) fSubsetWidth > wi dth ? 115 const uint32_t currSubsetWidth = x + (int) fSubsetWidth > wi dth ?
116 width - x : fSubsetWidth; 116 width - x : fSubsetWidth;
117 const uint32_t currSubsetHeight = y + (int) fSubsetHeight > height ? 117 const uint32_t currSubsetHeight = y + (int) fSubsetHeight > height ?
118 height - y : fSubsetHeight; 118 height - y : fSubsetHeight;
119 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, 119 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth,
120 currSubsetHeight); 120 currSubsetHeight);
121 decoder->decodeSubset(&bitmap, rect, fColorType); 121 decoder->decodeSubset(&bitmap, rect, fColorType);
122 } 122 }
123 } 123 }
124 } 124 }
125 } 125 }
126 } 126 }
OLDNEW
« no previous file with comments | « bench/subset/SubsetSingleBench.cpp ('k') | bench/subset/SubsetZoomBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698