| OLD | NEW |
| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return this->onDecodeSubset(bm, rect); | 151 return this->onDecodeSubset(bm, rect); |
| 152 } | 152 } |
| 153 | 153 |
| 154 bool SkImageDecoder::buildTileIndex(SkStreamRewindable* stream, int *width, int
*height) { | 154 bool SkImageDecoder::buildTileIndex(SkStreamRewindable* stream, int *width, int
*height) { |
| 155 // we reset this to false before calling onBuildTileIndex | 155 // we reset this to false before calling onBuildTileIndex |
| 156 fShouldCancelDecode = false; | 156 fShouldCancelDecode = false; |
| 157 | 157 |
| 158 return this->onBuildTileIndex(stream, width, height); | 158 return this->onBuildTileIndex(stream, width, height); |
| 159 } | 159 } |
| 160 | 160 |
| 161 bool SkImageDecoder::onBuildTileIndex(SkStreamRewindable* stream, int* /*width*/
, |
| 162 int* /*height*/) { |
| 163 SkDELETE(stream); |
| 164 return false; |
| 165 } |
| 166 |
| 167 |
| 161 bool SkImageDecoder::cropBitmap(SkBitmap *dst, SkBitmap *src, int sampleSize, | 168 bool SkImageDecoder::cropBitmap(SkBitmap *dst, SkBitmap *src, int sampleSize, |
| 162 int dstX, int dstY, int width, int height, | 169 int dstX, int dstY, int width, int height, |
| 163 int srcX, int srcY) { | 170 int srcX, int srcY) { |
| 164 int w = width / sampleSize; | 171 int w = width / sampleSize; |
| 165 int h = height / sampleSize; | 172 int h = height / sampleSize; |
| 166 if (src->colorType() == kIndex_8_SkColorType) { | 173 if (src->colorType() == kIndex_8_SkColorType) { |
| 167 // kIndex8 does not allow drawing via an SkCanvas, as is done below. | 174 // kIndex8 does not allow drawing via an SkCanvas, as is done below. |
| 168 // Instead, use extractSubset. Note that this shares the SkPixelRef and | 175 // Instead, use extractSubset. Note that this shares the SkPixelRef and |
| 169 // SkColorTable. | 176 // SkColorTable. |
| 170 // FIXME: Since src is discarded in practice, this holds on to more | 177 // FIXME: Since src is discarded in practice, this holds on to more |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 return true; | 212 return true; |
| 206 } | 213 } |
| 207 | 214 |
| 208 /////////////////////////////////////////////////////////////////////////////// | 215 /////////////////////////////////////////////////////////////////////////////// |
| 209 | 216 |
| 210 bool SkImageDecoder::DecodeFile(const char file[], SkBitmap* bm, SkColorType pre
f, Mode mode, | 217 bool SkImageDecoder::DecodeFile(const char file[], SkBitmap* bm, SkColorType pre
f, Mode mode, |
| 211 Format* format) { | 218 Format* format) { |
| 212 SkASSERT(file); | 219 SkASSERT(file); |
| 213 SkASSERT(bm); | 220 SkASSERT(bm); |
| 214 | 221 |
| 215 SkAutoTUnref<SkStreamRewindable> stream(SkStream::NewFromFile(file)); | 222 SkAutoTDelete<SkStreamRewindable> stream(SkStream::NewFromFile(file)); |
| 216 if (stream.get()) { | 223 if (stream.get()) { |
| 217 if (SkImageDecoder::DecodeStream(stream, bm, pref, mode, format)) { | 224 if (SkImageDecoder::DecodeStream(stream, bm, pref, mode, format)) { |
| 218 bm->pixelRef()->setURI(file); | 225 bm->pixelRef()->setURI(file); |
| 219 return true; | 226 return true; |
| 220 } | 227 } |
| 221 } | 228 } |
| 222 return false; | 229 return false; |
| 223 } | 230 } |
| 224 | 231 |
| 225 bool SkImageDecoder::DecodeMemory(const void* buffer, size_t size, SkBitmap* bm,
SkColorType pref, | 232 bool SkImageDecoder::DecodeMemory(const void* buffer, size_t size, SkBitmap* bm,
SkColorType pref, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 256 return success; | 263 return success; |
| 257 } | 264 } |
| 258 | 265 |
| 259 bool SkImageDecoder::decodeYUV8Planes(SkStream* stream, SkISize componentSizes[3
], void* planes[3], | 266 bool SkImageDecoder::decodeYUV8Planes(SkStream* stream, SkISize componentSizes[3
], void* planes[3], |
| 260 size_t rowBytes[3], SkYUVColorSpace* color
Space) { | 267 size_t rowBytes[3], SkYUVColorSpace* color
Space) { |
| 261 // we reset this to false before calling onDecodeYUV8Planes | 268 // we reset this to false before calling onDecodeYUV8Planes |
| 262 fShouldCancelDecode = false; | 269 fShouldCancelDecode = false; |
| 263 | 270 |
| 264 return this->onDecodeYUV8Planes(stream, componentSizes, planes, rowBytes, co
lorSpace); | 271 return this->onDecodeYUV8Planes(stream, componentSizes, planes, rowBytes, co
lorSpace); |
| 265 } | 272 } |
| OLD | NEW |