| 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 |
| 11 #define SkXfermode_DEFINED | 11 #define SkXfermode_DEFINED |
| 12 | 12 |
| 13 #include "SkFlattenable.h" | 13 #include "SkFlattenable.h" |
| 14 #include "SkColor.h" | 14 #include "SkColor.h" |
| 15 | 15 |
| 16 class GrContext; |
| 16 class GrFragmentProcessor; | 17 class GrFragmentProcessor; |
| 17 class GrTexture; | 18 class GrTexture; |
| 18 class GrXPFactory; | 19 class GrXPFactory; |
| 19 class SkString; | 20 class SkString; |
| 20 | 21 |
| 21 /** \class SkXfermode | 22 /** \class SkXfermode |
| 22 * | 23 * |
| 23 * SkXfermode is the base class for objects that are called to implement custom | 24 * SkXfermode is the base class for objects that are called to implement custom |
| 24 * "transfer-modes" in the drawing pipeline. The static function Create(Modes) | 25 * "transfer-modes" in the drawing pipeline. The static function Create(Modes) |
| 25 * can be called to return an instance of any of the predefined subclasses as | 26 * can be called to return an instance of any of the predefined subclasses as |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 parameter. Upon failure false is returned and the processor param is not
written to. | 211 parameter. Upon failure false is returned and the processor param is not
written to. |
| 211 */ | 212 */ |
| 212 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture* backgroun
d) const; | 213 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture* backgroun
d) const; |
| 213 | 214 |
| 214 /** A subclass may implement this factory function to work with the GPU back
end. It is legal | 215 /** A subclass may implement this factory function to work with the GPU back
end. It is legal |
| 215 to call this with xpf NULL to simply test the return value. If xpf is no
n-NULL then the | 216 to call this with xpf NULL to simply test the return value. If xpf is no
n-NULL then the |
| 216 xfermode may optionally allocate a factory to return to the caller as *x
pf. The caller | 217 xfermode may optionally allocate a factory to return to the caller as *x
pf. The caller |
| 217 will install it and own a ref to it. Since the xfermode may or may not a
ssign *xpf, the | 218 will install it and own a ref to it. Since the xfermode may or may not a
ssign *xpf, the |
| 218 caller should set *xpf to NULL beforehand. XferProcessors cannot use a b
ackground texture. | 219 caller should set *xpf to NULL beforehand. XferProcessors cannot use a b
ackground texture. |
| 219 */ | 220 */ |
| 220 virtual bool asXPFactory(GrXPFactory** xpf) const; | 221 virtual bool asXPFactory(const GrContext*, GrXPFactory** xpf) const; |
| 221 | 222 |
| 222 /** Returns true if the xfermode can be expressed as an xfer processor facto
ry (xpFactory). | 223 /** Returns true if the xfermode can be expressed as an xfer processor facto
ry (xpFactory). |
| 223 This helper calls the asXPFactory() virtual. If the xfermode is NULL, it
is treated as | 224 This helper calls the asXPFactory() virtual. If the xfermode is NULL, it
is treated as |
| 224 kSrcOver_Mode. It is legal to call this with xpf param NULL to simply te
st the return value. | 225 kSrcOver_Mode. It is legal to call this with xpf param NULL to simply te
st the return value. |
| 225 */ | 226 */ |
| 226 static bool AsXPFactory(SkXfermode*, GrXPFactory**); | 227 static bool AsXPFactory(SkXfermode*, const GrContext*, GrXPFactory**); |
| 227 | 228 |
| 228 SK_TO_STRING_PUREVIRT() | 229 SK_TO_STRING_PUREVIRT() |
| 229 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 230 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
| 230 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) | 231 SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) |
| 231 | 232 |
| 232 protected: | 233 protected: |
| 233 SkXfermode() {} | 234 SkXfermode() {} |
| 234 /** The default implementation of xfer32/xfer16/xferA8 in turn call this | 235 /** The default implementation of xfer32/xfer16/xferA8 in turn call this |
| 235 method, 1 color at a time (upscaled to a SkPMColor). The default | 236 method, 1 color at a time (upscaled to a SkPMColor). The default |
| 236 implmentation of this method just returns dst. If performance is | 237 implmentation of this method just returns dst. If performance is |
| 237 important, your subclass should override xfer32/xfer16/xferA8 directly. | 238 important, your subclass should override xfer32/xfer16/xferA8 directly. |
| 238 | 239 |
| 239 This method will not be called directly by the client, so it need not | 240 This method will not be called directly by the client, so it need not |
| 240 be implemented if your subclass has overridden xfer32/xfer16/xferA8 | 241 be implemented if your subclass has overridden xfer32/xfer16/xferA8 |
| 241 */ | 242 */ |
| 242 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; | 243 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; |
| 243 | 244 |
| 244 private: | 245 private: |
| 245 enum { | 246 enum { |
| 246 kModeCount = kLastMode + 1 | 247 kModeCount = kLastMode + 1 |
| 247 }; | 248 }; |
| 248 | 249 |
| 249 typedef SkFlattenable INHERITED; | 250 typedef SkFlattenable INHERITED; |
| 250 }; | 251 }; |
| 251 | 252 |
| 252 #endif | 253 #endif |
| OLD | NEW |