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

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

Issue 1351533004: share code between SkGr and Cacherator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: captured strict check in a helper function Created 5 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
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('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 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 #include "SkGr.h" 8 #include "SkGr.h"
9 9
10 #include "GrCaps.h" 10 #include "GrCaps.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 199
200 static void make_image_keys(uint32_t imageID, const SkIRect& subset, const Stret ch& stretch, 200 static void make_image_keys(uint32_t imageID, const SkIRect& subset, const Stret ch& stretch,
201 GrUniqueKey* key, GrUniqueKey* stretchedKey) { 201 GrUniqueKey* key, GrUniqueKey* stretchedKey) {
202 make_unstretched_key(key, imageID, subset); 202 make_unstretched_key(key, imageID, subset);
203 if (Stretch::kNone_Type != stretch.fType) { 203 if (Stretch::kNone_Type != stretch.fType) {
204 make_stretched_key(*key, stretch, stretchedKey); 204 make_stretched_key(*key, stretch, stretchedKey);
205 } 205 }
206 } 206 }
207 207
208 static void generate_bitmap_texture_desc(const SkBitmap& bitmap, GrSurfaceDesc* desc) { 208 GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo& info) {
209 desc->fFlags = kNone_GrSurfaceFlags; 209 GrSurfaceDesc desc;
210 desc->fWidth = bitmap.width(); 210 desc.fFlags = kNone_GrSurfaceFlags;
211 desc->fHeight = bitmap.height(); 211 desc.fWidth = info.width();
212 desc->fConfig = SkImageInfo2GrPixelConfig(bitmap.info()); 212 desc.fHeight = info.height();
213 desc->fSampleCnt = 0; 213 desc.fConfig = SkImageInfo2GrPixelConfig(info);
214 desc.fSampleCnt = 0;
215 return desc;
214 } 216 }
215 217
216 namespace { 218 namespace {
217 219
218 // When the SkPixelRef genID changes, invalidate a corresponding GrResource desc ribed by key. 220 // When the SkPixelRef genID changes, invalidate a corresponding GrResource desc ribed by key.
219 class BitmapInvalidator : public SkPixelRef::GenIDChangeListener { 221 class BitmapInvalidator : public SkPixelRef::GenIDChangeListener {
220 public: 222 public:
221 explicit BitmapInvalidator(const GrUniqueKey& key) : fMsg(key) {} 223 explicit BitmapInvalidator(const GrUniqueKey& key) : fMsg(key) {}
222 private: 224 private:
223 GrUniqueKeyInvalidatedMessage fMsg; 225 GrUniqueKeyInvalidatedMessage fMsg;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 const SkBitmap& origBitmap, 428 const SkBitmap& origBitmap,
427 const GrUniqueKey& optionalK ey) { 429 const GrUniqueKey& optionalK ey) {
428 if (origBitmap.width() < ctx->caps()->minTextureSize() || 430 if (origBitmap.width() < ctx->caps()->minTextureSize() ||
429 origBitmap.height() < ctx->caps()->minTextureSize()) { 431 origBitmap.height() < ctx->caps()->minTextureSize()) {
430 return nullptr; 432 return nullptr;
431 } 433 }
432 SkBitmap tmpBitmap; 434 SkBitmap tmpBitmap;
433 435
434 const SkBitmap* bitmap = &origBitmap; 436 const SkBitmap* bitmap = &origBitmap;
435 437
436 GrSurfaceDesc desc; 438 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap->info());
437 generate_bitmap_texture_desc(*bitmap, &desc);
438 const GrCaps* caps = ctx->caps(); 439 const GrCaps* caps = ctx->caps();
439 440
440 if (kIndex_8_SkColorType == bitmap->colorType()) { 441 if (kIndex_8_SkColorType == bitmap->colorType()) {
441 if (caps->isConfigTexturable(kIndex_8_GrPixelConfig)) { 442 if (caps->isConfigTexturable(kIndex_8_GrPixelConfig)) {
442 size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig , 443 size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig ,
443 bitmap->width(), bitma p->height()); 444 bitmap->width(), bitma p->height());
444 SkAutoMalloc storage(imageSize); 445 SkAutoMalloc storage(imageSize);
445 build_index8_data(storage.get(), origBitmap); 446 build_index8_data(storage.get(), origBitmap);
446 447
447 // our compressed data will be trimmed, so pass width() for its 448 // our compressed data will be trimmed, so pass width() for its
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 SkErrorInternals::SetError( kInvalidPaint_SkError, 850 SkErrorInternals::SetError( kInvalidPaint_SkError,
850 "Sorry, I don't understand the filtering " 851 "Sorry, I don't understand the filtering "
851 "mode you asked for. Falling back to " 852 "mode you asked for. Falling back to "
852 "MIPMaps."); 853 "MIPMaps.");
853 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 854 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
854 break; 855 break;
855 856
856 } 857 }
857 return textureFilterMode; 858 return textureFilterMode;
858 } 859 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698