| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #ifndef GrImageIDTextureAdjuster_DEFINED | 8 #ifndef GrImageIDTextureAdjuster_DEFINED |
| 9 #define GrImageIDTextureAdjuster_DEFINED | 9 #define GrImageIDTextureAdjuster_DEFINED |
| 10 | 10 |
| 11 #include "GrTextureParamsAdjuster.h" | 11 #include "GrTextureParamsAdjuster.h" |
| 12 #include "SkImage.h" | 12 #include "SkImage.h" |
| 13 | 13 |
| 14 class SkBitmap; | 14 class SkBitmap; |
| 15 class SkImage_Base; | 15 class SkImage_Base; |
| 16 class SkImageCacherator; | 16 class SkImageCacherator; |
| 17 | 17 |
| 18 /** Implementation for texture-backed SkBitmaps. The bitmap must stay in scope a
nd unmodified | 18 /** Implementation for texture-backed SkBitmaps. The bitmap must stay in scope a
nd unmodified |
| 19 while this object exists. */ | 19 while this object exists. */ |
| 20 class GrBitmapTextureAdjuster : public GrTextureAdjuster { | 20 class GrBitmapTextureAdjuster : public GrTextureAdjuster { |
| 21 public: | 21 public: |
| 22 explicit GrBitmapTextureAdjuster(const SkBitmap* bmp); | 22 explicit GrBitmapTextureAdjuster(const SkBitmap* bmp); |
| 23 | 23 |
| 24 protected: |
| 25 SkColorSpace* getColorSpace() override; |
| 26 |
| 24 private: | 27 private: |
| 25 void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override; | 28 void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override; |
| 26 | 29 |
| 27 void didCacheCopy(const GrUniqueKey& copyKey) override; | 30 void didCacheCopy(const GrUniqueKey& copyKey) override; |
| 28 | 31 |
| 29 const SkBitmap* fBmp; | 32 const SkBitmap* fBmp; |
| 30 | 33 |
| 31 typedef GrTextureAdjuster INHERITED; | 34 typedef GrTextureAdjuster INHERITED; |
| 32 }; | 35 }; |
| 33 | 36 |
| 34 /** Implementation for texture-backed SkImages. The image must stay in scope and
unmodified while | 37 /** Implementation for texture-backed SkImages. The image must stay in scope and
unmodified while |
| 35 this object exists. */ | 38 this object exists. */ |
| 36 class GrImageTextureAdjuster : public GrTextureAdjuster { | 39 class GrImageTextureAdjuster : public GrTextureAdjuster { |
| 37 public: | 40 public: |
| 38 explicit GrImageTextureAdjuster(const SkImage_Base* img); | 41 explicit GrImageTextureAdjuster(const SkImage_Base* img); |
| 39 | 42 |
| 43 protected: |
| 44 SkColorSpace* getColorSpace() override; |
| 45 |
| 40 private: | 46 private: |
| 41 void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override; | 47 void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override; |
| 42 | 48 |
| 43 void didCacheCopy(const GrUniqueKey& copyKey) override; | 49 void didCacheCopy(const GrUniqueKey& copyKey) override; |
| 44 | 50 |
| 45 const SkImage_Base* fImageBase; | 51 const SkImage_Base* fImageBase; |
| 46 | 52 |
| 47 typedef GrTextureAdjuster INHERITED; | 53 typedef GrTextureAdjuster INHERITED; |
| 48 }; | 54 }; |
| 49 | 55 |
| 50 /** This class manages the conversion of SW-backed bitmaps to GrTextures. If the
input bitmap is | 56 /** This class manages the conversion of SW-backed bitmaps to GrTextures. If the
input bitmap is |
| 51 non-volatile the texture is cached using a key created from the pixels' imag
e id and the | 57 non-volatile the texture is cached using a key created from the pixels' imag
e id and the |
| 52 subset of the pixelref specified by the bitmap. */ | 58 subset of the pixelref specified by the bitmap. */ |
| 53 class GrBitmapTextureMaker : public GrTextureMaker { | 59 class GrBitmapTextureMaker : public GrTextureMaker { |
| 54 public: | 60 public: |
| 55 GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap); | 61 GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap); |
| 56 | 62 |
| 57 protected: | 63 protected: |
| 58 GrTexture* refOriginalTexture(bool willBeMipped, SkSourceGammaTreatment) ove
rride; | 64 GrTexture* refOriginalTexture(bool willBeMipped, SkSourceGammaTreatment) ove
rride; |
| 59 | 65 |
| 60 void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) overrid
e; | 66 void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) overrid
e; |
| 61 | 67 |
| 62 void didCacheCopy(const GrUniqueKey& copyKey) override; | 68 void didCacheCopy(const GrUniqueKey& copyKey) override; |
| 63 | 69 |
| 70 SkColorSpace* getColorSpace() override; |
| 71 |
| 64 private: | 72 private: |
| 65 const SkBitmap fBitmap; | 73 const SkBitmap fBitmap; |
| 66 GrUniqueKey fOriginalKey; | 74 GrUniqueKey fOriginalKey; |
| 67 | 75 |
| 68 typedef GrTextureMaker INHERITED; | 76 typedef GrTextureMaker INHERITED; |
| 69 }; | 77 }; |
| 70 | 78 |
| 71 /** This class manages the conversion of generator-backed images to GrTextures.
If the caching hint | 79 /** This class manages the conversion of generator-backed images to GrTextures.
If the caching hint |
| 72 is kAllow the image's ID is used for the cache key. */ | 80 is kAllow the image's ID is used for the cache key. */ |
| 73 class GrImageTextureMaker : public GrTextureMaker { | 81 class GrImageTextureMaker : public GrTextureMaker { |
| 74 public: | 82 public: |
| 75 GrImageTextureMaker(GrContext* context, SkImageCacherator* cacher, const SkI
mage* client, | 83 GrImageTextureMaker(GrContext* context, SkImageCacherator* cacher, const SkI
mage* client, |
| 76 SkImage::CachingHint chint); | 84 SkImage::CachingHint chint); |
| 77 | 85 |
| 78 protected: | 86 protected: |
| 79 // TODO: consider overriding this, for the case where the underlying generat
or might be | 87 // TODO: consider overriding this, for the case where the underlying generat
or might be |
| 80 // able to efficiently produce a "stretched" texture natively (e.g. pi
cture-backed) | 88 // able to efficiently produce a "stretched" texture natively (e.g. pi
cture-backed) |
| 81 // GrTexture* generateTextureForParams(const CopyParams&) override; | 89 // GrTexture* generateTextureForParams(const CopyParams&) override; |
| 82 | 90 |
| 83 GrTexture* refOriginalTexture(bool willBeMipped, SkSourceGammaTreatment) ove
rride; | 91 GrTexture* refOriginalTexture(bool willBeMipped, SkSourceGammaTreatment) ove
rride; |
| 84 void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey) over
ride; | 92 void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey) over
ride; |
| 85 void didCacheCopy(const GrUniqueKey& copyKey) override; | 93 void didCacheCopy(const GrUniqueKey& copyKey) override; |
| 86 | 94 |
| 95 SkColorSpace* getColorSpace() override; |
| 96 |
| 87 private: | 97 private: |
| 88 SkImageCacherator* fCacher; | 98 SkImageCacherator* fCacher; |
| 89 const SkImage* fClient; | 99 const SkImage* fClient; |
| 90 GrUniqueKey fOriginalKey; | 100 GrUniqueKey fOriginalKey; |
| 91 SkImage::CachingHint fCachingHint; | 101 SkImage::CachingHint fCachingHint; |
| 92 | 102 |
| 93 typedef GrTextureMaker INHERITED; | 103 typedef GrTextureMaker INHERITED; |
| 94 }; | 104 }; |
| 95 | 105 |
| 96 #endif | 106 #endif |
| OLD | NEW |