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

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

Issue 1213983003: Fix CodecSubset benches seg faults for kIndex8 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 for (int count = 0; count < n; count++) { 61 for (int count = 0; count < n; count++) {
62 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplica te())); 62 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplica te()));
63 const SkImageInfo info = codec->getInfo().makeColorType(fColorType); 63 const SkImageInfo info = codec->getInfo().makeColorType(fColorType);
64 SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowByte s())); 64 SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowByte s()));
65 SkScanlineDecoder* scanlineDecoder = codec->getScanlineDecoder( 65 SkScanlineDecoder* scanlineDecoder = codec->getScanlineDecoder(
66 info, NULL, colors, &colorCount); 66 info, NULL, colors, &colorCount);
67 67
68 SkBitmap bitmap; 68 SkBitmap bitmap;
69 // Note that we use the same bitmap for all of the subsets. 69 // Note that we use the same bitmap for all of the subsets.
70 // It might be larger than necessary for the end subsets. 70 // It might be larger than necessary for the end subsets.
71 bitmap.allocPixels(info.makeWH(fSubsetWidth, fSubsetHeight)); 71 SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight);
72 alloc_pixels(&bitmap, subsetInfo, colors, colorCount);
72 73
73 for (int x = 0; x < info.width(); x += fSubsetWidth) { 74 for (int x = 0; x < info.width(); x += fSubsetWidth) {
74 for (int y = 0; y < info.height(); y += fSubsetHeight) { 75 for (int y = 0; y < info.height(); y += fSubsetHeight) {
75 scanlineDecoder->skipScanlines(y); 76 scanlineDecoder->skipScanlines(y);
76 const uint32_t currSubsetWidth = 77 const uint32_t currSubsetWidth =
77 x + (int) fSubsetWidth > info.width() ? 78 x + (int) fSubsetWidth > info.width() ?
78 info.width() - x : fSubsetWidth; 79 info.width() - x : fSubsetWidth;
79 const uint32_t currSubsetHeight = 80 const uint32_t currSubsetHeight =
80 y + (int) fSubsetHeight > info.height() ? 81 y + (int) fSubsetHeight > info.height() ?
81 info.height() - y : fSubsetHeight; 82 info.height() - y : fSubsetHeight;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const uint32_t currSubsetHeight = y + (int) fSubsetHeight > height ? 116 const uint32_t currSubsetHeight = y + (int) fSubsetHeight > height ?
116 height - y : fSubsetHeight; 117 height - y : fSubsetHeight;
117 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth, 118 SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth,
118 currSubsetHeight); 119 currSubsetHeight);
119 decoder->decodeSubset(&bitmap, rect, fColorType); 120 decoder->decodeSubset(&bitmap, rect, fColorType);
120 } 121 }
121 } 122 }
122 } 123 }
123 } 124 }
124 } 125 }
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