Index: include/gpu/GrXferProcessor.h |
diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b5ca717bd2f06beb3a24f8616166802d3af2268d |
--- /dev/null |
+++ b/include/gpu/GrXferProcessor.h |
@@ -0,0 +1,95 @@ |
+/* |
+ * Copyright 2014 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#ifndef GrXferProcessor_DEFINED |
+#define GrXferProcessor_DEFINED |
+ |
+#include "GrColor.h" |
+#include "GrFragmentProcessor.h" |
+#include "GrTypes.h" |
+#include "SkXfermode.h" |
+ |
+class GrDrawState; |
+ |
+/** |
+ * A GrGeomteryProcessor is used to perform computation in the vertex shader and |
+ * add support for custom vertex attributes. A GrGemeotryProcessor is typically |
+ * tied to the code that does a specific type of high-level primitive rendering |
+ * (e.g. anti-aliased circle rendering). The GrGeometryProcessor used for a draw is |
+ * specified using GrDrawState. There can only be one geometry processor active for |
+ * a draw. The custom vertex attributes required by the geometry processor must be |
+ * added to the vertex attribute array specified on the GrDrawState. |
+ * GrGeometryProcessor subclasses should be immutable after construction. |
+ */ |
joshualitt
2014/11/26 20:10:34
Comment refers to GP
egdaniel
2014/12/01 18:18:24
Done.
|
+class GrXferProcessor : public GrFragmentProcessor { |
+public: |
+ /** Returns true if this and other prceossor conservatively draw identically. It can only return |
+ true when the two prceossor are of the same subclass (i.e. they return the same object from |
bsalomon
2014/11/26 21:02:44
Does this comment apply? Will these have a backend
egdaniel
2014/12/01 18:18:24
In this current version the XP is derived from a f
|
+ from getFactory()). |
+ |
+ A return value of true from isEqual() should not be used to test whether the prceossor would |
+ generate the same shader code. To test for identical code generation use the prceossor' keys |
+ computed by the GrBackendProcessorFactory. */ |
+ bool isEqual(const GrXferProcessor& that) const { |
bsalomon
2014/11/26 21:02:45
non-virtual override?
egdaniel
2014/12/01 18:18:24
Code deleted since coeff's have been moved off bas
|
+ /* |
bsalomon
2014/11/26 21:02:45
?
egdaniel
2014/12/01 18:18:24
Done.
|
+ if (fSrcBlend != that.fSrcBlend || fDstBlend != that.fDstBlend) { |
+ return false; |
+ } |
+ */ |
joshualitt
2014/11/26 20:10:34
Is this code supposed to be commented out?
egdaniel
2014/12/01 18:18:24
nope
|
+ return this->onIsEqual(that); |
+ } |
+ |
+protected: |
+ GrXferProcessor() : fSrcBlend(kOne_GrBlendCoeff), fDstBlend(kZero_GrBlendCoeff) {} |
+ |
+ GrXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend) |
+ : fSrcBlend(srcBlend), fDstBlend(dstBlend) {} |
+ |
+private: |
+ virtual bool onIsEqual(const GrFragmentProcessor&) const = 0; |
+ |
+ GrBlendCoeff fSrcBlend; |
+ GrBlendCoeff fDstBlend; |
+ |
+ typedef GrFragmentProcessor INHERITED; |
+}; |
+ |
+class GrXPFactory : public GrProgramElement { |
+public: |
+ virtual const GrXferProcessor* createXferProcessor() const = 0; |
bsalomon
2014/11/26 21:02:44
no inputs?
egdaniel
2014/12/01 18:18:24
In this cl it has none, but in the next DrawState
|
+ |
+ virtual bool supportsLCDText(const GrDrawState&) const { return false; } |
bsalomon
2014/11/26 21:02:44
Can we call it LCDCoverage or RGBCoverage rather t
egdaniel
2014/12/01 18:18:24
Done.
|
+ |
joshualitt
2014/11/26 20:10:34
Is there a way to name this more generally? ie, w
|
+ virtual bool canApplyCoverage(const GrDrawState&) const { return false; } |
bsalomon
2014/11/26 21:02:44
This and the above need some clear documentation a
egdaniel
2014/12/01 18:18:24
Removed for now since it is unused in this CL. Wil
|
+ |
+protected: |
+ GrXPFactory() |
+ : INHERITED(), fSrc(kOne_GrBlendCoeff), fDst(kZero_GrBlendCoeff) {} |
+ |
+ GrXPFactory(GrBlendCoeff src, GrBlendCoeff dst) |
+ : fSrc(src), fDst(dst) {} |
+ |
+ GrBlendCoeff fSrc; |
+ GrBlendCoeff fDst; |
+ |
+private: |
+ typedef GrProgramElement INHERITED; |
+}; |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+ |
+/** |
+ * This creates an effect outside of the effect memory pool. The effect's destructor will be called |
+ * at global destruction time. NAME will be the name of the created GrProcessor. |
+ */ |
+#define GR_CREATE_STATIC_XP_FACTORY(NAME, XPF_CLASS, ARGS) \ |
bsalomon
2014/11/26 21:02:44
You must be coming from a really old revision. The
egdaniel
2014/12/01 18:18:24
This isn't a GrProcessor subclass, it is for GrXPF
bsalomon
2014/12/01 19:24:39
Acknowledged.
|
+static SkAlignedSStorage<sizeof(XPF_CLASS)> g_##NAME##_Storage; \ |
+static GrXPFactory* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), XPF_CLASS, ARGS); \ |
+static SkAutoTDestroy<GrXPFactory> NAME##_ad(NAME); |
+ |
+#endif |
+ |