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

Side by Side Diff: src/gpu/gl/GrGLGeometryProcessor.h

Issue 746423007: Draft change to start pulling uniform color into GP (Closed) Base URL: https://skia.googlesource.com/skia.git@no_factories
Patch Set: cleanup Created 6 years 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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrGLGeometryProcessor_DEFINED 8 #ifndef GrGLGeometryProcessor_DEFINED
9 #define GrGLGeometryProcessor_DEFINED 9 #define GrGLGeometryProcessor_DEFINED
10 10
11 #include "GrGLProcessor.h" 11 #include "GrGLProcessor.h"
12 12
13 class GrBatchTracker; 13 class GrBatchTracker;
14 class GrGLGPBuilder; 14 class GrGLGPBuilder;
15 15
16 /** 16 /**
17 * If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, the n it must inherit 17 * If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, the n it must inherit
18 * from this class. Since paths don't have vertices, this class is only meant to be used internally 18 * from this class. Since paths don't have vertices, this class is only meant to be used internally
19 * by skia, for special cases. 19 * by skia, for special cases.
20 */ 20 */
21 class GrGLGeometryProcessor { 21 class GrGLGeometryProcessor {
22 public: 22 public:
23 GrGLGeometryProcessor() {} 23 GrGLGeometryProcessor() {}
24 virtual ~GrGLGeometryProcessor() {} 24 virtual ~GrGLGeometryProcessor() {}
25 25
26 typedef GrGLProgramDataManager::UniformHandle UniformHandle;
26 typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; 27 typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
28
27 struct EmitArgs { 29 struct EmitArgs {
28 EmitArgs(GrGLGPBuilder* pb, 30 EmitArgs(GrGLGPBuilder* pb,
29 const GrGeometryProcessor& gp, 31 const GrGeometryProcessor& gp,
30 const GrBatchTracker& bt, 32 const GrBatchTracker& bt,
31 const char* outputColor, 33 const char* outputColor,
32 const char* outputCoverage, 34 const char* outputCoverage,
33 const TextureSamplerArray& samplers) 35 const TextureSamplerArray& samplers)
34 : fPB(pb) 36 : fPB(pb)
35 , fGP(gp) 37 , fGP(gp)
36 , fBT(bt) 38 , fBT(bt)
37 , fOutputColor(outputColor) 39 , fOutputColor(outputColor)
38 , fOutputCoverage(outputCoverage) 40 , fOutputCoverage(outputCoverage)
39 , fSamplers(samplers) {} 41 , fSamplers(samplers) {}
40 GrGLGPBuilder* fPB; 42 GrGLGPBuilder* fPB;
41 const GrGeometryProcessor& fGP; 43 const GrGeometryProcessor& fGP;
42 const GrBatchTracker& fBT; 44 const GrBatchTracker& fBT;
43 const char* fOutputColor; 45 const char* fOutputColor;
44 const char* fOutputCoverage; 46 const char* fOutputCoverage;
45 const TextureSamplerArray& fSamplers; 47 const TextureSamplerArray& fSamplers;
46 }; 48 };
49
47 /** 50 /**
48 * This is similar to emitCode() in the base class, except it takes a full s hader builder. 51 * This is similar to emitCode() in the base class, except it takes a full s hader builder.
49 * This allows the effect subclass to emit vertex code. 52 * This allows the effect subclass to emit vertex code.
50 */ 53 */
51 virtual void emitCode(const EmitArgs&) = 0; 54 virtual void emitCode(const EmitArgs&) = 0;
52 55
53 /** A GrGLGeometryProcessor instance can be reused with any GrGLGeometryProc essor that produces 56 /** A GrGLGeometryProcessor instance can be reused with any GrGLGeometryProc essor that produces
54 the same stage key; this function reads data from a GrGLGeometryProcesso r and uploads any 57 the same stage key; this function reads data from a GrGLGeometryProcesso r and uploads any
55 uniform variables required by the shaders created in emitCode(). The Gr GeometryProcessor 58 uniform variables required by the shaders created in emitCode(). The Gr GeometryProcessor
56 parameter is guaranteed to be of the same type that created this GrGLGeo metryProcessor and 59 parameter is guaranteed to be of the same type that created this GrGLGeo metryProcessor and
57 to have an identical processor key as the one that created this GrGLGeom etryProcessor. */ 60 to have an identical processor key as the one that created this GrGLGeom etryProcessor. */
58 virtual void setData(const GrGLProgramDataManager&, 61 virtual void setData(const GrGLProgramDataManager&,
59 const GrGeometryProcessor&, 62 const GrGeometryProcessor&,
60 const GrBatchTracker&) = 0; 63 const GrBatchTracker&) = 0;
61 64
65 /* a helper for uploading uniform color */
bsalomon 2014/12/12 14:29:35 should these helpers be protected? Could use some
66 void setUniformColorIfRequired(const GrGLProgramDataManager& pdman, GPInput output,
bsalomon 2014/12/12 14:29:35 ..., GPInput output, ... head explodes
67 GrColor color, UniformHandle colorUniform) {
68 if (kUniform_GPInput == output) {
69 GrGLfloat c[4];
70 GrColorToRGBAFloat(color, c);
71 pdman.set4fv(colorUniform, 1, c);
72 }
73 }
74
75 /* a helper which can setup vertex, constant, or uniform color depending on outputType */
76 void setupColor(GrGLGPBuilder* pb,
77 GPInput outputType,
78 const char* outputName,
79 const GrGeometryProcessor::GrAttribute* colorAttr,
80 UniformHandle* colorUniform);
62 private: 81 private:
63 typedef GrGLProcessor INHERITED; 82 typedef GrGLProcessor INHERITED;
64 }; 83 };
65 84
66 #endif 85 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698