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

Side by Side Diff: include/gpu/GrFragmentProcessor.h

Issue 1298233002: Added fNumTransformsExclChildren and fNumTexturesExclChildren; changed emitChild() to forward search (Closed) Base URL: https://skia.googlesource.com/skia@cs3_emitchild
Patch Set: Created 5 years, 4 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 | « no previous file | include/gpu/GrProcessor.h » ('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 2014 Google Inc. 2 * Copyright 2014 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 GrFragmentProcessor_DEFINED 8 #ifndef GrFragmentProcessor_DEFINED
9 #define GrFragmentProcessor_DEFINED 9 #define GrFragmentProcessor_DEFINED
10 10
11 #include "GrProcessor.h" 11 #include "GrProcessor.h"
12 #include "GrStagedProcessor.h" 12 #include "GrStagedProcessor.h"
13 13
14 class GrCoordTransform; 14 class GrCoordTransform;
15 class GrGLSLCaps; 15 class GrGLSLCaps;
16 class GrGLFragmentProcessor; 16 class GrGLFragmentProcessor;
17 class GrProcessorKeyBuilder; 17 class GrProcessorKeyBuilder;
18 18
19 /** Provides custom fragment shader code. Fragment processors receive an input c olor (vec4f) and 19 /** Provides custom fragment shader code. Fragment processors receive an input c olor (vec4f) and
20 produce an output color. They may reference textures and uniforms. They may use 20 produce an output color. They may reference textures and uniforms. They may use
21 GrCoordTransforms to receive a transformation of the local coordinates that map from local space 21 GrCoordTransforms to receive a transformation of the local coordinates that map from local space
22 to the fragment being processed. 22 to the fragment being processed.
23 */ 23 */
24 class GrFragmentProcessor : public GrProcessor { 24 class GrFragmentProcessor : public GrProcessor {
25 public: 25 public:
26 GrFragmentProcessor() 26 GrFragmentProcessor()
27 : INHERITED() 27 : INHERITED()
28 , fUsesLocalCoords(false) {} 28 , fUsesLocalCoords(false)
29 , fNumTexturesExclChildren(0)
30 , fNumTransformsExclChildren(0) {}
29 31
30 GrGLFragmentProcessor* createGLInstance() const; 32 GrGLFragmentProcessor* createGLInstance() const;
31 33
32 /** Human-meaningful string to identify this GrFragmentProcessor; may be emb edded 34 /** Human-meaningful string to identify this GrFragmentProcessor; may be emb edded
33 in generated shader code. */ 35 in generated shader code. */
34 virtual const char* name() const = 0; 36 virtual const char* name() const = 0;
35 37
36 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con st { 38 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con st {
37 this->onGetGLProcessorKey(caps, b); 39 this->onGetGLProcessorKey(caps, b);
38 for (int i = 0; i < fChildProcessors.count(); ++i) { 40 for (int i = 0; i < fChildProcessors.count(); ++i) {
39 fChildProcessors[i].processor()->getGLProcessorKey(caps, b); 41 fChildProcessors[i].processor()->getGLProcessorKey(caps, b);
40 } 42 }
41 } 43 }
42 44
45 int numTexturesExclChildren() const { return fNumTexturesExclChildren; }
tomhudson 2015/08/18 19:36:11 nit: abbreviation in API smells bad - but I can un
bsalomon 2015/08/19 14:22:17 Nonrecursive? I can't come up with anything I rea
46
47 int numTransformsExclChildren() const { return fNumTransformsExclChildren; }
48
43 int numTransforms() const { return fCoordTransforms.count(); } 49 int numTransforms() const { return fCoordTransforms.count(); }
44 50
45 /** Returns the coordinate transformation at index. index must be valid acco rding to 51 /** Returns the coordinate transformation at index. index must be valid acco rding to
46 numTransforms(). */ 52 numTransforms(). */
47 const GrCoordTransform& coordTransform(int index) const { return *fCoordTran sforms[index]; } 53 const GrCoordTransform& coordTransform(int index) const { return *fCoordTran sforms[index]; }
48 54
49 const SkTArray<const GrCoordTransform*, true>& coordTransforms() const { 55 const SkTArray<const GrCoordTransform*, true>& coordTransforms() const {
50 return fCoordTransforms; 56 return fCoordTransforms;
51 } 57 }
52 58
(...skipping 24 matching lines...) Expand all
77 * This function is used to perform optimizations. When called the invarient Ouput param 83 * This function is used to perform optimizations. When called the invarient Ouput param
78 * indicate whether the input components to this processor in the FS will ha ve known values. 84 * indicate whether the input components to this processor in the FS will ha ve known values.
79 * In inout the validFlags member is a bitfield of GrColorComponentFlags. Th e isSingleComponent 85 * In inout the validFlags member is a bitfield of GrColorComponentFlags. Th e isSingleComponent
80 * member indicates whether the input will be 1 or 4 bytes. The function upd ates the members of 86 * member indicates whether the input will be 1 or 4 bytes. The function upd ates the members of
81 * inout to indicate known values of its output. A component of the color me mber only has 87 * inout to indicate known values of its output. A component of the color me mber only has
82 * meaning if the corresponding bit in validFlags is set. 88 * meaning if the corresponding bit in validFlags is set.
83 */ 89 */
84 void computeInvariantOutput(GrInvariantOutput* inout) const; 90 void computeInvariantOutput(GrInvariantOutput* inout) const;
85 91
86 protected: 92 protected:
93 void addTextureAccess(const GrTextureAccess* textureAccess) override;
94
87 /** 95 /**
88 * Fragment Processor subclasses call this from their constructor to registe r coordinate 96 * Fragment Processor subclasses call this from their constructor to registe r coordinate
89 * transformations. Coord transforms provide a mechanism for a processor to receive coordinates 97 * transformations. Coord transforms provide a mechanism for a processor to receive coordinates
90 * in their FS code. The matrix expresses a transformation from local space. For a given 98 * in their FS code. The matrix expresses a transformation from local space. For a given
91 * fragment the matrix will be applied to the local coordinate that maps to the fragment. 99 * fragment the matrix will be applied to the local coordinate that maps to the fragment.
92 * 100 *
93 * When the transformation has perspective, the transformed coordinates will have 101 * When the transformation has perspective, the transformed coordinates will have
94 * 3 components. Otherwise they'll have 2. 102 * 3 components. Otherwise they'll have 2.
95 * 103 *
96 * This must only be called from the constructor because GrProcessors are im mutable. The 104 * This must only be called from the constructor because GrProcessors are im mutable. The
97 * processor subclass manages the lifetime of the transformations (this func tion only stores a 105 * processor subclass manages the lifetime of the transformations (this func tion only stores a
98 * pointer). The GrCoordTransform is typically a member field of the GrProce ssor subclass. 106 * pointer). The GrCoordTransform is typically a member field of the GrProce ssor subclass.
99 * 107 *
100 * A processor subclass that has multiple methods of construction should alw ays add its coord 108 * A processor subclass that has multiple methods of construction should alw ays add its coord
101 * transforms in a consistent order. The non-virtual implementation of isEqu al() automatically 109 * transforms in a consistent order. The non-virtual implementation of isEqu al() automatically
102 * compares transforms and will assume they line up across the two processor instances. 110 * compares transforms and will assume they line up across the two processor instances.
103 */ 111 */
104 void addCoordTransform(const GrCoordTransform*); 112 void addCoordTransform(const GrCoordTransform*);
105 113
106 /** 114 /**
107 * FragmentProcessor subclasses call this from their constructor to register any child 115 * FragmentProcessor subclasses call this from their constructor to register any child
108 * FragmentProcessors they have. 116 * FragmentProcessors they have. This must be called AFTER all texture acces ses and coord
117 * transforms have been added.
109 * This is for processors whose shader code will be composed of nested proce ssors whose output 118 * This is for processors whose shader code will be composed of nested proce ssors whose output
110 * colors will be combined somehow to produce its output color. Registering these child 119 * colors will be combined somehow to produce its output color. Registering these child
111 * processors will allow the ProgramBuilder to automatically handle their tr ansformed coords and 120 * processors will allow the ProgramBuilder to automatically handle their tr ansformed coords and
112 * texture accesses and mangle their uniform and output color names. 121 * texture accesses and mangle their uniform and output color names.
113 */ 122 */
114 int registerChildProcessor(const GrFragmentProcessor* child); 123 int registerChildProcessor(const GrFragmentProcessor* child);
115 124
116 /** 125 /**
117 * Subclass implements this to support getConstantColorComponents(...). 126 * Subclass implements this to support getConstantColorComponents(...).
118 * 127 *
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 * [b1,b2,c1] [d1,e1,e2,e3,f1,f2] 170 * [b1,b2,c1] [d1,e1,e2,e3,f1,f2]
162 * / / \ 171 * / / \
163 * / / \ 172 * / / \
164 * (C) (E) (F) 173 * (C) (E) (F)
165 * [c1] [e1,e2,e3] [f1,f2] 174 * [c1] [e1,e2,e3] [f1,f2]
166 * 175 *
167 * The same goes for fTextureAccesses with textures. 176 * The same goes for fTextureAccesses with textures.
168 */ 177 */
169 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; 178 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
170 179
180 int fNumTexturesExclChildren;
181 int fNumTransformsExclChildren;
182
171 SkTArray<GrFragmentStage, false> fChildProcessors; 183 SkTArray<GrFragmentStage, false> fChildProcessors;
172 184
173 typedef GrProcessor INHERITED; 185 typedef GrProcessor INHERITED;
174 }; 186 };
175 187
176 #endif 188 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698