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

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

Issue 851143003: Remove willReadDst from GrFragmentProcessor. (Closed) Base URL: https://skia.googlesource.com/skia.git@xferXP
Patch Set: Rebase Created 5 years, 11 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/GrXferProcessor.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 12
13 class GrCoordTransform; 13 class GrCoordTransform;
14 class GrGLCaps; 14 class GrGLCaps;
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 , fWillReadDstColor(false)
28 , fWillUseInputColor(true) 27 , fWillUseInputColor(true)
29 , fUsesLocalCoords(false) {} 28 , fUsesLocalCoords(false) {}
30 29
31 /** Implemented using GLFragmentProcessor::GenKey as described in this class 's comment. */ 30 /** Implemented using GLFragmentProcessor::GenKey as described in this class 's comment. */
32 virtual void getGLProcessorKey(const GrGLCaps& caps, 31 virtual void getGLProcessorKey(const GrGLCaps& caps,
33 GrProcessorKeyBuilder* b) const = 0; 32 GrProcessorKeyBuilder* b) const = 0;
34 33
35 /** Returns a new instance of the appropriate *GL* implementation class 34 /** Returns a new instance of the appropriate *GL* implementation class
36 for the given GrFragmentProcessor; caller is responsible for deleting 35 for the given GrFragmentProcessor; caller is responsible for deleting
37 the object. */ 36 the object. */
38 virtual GrGLFragmentProcessor* createGLInstance() const = 0; 37 virtual GrGLFragmentProcessor* createGLInstance() const = 0;
39 38
40 /** Human-meaningful string to identify this GrFragmentProcessor; may be emb edded 39 /** Human-meaningful string to identify this GrFragmentProcessor; may be emb edded
41 in generated shader code. */ 40 in generated shader code. */
42 virtual const char* name() const = 0; 41 virtual const char* name() const = 0;
43 42
44 int numTransforms() const { return fCoordTransforms.count(); } 43 int numTransforms() const { return fCoordTransforms.count(); }
45 44
46 /** Returns the coordinate transformation at index. index must be valid acco rding to 45 /** Returns the coordinate transformation at index. index must be valid acco rding to
47 numTransforms(). */ 46 numTransforms(). */
48 const GrCoordTransform& coordTransform(int index) const { return *fCoordTran sforms[index]; } 47 const GrCoordTransform& coordTransform(int index) const { return *fCoordTran sforms[index]; }
49 48
50 const SkTArray<const GrCoordTransform*, true>& coordTransforms() const { 49 const SkTArray<const GrCoordTransform*, true>& coordTransforms() const {
51 return fCoordTransforms; 50 return fCoordTransforms;
52 } 51 }
53 52
54 /** Will this prceossor read the destination pixel value? */
55 bool willReadDstColor() const { return fWillReadDstColor; }
56
57 /** Will this prceossor read the source color value? */ 53 /** Will this prceossor read the source color value? */
58 bool willUseInputColor() const { return fWillUseInputColor; } 54 bool willUseInputColor() const { return fWillUseInputColor; }
59 55
60 /** Do any of the coordtransforms for this processor require local coords? * / 56 /** Do any of the coordtransforms for this processor require local coords? * /
61 bool usesLocalCoords() const { return fUsesLocalCoords; } 57 bool usesLocalCoords() const { return fUsesLocalCoords; }
62 58
63 /** Returns true if this and other processor conservatively draw identically . It can only return 59 /** Returns true if this and other processor conservatively draw identically . It can only return
64 true when the two processor are of the same subclass (i.e. they return t he same object from 60 true when the two processor are of the same subclass (i.e. they return t he same object from
65 from getFactory()). 61 from getFactory()).
66 62
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 * processor subclass manages the lifetime of the transformations (this func tion only stores a 95 * processor subclass manages the lifetime of the transformations (this func tion only stores a
100 * pointer). The GrCoordTransform is typically a member field of the GrProce ssor subclass. 96 * pointer). The GrCoordTransform is typically a member field of the GrProce ssor subclass.
101 * 97 *
102 * A processor subclass that has multiple methods of construction should alw ays add its coord 98 * A processor subclass that has multiple methods of construction should alw ays add its coord
103 * transforms in a consistent order. The non-virtual implementation of isEqu al() automatically 99 * transforms in a consistent order. The non-virtual implementation of isEqu al() automatically
104 * compares transforms and will assume they line up across the two processor instances. 100 * compares transforms and will assume they line up across the two processor instances.
105 */ 101 */
106 void addCoordTransform(const GrCoordTransform*); 102 void addCoordTransform(const GrCoordTransform*);
107 103
108 /** 104 /**
109 * If the prceossor subclass will read the destination pixel value then it m ust call this
110 * function from its constructor. Otherwise, when its generated backend-spec ific prceossor class
111 * attempts to generate code that reads the destination pixel it will fail.
112 */
113 void setWillReadDstColor() { fWillReadDstColor = true; }
114
115 /**
116 * If the prceossor will generate a result that does not depend on the input color value then it 105 * If the prceossor will generate a result that does not depend on the input color value then it
117 * must call this function from its constructor. Otherwise, when its generat ed backend-specific 106 * must call this function from its constructor. Otherwise, when its generat ed backend-specific
118 * code might fail during variable binding due to unused variables. 107 * code might fail during variable binding due to unused variables.
119 */ 108 */
120 void setWillNotUseInputColor() { fWillUseInputColor = false; } 109 void setWillNotUseInputColor() { fWillUseInputColor = false; }
121 110
122 /** 111 /**
123 * Subclass implements this to support getConstantColorComponents(...). 112 * Subclass implements this to support getConstantColorComponents(...).
124 */ 113 */
125 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; 114 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0;
126 115
127 private: 116 private:
128 /** 117 /**
129 * Subclass implements this to support isEqual(). It will only be called if it is known that 118 * Subclass implements this to support isEqual(). It will only be called if it is known that
130 * the two processors are of the same subclass (i.e. they return the same ob ject from 119 * the two processors are of the same subclass (i.e. they return the same ob ject from
131 * getFactory()). The processor subclass should not compare its coord transf orms as that will 120 * getFactory()). The processor subclass should not compare its coord transf orms as that will
132 * be performed automatically in the non-virtual isEqual(). 121 * be performed automatically in the non-virtual isEqual().
133 */ 122 */
134 virtual bool onIsEqual(const GrFragmentProcessor&) const = 0; 123 virtual bool onIsEqual(const GrFragmentProcessor&) const = 0;
135 124
136 bool hasSameTransforms(const GrFragmentProcessor&) const; 125 bool hasSameTransforms(const GrFragmentProcessor&) const;
137 126
138 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; 127 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
139 bool fWillReadDstColor;
140 bool fWillUseInputColor; 128 bool fWillUseInputColor;
141 bool fUsesLocalCoords; 129 bool fUsesLocalCoords;
142 130
143 typedef GrProcessor INHERITED; 131 typedef GrProcessor INHERITED;
144 }; 132 };
145 133
146 #endif 134 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrXferProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698