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

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

Issue 1728093005: Move Budgeted enum out of SkSurface, use in GrTextureProvider (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add aliases for Chrome Created 4 years, 10 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 | « src/gpu/SkGpuDevice.cpp ('k') | src/gpu/SkGrPixelRef.cpp » ('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 10
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return nullptr; 205 return nullptr;
206 } 206 }
207 207
208 const void* startOfTexData; 208 const void* startOfTexData;
209 desc.fConfig = GrIsCompressedTextureDataSupported(ctx, data, bm.width(), bm. height(), 209 desc.fConfig = GrIsCompressedTextureDataSupported(ctx, data, bm.width(), bm. height(),
210 &startOfTexData); 210 &startOfTexData);
211 if (kUnknown_GrPixelConfig == desc.fConfig) { 211 if (kUnknown_GrPixelConfig == desc.fConfig) {
212 return nullptr; 212 return nullptr;
213 } 213 }
214 214
215 return ctx->textureProvider()->createTexture(desc, true, startOfTexData, 0); 215 return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, startOf TexData, 0);
216 } 216 }
217 217
218 GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bmp) { 218 GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bmp) {
219 SkASSERT(!bmp.getTexture()); 219 SkASSERT(!bmp.getTexture());
220 220
221 SkBitmap tmpBitmap; 221 SkBitmap tmpBitmap;
222 const SkBitmap* bitmap = &bmp; 222 const SkBitmap* bitmap = &bmp;
223 223
224 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap->info()); 224 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap->info());
225 const GrCaps* caps = ctx->caps(); 225 const GrCaps* caps = ctx->caps();
226 226
227 if (kIndex_8_SkColorType == bitmap->colorType()) { 227 if (kIndex_8_SkColorType == bitmap->colorType()) {
228 if (caps->isConfigTexturable(kIndex_8_GrPixelConfig)) { 228 if (caps->isConfigTexturable(kIndex_8_GrPixelConfig)) {
229 size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig , 229 size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig ,
230 bitmap->width(), bitma p->height()); 230 bitmap->width(), bitma p->height());
231 SkAutoMalloc storage(imageSize); 231 SkAutoMalloc storage(imageSize);
232 build_index8_data(storage.get(), bmp); 232 build_index8_data(storage.get(), bmp);
233 233
234 // our compressed data will be trimmed, so pass width() for its 234 // our compressed data will be trimmed, so pass width() for its
235 // "rowBytes", since they are the same now. 235 // "rowBytes", since they are the same now.
236 return ctx->textureProvider()->createTexture(desc, true, storage.get (), 236 return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, storage.get(),
237 bitmap->width()); 237 bitmap->width());
238 } else { 238 } else {
239 bmp.copyTo(&tmpBitmap, kN32_SkColorType); 239 bmp.copyTo(&tmpBitmap, kN32_SkColorType);
240 // now bitmap points to our temp, which has been promoted to 32bits 240 // now bitmap points to our temp, which has been promoted to 32bits
241 bitmap = &tmpBitmap; 241 bitmap = &tmpBitmap;
242 desc.fConfig = SkImageInfo2GrPixelConfig(bitmap->info()); 242 desc.fConfig = SkImageInfo2GrPixelConfig(bitmap->info());
243 } 243 }
244 } else if (!bitmap->readyToDraw()) { 244 } else if (!bitmap->readyToDraw()) {
245 // If the bitmap had compressed data and was then uncompressed, it'll st ill return 245 // If the bitmap had compressed data and was then uncompressed, it'll st ill return
246 // compressed data on 'refEncodedData' and upload it. Probably not good, since if 246 // compressed data on 'refEncodedData' and upload it. Probably not good, since if
(...skipping 11 matching lines...) Expand all
258 GrTexture *texture = create_texture_from_yuv(ctx, *bitmap, desc); 258 GrTexture *texture = create_texture_from_yuv(ctx, *bitmap, desc);
259 if (texture) { 259 if (texture) {
260 return texture; 260 return texture;
261 } 261 }
262 262
263 SkAutoLockPixels alp(*bitmap); 263 SkAutoLockPixels alp(*bitmap);
264 if (!bitmap->readyToDraw()) { 264 if (!bitmap->readyToDraw()) {
265 return nullptr; 265 return nullptr;
266 } 266 }
267 267
268 return ctx->textureProvider()->createTexture(desc, true, bitmap->getPixels() , 268 return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, bitmap- >getPixels(),
269 bitmap->rowBytes()); 269 bitmap->rowBytes());
270 } 270 }
271 271
272 272
273 //////////////////////////////////////////////////////////////////////////////// 273 ////////////////////////////////////////////////////////////////////////////////
274 274
275 void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pix elRef) { 275 void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pix elRef) {
276 class Invalidator : public SkPixelRef::GenIDChangeListener { 276 class Invalidator : public SkPixelRef::GenIDChangeListener {
277 public: 277 public:
278 explicit Invalidator(const GrUniqueKey& key) : fMsg(key) {} 278 explicit Invalidator(const GrUniqueKey& key) : fMsg(key) {}
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 SkErrorInternals::SetError( kInvalidPaint_SkError, 634 SkErrorInternals::SetError( kInvalidPaint_SkError,
635 "Sorry, I don't understand the filtering " 635 "Sorry, I don't understand the filtering "
636 "mode you asked for. Falling back to " 636 "mode you asked for. Falling back to "
637 "MIPMaps."); 637 "MIPMaps.");
638 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 638 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
639 break; 639 break;
640 640
641 } 641 }
642 return textureFilterMode; 642 return textureFilterMode;
643 } 643 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/gpu/SkGrPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698