OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrXferProcessor_DEFINED | 8 #ifndef GrXferProcessor_DEFINED |
9 #define GrXferProcessor_DEFINED | 9 #define GrXferProcessor_DEFINED |
10 | 10 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 * A caller who calls this function on a XP is required to honor the returne
d OptFlags | 118 * A caller who calls this function on a XP is required to honor the returne
d OptFlags |
119 * and color values for its draw. | 119 * and color values for its draw. |
120 */ | 120 */ |
121 virtual OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | 121 virtual OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
122 const GrProcOptInfo& coveragePOI, | 122 const GrProcOptInfo& coveragePOI, |
123 bool doesStencilWrite, | 123 bool doesStencilWrite, |
124 GrColor* overrideColor, | 124 GrColor* overrideColor, |
125 const GrDrawTargetCaps& caps) = 0; | 125 const GrDrawTargetCaps& caps) = 0; |
126 | 126 |
127 struct BlendInfo { | 127 struct BlendInfo { |
128 BlendInfo() : fWriteColor(true) {} | 128 void reset() { |
| 129 fSrcBlend = kOne_GrBlendCoeff; |
| 130 fDstBlend = kZero_GrBlendCoeff; |
| 131 fBlendConstant = 0; |
| 132 fWriteColor = true; |
| 133 } |
129 | 134 |
130 GrBlendCoeff fSrcBlend; | 135 GrBlendCoeff fSrcBlend; |
131 GrBlendCoeff fDstBlend; | 136 GrBlendCoeff fDstBlend; |
132 GrColor fBlendConstant; | 137 GrColor fBlendConstant; |
133 bool fWriteColor; | 138 bool fWriteColor; |
134 }; | 139 }; |
135 | 140 |
136 virtual void getBlendInfo(BlendInfo* blendInfo) const = 0; | 141 void getBlendInfo(BlendInfo* blendInfo) const { |
| 142 blendInfo->reset(); |
| 143 this->onGetBlendInfo(blendInfo); |
| 144 } |
137 | 145 |
138 bool willReadDstColor() const { return fWillReadDstColor; } | 146 bool willReadDstColor() const { return fWillReadDstColor; } |
139 | 147 |
140 /** | 148 /** |
141 * Returns the texture to be used as the destination when reading the dst in
the fragment | 149 * Returns the texture to be used as the destination when reading the dst in
the fragment |
142 * shader. If the returned texture is NULL then the XP is either not reading
the dst or we have | 150 * shader. If the returned texture is NULL then the XP is either not reading
the dst or we have |
143 * extentions that support framebuffer fetching and thus don't need a copy o
f the dst texture. | 151 * extentions that support framebuffer fetching and thus don't need a copy o
f the dst texture. |
144 */ | 152 */ |
145 const GrTexture* getDstCopyTexture() const { return fDstCopy.getTexture(); } | 153 const GrTexture* getDstCopyTexture() const { return fDstCopy.getTexture(); } |
146 | 154 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 GrXferProcessor(const GrDeviceCoordTexture* dstCopy, bool willReadDstColor); | 195 GrXferProcessor(const GrDeviceCoordTexture* dstCopy, bool willReadDstColor); |
188 | 196 |
189 private: | 197 private: |
190 /** | 198 /** |
191 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate
d with this xfer | 199 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate
d with this xfer |
192 * processor's GL backend implementation. | 200 * processor's GL backend implementation. |
193 */ | 201 */ |
194 virtual void onGetGLProcessorKey(const GrGLCaps& caps, | 202 virtual void onGetGLProcessorKey(const GrGLCaps& caps, |
195 GrProcessorKeyBuilder* b) const = 0; | 203 GrProcessorKeyBuilder* b) const = 0; |
196 | 204 |
| 205 /** |
| 206 * Retrieves the hardware blend state required by this Xfer processor. The B
lendInfo struct |
| 207 * comes initialized to default values, so the Xfer processor only needs to
set the state it |
| 208 * needs. It may not even need to override this method at all. |
| 209 */ |
| 210 virtual void onGetBlendInfo(BlendInfo*) const {} |
| 211 |
197 virtual bool onIsEqual(const GrXferProcessor&) const = 0; | 212 virtual bool onIsEqual(const GrXferProcessor&) const = 0; |
198 | 213 |
199 bool fWillReadDstColor; | 214 bool fWillReadDstColor; |
200 SkIPoint fDstCopyTextureOffset; | 215 SkIPoint fDstCopyTextureOffset; |
201 GrTextureAccess fDstCopy; | 216 GrTextureAccess fDstCopy; |
202 | 217 |
203 typedef GrFragmentProcessor INHERITED; | 218 typedef GrFragmentProcessor INHERITED; |
204 }; | 219 }; |
205 | 220 |
206 GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags); | 221 GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 enum { | 325 enum { |
311 kIllegalXPFClassID = 0, | 326 kIllegalXPFClassID = 0, |
312 }; | 327 }; |
313 static int32_t gCurrXPFClassID; | 328 static int32_t gCurrXPFClassID; |
314 | 329 |
315 typedef GrProgramElement INHERITED; | 330 typedef GrProgramElement INHERITED; |
316 }; | 331 }; |
317 | 332 |
318 #endif | 333 #endif |
319 | 334 |
OLD | NEW |