Index: include/gpu/GrXferProcessor.h |
diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5c40ec0d3032987a396f4347b7820425329e77f5 |
--- /dev/null |
+++ b/include/gpu/GrXferProcessor.h |
@@ -0,0 +1,58 @@ |
+/* |
+ * 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 GrXferProcessor is used to combine the output of the color and coverage stages into one or two |
bsalomon
2014/12/01 19:24:39
I think this comment will be confusing to someone
egdaniel
2014/12/02 15:07:09
Done.
|
+ * output colors (two if dual source is enabled). All blending is handled internally inside the xfer |
+ * processor and thus the client code can be oblivious to how the blending works. A GrXP is never |
+ * created directly by a client. Instead, a GrXPFactory class is used. At the time of snapping the |
+ * draw state and creating optimizations, the XPFactory will create an XP. This XP also serves as a |
+ * feedback loop into the OptDrawState, informing the OptDrawState what additional optimizations to |
+ * perform based on blending. The XP does not have local coords and will never read the fragment |
+ * position. However, it can possibly read the destination color when doing blending. The final draw |
+ * state will always have one and only one GrXferProcessor. |
+ */ |
+class GrXferProcessor : public GrFragmentProcessor { |
+private: |
+ virtual bool onIsEqual(const GrFragmentProcessor&) const = 0; |
bsalomon
2014/12/01 19:24:40
pure virtual override?
egdaniel
2014/12/02 15:07:09
because we all love code that does nothing of cour
|
+ |
+ typedef GrFragmentProcessor INHERITED; |
+}; |
+ |
+class GrXPFactory : public GrProgramElement { |
+public: |
+ virtual const GrXferProcessor* createXferProcessor() const = 0; |
+ |
+ virtual bool supportsRGBCoverage(const GrDrawState&) const { return false; } |
bsalomon
2014/12/01 19:24:40
comment about what this means?
Also, GrDrawState
egdaniel
2014/12/02 15:07:09
Done.
|
+ |
+private: |
+ typedef GrProgramElement INHERITED; |
+}; |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+ |
+/** |
+ * This creates a factory outside of the effect memory pool. The factory's destructor will be called |
+ * at global destruction time. NAME will be the name of the created GrXPFactory. |
+ */ |
+#define GR_CREATE_STATIC_XP_FACTORY(NAME, XPF_CLASS, ARGS) \ |
+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 |
+ |