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

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

Issue 978713002: Add constant color GrFP. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix mulAlphaByKnownFourComponents Created 5 years, 9 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
« no previous file with comments | « include/gpu/SkGr.h ('k') | src/gpu/GrProcessor.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/effects/GrConstColorProcessor.h
diff --git a/include/gpu/effects/GrConstColorProcessor.h b/include/gpu/effects/GrConstColorProcessor.h
new file mode 100644
index 0000000000000000000000000000000000000000..27ee0dfd08c6ba34d65df35c769f646dc3b9f428
--- /dev/null
+++ b/include/gpu/effects/GrConstColorProcessor.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 outputs a constant color. It may do one of the
+ * following with its input color: ignore it, or multiply it by the constant color, multiply its
+ * alpha by the constant color and ignore the input color's r, g, and b.
+ */
+class GrConstColorProcessor : public GrFragmentProcessor {
+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(GrConstColorProcessor, (color, mode));
+ }
+
+ ~GrConstColorProcessor() override {}
+
+ const char* name() const override { return "Color"; }
+
+ void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const override;
+
+ GrGLFragmentProcessor* createGLInstance() const override;
+
+ GrColor color() const { return fColor; }
+
+ InputMode inputMode() const { return fMode; }
+
+private:
+ GrConstColorProcessor(GrColor color, InputMode mode) : fColor(color), fMode(mode) {
+ this->initClassID<GrConstColorProcessor>();
+ }
+
+ bool onIsEqual(const GrFragmentProcessor&) const override;
+
+ void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
+
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
+
+ GrColor fColor;
+ InputMode fMode;
+
+ typedef GrFragmentProcessor INHERITED;
+};
+
+#endif
« no previous file with comments | « include/gpu/SkGr.h ('k') | src/gpu/GrProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698