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

Side by Side Diff: src/gpu/GrTextureParamsAdjuster.h

Issue 1507973005: Make "alpha only" be a property of GrTextureProducer (Closed) Base URL: https://skia.googlesource.com/skia.git@producernine
Patch Set: fix unused var Created 5 years 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/GrImageIDTextureAdjuster.cpp ('k') | src/gpu/GrTextureParamsAdjuster.cpp » ('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 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 const SkMatrix& textureMatrix, 63 const SkMatrix& textureMatrix,
64 const SkRect& constraintRect, 64 const SkRect& constraintRect,
65 FilterConstraint filterConstraint, 65 FilterConstraint filterConstraint,
66 bool coordsLimitedToConstraintRect, 66 bool coordsLimitedToConstraintRect,
67 const GrTextureParams::FilterMode* filterOrN ullForBicubic) = 0; 67 const GrTextureParams::FilterMode* filterOrN ullForBicubic) = 0;
68 68
69 virtual ~GrTextureProducer() {} 69 virtual ~GrTextureProducer() {}
70 70
71 int width() const { return fWidth; } 71 int width() const { return fWidth; }
72 int height() const { return fHeight; } 72 int height() const { return fHeight; }
73 bool isAlphaOnly() const { return fIsAlphaOnly; }
73 74
74 protected: 75 protected:
75 GrTextureProducer(int width, int height) : fWidth(width), fHeight(height) {} 76 GrTextureProducer(int width, int height, bool isAlphaOnly)
77 : fWidth(width)
78 , fHeight(height)
79 , fIsAlphaOnly(isAlphaOnly) {}
76 80
77 /** Helper for creating a key for a copy from an original key. */ 81 /** Helper for creating a key for a copy from an original key. */
78 static void MakeCopyKeyFromOrigKey(const GrUniqueKey& origKey, 82 static void MakeCopyKeyFromOrigKey(const GrUniqueKey& origKey,
79 const CopyParams& copyParams, 83 const CopyParams& copyParams,
80 GrUniqueKey* copyKey) { 84 GrUniqueKey* copyKey) {
81 SkASSERT(!copyKey->isValid()); 85 SkASSERT(!copyKey->isValid());
82 if (origKey.isValid()) { 86 if (origKey.isValid()) {
83 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDoma in(); 87 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDoma in();
84 GrUniqueKey::Builder builder(copyKey, origKey, kDomain, 3); 88 GrUniqueKey::Builder builder(copyKey, origKey, kDomain, 3);
85 builder[0] = copyParams.fFilter; 89 builder[0] = copyParams.fFilter;
(...skipping 11 matching lines...) Expand all
97 virtual void makeCopyKey(const CopyParams&, GrUniqueKey* copyKey) = 0; 101 virtual void makeCopyKey(const CopyParams&, GrUniqueKey* copyKey) = 0;
98 102
99 /** 103 /**
100 * If a stretched version of the texture is generated, it may be cached (ass uming that 104 * If a stretched version of the texture is generated, it may be cached (ass uming that
101 * makeCopyKey() returns true). In that case, the maker is notified in case it 105 * makeCopyKey() returns true). In that case, the maker is notified in case it
102 * wants to note that for when the maker is destroyed. 106 * wants to note that for when the maker is destroyed.
103 */ 107 */
104 virtual void didCacheCopy(const GrUniqueKey& copyKey) = 0; 108 virtual void didCacheCopy(const GrUniqueKey& copyKey) = 0;
105 109
106 private: 110 private:
107 const int fWidth; 111 const int fWidth;
108 const int fHeight; 112 const int fHeight;
113 const bool fIsAlphaOnly;
109 114
110 typedef SkNoncopyable INHERITED; 115 typedef SkNoncopyable INHERITED;
111 }; 116 };
112 117
113 /** 118 /**
114 * Base class for sources that start out as textures. Optionally allows for a co ntent area subrect. 119 * Base class for sources that start out as textures. Optionally allows for a co ntent area subrect.
115 * The intent is not to use content area for subrect rendering. Rather, the pixe ls outside the 120 * The intent is not to use content area for subrect rendering. Rather, the pixe ls outside the
116 * content area have undefined values and shouldn't be read *regardless* of filt ering mode or 121 * content area have undefined values and shouldn't be read *regardless* of filt ering mode or
117 * the SkCanvas::SrcRectConstraint used for subrect draws. 122 * the SkCanvas::SrcRectConstraint used for subrect draws.
118 */ 123 */
119 class GrTextureAdjuster : public GrTextureProducer { 124 class GrTextureAdjuster : public GrTextureProducer {
120 public: 125 public:
121 /** Makes the subset of the texture safe to use with the given texture param eters. 126 /** Makes the subset of the texture safe to use with the given texture param eters.
122 outOffset will be the top-left corner of the subset if a copy is not mad e. Otherwise, 127 outOffset will be the top-left corner of the subset if a copy is not mad e. Otherwise,
123 the copy will be tight to the contents and outOffset will be (0, 0). If the copy's size 128 the copy will be tight to the contents and outOffset will be (0, 0). If the copy's size
124 does not match subset's dimensions then the contents are scaled to fit t he copy.*/ 129 does not match subset's dimensions then the contents are scaled to fit t he copy.*/
125 GrTexture* refTextureSafeForParams(const GrTextureParams&, SkIPoint* outOffs et); 130 GrTexture* refTextureSafeForParams(const GrTextureParams&, SkIPoint* outOffs et);
126 131
127 const GrFragmentProcessor* createFragmentProcessor( 132 const GrFragmentProcessor* createFragmentProcessor(
128 const SkMatrix& textureMatrix, 133 const SkMatrix& textureMatrix,
129 const SkRect& constraintRect, 134 const SkRect& constraintRect,
130 FilterConstraint, 135 FilterConstraint,
131 bool coordsLimitedToConstraintRect, 136 bool coordsLimitedToConstraintRect,
132 const GrTextureParams::FilterMode* filterOrNullF orBicubic) override; 137 const GrTextureParams::FilterMode* filterOrNullF orBicubic) override;
133 138
134 protected: 139 protected:
135 /** The whole texture is content. */ 140 /** The whole texture is content. */
136 explicit GrTextureAdjuster(GrTexture* original) 141 explicit GrTextureAdjuster(GrTexture* original, bool isAlphaOnly)
137 : INHERITED(original->width(), original->height()) 142 : INHERITED(original->width(), original->height(), isAlphaOnly)
138 , fOriginal(original) {} 143 , fOriginal(original) {}
139 144
140 GrTextureAdjuster(GrTexture* original, const SkIRect& contentArea); 145 GrTextureAdjuster(GrTexture* original, const SkIRect& contentArea, bool isAl phaOnly);
141 146
142 GrTexture* originalTexture() const { return fOriginal; } 147 GrTexture* originalTexture() const { return fOriginal; }
143 148
144 /** Returns the content area or null for the whole original texture */ 149 /** Returns the content area or null for the whole original texture */
145 const SkIRect* contentAreaOrNull() { return fContentArea.getMaybeNull(); } 150 const SkIRect* contentAreaOrNull() { return fContentArea.getMaybeNull(); }
146 151
147 private: 152 private:
148 SkTLazy<SkIRect> fContentArea; 153 SkTLazy<SkIRect> fContentArea;
149 GrTexture* fOriginal; 154 GrTexture* fOriginal;
150 155
(...skipping 12 matching lines...) Expand all
163 GrTexture* refTextureForParams(const GrTextureParams&); 168 GrTexture* refTextureForParams(const GrTextureParams&);
164 169
165 const GrFragmentProcessor* createFragmentProcessor( 170 const GrFragmentProcessor* createFragmentProcessor(
166 const SkMatrix& textureMatrix, 171 const SkMatrix& textureMatrix,
167 const SkRect& constraintRect, 172 const SkRect& constraintRect,
168 FilterConstraint filterConstraint, 173 FilterConstraint filterConstraint,
169 bool coordsLimitedToConstraintRect, 174 bool coordsLimitedToConstraintRect,
170 const GrTextureParams::FilterMode* filterOrNullF orBicubic) override; 175 const GrTextureParams::FilterMode* filterOrNullF orBicubic) override;
171 176
172 protected: 177 protected:
173 GrTextureMaker(GrContext* context, int width, int height) 178 GrTextureMaker(GrContext* context, int width, int height, bool isAlphaOnly)
174 : INHERITED(width, height) 179 : INHERITED(width, height, isAlphaOnly)
175 , fContext(context) {} 180 , fContext(context) {}
176 181
177 /** 182 /**
178 * Return the maker's "original" texture. It is the responsibility of the m aker to handle any 183 * Return the maker's "original" texture. It is the responsibility of the m aker to handle any
179 * caching of the original if desired. 184 * caching of the original if desired.
180 */ 185 */
181 virtual GrTexture* refOriginalTexture() = 0; 186 virtual GrTexture* refOriginalTexture() = 0;
182 187
183 /** 188 /**
184 * Return a new (uncached) texture that is the stretch of the maker's origi nal. 189 * Return a new (uncached) texture that is the stretch of the maker's origi nal.
185 * 190 *
186 * The base-class handles general logic for this, and only needs access to the following 191 * The base-class handles general logic for this, and only needs access to the following
187 * method: 192 * method:
188 * - refOriginalTexture() 193 * - refOriginalTexture()
189 * 194 *
190 * Subclass may override this if they can handle creating the texture more directly than 195 * Subclass may override this if they can handle creating the texture more directly than
191 * by copying. 196 * by copying.
192 */ 197 */
193 virtual GrTexture* generateTextureForParams(const CopyParams&); 198 virtual GrTexture* generateTextureForParams(const CopyParams&);
194 199
195 GrContext* context() const { return fContext; } 200 GrContext* context() const { return fContext; }
196 201
197 private: 202 private:
198 GrContext* fContext; 203 GrContext* fContext;
199 204
200 typedef GrTextureProducer INHERITED; 205 typedef GrTextureProducer INHERITED;
201 }; 206 };
202 207
203 #endif 208 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrImageIDTextureAdjuster.cpp ('k') | src/gpu/GrTextureParamsAdjuster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698