Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: include/gpu/GrXferProcessor.h

Issue 751283002: Add XferProcessor factory in GrPaint and GrDrawState. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Review changes Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
+
« no previous file with comments | « include/gpu/GrPaint.h ('k') | src/core/SkXfermode.cpp » ('j') | src/core/SkXfermode.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698