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

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

Issue 1131513005: remove localmatrix from GrGeometryProcessor base class (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup4
Patch Set: tweaks Created 5 years, 7 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/effects/GrDistanceFieldGeoProc.cpp ('k') | src/gpu/gl/GrGLGeometryProcessor.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 void setTransformData(const GrPrimitiveProcessor&, 25 // By default we use the identity matrix
26 const GrGLProgramDataManager&, 26 virtual void setTransformData(const GrPrimitiveProcessor&,
27 int index, 27 const GrGLProgramDataManager& pdman,
28 const SkTArray<const GrCoordTransform*, true>& transfo rms); 28 int index,
29 const SkTArray<const GrCoordTransform*, true>& transforms) {
30 this->setTransformDataMatrix(SkMatrix::I(), pdman, index, transforms);
31 }
32
33 // A helper which subclasses can use if needed
34 template <class GeometryProcessor>
35 void setTransformDataHelper(const GrPrimitiveProcessor& primProc,
36 const GrGLProgramDataManager& pdman,
37 int index,
38 const SkTArray<const GrCoordTransform*, true>& t ransforms) {
39 const GeometryProcessor& gp = primProc.cast<GeometryProcessor>();
40 this->setTransformDataMatrix(gp.localMatrix(), pdman, index, transforms) ;
41 }
29 42
30 protected: 43 protected:
31 // Many GrGeometryProcessors do not need explicit local coords 44 // A helper for subclasses which don't have an explicit local matrix
32 void emitTransforms(GrGLGPBuilder* gp, 45 void emitTransforms(GrGLGPBuilder* gp,
33 const GrShaderVar& posVar, 46 const GrShaderVar& posVar,
34 const SkMatrix& localMatrix, 47 const char* localCoords,
35 const TransformsIn& tin, 48 const TransformsIn& tin,
36 TransformsOut* tout) { 49 TransformsOut* tout) {
37 this->emitTransforms(gp, posVar, posVar.c_str(), localMatrix, tin, tout) ; 50 this->emitTransforms(gp, posVar, localCoords, SkMatrix::I(), tin, tout);
38 } 51 }
39 52
40 void emitTransforms(GrGLGPBuilder*, 53 void emitTransforms(GrGLGPBuilder*,
41 const GrShaderVar& posVar, 54 const GrShaderVar& posVar,
42 const char* localCoords, 55 const char* localCoords,
43 const SkMatrix& localMatrix, 56 const SkMatrix& localMatrix,
44 const TransformsIn&, 57 const TransformsIn&,
45 TransformsOut*); 58 TransformsOut*);
46 59
47 struct GrGPArgs { 60 struct GrGPArgs {
(...skipping 12 matching lines...) Expand all
60 if (mat.isIdentity()) { 73 if (mat.isIdentity()) {
61 return 0x0; 74 return 0x0;
62 } else if (!mat.hasPerspective()) { 75 } else if (!mat.hasPerspective()) {
63 return 0x01; 76 return 0x01;
64 } else { 77 } else {
65 return 0x02; 78 return 0x02;
66 } 79 }
67 } 80 }
68 81
69 private: 82 private:
83 void setTransformDataMatrix(const SkMatrix& localMatrix,
84 const GrGLProgramDataManager& pdman,
85 int index,
86 const SkTArray<const GrCoordTransform*, true>& t ransforms) {
87 SkSTArray<2, Transform, true>& procTransforms = fInstalledTransforms[ind ex];
88 int numTransforms = transforms.count();
89 for (int t = 0; t < numTransforms; ++t) {
90 SkASSERT(procTransforms[t].fHandle.isValid());
91 const SkMatrix& transform = GetTransformMatrix(localMatrix, *transfo rms[t]);
92 if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) {
93 pdman.setSkMatrix(procTransforms[t].fHandle.convertToUniformHand le(), transform);
94 procTransforms[t].fCurrentValue = transform;
95 }
96 }
97 }
98
70 virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0; 99 virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0;
71 100
72 typedef GrGLPrimitiveProcessor INHERITED; 101 typedef GrGLPrimitiveProcessor INHERITED;
73 }; 102 };
74 103
75 #endif 104 #endif
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDistanceFieldGeoProc.cpp ('k') | src/gpu/gl/GrGLGeometryProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698