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

Unified Diff: include/gpu/effects/GrColorProcessor.h

Issue 978713002: Add constant color GrFP. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 5 years, 10 months 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/effects/GrColorProcessor.h
diff --git a/include/gpu/effects/GrColorProcessor.h b/include/gpu/effects/GrColorProcessor.h
new file mode 100644
index 0000000000000000000000000000000000000000..86bb58196ca7161a919989dffa6d50e24a41436a
--- /dev/null
+++ b/include/gpu/effects/GrColorProcessor.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrColorProcessor_DEFINED
+#define GrColorProcessor_DEFINED
+
+#include "GrFragmentProcessor.h"
+
+class GrInvariantOutput;
+
+/**
+ * This is a simple GrFragmentProcessor that simply outputs a constant color. It may do one of the
egdaniel 2015/03/04 20:22:34 maybe "This is a simple GrFragmentProcessor that s
bsalomon 2015/03/31 19:33:42 Done. :)
+ * following with its input color: ignore it, multiply it by the constant color, multiply its alpha
egdaniel 2015/03/04 20:22:34 , or multiply
bsalomon 2015/03/31 19:33:42 Done.
+ * by the constant color and ignore the input color's r, g, and b.
+ */
+class GrColorProcessor : public GrFragmentProcessor {
egdaniel 2015/03/04 20:22:34 Can we call this GrContColorProcessor, or somethin
bsalomon 2015/03/31 19:33:42 Done.
+public:
+ enum InputMode {
+ kIgnore_InputMode,
+ kModulateRGBA_InputMode,
+ kModulateA_InputMode,
+
+ kLastInputMode = kModulateA_InputMode
+ };
+ static const int kInputModeCnt = kLastInputMode + 1;
+
+ static GrFragmentProcessor* Create(GrColor color, InputMode mode) {
+ return SkNEW_ARGS(GrColorProcessor, (color, mode));
+ }
+
+ ~GrColorProcessor() SK_OVERRIDE {}
+
+ const char* name() const SK_OVERRIDE { return "Color"; }
+
+ void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
+
+ GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
+
+ GrColor color() const { return fColor; }
+
+ InputMode inputMode() const { return fMode; }
+
+private:
+ GrColorProcessor(GrColor color, InputMode mode) : fColor(color), fMode(mode) {
+ this->initClassID<GrColorProcessor>();
+ }
+
+ bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE;
+
+ void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE;
+
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
+
+ GrColor fColor;
+ InputMode fMode;
+
+ typedef GrFragmentProcessor INHERITED;
+};
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698