Index: include/gpu/GrXferProcessor.h |
diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..353060465350f4f59bc88dc8d75ef7d1e7c5f804 |
--- /dev/null |
+++ b/include/gpu/GrXferProcessor.h |
@@ -0,0 +1,59 @@ |
+/* |
+ * 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" |
+ |
+/** |
+ * GrXferProcessor is responsible for implementing the xfer mode that blends the src color and dst |
+ * color. It does this by emitting fragment shader code and controlling the fixed-function blend |
+ * state. The inputs to its shader code are the final computed src color and fractional pixel |
+ * coverage. The GrXferProcessor's shader code writes the fragment shader output color that coes |
bsalomon
2014/12/02 15:36:32
coes->goes
egdaniel
2014/12/02 18:09:51
Done.
|
+ * into the fixed-function blend. When dual-source blending is available, it may also write a |
+ * seconday fragment shader output color. When allowed by the backend API, the GrXferProcessor may |
+ * read the destination color. The GrXferProcessor is responsible for setting the blend coefficients |
+ * and blend constant color. |
+ */ |
+class GrXferProcessor : public GrFragmentProcessor { |
bsalomon
2014/12/02 15:36:32
Somewhere we need an explanation (from a subclass
egdaniel
2014/12/02 18:09:51
Added below before GrXPFactory.
|
+private: |
+ |
+ typedef GrFragmentProcessor INHERITED; |
+}; |
+ |
+class GrXPFactory : public GrProgramElement { |
+public: |
+ virtual const GrXferProcessor* createXferProcessor() const = 0; |
+ |
+ /** |
+ * This function returns true if the GrXferProcessor generated from this factory will be able to |
+ * correctly blend when using RGB coverage. The knownColor and knownColorFlags represent the |
+ * final computed color from the color stages. |
+ */ |
+ virtual bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const = 0; |
+ |
+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 |
+ |