Chromium Code Reviews| 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 |
| 11 #include "GrTextureParams.h" | 11 #include "GrTextureParams.h" |
| 12 #include "GrResourceKey.h" | 12 #include "GrResourceKey.h" |
| 13 #include "GrTexture.h" | |
| 13 #include "SkTLazy.h" | 14 #include "SkTLazy.h" |
| 14 | 15 |
| 15 class GrContext; | 16 class GrContext; |
| 16 class GrTexture; | |
| 17 class GrTextureParams; | 17 class GrTextureParams; |
| 18 class GrUniqueKey; | 18 class GrUniqueKey; |
| 19 class SkBitmap; | 19 class SkBitmap; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Different GPUs and API extensions have different requirements with respect to what texture | 22 * Different GPUs and API extensions have different requirements with respect to what texture |
| 23 * sampling parameters may be used with textures of various types. This class fa cilitates making | 23 * sampling parameters may be used with textures of various types. This class fa cilitates making |
| 24 * texture compatible with a given GrTextureParams. There are two immediate subc lasses defined | 24 * texture compatible with a given GrTextureParams. There are two immediate subc lasses defined |
| 25 * below. One is a base class for sources that are inherently texture-backed (e. g. a texture-backed | 25 * below. One is a base class for sources that are inherently texture-backed (e. g. a texture-backed |
| 26 * SkImage). It supports subsetting the original texture. The other is for use c ases where the | 26 * SkImage). It supports subsetting the original texture. The other is for use c ases where the |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 * content area have undefined values and shouldn't be read *regardless* of filt ering mode or | 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. | 76 * the SkCanvas::SrcRectConstraint used for subrect draws. |
| 77 */ | 77 */ |
| 78 class GrTextureAdjuster : public GrTextureProducer { | 78 class GrTextureAdjuster : public GrTextureProducer { |
| 79 public: | 79 public: |
| 80 /** 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. |
| 81 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, |
| 82 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 |
| 83 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.*/ |
| 84 GrTexture* refTextureSafeForParams(const GrTextureParams&, SkIPoint* outOffs et); | 84 GrTexture* refTextureSafeForParams(const GrTextureParams&, SkIPoint* outOffs et); |
| 85 | 85 |
|
robertphillips
2015/11/06 20:54:51
Can any of these new entry points be const ?
bsalomon
2015/11/09 19:35:22
Done.
| |
| 86 enum FilterConstraint { | |
| 87 kYes_FilterConstraint, | |
| 88 kNo_FilterConstraint, | |
| 89 }; | |
| 90 | |
| 91 /** | |
| 92 * Helper for creating a fragment processor to sample the texture with a giv en filtering mode. | |
| 93 * It attempts to avoids making a copy of the texture and avoid using a text ure domain unless | |
| 94 * necessary. | |
| 95 * | |
| 96 * @param textureMatrix Matrix to transform local coords by to compute | |
| 97 * texture coords. | |
| 98 * @param constraintRect Subrect of content area to be ren dered. Must be | |
| 99 * clipped to the content area alrea dy. | |
|
robertphillips
2015/11/06 20:54:51
iang -> aint ?
is -> needs to be ?
bsalomon
2015/11/09 19:35:22
Done.
| |
| 100 * @param filterConstriang Indicates whether filtering is li mited to | |
| 101 * constraintRect. | |
| 102 * @param coordsLimitedToConstraintRect Is it known that textureMatrix*lo calCoords is bound | |
| 103 * by the portion of the texture ind icated by | |
| 104 * constraintRect (without considera tion of filter | |
| 105 * width, just the raw coords). | |
| 106 * @param filterOrNullForBicubic If non-null indicates the filter mode. If null means | |
| 107 * use bicubic filtering. | |
| 108 **/ | |
| 109 const GrFragmentProcessor* createFragmentProcessor( | |
| 110 const SkMatrix& textureMatrix, | |
| 111 const SkRect& constraintRect, | |
| 112 FilterConstraint filterConstraint, | |
| 113 bool coordsLimitedToConstraintRect, | |
| 114 const GrTextureParams::FilterMode* filterOrNullForBicubic); | |
| 115 | |
| 116 GrTexture* originalTexture() { return fOriginal; } | |
| 117 | |
| 118 void getContentArea(SkIRect* contentArea) { | |
| 119 if (fContentArea.isValid()) { | |
| 120 *contentArea = *fContentArea.get(); | |
| 121 } else { | |
| 122 *contentArea = SkIRect::MakeWH(fOriginal->width(), fOriginal->height ()); | |
| 123 } | |
| 124 } | |
| 125 | |
| 86 protected: | 126 protected: |
| 87 /** The whole texture is content. */ | 127 /** The whole texture is content. */ |
| 88 explicit GrTextureAdjuster(GrTexture* original): fOriginal(original) {} | 128 explicit GrTextureAdjuster(GrTexture* original): fOriginal(original) {} |
| 89 | 129 |
| 90 GrTextureAdjuster(GrTexture* original, const SkIRect& contentArea); | 130 GrTextureAdjuster(GrTexture* original, const SkIRect& contentArea); |
| 91 | 131 |
| 92 GrTexture* originalTexture() { return fOriginal; } | |
| 93 | |
| 94 /** Returns the content area or null for the whole original texture */ | 132 /** Returns the content area or null for the whole original texture */ |
| 95 const SkIRect* contentArea() { return fContentArea.getMaybeNull(); } | 133 const SkIRect* contentAreaOrNull() { return fContentArea.getMaybeNull(); } |
| 96 | 134 |
| 97 private: | 135 private: |
| 98 SkTLazy<SkIRect> fContentArea; | 136 SkTLazy<SkIRect> fContentArea; |
| 99 GrTexture* fOriginal; | 137 GrTexture* fOriginal; |
| 100 | 138 |
| 101 typedef GrTextureProducer INHERITED; | 139 typedef GrTextureProducer INHERITED; |
| 102 }; | 140 }; |
| 103 | 141 |
| 104 /** | 142 /** |
| 105 * Base class for sources that start out as something other than a texture (enco ded image, | 143 * Base class for sources that start out as something other than a texture (enco ded image, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 virtual GrTexture* generateTextureForParams(GrContext*, const CopyParams&); | 185 virtual GrTexture* generateTextureForParams(GrContext*, const CopyParams&); |
| 148 | 186 |
| 149 private: | 187 private: |
| 150 const int fWidth; | 188 const int fWidth; |
| 151 const int fHeight; | 189 const int fHeight; |
| 152 | 190 |
| 153 typedef GrTextureProducer INHERITED; | 191 typedef GrTextureProducer INHERITED; |
| 154 }; | 192 }; |
| 155 | 193 |
| 156 #endif | 194 #endif |
| OLD | NEW |