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

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

Issue 1405383002: Remove check for whole image in the cache in SkGpuDevice::shouldTileImage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unused function Created 5 years, 2 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/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 #include "GrTextureMaker.h" 8 #include "GrTextureMaker.h"
9 9
10 #include "SkGr.h" 10 #include "SkGr.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 GrUniqueKey tmpKey; 166 GrUniqueKey tmpKey;
167 make_unstretched_key(&tmpKey, imageID, subset); 167 make_unstretched_key(&tmpKey, imageID, subset);
168 if (!GrMakeStretchedKey(tmpKey, stretch, key)) { 168 if (!GrMakeStretchedKey(tmpKey, stretch, key)) {
169 *key = tmpKey; 169 *key = tmpKey;
170 } 170 }
171 } else { 171 } else {
172 make_unstretched_key(key, imageID, subset); 172 make_unstretched_key(key, imageID, subset);
173 } 173 }
174 } 174 }
175 175
176 static void make_image_keys(uint32_t imageID, const SkIRect& subset, const SkGrS tretch& stretch,
177 GrUniqueKey* key, GrUniqueKey* stretchedKey) {
178 make_unstretched_key(key, imageID, subset);
179 if (SkGrStretch::kNone_Type != stretch.fType) {
180 GrMakeStretchedKey(*key, stretch, stretchedKey);
181 }
182 }
183
184 GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo& info) { 176 GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo& info) {
185 GrSurfaceDesc desc; 177 GrSurfaceDesc desc;
186 desc.fFlags = kNone_GrSurfaceFlags; 178 desc.fFlags = kNone_GrSurfaceFlags;
187 desc.fWidth = info.width(); 179 desc.fWidth = info.width();
188 desc.fHeight = info.height(); 180 desc.fHeight = info.height();
189 desc.fConfig = SkImageInfo2GrPixelConfig(info); 181 desc.fConfig = SkImageInfo2GrPixelConfig(info);
190 desc.fSampleCnt = 0; 182 desc.fSampleCnt = 0;
191 return desc; 183 return desc;
192 } 184 }
193 185
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 break; 461 break;
470 case SkGrStretch::kNone_Type: 462 case SkGrStretch::kNone_Type:
471 SkDEBUGFAIL("Shouldn't get here."); 463 SkDEBUGFAIL("Shouldn't get here.");
472 break; 464 break;
473 } 465 }
474 SkRect dstRect = SkRect::MakeWH(SkIntToScalar(stretch.fWidth), SkIntToScalar (stretch.fHeight)); 466 SkRect dstRect = SkRect::MakeWH(SkIntToScalar(stretch.fWidth), SkIntToScalar (stretch.fHeight));
475 canvas.drawBitmapRect(bmp, dstRect, &paint); 467 canvas.drawBitmapRect(bmp, dstRect, &paint);
476 return stretched; 468 return stretched;
477 } 469 }
478 470
479 bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& sub set,
480 GrTexture* nativeTexture, const GrTextureParams& params) {
481 SkGrStretch stretch;
482 get_stretch(*ctx->caps(), subset.width(), subset.height(), params, &stretch) ;
483
484 // Handle the case where the bitmap/image is explicitly texture backed.
485 if (nativeTexture) {
486 if (SkGrStretch::kNone_Type == stretch.fType) {
487 return true;
488 }
489 const GrUniqueKey& key = nativeTexture->getUniqueKey();
490 if (!key.isValid()) {
491 return false;
492 }
493 GrUniqueKey stretchedKey;
494 GrMakeStretchedKey(key, stretch, &stretchedKey);
495 return ctx->textureProvider()->existsTextureWithUniqueKey(stretchedKey);
496 }
497
498 GrUniqueKey key, stretchedKey;
499 make_image_keys(imageID, subset, stretch, &key, &stretchedKey);
500 return ctx->textureProvider()->existsTextureWithUniqueKey(
501 (SkGrStretch::kNone_Type == stretch.fType) ? key : stretchedKey);
502 }
503
504 class Bitmap_GrTextureMaker : public GrTextureMaker { 471 class Bitmap_GrTextureMaker : public GrTextureMaker {
505 public: 472 public:
506 Bitmap_GrTextureMaker(const SkBitmap& bitmap) 473 Bitmap_GrTextureMaker(const SkBitmap& bitmap)
507 : INHERITED(bitmap.width(), bitmap.height()) 474 : INHERITED(bitmap.width(), bitmap.height())
508 , fBitmap(bitmap) 475 , fBitmap(bitmap)
509 {} 476 {}
510 477
511 protected: 478 protected:
512 GrTexture* onRefUnstretchedTexture(GrContext* ctx) override { 479 GrTexture* onRefUnstretchedTexture(GrContext* ctx) override {
513 GrTexture* tex = fBitmap.getTexture(); 480 GrTexture* tex = fBitmap.getTexture();
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 SkBitmap stretchedBmp = stretch_on_cpu(bitmap, stretch); 885 SkBitmap stretchedBmp = stretch_on_cpu(bitmap, stretch);
919 return create_unstretched_bitmap_texture(ctx, stretchedBmp, GrUniqueKey( )); 886 return create_unstretched_bitmap_texture(ctx, stretchedBmp, GrUniqueKey( ));
920 } else { 887 } else {
921 SkAutoTUnref<GrTexture> unstretched(this->onRefUnstretchedTexture(ctx)); 888 SkAutoTUnref<GrTexture> unstretched(this->onRefUnstretchedTexture(ctx));
922 if (!unstretched) { 889 if (!unstretched) {
923 return nullptr; 890 return nullptr;
924 } 891 }
925 return stretch_texture(unstretched, stretch, nullptr, GrUniqueKey()); 892 return stretch_texture(unstretched, stretch, nullptr, GrUniqueKey());
926 } 893 }
927 } 894 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/gpu/SkGrPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698