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

Side by Side Diff: src/gpu/gl/GrGLPathProcessor.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 unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLPathProcessor.h ('k') | src/gpu/gl/GrGLProgram.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrGLPathProcessor.h"
9
10 #include "GrPathProcessor.h"
11 #include "GrGLGpu.h"
12 #include "GrGLPathRendering.h"
13
14 GrGLPathProcessor::GrGLPathProcessor()
15 : fColor(GrColor_ILLEGAL) {}
16
17 void GrGLPathProcessor::emitCode(EmitArgs& args) {
18 GrGLGPBuilder* pb = args.fPB;
19 GrGLFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder();
20 const GrPathProcessor& pathProc = args.fGP.cast<GrPathProcessor>();
21
22 // emit transforms
23 this->emitTransforms(args.fPB, args.fTransformsIn, args.fTransformsOut);
24
25 // Setup uniform color
26 if (pathProc.opts().readsColor()) {
27 const char* stagedLocalVarName;
28 fColorUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
29 kVec4f_GrSLType,
30 kDefault_GrSLPrecision,
31 "Color",
32 &stagedLocalVarName);
33 fs->codeAppendf("%s = %s;", args.fOutputColor, stagedLocalVarName);
34 }
35
36 // setup constant solid coverage
37 if (pathProc.opts().readsCoverage()) {
38 fs->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
39 }
40 }
41
42 void GrGLPathProcessor::GenKey(const GrPathProcessor& pathProc,
43 const GrGLSLCaps&,
44 GrProcessorKeyBuilder* b) {
45 b->add32(SkToInt(pathProc.opts().readsColor()) |
46 SkToInt(pathProc.opts().readsCoverage()) << 16);
47 }
48
49 void GrGLPathProcessor::setData(const GrGLProgramDataManager& pdman,
50 const GrPrimitiveProcessor& primProc) {
51 const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
52 if (pathProc.opts().readsColor() && pathProc.color() != fColor) {
53 GrGLfloat c[4];
54 GrColorToRGBAFloat(pathProc.color(), c);
55 pdman.set4fv(fColorUniform, 1, c);
56 fColor = pathProc.color();
57 }
58 }
59
60 void GrGLPathProcessor::emitTransforms(GrGLGPBuilder* pb, const TransformsIn& ti n,
61 TransformsOut* tout) {
62 tout->push_back_n(tin.count());
63 fInstalledTransforms.push_back_n(tin.count());
64 for (int i = 0; i < tin.count(); i++) {
65 const ProcCoords& coordTransforms = tin[i];
66 fInstalledTransforms[i].push_back_n(coordTransforms.count());
67 for (int t = 0; t < coordTransforms.count(); t++) {
68 GrSLType varyingType =
69 coordTransforms[t]->getMatrix().hasPerspective() ? kVec3f_Gr SLType :
70 kVec2f_Gr SLType;
71
72 SkString strVaryingName("MatrixCoord");
73 strVaryingName.appendf("_%i_%i", i, t);
74 GrGLVertToFrag v(varyingType);
75 fInstalledTransforms[i][t].fHandle =
76 pb->addSeparableVarying(strVaryingName.c_str(), &v).toIndex( );
77 fInstalledTransforms[i][t].fType = varyingType;
78
79 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCoords ,
80 (SkString(v.fsIn()), varyingType));
81 }
82 }
83 }
84
85 void GrGLPathProcessor::setTransformData(
86 const GrPrimitiveProcessor& primProc,
87 const GrGLProgramDataManager& pdman,
88 int index,
89 const SkTArray<const GrCoordTransform*, true>& coordTransforms) {
90 const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
91 SkSTArray<2, Transform, true>& transforms = fInstalledTransforms[index];
92 int numTransforms = transforms.count();
93 for (int t = 0; t < numTransforms; ++t) {
94 SkASSERT(transforms[t].fHandle.isValid());
95 const SkMatrix& transform = GetTransformMatrix(pathProc.localMatrix(),
96 *coordTransforms[t]);
97 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) {
98 continue;
99 }
100 transforms[t].fCurrentValue = transform;
101
102 SkASSERT(transforms[t].fType == kVec2f_GrSLType ||
103 transforms[t].fType == kVec3f_GrSLType);
104 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3;
105 pdman.setPathFragmentInputTransform(transforms[t].fHandle, components, t ransform);
106 }
107 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLPathProcessor.h ('k') | src/gpu/gl/GrGLProgram.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698