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

Side by Side Diff: src/lazy/SkLazyPixelRef.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 "Sk64.h" 8 #include "Sk64.h"
9 #include "SkLazyPixelRef.h" 9 #include "SkLazyPixelRef.h"
10 #include "SkColorTable.h" 10 #include "SkColorTable.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 #include "SkImagePriv.h" 149 #include "SkImagePriv.h"
150 150
151 static bool init_from_info(SkBitmap* bm, const SkImage::Info& info, 151 static bool init_from_info(SkBitmap* bm, const SkImage::Info& info,
152 size_t rowBytes) { 152 size_t rowBytes) {
153 bool isOpaque; 153 bool isOpaque;
154 SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque); 154 SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque);
155 if (SkBitmap::kNo_Config == config) { 155 if (SkBitmap::kNo_Config == config) {
156 return false; 156 return false;
157 } 157 }
158 158
159 bm->setConfig(config, info.fWidth, info.fHeight, rowBytes); 159 return bm->setConfig(config, info.fWidth, info.fHeight, rowBytes,
160 bm->setIsOpaque(isOpaque); 160 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType)
scroggo 2013/10/18 19:32:40 info has the actual alpha type.
161 return bm->allocPixels(); 161 &&
162 bm->allocPixels();
162 } 163 }
163 164
164 bool SkLazyPixelRef::onImplementsDecodeInto() { 165 bool SkLazyPixelRef::onImplementsDecodeInto() {
165 return true; 166 return true;
166 } 167 }
167 168
168 bool SkLazyPixelRef::onDecodeInto(int pow2, SkBitmap* bitmap) { 169 bool SkLazyPixelRef::onDecodeInto(int pow2, SkBitmap* bitmap) {
169 SkASSERT(fData != NULL && fData->size() > 0); 170 SkASSERT(fData != NULL && fData->size() > 0);
170 if (fErrorInDecoding) { 171 if (fErrorInDecoding) {
171 return false; 172 return false;
(...skipping 17 matching lines...) Expand all
189 190
190 target.fAddr = tmp.getPixels(); 191 target.fAddr = tmp.getPixels();
191 fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, &target ); 192 fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, &target );
192 if (fErrorInDecoding) { 193 if (fErrorInDecoding) {
193 return false; 194 return false;
194 } 195 }
195 196
196 *bitmap = tmp; 197 *bitmap = tmp;
197 return true; 198 return true;
198 } 199 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698