| OLD | NEW |
| 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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 make_stretched_key(key, stretch, &stretchedKey); | 513 make_stretched_key(key, stretch, &stretchedKey); |
| 514 return ctx->textureProvider()->existsTextureWithUniqueKey(stretchedKey); | 514 return ctx->textureProvider()->existsTextureWithUniqueKey(stretchedKey); |
| 515 } | 515 } |
| 516 | 516 |
| 517 GrUniqueKey key, stretchedKey; | 517 GrUniqueKey key, stretchedKey; |
| 518 make_image_keys(imageID, subset, stretch, &key, &stretchedKey); | 518 make_image_keys(imageID, subset, stretch, &key, &stretchedKey); |
| 519 return ctx->textureProvider()->existsTextureWithUniqueKey( | 519 return ctx->textureProvider()->existsTextureWithUniqueKey( |
| 520 (SkGrStretch::kNone_Type == stretch.fType) ? key : stretchedKey); | 520 (SkGrStretch::kNone_Type == stretch.fType) ? key : stretchedKey); |
| 521 } | 521 } |
| 522 | 522 |
| 523 bool GrIsBitmapInCache(const GrContext* ctx, const SkBitmap& bitmap, | |
| 524 const GrTextureParams* params) { | |
| 525 if (bitmap.isVolatile()) { | |
| 526 return false; // we don't cache volatile bitmaps. | |
| 527 } | |
| 528 return GrIsImageInCache(ctx, bitmap.getGenerationID(), bitmap.getSubset(), b
itmap.getTexture(), | |
| 529 params); | |
| 530 } | |
| 531 | |
| 532 class Bitmap_GrTextureMaker : public GrTextureMaker { | 523 class Bitmap_GrTextureMaker : public GrTextureMaker { |
| 533 public: | 524 public: |
| 534 Bitmap_GrTextureMaker(const SkBitmap& bitmap) | 525 Bitmap_GrTextureMaker(const SkBitmap& bitmap) |
| 535 : INHERITED(bitmap.width(), bitmap.height()) | 526 : INHERITED(bitmap.width(), bitmap.height()) |
| 536 , fBitmap(bitmap) | 527 , fBitmap(bitmap) |
| 537 {} | 528 {} |
| 538 | 529 |
| 539 protected: | 530 protected: |
| 540 GrTexture* onRefUnstretchedTexture(GrContext* ctx) override { | 531 GrTexture* onRefUnstretchedTexture(GrContext* ctx) override { |
| 541 GrTexture* tex = fBitmap.getTexture(); | 532 GrTexture* tex = fBitmap.getTexture(); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 SkBitmap stretchedBmp = stretch_on_cpu(bitmap, stretch); | 949 SkBitmap stretchedBmp = stretch_on_cpu(bitmap, stretch); |
| 959 return create_unstretched_bitmap_texture(ctx, stretchedBmp, GrUniqueKey(
)); | 950 return create_unstretched_bitmap_texture(ctx, stretchedBmp, GrUniqueKey(
)); |
| 960 } else { | 951 } else { |
| 961 SkAutoTUnref<GrTexture> unstretched(this->onRefUnstretchedTexture(ctx)); | 952 SkAutoTUnref<GrTexture> unstretched(this->onRefUnstretchedTexture(ctx)); |
| 962 if (!unstretched) { | 953 if (!unstretched) { |
| 963 return nullptr; | 954 return nullptr; |
| 964 } | 955 } |
| 965 return stretch_texture(unstretched, stretch, nullptr, GrUniqueKey()); | 956 return stretch_texture(unstretched, stretch, nullptr, GrUniqueKey()); |
| 966 } | 957 } |
| 967 } | 958 } |
| OLD | NEW |