OLD | NEW |
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 "GrTexture.h" | 13 #include "GrProgramElement.h" |
14 #include "GrTextureAccess.h" | 14 #include "GrTextureAccess.h" |
15 #include "GrTypesPriv.h" | 15 #include "GrTypesPriv.h" |
16 | 16 |
17 class GrBackendEffectFactory; | 17 class GrBackendEffectFactory; |
18 class GrContext; | 18 class GrContext; |
19 class GrCoordTransform; | 19 class GrCoordTransform; |
20 class GrEffect; | 20 |
21 class GrVertexEffect; | |
22 class SkString; | |
23 | 21 |
24 /** Provides custom vertex shader, fragment shader, uniform data for a particula
r stage of the | 22 /** Provides custom vertex shader, fragment shader, uniform data for a particula
r stage of the |
25 Ganesh shading pipeline. | 23 Ganesh shading pipeline. |
26 Subclasses must have a function that produces a human-readable name: | 24 Subclasses must have a function that produces a human-readable name: |
27 static const char* Name(); | 25 static const char* Name(); |
28 GrEffect objects *must* be immutable: after being constructed, their fields
may not change. | 26 GrEffect objects *must* be immutable: after being constructed, their fields
may not change. |
29 | 27 |
30 Dynamically allocated GrEffects are managed by a per-thread memory pool. The
ref count of an | 28 Dynamically allocated GrEffects are managed by a per-thread memory pool. The
ref count of an |
31 effect must reach 0 before the thread terminates and the pool is destroyed.
To create a static | 29 effect must reach 0 before the thread terminates and the pool is destroyed.
To create a static |
32 effect use the macro GR_CREATE_STATIC_EFFECT declared below. | 30 effect use the macro GR_CREATE_STATIC_EFFECT declared below. |
33 */ | 31 */ |
34 class GrEffect : public SkRefCnt { | 32 class GrEffect : public GrProgramElement { |
35 public: | 33 public: |
36 SK_DECLARE_INST_COUNT(GrEffect) | 34 SK_DECLARE_INST_COUNT(GrEffect) |
37 | 35 |
38 virtual ~GrEffect(); | 36 virtual ~GrEffect(); |
39 | 37 |
40 /** | 38 /** |
41 * This function is used to perform optimizations. When called the color and
validFlags params | 39 * This function is used to perform optimizations. When called the color and
validFlags params |
42 * indicate whether the input components to this effect in the FS will have
known values. | 40 * indicate whether the input components to this effect in the FS will have
known values. |
43 * validFlags is a bitfield of GrColorComponentFlags. The function updates b
oth params to | 41 * validFlags is a bitfield of GrColorComponentFlags. The function updates b
oth params to |
44 * indicate known values of its output. A component of the color param only
has meaning if the | 42 * indicate known values of its output. A component of the color param only
has meaning if the |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 friend class GrVertexEffect; // to set fRequiresVertexShader and build fVert
exAttribTypes. | 196 friend class GrVertexEffect; // to set fRequiresVertexShader and build fVert
exAttribTypes. |
199 | 197 |
200 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; | 198 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; |
201 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses; | 199 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses; |
202 SkSTArray<kMaxVertexAttribs, GrSLType, true> fVertexAttribTypes; | 200 SkSTArray<kMaxVertexAttribs, GrSLType, true> fVertexAttribTypes; |
203 bool fWillReadDstColor; | 201 bool fWillReadDstColor; |
204 bool fWillReadFragmentPosition; | 202 bool fWillReadFragmentPosition; |
205 bool fWillUseInputColor; | 203 bool fWillUseInputColor; |
206 bool fRequiresVertexShader; | 204 bool fRequiresVertexShader; |
207 | 205 |
208 typedef SkRefCnt INHERITED; | 206 typedef GrProgramElement INHERITED; |
209 }; | 207 }; |
210 | 208 |
211 /** | 209 /** |
212 * This creates an effect outside of the effect memory pool. The effect's destru
ctor will be called | 210 * This creates an effect outside of the effect memory pool. The effect's destru
ctor will be called |
213 * at global destruction time. NAME will be the name of the created GrEffect. | 211 * at global destruction time. NAME will be the name of the created GrEffect. |
214 */ | 212 */ |
215 #define GR_CREATE_STATIC_EFFECT(NAME, EFFECT_CLASS, ARGS)
\ | 213 #define GR_CREATE_STATIC_EFFECT(NAME, EFFECT_CLASS, ARGS)
\ |
216 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage;
\ | 214 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage;
\ |
217 static GrEffect* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLAS
S, ARGS); \ | 215 static GrEffect* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLAS
S, ARGS); \ |
218 static SkAutoTDestroy<GrEffect> NAME##_ad(NAME); | 216 static SkAutoTDestroy<GrEffect> NAME##_ad(NAME); |
219 | 217 |
220 | |
221 #endif | 218 #endif |
OLD | NEW |