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

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

Issue 25275004: store SkAlphaType inside SkBitmap, on road to support unpremul (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 months 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 | Annotate | Revision Log
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
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->alphaType());
249 dst->setIsOpaque(src->isOpaque());
250 249
251 if (!this->allocPixelRef(dst, NULL)) { 250 if (!this->allocPixelRef(dst, NULL)) {
252 SkDEBUGF(("failed to allocate pixels needed to crop the bitmap")); 251 SkDEBUGF(("failed to allocate pixels needed to crop the bitmap"));
253 return false; 252 return false;
254 } 253 }
255 } 254 }
256 // check to see if the destination is large enough to decode the desired 255 // 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 256 // region. If this assert fails we will just draw as much of the source
258 // into the destination that we can. 257 // into the destination that we can.
259 if (dst->width() < w || dst->height() < h) { 258 if (dst->width() < w || dst->height() < h) {
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 if (kUnknown_Format == *format) { 463 if (kUnknown_Format == *format) {
465 if (stream->rewind()) { 464 if (stream->rewind()) {
466 *format = GetStreamFormat(stream); 465 *format = GetStreamFormat(stream);
467 } 466 }
468 } 467 }
469 } 468 }
470 delete codec; 469 delete codec;
471 } 470 }
472 return success; 471 return success;
473 } 472 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698