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

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

Issue 1259303003: Removed GrFragmentProcessor::fWillUseInputColor (Closed) Base URL: https://skia.googlesource.com/skia@master
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 | no next file » | 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 12
13 class GrCoordTransform; 13 class GrCoordTransform;
14 class GrGLSLCaps; 14 class GrGLSLCaps;
15 class GrGLFragmentProcessor; 15 class GrGLFragmentProcessor;
16 class GrProcessorKeyBuilder; 16 class GrProcessorKeyBuilder;
17 17
18 /** Provides custom fragment shader code. Fragment processors receive an input c olor (vec4f) and 18 /** Provides custom fragment shader code. Fragment processors receive an input c olor (vec4f) and
19 produce an output color. They may reference textures and uniforms. They may use 19 produce an output color. They may reference textures and uniforms. They may use
20 GrCoordTransforms to receive a transformation of the local coordinates that map from local space 20 GrCoordTransforms to receive a transformation of the local coordinates that map from local space
21 to the fragment being processed. 21 to the fragment being processed.
22 */ 22 */
23 class GrFragmentProcessor : public GrProcessor { 23 class GrFragmentProcessor : public GrProcessor {
24 public: 24 public:
25 GrFragmentProcessor() 25 GrFragmentProcessor()
26 : INHERITED() 26 : INHERITED()
27 , fWillUseInputColor(true)
28 , fUsesLocalCoords(false) {} 27 , fUsesLocalCoords(false) {}
29 28
30 /** Implemented using GLFragmentProcessor::GenKey as described in this class 's comment. */ 29 /** Implemented using GLFragmentProcessor::GenKey as described in this class 's comment. */
31 virtual void getGLProcessorKey(const GrGLSLCaps& caps, 30 virtual void getGLProcessorKey(const GrGLSLCaps& caps,
32 GrProcessorKeyBuilder* b) const = 0; 31 GrProcessorKeyBuilder* b) const = 0;
33 32
34 /** Returns a new instance of the appropriate *GL* implementation class 33 /** Returns a new instance of the appropriate *GL* implementation class
35 for the given GrFragmentProcessor; caller is responsible for deleting 34 for the given GrFragmentProcessor; caller is responsible for deleting
36 the object. */ 35 the object. */
37 virtual GrGLFragmentProcessor* createGLInstance() const = 0; 36 virtual GrGLFragmentProcessor* createGLInstance() const = 0;
38 37
39 /** Human-meaningful string to identify this GrFragmentProcessor; may be emb edded 38 /** Human-meaningful string to identify this GrFragmentProcessor; may be emb edded
40 in generated shader code. */ 39 in generated shader code. */
41 virtual const char* name() const = 0; 40 virtual const char* name() const = 0;
42 41
43 int numTransforms() const { return fCoordTransforms.count(); } 42 int numTransforms() const { return fCoordTransforms.count(); }
44 43
45 /** Returns the coordinate transformation at index. index must be valid acco rding to 44 /** Returns the coordinate transformation at index. index must be valid acco rding to
46 numTransforms(). */ 45 numTransforms(). */
47 const GrCoordTransform& coordTransform(int index) const { return *fCoordTran sforms[index]; } 46 const GrCoordTransform& coordTransform(int index) const { return *fCoordTran sforms[index]; }
48 47
49 const SkTArray<const GrCoordTransform*, true>& coordTransforms() const { 48 const SkTArray<const GrCoordTransform*, true>& coordTransforms() const {
50 return fCoordTransforms; 49 return fCoordTransforms;
51 } 50 }
52 51
53 /** Will this prceossor read the source color value? */
54 bool willUseInputColor() const { return fWillUseInputColor; }
55
56 /** Do any of the coordtransforms for this processor require local coords? * / 52 /** Do any of the coordtransforms for this processor require local coords? * /
57 bool usesLocalCoords() const { return fUsesLocalCoords; } 53 bool usesLocalCoords() const { return fUsesLocalCoords; }
58 54
59 /** Returns true if this and other processor conservatively draw identically . It can only return 55 /** Returns true if this and other processor conservatively draw identically . It can only return
60 true when the two processor are of the same subclass (i.e. they return t he same object from 56 true when the two processor are of the same subclass (i.e. they return t he same object from
61 from getFactory()). 57 from getFactory()).
62 58
63 A return value of true from isEqual() should not be used to test whether the processor would 59 A return value of true from isEqual() should not be used to test whether the processor would
64 generate the same shader code. To test for identical code generation use getGLProcessorKey*/ 60 generate the same shader code. To test for identical code generation use getGLProcessorKey*/
65 bool isEqual(const GrFragmentProcessor& that) const { 61 bool isEqual(const GrFragmentProcessor& that) const {
(...skipping 29 matching lines...) Expand all
95 * processor subclass manages the lifetime of the transformations (this func tion only stores a 91 * processor subclass manages the lifetime of the transformations (this func tion only stores a
96 * pointer). The GrCoordTransform is typically a member field of the GrProce ssor subclass. 92 * pointer). The GrCoordTransform is typically a member field of the GrProce ssor subclass.
97 * 93 *
98 * A processor subclass that has multiple methods of construction should alw ays add its coord 94 * A processor subclass that has multiple methods of construction should alw ays add its coord
99 * transforms in a consistent order. The non-virtual implementation of isEqu al() automatically 95 * transforms in a consistent order. The non-virtual implementation of isEqu al() automatically
100 * compares transforms and will assume they line up across the two processor instances. 96 * compares transforms and will assume they line up across the two processor instances.
101 */ 97 */
102 void addCoordTransform(const GrCoordTransform*); 98 void addCoordTransform(const GrCoordTransform*);
103 99
104 /** 100 /**
105 * If the prceossor will generate a result that does not depend on the input color value then it
106 * must call this function from its constructor. Otherwise, when its generat ed backend-specific
107 * code might fail during variable binding due to unused variables.
108 */
109 void setWillNotUseInputColor() { fWillUseInputColor = false; }
110
111 /**
112 * Subclass implements this to support getConstantColorComponents(...). 101 * Subclass implements this to support getConstantColorComponents(...).
113 */ 102 */
114 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; 103 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0;
115 104
116 private: 105 private:
117 /** 106 /**
118 * Subclass implements this to support isEqual(). It will only be called if it is known that 107 * Subclass implements this to support isEqual(). It will only be called if it is known that
119 * the two processors are of the same subclass (i.e. they return the same ob ject from 108 * the two processors are of the same subclass (i.e. they return the same ob ject from
120 * getFactory()). The processor subclass should not compare its coord transf orms as that will 109 * getFactory()). The processor subclass should not compare its coord transf orms as that will
121 * be performed automatically in the non-virtual isEqual(). 110 * be performed automatically in the non-virtual isEqual().
122 */ 111 */
123 virtual bool onIsEqual(const GrFragmentProcessor&) const = 0; 112 virtual bool onIsEqual(const GrFragmentProcessor&) const = 0;
124 113
125 bool hasSameTransforms(const GrFragmentProcessor&) const; 114 bool hasSameTransforms(const GrFragmentProcessor&) const;
126 115
127 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; 116 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
128 bool fWillUseInputColor;
129 bool fUsesLocalCoords; 117 bool fUsesLocalCoords;
130 118
131 typedef GrProcessor INHERITED; 119 typedef GrProcessor INHERITED;
132 }; 120 };
133 121
134 #endif 122 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698