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

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: 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
« no previous file with comments | « 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 init_from_info(SkBitmap* bm, const SkImage::Info& info,
152 size_t rowBytes) {
153 bool isOpaque;
154 SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque);
155 if (SkBitmap::kNo_Config == config) {
156 return false;
157 }
158
159 bm->setConfig(config, info.fWidth, info.fHeight, rowBytes);
160 bm->setIsOpaque(isOpaque);
161 return bm->allocPixels();
162 }
163
164 bool SkLazyPixelRef::onImplementsDecodeInto() {
165 return true;
166 }
167
168 bool SkLazyPixelRef::onDecodeInto(int pow2, SkBitmap* bitmap) {
169 SkASSERT(fData != NULL && fData->size() > 0);
170 if (fErrorInDecoding) {
171 return false;
172 }
173
174 SkImage::Info info;
175 // Determine the size of the image in order to determine how much memory to allocate.
176 // FIXME: As an optimization, only do this part once.
177 fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, NULL);
178 if (fErrorInDecoding) {
179 return false;
180 }
181
182 SkBitmapFactory::Target target;
183 (void)ComputeMinRowBytesAndSize(info, &target.fRowBytes);
184
185 SkBitmap tmp;
186 if (!init_from_info(&tmp, info, target.fRowBytes)) {
187 return false;
188 }
189
190 target.fAddr = tmp.getPixels();
191 fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, &target );
192 if (fErrorInDecoding) {
193 return false;
194 }
195
196 *bitmap = tmp;
197 return true;
198 }
199
200
OLDNEW
« no previous file with comments | « src/lazy/SkLazyPixelRef.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698