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

Unified Diff: src/gpu/GrPathProcessor.cpp

Issue 1333423003: move GrGLPathProcessor back into GrPathProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@pathgp2
Patch Set: Created 5 years, 3 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 | « gyp/gpu.gypi ('k') | src/gpu/gl/GrGLPathProcessor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrPathProcessor.cpp
diff --git a/src/gpu/GrPathProcessor.cpp b/src/gpu/GrPathProcessor.cpp
index 3702998dd94934a77426b51d47d21dc3aec00e62..aa5095448f07d5e3c6ef676139edeb2a8ce6e875 100644
--- a/src/gpu/GrPathProcessor.cpp
+++ b/src/gpu/GrPathProcessor.cpp
@@ -7,11 +7,110 @@
#include "GrPathProcessor.h"
-#include "gl/GrGLPathProcessor.h"
#include "gl/GrGLGpu.h"
#include "glsl/GrGLSLCaps.h"
+class GrGLPathProcessor : public GrGLPrimitiveProcessor {
+public:
+ GrGLPathProcessor() : fColor(GrColor_ILLEGAL) {}
+
+ static void GenKey(const GrPathProcessor& pathProc,
+ const GrGLSLCaps&,
+ GrProcessorKeyBuilder* b) {
+ b->add32(SkToInt(pathProc.opts().readsColor()) |
+ SkToInt(pathProc.opts().readsCoverage()) << 16);
+ }
+
+ void emitCode(EmitArgs& args) override {
+ GrGLGPBuilder* pb = args.fPB;
+ GrGLFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder();
+ const GrPathProcessor& pathProc = args.fGP.cast<GrPathProcessor>();
+
+ // emit transforms
+ this->emitTransforms(args.fPB, args.fTransformsIn, args.fTransformsOut);
+
+ // Setup uniform color
+ if (pathProc.opts().readsColor()) {
+ const char* stagedLocalVarName;
+ fColorUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ kVec4f_GrSLType,
+ kDefault_GrSLPrecision,
+ "Color",
+ &stagedLocalVarName);
+ fs->codeAppendf("%s = %s;", args.fOutputColor, stagedLocalVarName);
+ }
+
+ // setup constant solid coverage
+ if (pathProc.opts().readsCoverage()) {
+ fs->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
+ }
+ }
+
+ void emitTransforms(GrGLGPBuilder* pb, const TransformsIn& tin, TransformsOut* tout) {
+ tout->push_back_n(tin.count());
+ fInstalledTransforms.push_back_n(tin.count());
+ for (int i = 0; i < tin.count(); i++) {
+ const ProcCoords& coordTransforms = tin[i];
+ fInstalledTransforms[i].push_back_n(coordTransforms.count());
+ for (int t = 0; t < coordTransforms.count(); t++) {
+ GrSLType varyingType =
+ coordTransforms[t]->getMatrix().hasPerspective() ? kVec3f_GrSLType :
+ kVec2f_GrSLType;
+
+ SkString strVaryingName("MatrixCoord");
+ strVaryingName.appendf("_%i_%i", i, t);
+ GrGLVertToFrag v(varyingType);
+ fInstalledTransforms[i][t].fHandle =
+ pb->addSeparableVarying(strVaryingName.c_str(), &v).toIndex();
+ fInstalledTransforms[i][t].fType = varyingType;
+
+ SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCoords,
+ (SkString(v.fsIn()), varyingType));
+ }
+ }
+ }
+
+ void setData(const GrGLProgramDataManager& pd, const GrPrimitiveProcessor& primProc) override {
+ const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
+ if (pathProc.opts().readsColor() && pathProc.color() != fColor) {
+ GrGLfloat c[4];
+ GrColorToRGBAFloat(pathProc.color(), c);
+ pd.set4fv(fColorUniform, 1, c);
+ fColor = pathProc.color();
+ }
+ }
+
+ void setTransformData(const GrPrimitiveProcessor& primProc,
+ const GrGLProgramDataManager& pdman,
+ int index,
+ const SkTArray<const GrCoordTransform*, true>& coordTransforms) override {
+ const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
+ SkSTArray<2, Transform, true>& transforms = fInstalledTransforms[index];
+ int numTransforms = transforms.count();
+ for (int t = 0; t < numTransforms; ++t) {
+ SkASSERT(transforms[t].fHandle.isValid());
+ const SkMatrix& transform = GetTransformMatrix(pathProc.localMatrix(),
+ *coordTransforms[t]);
+ if (transforms[t].fCurrentValue.cheapEqualTo(transform)) {
+ continue;
+ }
+ transforms[t].fCurrentValue = transform;
+
+ SkASSERT(transforms[t].fType == kVec2f_GrSLType ||
+ transforms[t].fType == kVec3f_GrSLType);
+ unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3;
+ pdman.setPathFragmentInputTransform(transforms[t].fHandle, components, transform);
+ }
+ }
+
+private:
+ UniformHandle fColorUniform;
+ GrColor fColor;
+
+ typedef GrGLPrimitiveProcessor INHERITED;
+};
+
GrPathProcessor::GrPathProcessor(GrColor color,
const GrPipelineOptimizations& opts,
const SkMatrix& viewMatrix,
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/gl/GrGLPathProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698