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

Side by Side Diff: src/lazy/SkLazyPixelRef.cpp

Issue 23591030: start to remove lockPixels from bitmapshader (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review suggestions Created 7 years, 3 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
« src/core/SkBitmapProcState.cpp ('K') | « src/lazy/SkLazyPixelRef.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 if (fCacheId != SkImageCache::UNINITIALIZED_ID) { 139 if (fCacheId != SkImageCache::UNINITIALIZED_ID) {
140 fImageCache->releaseCache(fCacheId); 140 fImageCache->releaseCache(fCacheId);
141 } 141 }
142 } 142 }
143 143
144 SkData* SkLazyPixelRef::onRefEncodedData() { 144 SkData* SkLazyPixelRef::onRefEncodedData() {
145 fData->ref(); 145 fData->ref();
146 return fData; 146 return fData;
147 } 147 }
148
149 #include "SkImagePriv.h"
150
151 static bool initFromInfo(SkBitmap* bm, const SkImage::Info& info, size_t rowByte s) {
scroggo 2013/09/10 21:51:41 init_from_info*
reed1 2013/09/11 14:16:36 Done.
152 bool isOpaque;
153 SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque);
154 if (SkBitmap::kNo_Config == config) {
155 return false;
156 }
157
158 bm->setConfig(config, info.fWidth, info.fHeight, rowBytes);
159 bm->setIsOpaque(isOpaque);
160 return bm->allocPixels();
161 }
162
163 bool SkLazyPixelRef::onDecodeInto(int pow2, SkBitmap* bitmap) {
164 SkASSERT(fData != NULL && fData->size() > 0);
165 if (fErrorInDecoding) {
166 return false;
167 }
168
169 SkImage::Info info;
170 // Determine the size of the image in order to determine how much memory to allocate.
171 // FIXME: As an optimization, only do this part once.
172 fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, NULL);
173 if (fErrorInDecoding) {
174 return false;
175 }
176
177 SkBitmapFactory::Target target;
178 (void)ComputeMinRowBytesAndSize(info, &target.fRowBytes);
179
180 SkBitmap tmp;
181 if (!initFromInfo(&tmp, info, target.fRowBytes)) {
182 return false;
183 }
184
185 target.fAddr = tmp.getPixels();
186 fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, &target );
187 if (fErrorInDecoding) {
188 return false;
189 }
190
191 *bitmap = tmp;
192 return true;
193 }
194
195
OLDNEW
« src/core/SkBitmapProcState.cpp ('K') | « src/lazy/SkLazyPixelRef.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698