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

Unified Diff: src/gpu/GrGeometryProcessor.cpp

Issue 1404473003: Add passthrough GP for cases where no color or coverage should be emitted by GP (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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
« src/gpu/GrGeometryProcessor.h ('K') | « src/gpu/GrGeometryProcessor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrGeometryProcessor.cpp
diff --git a/src/gpu/GrGeometryProcessor.cpp b/src/gpu/GrGeometryProcessor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..26f8d9a40445705e1b555f518e2c637dc7d3cb13
--- /dev/null
+++ b/src/gpu/GrGeometryProcessor.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrGeometryProcessor.h"
+#include "gl/GrGLGeometryProcessor.h"
+#include "gl/builders/GrGLProgramBuilder.h"
+#include "gl/builders/GrGLVertexShaderBuilder.h"
+
+const GrGeometryProcessor* GrGeometryProcessor::CreatePassthroughGP(size_t vertexStride) {
+ class NullGP : public GrGeometryProcessor {
+ public:
+ NullGP(size_t vertexStride) {
+ this->initClassID<NullGP>();
+ fPosAttr = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
+ // Must call this after setting fPosAttr as that function adds 2 floats to the vertex
+ // stride.
+ SkASSERT(vertexStride >= sizeof(float) * 2);
+ fVertexStride = vertexStride;
+ }
+
+ const char* name() const override { return "Null"; }
+
+ void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {}
+
+ GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps& caps) const override {
+ class GLGP : public GrGLGeometryProcessor {
+ private:
+ void onEmitCode(EmitArgs& emitArgs, GrGPArgs* gpArgs) override {
+ SkASSERT(!emitArgs.fTransformsIn.count());
+ const NullGP& gp = emitArgs.fGP.cast<NullGP>();
+ GrGLGPBuilder* pb = emitArgs.fPB;
+ GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
+ vsBuilder->emitAttributes(gp);
+ this->setupPosition(pb, gpArgs, gp.fPosAttr->fName);
+ }
+ void setData(const GrGLProgramDataManager&, const GrPrimitiveProcessor&) override {}
+ };
+ return new GLGP();
+ }
+ private:
+ const Attribute* fPosAttr;
+ };
+ return new NullGP(vertexStride);
+}
« src/gpu/GrGeometryProcessor.h ('K') | « src/gpu/GrGeometryProcessor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698