| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // savings are more important than speed here. This also means | 235 // savings are more important than speed here. This also means |
| 236 // that the pixels in dst can not be reused (though there is no | 236 // that the pixels in dst can not be reused (though there is no |
| 237 // allocation, which was already done on src). | 237 // allocation, which was already done on src). |
| 238 int x = (dstX - srcX) / sampleSize; | 238 int x = (dstX - srcX) / sampleSize; |
| 239 int y = (dstY - srcY) / sampleSize; | 239 int y = (dstY - srcY) / sampleSize; |
| 240 SkIRect subset = SkIRect::MakeXYWH(x, y, w, h); | 240 SkIRect subset = SkIRect::MakeXYWH(x, y, w, h); |
| 241 return src->extractSubset(dst, subset); | 241 return src->extractSubset(dst, subset); |
| 242 } | 242 } |
| 243 // if the destination has no pixels then we must allocate them. | 243 // if the destination has no pixels then we must allocate them. |
| 244 if (dst->isNull()) { | 244 if (dst->isNull()) { |
| 245 dst->setConfig(src->getConfig(), w, h); | 245 dst->setConfig(src->getConfig(), w, h, 0, src->isOpaque() ? |
| 246 dst->setIsOpaque(src->isOpaque()); | 246 kOpaque_SkAlphaType : kPremul_SkAlphaType); |
| 247 | 247 |
| 248 if (!this->allocPixelRef(dst, NULL)) { | 248 if (!this->allocPixelRef(dst, NULL)) { |
| 249 SkDEBUGF(("failed to allocate pixels needed to crop the bitmap")); | 249 SkDEBUGF(("failed to allocate pixels needed to crop the bitmap")); |
| 250 return false; | 250 return false; |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 // check to see if the destination is large enough to decode the desired | 253 // check to see if the destination is large enough to decode the desired |
| 254 // region. If this assert fails we will just draw as much of the source | 254 // region. If this assert fails we will just draw as much of the source |
| 255 // into the destination that we can. | 255 // into the destination that we can. |
| 256 if (dst->width() < w || dst->height() < h) { | 256 if (dst->width() < w || dst->height() < h) { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 if (kUnknown_Format == *format) { | 461 if (kUnknown_Format == *format) { |
| 462 if (stream->rewind()) { | 462 if (stream->rewind()) { |
| 463 *format = GetStreamFormat(stream); | 463 *format = GetStreamFormat(stream); |
| 464 } | 464 } |
| 465 } | 465 } |
| 466 } | 466 } |
| 467 delete codec; | 467 delete codec; |
| 468 } | 468 } |
| 469 return success; | 469 return success; |
| 470 } | 470 } |
| OLD | NEW |