| 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 GrTextureMaker_DEFINED | 8 #ifndef GrTextureMaker_DEFINED |
| 9 #define GrTextureMaker_DEFINED | 9 #define GrTextureMaker_DEFINED |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 /** | 62 /** |
| 63 * If a stretched version of the texture is generated, it may be cached (ass
uming that | 63 * If a stretched version of the texture is generated, it may be cached (ass
uming that |
| 64 * makeCopyKey() returns true). In that case, the maker is notified in case
it | 64 * makeCopyKey() returns true). In that case, the maker is notified in case
it |
| 65 * wants to note that for when the maker is destroyed. | 65 * wants to note that for when the maker is destroyed. |
| 66 */ | 66 */ |
| 67 virtual void didCacheCopy(const GrUniqueKey& copyKey) = 0; | 67 virtual void didCacheCopy(const GrUniqueKey& copyKey) = 0; |
| 68 | 68 |
| 69 typedef SkNoncopyable INHERITED; | 69 typedef SkNoncopyable INHERITED; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 /** Base class for sources that start out as textures */ | 72 /** |
| 73 * Base class for sources that start out as textures. Optionally allows for a co
ntent area subrect. |
| 74 * The intent is not to use content area for subrect rendering. Rather, the pixe
ls outside the |
| 75 * content area have undefined values and shouldn't be read *regardless* of filt
ering mode or |
| 76 * the SkCanvas::SrcRectConstraint used for subrect draws. |
| 77 */ |
| 73 class GrTextureAdjuster : public GrTextureProducer { | 78 class GrTextureAdjuster : public GrTextureProducer { |
| 74 public: | 79 public: |
| 75 /** Makes the subset of the texture safe to use with the given texture param
eters. | 80 /** Makes the subset of the texture safe to use with the given texture param
eters. |
| 76 outOffset will be the top-left corner of the subset if a copy is not mad
e. Otherwise, | 81 outOffset will be the top-left corner of the subset if a copy is not mad
e. Otherwise, |
| 77 the copy will be tight to the contents and outOffset will be (0, 0). If
the copy's size | 82 the copy will be tight to the contents and outOffset will be (0, 0). If
the copy's size |
| 78 does not match subset's dimensions then the contents are scaled to fit t
he copy.*/ | 83 does not match subset's dimensions then the contents are scaled to fit t
he copy.*/ |
| 79 GrTexture* refTextureSafeForParams(const GrTextureParams&, SkIPoint* outOffs
et); | 84 GrTexture* refTextureSafeForParams(const GrTextureParams&, SkIPoint* outOffs
et); |
| 80 | 85 |
| 81 protected: | 86 protected: |
| 82 /** No subset, use the whole texture */ | 87 /** The whole texture is content. */ |
| 83 explicit GrTextureAdjuster(GrTexture* original): fOriginal(original) {} | 88 explicit GrTextureAdjuster(GrTexture* original): fOriginal(original) {} |
| 84 | 89 |
| 85 GrTextureAdjuster(GrTexture* original, const SkIRect& subset); | 90 GrTextureAdjuster(GrTexture* original, const SkIRect& contentArea); |
| 86 | 91 |
| 87 GrTexture* originalTexture() { return fOriginal; } | 92 GrTexture* originalTexture() { return fOriginal; } |
| 88 | 93 |
| 89 /** Returns the subset or null for the whole original texture */ | 94 /** Returns the content area or null for the whole original texture */ |
| 90 const SkIRect* subset() { return fSubset.getMaybeNull(); } | 95 const SkIRect* contentArea() { return fContentArea.getMaybeNull(); } |
| 91 | 96 |
| 92 private: | 97 private: |
| 93 GrTexture* internalRefTextureSafeForParams(GrTexture*, const SkIRect* subset
, | 98 SkTLazy<SkIRect> fContentArea; |
| 94 const GrTextureParams&, SkIPoint*
outOffset); | |
| 95 SkTLazy<SkIRect> fSubset; | |
| 96 GrTexture* fOriginal; | 99 GrTexture* fOriginal; |
| 97 | 100 |
| 98 typedef GrTextureProducer INHERITED; | 101 typedef GrTextureProducer INHERITED; |
| 99 }; | 102 }; |
| 100 | 103 |
| 101 /** | 104 /** |
| 102 * Base class for sources that start out as something other than a texture (enco
ded image, | 105 * Base class for sources that start out as something other than a texture (enco
ded image, |
| 103 * picture, ...). | 106 * picture, ...). |
| 104 */ | 107 */ |
| 105 class GrTextureMaker : public GrTextureProducer { | 108 class GrTextureMaker : public GrTextureProducer { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 virtual GrTexture* generateTextureForParams(GrContext*, const CopyParams&); | 147 virtual GrTexture* generateTextureForParams(GrContext*, const CopyParams&); |
| 145 | 148 |
| 146 private: | 149 private: |
| 147 const int fWidth; | 150 const int fWidth; |
| 148 const int fHeight; | 151 const int fHeight; |
| 149 | 152 |
| 150 typedef GrTextureProducer INHERITED; | 153 typedef GrTextureProducer INHERITED; |
| 151 }; | 154 }; |
| 152 | 155 |
| 153 #endif | 156 #endif |
| OLD | NEW |