OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkXfermode_DEFINED | 10 #ifndef SkXfermode_DEFINED |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 * that will be given to the xfer mode. | 187 * that will be given to the xfer mode. |
188 */ | 188 */ |
189 virtual bool isOpaque(SrcColorOpacity opacityType) const; | 189 virtual bool isOpaque(SrcColorOpacity opacityType) const; |
190 | 190 |
191 /** | 191 /** |
192 * The same as calling xfermode->isOpaque(...), except that this also check
s if | 192 * The same as calling xfermode->isOpaque(...), except that this also check
s if |
193 * the xfermode is NULL, and if so, treats it as kSrcOver_Mode. | 193 * the xfermode is NULL, and if so, treats it as kSrcOver_Mode. |
194 */ | 194 */ |
195 static bool IsOpaque(const SkXfermode* xfer, SrcColorOpacity opacityType); | 195 static bool IsOpaque(const SkXfermode* xfer, SrcColorOpacity opacityType); |
196 | 196 |
197 /** Implemented by a subclass to support use as an image filter in the GPU b
ackend. When used as | 197 /** Used to do in-shader blending between two colors computed in the shader
via a |
198 an image filter the xfer mode blends the source color against a backgrou
nd texture rather | 198 GrFragmentProcessor. The input to the returned FP is the src color. The
dst color is |
199 than the destination. It is implemented as a fragment processor. This ca
n be called with | 199 provided by the dst param which becomes a child FP of the returned FP. I
f the params are |
200 both params set to NULL to query whether it would succeed. Otherwise, bo
th params are | 200 null then this is just a query of whether the SkXfermode could support t
his functionality. |
201 required. Upon success the function returns true and the caller owns a r
ef to the fragment | 201 It is legal for the function to succeed but return a null output. This i
ndicates that |
202 parameter. Upon failure false is returned and the processor param is not
written to. | 202 the output of the blend is simply the src color. |
203 */ | 203 */ |
204 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrProcessorDataManag
er*, | 204 virtual bool asFragmentProcessor(const GrFragmentProcessor** output, GrProce
ssorDataManager*, |
205 GrTexture* background) const; | 205 const GrFragmentProcessor* dst) const; |
206 | 206 |
207 /** A subclass may implement this factory function to work with the GPU back
end. It is legal | 207 /** A subclass may implement this factory function to work with the GPU back
end. It is legal |
208 to call this with xpf NULL to simply test the return value. If xpf is no
n-NULL then the | 208 to call this with xpf NULL to simply test the return value. If xpf is no
n-NULL then the |
209 xfermode may optionally allocate a factory to return to the caller as *x
pf. The caller | 209 xfermode may optionally allocate a factory to return to the caller as *x
pf. The caller |
210 will install it and own a ref to it. Since the xfermode may or may not a
ssign *xpf, the | 210 will install it and own a ref to it. Since the xfermode may or may not a
ssign *xpf, the |
211 caller should set *xpf to NULL beforehand. XferProcessors cannot use a b
ackground texture. | 211 caller should set *xpf to NULL beforehand. XferProcessors cannot use a b
ackground texture. |
212 */ | 212 */ |
213 virtual bool asXPFactory(GrXPFactory** xpf) const; | 213 virtual bool asXPFactory(GrXPFactory** xpf) const; |
214 | 214 |
215 /** Returns true if the xfermode can be expressed as an xfer processor facto
ry (xpFactory). | 215 /** Returns true if the xfermode can be expressed as an xfer processor facto
ry (xpFactory). |
216 This helper calls the asXPFactory() virtual. If the xfermode is NULL, it
is treated as | 216 This helper calls the asXPFactory() virtual. If the xfermode is NULL, it
is treated as |
217 kSrcOver_Mode. It is legal to call this with xpf param NULL to simply te
st the return value. | 217 kSrcOver_Mode. It is legal to call this with xpf param NULL to simply te
st the return value. |
218 */ | 218 */ |
219 static bool AsXPFactory(SkXfermode*, GrXPFactory**); | 219 static bool AsXPFactory(SkXfermode*, GrXPFactory**); |
220 | 220 |
221 SK_TO_STRING_PUREVIRT() | 221 SK_TO_STRING_PUREVIRT() |
222 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 222 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
223 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) | 223 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) |
224 | 224 |
225 protected: | 225 protected: |
226 SkXfermode() {} | 226 SkXfermode() {} |
227 /** The default implementation of xfer32/xfer16/xferA8 in turn call this | 227 /** The default implementation of xfer32/xfer16/xferA8 in turn call this |
228 method, 1 color at a time (upscaled to a SkPMColor). The default | 228 method, 1 color at a time (upscaled to a SkPMColor). The default |
229 implmentation of this method just returns dst. If performance is | 229 implementation of this method just returns dst. If performance is |
230 important, your subclass should override xfer32/xfer16/xferA8 directly. | 230 important, your subclass should override xfer32/xfer16/xferA8 directly. |
231 | 231 |
232 This method will not be called directly by the client, so it need not | 232 This method will not be called directly by the client, so it need not |
233 be implemented if your subclass has overridden xfer32/xfer16/xferA8 | 233 be implemented if your subclass has overridden xfer32/xfer16/xferA8 |
234 */ | 234 */ |
235 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; | 235 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; |
236 | 236 |
237 private: | 237 private: |
238 enum { | 238 enum { |
239 kModeCount = kLastMode + 1 | 239 kModeCount = kLastMode + 1 |
240 }; | 240 }; |
241 | 241 |
242 typedef SkFlattenable INHERITED; | 242 typedef SkFlattenable INHERITED; |
243 }; | 243 }; |
244 | 244 |
245 #endif | 245 #endif |
OLD | NEW |