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

Side by Side Diff: src/gpu/SkGr.cpp

Issue 1809663002: Propogate SkBudgeted for NewFromDeferredTextureImageData (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | src/gpu/SkGrPriv.h » ('j') | 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 2010 Google Inc. 2 * Copyright 2010 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 8
9 #include "SkGr.h" 9 #include "SkGr.h"
10 #include "SkGrPriv.h" 10 #include "SkGrPriv.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 224
225 SkAutoLockPixels alp(bitmap); 225 SkAutoLockPixels alp(bitmap);
226 if (!bitmap.readyToDraw()) { 226 if (!bitmap.readyToDraw()) {
227 return nullptr; 227 return nullptr;
228 } 228 }
229 SkPixmap pixmap; 229 SkPixmap pixmap;
230 if (!bitmap.peekPixels(&pixmap)) { 230 if (!bitmap.peekPixels(&pixmap)) {
231 return nullptr; 231 return nullptr;
232 } 232 }
233 return GrUploadPixmapToTexture(ctx, pixmap); 233 return GrUploadPixmapToTexture(ctx, pixmap, SkBudgeted::kYes);
234 } 234 }
235 235
236 GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap) { 236 GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud geted budgeted) {
237 const SkPixmap* pmap = &pixmap; 237 const SkPixmap* pmap = &pixmap;
238 SkPixmap tmpPixmap; 238 SkPixmap tmpPixmap;
239 SkBitmap tmpBitmap; 239 SkBitmap tmpBitmap;
240 240
241 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info()); 241 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info());
242 const GrCaps* caps = ctx->caps(); 242 const GrCaps* caps = ctx->caps();
243 243
244 if (kIndex_8_SkColorType == pixmap.colorType()) { 244 if (kIndex_8_SkColorType == pixmap.colorType()) {
245 if (caps->isConfigTexturable(kIndex_8_GrPixelConfig)) { 245 if (caps->isConfigTexturable(kIndex_8_GrPixelConfig)) {
246 size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig , 246 size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig ,
247 pixmap.width(), pixmap .height()); 247 pixmap.width(), pixmap .height());
248 SkAutoMalloc storage(imageSize); 248 SkAutoMalloc storage(imageSize);
249 build_index8_data(storage.get(), pixmap); 249 build_index8_data(storage.get(), pixmap);
250 250
251 // our compressed data will be trimmed, so pass width() for its 251 // our compressed data will be trimmed, so pass width() for its
252 // "rowBytes", since they are the same now. 252 // "rowBytes", since they are the same now.
253 return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, storage.get(), 253 return ctx->textureProvider()->createTexture(desc, budgeted, storage .get(),
254 pixmap.width()); 254 pixmap.width());
255 } else { 255 } else {
256 SkImageInfo info = SkImageInfo::MakeN32Premul(pixmap.width(), pixmap .height()); 256 SkImageInfo info = SkImageInfo::MakeN32Premul(pixmap.width(), pixmap .height());
257 tmpBitmap.allocPixels(info); 257 tmpBitmap.allocPixels(info);
258 if (!pixmap.readPixels(info, tmpBitmap.getPixels(), tmpBitmap.rowByt es())) { 258 if (!pixmap.readPixels(info, tmpBitmap.getPixels(), tmpBitmap.rowByt es())) {
259 return nullptr; 259 return nullptr;
260 } 260 }
261 if (!tmpBitmap.peekPixels(&tmpPixmap)) { 261 if (!tmpBitmap.peekPixels(&tmpPixmap)) {
262 return nullptr; 262 return nullptr;
263 } 263 }
264 pmap = &tmpPixmap; 264 pmap = &tmpPixmap;
265 // must rebuild desc, since we've forced the info to be N32 265 // must rebuild desc, since we've forced the info to be N32
266 desc = GrImageInfoToSurfaceDesc(pmap->info()); 266 desc = GrImageInfoToSurfaceDesc(pmap->info());
267 } 267 }
268 } 268 }
269 269
270 return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, pmap->a ddr(), 270 return ctx->textureProvider()->createTexture(desc, budgeted, pmap->addr(),
271 pmap->rowBytes()); 271 pmap->rowBytes());
272 } 272 }
273 273
274 274
275 //////////////////////////////////////////////////////////////////////////////// 275 ////////////////////////////////////////////////////////////////////////////////
276 276
277 void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pix elRef) { 277 void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pix elRef) {
278 class Invalidator : public SkPixelRef::GenIDChangeListener { 278 class Invalidator : public SkPixelRef::GenIDChangeListener {
279 public: 279 public:
280 explicit Invalidator(const GrUniqueKey& key) : fMsg(key) {} 280 explicit Invalidator(const GrUniqueKey& key) : fMsg(key) {}
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 SkErrorInternals::SetError( kInvalidPaint_SkError, 695 SkErrorInternals::SetError( kInvalidPaint_SkError,
696 "Sorry, I don't understand the filtering " 696 "Sorry, I don't understand the filtering "
697 "mode you asked for. Falling back to " 697 "mode you asked for. Falling back to "
698 "MIPMaps."); 698 "MIPMaps.");
699 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 699 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
700 break; 700 break;
701 701
702 } 702 }
703 return textureFilterMode; 703 return textureFilterMode;
704 } 704 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/SkGrPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698