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