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

Side by Side Diff: src/images/SkImageDecoder.cpp

Issue 1426943009: Delete dead SkImageDecoder::buildTileIndex and decodeSubset code (Closed) Base URL: https://skia.googlesource.com/skia.git@delete-tools
Patch Set: Created 5 years, 1 month 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 | « include/core/SkImageDecoder.h ('k') | src/images/SkImageDecoder_libjpeg.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 8
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // pass a temporary bitmap, so that if we return false, we are assured of 135 // pass a temporary bitmap, so that if we return false, we are assured of
136 // leaving the caller's bitmap untouched. 136 // leaving the caller's bitmap untouched.
137 SkBitmap tmp; 137 SkBitmap tmp;
138 const Result result = this->onDecode(stream, &tmp, mode); 138 const Result result = this->onDecode(stream, &tmp, mode);
139 if (kFailure != result) { 139 if (kFailure != result) {
140 bm->swap(tmp); 140 bm->swap(tmp);
141 } 141 }
142 return result; 142 return result;
143 } 143 }
144 144
145 bool SkImageDecoder::decodeSubset(SkBitmap* bm, const SkIRect& rect, SkColorType pref) {
146 // we reset this to false before calling onDecodeSubset
147 fShouldCancelDecode = false;
148 // assign this, for use by getPrefColorType(), in case fUsePrefTable is fals e
149 fDefaultPref = pref;
150
151 return this->onDecodeSubset(bm, rect);
152 }
153
154 bool SkImageDecoder::buildTileIndex(SkStreamRewindable* stream, int *width, int *height) {
155 // we reset this to false before calling onBuildTileIndex
156 fShouldCancelDecode = false;
157
158 return this->onBuildTileIndex(stream, width, height);
159 }
160
161 bool SkImageDecoder::onBuildTileIndex(SkStreamRewindable* stream, int* /*width*/ ,
162 int* /*height*/) {
163 delete stream;
164 return false;
165 }
166
167
168 bool SkImageDecoder::cropBitmap(SkBitmap *dst, SkBitmap *src, int sampleSize,
169 int dstX, int dstY, int width, int height,
170 int srcX, int srcY) {
171 int w = width / sampleSize;
172 int h = height / sampleSize;
173 if (src->colorType() == kIndex_8_SkColorType) {
174 // kIndex8 does not allow drawing via an SkCanvas, as is done below.
175 // Instead, use extractSubset. Note that this shares the SkPixelRef and
176 // SkColorTable.
177 // FIXME: Since src is discarded in practice, this holds on to more
178 // pixels than is strictly necessary. Switch to a copy if memory
179 // savings are more important than speed here. This also means
180 // that the pixels in dst can not be reused (though there is no
181 // allocation, which was already done on src).
182 int x = (dstX - srcX) / sampleSize;
183 int y = (dstY - srcY) / sampleSize;
184 SkIRect subset = SkIRect::MakeXYWH(x, y, w, h);
185 return src->extractSubset(dst, subset);
186 }
187 // if the destination has no pixels then we must allocate them.
188 if (dst->isNull()) {
189 dst->setInfo(src->info().makeWH(w, h));
190
191 if (!this->allocPixelRef(dst, nullptr)) {
192 SkDEBUGF(("failed to allocate pixels needed to crop the bitmap"));
193 return false;
194 }
195 }
196 // check to see if the destination is large enough to decode the desired
197 // region. If this assert fails we will just draw as much of the source
198 // into the destination that we can.
199 if (dst->width() < w || dst->height() < h) {
200 SkDEBUGF(("SkImageDecoder::cropBitmap does not have a large enough bitma p.\n"));
201 }
202
203 // Set the Src_Mode for the paint to prevent transparency issue in the
204 // dest in the event that the dest was being re-used.
205 SkPaint paint;
206 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
207
208 SkCanvas canvas(*dst);
209 canvas.drawBitmap(*src, SkIntToScalar((srcX - dstX) / sampleSize),
210 SkIntToScalar((srcY - dstY) / sampleSize),
211 &paint);
212 return true;
213 }
214
215 /////////////////////////////////////////////////////////////////////////////// 145 ///////////////////////////////////////////////////////////////////////////////
216 146
217 bool SkImageDecoder::DecodeFile(const char file[], SkBitmap* bm, SkColorType pre f, Mode mode, 147 bool SkImageDecoder::DecodeFile(const char file[], SkBitmap* bm, SkColorType pre f, Mode mode,
218 Format* format) { 148 Format* format) {
219 SkASSERT(file); 149 SkASSERT(file);
220 SkASSERT(bm); 150 SkASSERT(bm);
221 151
222 SkAutoTDelete<SkStreamRewindable> stream(SkStream::NewFromFile(file)); 152 SkAutoTDelete<SkStreamRewindable> stream(SkStream::NewFromFile(file));
223 if (stream.get()) { 153 if (stream.get()) {
224 if (SkImageDecoder::DecodeStream(stream, bm, pref, mode, format)) { 154 if (SkImageDecoder::DecodeStream(stream, bm, pref, mode, format)) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return success; 195 return success;
266 } 196 }
267 197
268 bool SkImageDecoder::decodeYUV8Planes(SkStream* stream, SkISize componentSizes[3 ], void* planes[3], 198 bool SkImageDecoder::decodeYUV8Planes(SkStream* stream, SkISize componentSizes[3 ], void* planes[3],
269 size_t rowBytes[3], SkYUVColorSpace* color Space) { 199 size_t rowBytes[3], SkYUVColorSpace* color Space) {
270 // we reset this to false before calling onDecodeYUV8Planes 200 // we reset this to false before calling onDecodeYUV8Planes
271 fShouldCancelDecode = false; 201 fShouldCancelDecode = false;
272 202
273 return this->onDecodeYUV8Planes(stream, componentSizes, planes, rowBytes, co lorSpace); 203 return this->onDecodeYUV8Planes(stream, componentSizes, planes, rowBytes, co lorSpace);
274 } 204 }
OLDNEW
« no previous file with comments | « include/core/SkImageDecoder.h ('k') | src/images/SkImageDecoder_libjpeg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698