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

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

Issue 543623004: Removing vertex attrib indices (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 6 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 GrEffect_DEFINED 8 #ifndef GrEffect_DEFINED
9 #define GrEffect_DEFINED 9 #define GrEffect_DEFINED
10 10
11 #include "GrColor.h" 11 #include "GrColor.h"
12 #include "GrEffectUnitTest.h" 12 #include "GrEffectUnitTest.h"
13 #include "GrProgramElement.h" 13 #include "GrProgramElement.h"
14 #include "GrShaderVar.h"
14 #include "GrTextureAccess.h" 15 #include "GrTextureAccess.h"
15 #include "GrTypesPriv.h" 16 #include "GrTypesPriv.h"
17 #include "SkString.h"
16 18
17 class GrBackendEffectFactory; 19 class GrBackendEffectFactory;
18 class GrContext; 20 class GrContext;
19 class GrCoordTransform; 21 class GrCoordTransform;
20 22
21
22 /** Provides custom vertex shader, fragment shader, uniform data for a particula r stage of the 23 /** Provides custom vertex shader, fragment shader, uniform data for a particula r stage of the
23 Ganesh shading pipeline. 24 Ganesh shading pipeline.
24 Subclasses must have a function that produces a human-readable name: 25 Subclasses must have a function that produces a human-readable name:
25 static const char* Name(); 26 static const char* Name();
26 GrEffect objects *must* be immutable: after being constructed, their fields may not change. 27 GrEffect objects *must* be immutable: after being constructed, their fields may not change.
27 28
28 Dynamically allocated GrEffects are managed by a per-thread memory pool. The ref count of an 29 Dynamically allocated GrEffects are managed by a per-thread memory pool. The ref count of an
29 effect must reach 0 before the thread terminates and the pool is destroyed. To create a static 30 effect must reach 0 before the thread terminates and the pool is destroyed. To create a static
30 effect use the macro GR_CREATE_STATIC_EFFECT declared below. 31 effect use the macro GR_CREATE_STATIC_EFFECT declared below.
31 */ 32 */
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 /** Will this effect read the destination pixel value? */ 108 /** Will this effect read the destination pixel value? */
108 bool willReadDstColor() const { return fWillReadDstColor; } 109 bool willReadDstColor() const { return fWillReadDstColor; }
109 110
110 /** Will this effect read the fragment position? */ 111 /** Will this effect read the fragment position? */
111 bool willReadFragmentPosition() const { return fWillReadFragmentPosition; } 112 bool willReadFragmentPosition() const { return fWillReadFragmentPosition; }
112 113
113 /** Will this effect emit custom vertex shader code? 114 /** Will this effect emit custom vertex shader code?
114 (To set this value the effect must inherit from GrEffect.) */ 115 (To set this value the effect must inherit from GrEffect.) */
115 bool requiresVertexShader() const { return fRequiresVertexShader; } 116 bool requiresVertexShader() const { return fRequiresVertexShader; }
116 117
117 int numVertexAttribs() const { 118 static const int kMaxVertexAttribs = 2;
118 SkASSERT(0 == fVertexAttribTypes.count() || fRequiresVertexShader); 119 typedef SkSTArray<kMaxVertexAttribs, GrShaderVar, true> VertexAttribArray;
119 return fVertexAttribTypes.count();
120 }
121 120
122 GrSLType vertexAttribType(int index) const { return fVertexAttribTypes[index ]; } 121 const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; }
123
124 static const int kMaxVertexAttribs = 2;
125 122
126 void* operator new(size_t size); 123 void* operator new(size_t size);
127 void operator delete(void* target); 124 void operator delete(void* target);
128 125
129 void* operator new(size_t size, void* placement) { 126 void* operator new(size_t size, void* placement) {
130 return ::operator new(size, placement); 127 return ::operator new(size, placement);
131 } 128 }
132 void operator delete(void* target, void* placement) { 129 void operator delete(void* target, void* placement) {
133 ::operator delete(target, placement); 130 ::operator delete(target, placement);
134 } 131 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 void setWillNotUseInputColor() { fWillUseInputColor = false; } 183 void setWillNotUseInputColor() { fWillUseInputColor = false; }
187 184
188 private: 185 private:
189 SkDEBUGCODE(void assertEquality(const GrEffect& other) const;) 186 SkDEBUGCODE(void assertEquality(const GrEffect& other) const;)
190 187
191 /** Subclass implements this to support isEqual(). It will only be called if it is known that 188 /** Subclass implements this to support isEqual(). It will only be called if it is known that
192 the two effects are of the same subclass (i.e. they return the same obje ct from 189 the two effects are of the same subclass (i.e. they return the same obje ct from
193 getFactory()).*/ 190 getFactory()).*/
194 virtual bool onIsEqual(const GrEffect& other) const = 0; 191 virtual bool onIsEqual(const GrEffect& other) const = 0;
195 192
196 friend class GrVertexEffect; // to set fRequiresVertexShader and build fVert exAttribTypes. 193 friend class GrGeometryProcessor; // to set fRequiresVertexShader and build fVertexAttribTypes.
197 194
198 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; 195 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
199 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses; 196 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses;
200 SkSTArray<kMaxVertexAttribs, GrSLType, true> fVertexAttribTypes; 197 VertexAttribArray fVertexAttribs;
201 bool fWillReadDstColor; 198 bool fWillReadDstColor;
202 bool fWillReadFragmentPosition; 199 bool fWillReadFragmentPosition;
203 bool fWillUseInputColor; 200 bool fWillUseInputColor;
204 bool fRequiresVertexShader; 201 bool fRequiresVertexShader;
205 202
206 typedef GrProgramElement INHERITED; 203 typedef GrProgramElement INHERITED;
207 }; 204 };
208 205
209 /** 206 /**
210 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called 207 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called
211 * at global destruction time. NAME will be the name of the created GrEffect. 208 * at global destruction time. NAME will be the name of the created GrEffect.
212 */ 209 */
213 #define GR_CREATE_STATIC_EFFECT(NAME, EFFECT_CLASS, ARGS) \ 210 #define GR_CREATE_STATIC_EFFECT(NAME, EFFECT_CLASS, ARGS) \
214 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage; \ 211 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage; \
215 static GrEffect* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLAS S, ARGS); \ 212 static GrEffect* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLAS S, ARGS); \
216 static SkAutoTDestroy<GrEffect> NAME##_ad(NAME); 213 static SkAutoTDestroy<GrEffect> NAME##_ad(NAME);
217 214
218 #endif 215 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698