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

Side by Side Diff: src/gpu/glsl/GrGLSLGeometryProcessor.h

Issue 2339203002: Stop flattening GrCoordTransforms in parent GrFragmentProcessors. (Closed)
Patch Set: Fix issue of taking ref to a temporary Created 4 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 unified diff | Download patch
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentProcessor.cpp ('k') | src/gpu/glsl/GrGLSLGeometryProcessor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 GrGLSLGeometryProcessor_DEFINED 8 #ifndef GrGLSLGeometryProcessor_DEFINED
9 #define GrGLSLGeometryProcessor_DEFINED 9 #define GrGLSLGeometryProcessor_DEFINED
10 10
11 #include "GrGLSLPrimitiveProcessor.h" 11 #include "GrGLSLPrimitiveProcessor.h"
12 12
13 class GrGLSLGPBuilder; 13 class GrGLSLGPBuilder;
14 14
15 /** 15 /**
16 * If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, the n it must inherit 16 * If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, the n it must inherit
17 * from this class. Since paths don't have vertices, this class is only meant to be used internally 17 * from this class. Since paths don't have vertices, this class is only meant to be used internally
18 * by skia, for special cases. 18 * by skia, for special cases.
19 */ 19 */
20 class GrGLSLGeometryProcessor : public GrGLSLPrimitiveProcessor { 20 class GrGLSLGeometryProcessor : public GrGLSLPrimitiveProcessor {
21 public: 21 public:
22 /* Any general emit code goes in the base class emitCode. Subclasses overri de onEmitCode */ 22 /* Any general emit code goes in the base class emitCode. Subclasses overri de onEmitCode */
23 void emitCode(EmitArgs&) override; 23 void emitCode(EmitArgs&) override;
24 24
25 // By default we use the identity matrix
26 void setTransformData(const GrPrimitiveProcessor&,
27 const GrGLSLProgramDataManager& pdman,
28 int index,
29 const SkTArray<const GrCoordTransform*, true>& transfo rms) override {
30 this->setTransformDataHelper(SkMatrix::I(), pdman, index, transforms);
31 }
32
33 protected: 25 protected:
34 // A helper which subclasses can use if needed and used above in the default setTransformData(). 26 // A helper which subclasses can use if needed and used above in the default setTransformData().
35 void setTransformDataHelper(const SkMatrix& localMatrix, 27 void setTransformDataHelper(const SkMatrix& localMatrix,
36 const GrGLSLProgramDataManager& pdman, 28 const GrGLSLProgramDataManager& pdman,
37 int index, 29 FPCoordTransformIter*);
38 const SkTArray<const GrCoordTransform*, true>& t ransforms) {
39 SkTArray<TransformUniform, true>& procTransforms = fInstalledTransforms[ index];
40 int numTransforms = transforms.count();
41 for (int t = 0; t < numTransforms; ++t) {
42 SkASSERT(procTransforms[t].fHandle.isValid());
43 const SkMatrix& transform = GetTransformMatrix(localMatrix, *transfo rms[t]);
44 if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) {
45 pdman.setSkMatrix(procTransforms[t].fHandle.toIndex(), transform );
46 procTransforms[t].fCurrentValue = transform;
47 }
48 }
49 }
50 30
51 // Emit a uniform matrix for each coord transform. 31 // Emit a uniform matrix for each coord transform.
52 void emitTransforms(GrGLSLVertexBuilder* vb, 32 void emitTransforms(GrGLSLVertexBuilder* vb,
53 GrGLSLVaryingHandler* varyingHandler, 33 GrGLSLVaryingHandler* varyingHandler,
54 GrGLSLUniformHandler* uniformHandler, 34 GrGLSLUniformHandler* uniformHandler,
55 const GrShaderVar& posVar, 35 const GrShaderVar& posVar,
56 const char* localCoords, 36 const char* localCoords,
57 const TransformsIn& tin, 37 FPCoordTransformHandler* handler) {
58 TransformsOut* tout) {
59 this->emitTransforms(vb, varyingHandler, uniformHandler, 38 this->emitTransforms(vb, varyingHandler, uniformHandler,
60 posVar, localCoords, SkMatrix::I(), tin, tout); 39 posVar, localCoords, SkMatrix::I(), handler);
61 } 40 }
62 41
63 // Emit pre-transformed coords as a vertex attribute per coord-transform. 42 // Emit pre-transformed coords as a vertex attribute per coord-transform.
64 void emitTransforms(GrGLSLVertexBuilder*, 43 void emitTransforms(GrGLSLVertexBuilder*,
65 GrGLSLVaryingHandler*, 44 GrGLSLVaryingHandler*,
66 GrGLSLUniformHandler*, 45 GrGLSLUniformHandler*,
67 const GrShaderVar& posVar, 46 const GrShaderVar& posVar,
68 const char* localCoords, 47 const char* localCoords,
69 const SkMatrix& localMatrix, 48 const SkMatrix& localMatrix,
70 const TransformsIn&, 49 FPCoordTransformHandler*);
71 TransformsOut*);
72 50
73 struct GrGPArgs { 51 struct GrGPArgs {
74 // The variable used by a GP to store its position. It can be 52 // The variable used by a GP to store its position. It can be
75 // either a vec2 or a vec3 depending on the presence of perspective. 53 // either a vec2 or a vec3 depending on the presence of perspective.
76 GrShaderVar fPositionVar; 54 GrShaderVar fPositionVar;
77 }; 55 };
78 56
79 // Create the correct type of position variable given the CTM 57 // Create the correct type of position variable given the CTM
80 void setupPosition(GrGLSLVertexBuilder*, GrGPArgs*, const char* posName); 58 void setupPosition(GrGLSLVertexBuilder*, GrGPArgs*, const char* posName);
81 void setupPosition(GrGLSLVertexBuilder*, 59 void setupPosition(GrGLSLVertexBuilder*,
(...skipping 14 matching lines...) Expand all
96 } 74 }
97 75
98 private: 76 private:
99 virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0; 77 virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0;
100 78
101 struct TransformUniform { 79 struct TransformUniform {
102 UniformHandle fHandle; 80 UniformHandle fHandle;
103 SkMatrix fCurrentValue = SkMatrix::InvalidMatrix(); 81 SkMatrix fCurrentValue = SkMatrix::InvalidMatrix();
104 }; 82 };
105 83
106 SkSTArray<8, SkSTArray<2, TransformUniform, true> > fInstalledTransforms; 84 SkTArray<TransformUniform, true> fInstalledTransforms;
107 85
108 typedef GrGLSLPrimitiveProcessor INHERITED; 86 typedef GrGLSLPrimitiveProcessor INHERITED;
109 }; 87 };
110 88
111 #endif 89 #endif
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentProcessor.cpp ('k') | src/gpu/glsl/GrGLSLGeometryProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698