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

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

Issue 1428543003: Create GLSL base class for ProgramDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add space Created 5 years, 1 month 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/GrGLFragmentProcessor.cpp ('k') | src/gpu/gl/GrGLGpuProgramCache.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 GrGLGeometryProcessor_DEFINED 8 #ifndef GrGLGeometryProcessor_DEFINED
9 #define GrGLGeometryProcessor_DEFINED 9 #define GrGLGeometryProcessor_DEFINED
10 10
11 #include "GrGLPrimitiveProcessor.h" 11 #include "GrGLPrimitiveProcessor.h"
12 12
13 class GrGLGPBuilder; 13 class GrGLGPBuilder;
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 GrGLGeometryProcessor : public GrGLPrimitiveProcessor { 20 class GrGLGeometryProcessor : public GrGLPrimitiveProcessor {
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 25 // By default we use the identity matrix
26 void setTransformData(const GrPrimitiveProcessor&, 26 void setTransformData(const GrPrimitiveProcessor&,
27 const GrGLProgramDataManager& pdman, 27 const GrGLSLProgramDataManager& pdman,
28 int index, 28 int index,
29 const SkTArray<const GrCoordTransform*, true>& transfo rms) override { 29 const SkTArray<const GrCoordTransform*, true>& transfo rms) override {
30 this->setTransformDataMatrix(SkMatrix::I(), pdman, index, transforms); 30 this->setTransformDataMatrix(SkMatrix::I(), pdman, index, transforms);
31 } 31 }
32 32
33 // A helper which subclasses can use if needed 33 // A helper which subclasses can use if needed
34 template <class GeometryProcessor> 34 template <class GeometryProcessor>
35 void setTransformDataHelper(const GrPrimitiveProcessor& primProc, 35 void setTransformDataHelper(const GrPrimitiveProcessor& primProc,
36 const GrGLProgramDataManager& pdman, 36 const GrGLSLProgramDataManager& pdman,
37 int index, 37 int index,
38 const SkTArray<const GrCoordTransform*, true>& t ransforms) { 38 const SkTArray<const GrCoordTransform*, true>& t ransforms) {
39 const GeometryProcessor& gp = primProc.cast<GeometryProcessor>(); 39 const GeometryProcessor& gp = primProc.cast<GeometryProcessor>();
40 this->setTransformDataMatrix(gp.localMatrix(), pdman, index, transforms) ; 40 this->setTransformDataMatrix(gp.localMatrix(), pdman, index, transforms) ;
41 } 41 }
42 42
43 protected: 43 protected:
44 // Emit a uniform matrix for each coord transform. 44 // Emit a uniform matrix for each coord transform.
45 void emitTransforms(GrGLGPBuilder* gp, 45 void emitTransforms(GrGLGPBuilder* gp,
46 const GrShaderVar& posVar, 46 const GrShaderVar& posVar,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return 0x0; 80 return 0x0;
81 } else if (!mat.hasPerspective()) { 81 } else if (!mat.hasPerspective()) {
82 return 0x01; 82 return 0x01;
83 } else { 83 } else {
84 return 0x02; 84 return 0x02;
85 } 85 }
86 } 86 }
87 87
88 private: 88 private:
89 void setTransformDataMatrix(const SkMatrix& localMatrix, 89 void setTransformDataMatrix(const SkMatrix& localMatrix,
90 const GrGLProgramDataManager& pdman, 90 const GrGLSLProgramDataManager& pdman,
91 int index, 91 int index,
92 const SkTArray<const GrCoordTransform*, true>& t ransforms) { 92 const SkTArray<const GrCoordTransform*, true>& t ransforms) {
93 SkSTArray<2, Transform, true>& procTransforms = fInstalledTransforms[ind ex]; 93 SkSTArray<2, Transform, true>& procTransforms = fInstalledTransforms[ind ex];
94 int numTransforms = transforms.count(); 94 int numTransforms = transforms.count();
95 for (int t = 0; t < numTransforms; ++t) { 95 for (int t = 0; t < numTransforms; ++t) {
96 SkASSERT(procTransforms[t].fHandle.isValid()); 96 SkASSERT(procTransforms[t].fHandle.isValid());
97 const SkMatrix& transform = GetTransformMatrix(localMatrix, *transfo rms[t]); 97 const SkMatrix& transform = GetTransformMatrix(localMatrix, *transfo rms[t]);
98 if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) { 98 if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) {
99 pdman.setSkMatrix(procTransforms[t].fHandle.toIndex(), transform ); 99 pdman.setSkMatrix(procTransforms[t].fHandle.toIndex(), transform );
100 procTransforms[t].fCurrentValue = transform; 100 procTransforms[t].fCurrentValue = transform;
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0; 105 virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0;
106 106
107 typedef GrGLPrimitiveProcessor INHERITED; 107 typedef GrGLPrimitiveProcessor INHERITED;
108 }; 108 };
109 109
110 #endif 110 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLFragmentProcessor.cpp ('k') | src/gpu/gl/GrGLGpuProgramCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698