| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 fShouldCancelDecode = false; | 202 fShouldCancelDecode = false; |
| 203 | 203 |
| 204 return this->onBuildTileIndex(stream, width, height); | 204 return this->onBuildTileIndex(stream, width, height); |
| 205 } | 205 } |
| 206 | 206 |
| 207 bool SkImageDecoder::cropBitmap(SkBitmap *dst, SkBitmap *src, int sampleSize, | 207 bool SkImageDecoder::cropBitmap(SkBitmap *dst, SkBitmap *src, int sampleSize, |
| 208 int dstX, int dstY, int width, int height, | 208 int dstX, int dstY, int width, int height, |
| 209 int srcX, int srcY) { | 209 int srcX, int srcY) { |
| 210 int w = width / sampleSize; | 210 int w = width / sampleSize; |
| 211 int h = height / sampleSize; | 211 int h = height / sampleSize; |
| 212 if (src->config() == SkBitmap::kIndex8_Config) { | 212 if (src->colorType() == kIndex_8_SkColorType) { |
| 213 // kIndex8 does not allow drawing via an SkCanvas, as is done below. | 213 // kIndex8 does not allow drawing via an SkCanvas, as is done below. |
| 214 // Instead, use extractSubset. Note that this shares the SkPixelRef and | 214 // Instead, use extractSubset. Note that this shares the SkPixelRef and |
| 215 // SkColorTable. | 215 // SkColorTable. |
| 216 // FIXME: Since src is discarded in practice, this holds on to more | 216 // FIXME: Since src is discarded in practice, this holds on to more |
| 217 // pixels than is strictly necessary. Switch to a copy if memory | 217 // pixels than is strictly necessary. Switch to a copy if memory |
| 218 // savings are more important than speed here. This also means | 218 // savings are more important than speed here. This also means |
| 219 // that the pixels in dst can not be reused (though there is no | 219 // that the pixels in dst can not be reused (though there is no |
| 220 // allocation, which was already done on src). | 220 // allocation, which was already done on src). |
| 221 int x = (dstX - srcX) / sampleSize; | 221 int x = (dstX - srcX) / sampleSize; |
| 222 int y = (dstY - srcY) / sampleSize; | 222 int y = (dstY - srcY) / sampleSize; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 if (kUnknown_Format == *format) { | 294 if (kUnknown_Format == *format) { |
| 295 if (stream->rewind()) { | 295 if (stream->rewind()) { |
| 296 *format = GetStreamFormat(stream); | 296 *format = GetStreamFormat(stream); |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 } | 299 } |
| 300 delete codec; | 300 delete codec; |
| 301 } | 301 } |
| 302 return success; | 302 return success; |
| 303 } | 303 } |
| OLD | NEW |