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

Side by Side Diff: src/lazy/SkBitmapFactory.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 2012 Google Inc. 2 * Copyright 2012 Google Inc.
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 #include "SkBitmapFactory.h" 8 #include "SkBitmapFactory.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 bool SkBitmapFactory::installPixelRef(SkData* data, SkBitmap* dst) { 46 bool SkBitmapFactory::installPixelRef(SkData* data, SkBitmap* dst) {
47 if (NULL == data || 0 == data->size() || dst == NULL) { 47 if (NULL == data || 0 == data->size() || dst == NULL) {
48 return false; 48 return false;
49 } 49 }
50 50
51 SkImage::Info info; 51 SkImage::Info info;
52 if (!fDecodeProc(data->data(), data->size(), &info, NULL)) { 52 if (!fDecodeProc(data->data(), data->size(), &info, NULL)) {
53 return false; 53 return false;
54 } 54 }
55 55
56 bool isOpaque = false; 56 SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
57 SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque);
58 57
59 Target target; 58 Target target;
60 // FIMXE: There will be a problem if this rowbytes is calculated differently from 59 // FIMXE: There will be a problem if this rowbytes is calculated differently from
61 // in SkLazyPixelRef. 60 // in SkLazyPixelRef.
62 target.fRowBytes = SkImageMinRowBytes(info); 61 target.fRowBytes = SkImageMinRowBytes(info);
63 62 dst->setConfig(config, info.fWidth, info.fHeight, target.fRowBytes, info.fAl phaType);
64 dst->setConfig(config, info.fWidth, info.fHeight, target.fRowBytes);
65 dst->setIsOpaque(isOpaque);
66 63
67 // fImageCache and fCacheSelector are mutually exclusive. 64 // fImageCache and fCacheSelector are mutually exclusive.
68 SkASSERT(NULL == fImageCache || NULL == fCacheSelector); 65 SkASSERT(NULL == fImageCache || NULL == fCacheSelector);
69 66
70 SkImageCache* cache = NULL == fCacheSelector ? fImageCache : fCacheSelector- >selectCache(info); 67 SkImageCache* cache = NULL == fCacheSelector ? fImageCache : fCacheSelector- >selectCache(info);
71 68
72 if (cache != NULL) { 69 if (cache != NULL) {
73 // Now set a new LazyPixelRef on dst. 70 // Now set a new LazyPixelRef on dst.
74 SkAutoTUnref<SkLazyPixelRef> lazyRef(SkNEW_ARGS(SkLazyPixelRef, 71 SkAutoTUnref<SkLazyPixelRef> lazyRef(SkNEW_ARGS(SkLazyPixelRef,
75 (data, fDecodeProc, cach e))); 72 (data, fDecodeProc, cach e)));
76 dst->setPixelRef(lazyRef); 73 dst->setPixelRef(lazyRef);
77 return true; 74 return true;
78 } else { 75 } else {
79 dst->allocPixels(); 76 dst->allocPixels();
80 target.fAddr = dst->getPixels(); 77 target.fAddr = dst->getPixels();
81 return fDecodeProc(data->data(), data->size(), &info, &target); 78 return fDecodeProc(data->data(), data->size(), &info, &target);
82 } 79 }
83 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698