OLD | NEW |
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 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 * Fragment Processor subclasses call this from their constructor to registe
r coordinate | 63 * Fragment Processor subclasses call this from their constructor to registe
r coordinate |
64 * transformations. The processor subclass manages the lifetime of the trans
formations (this | 64 * transformations. The processor subclass manages the lifetime of the trans
formations (this |
65 * function only stores a pointer). The GrCoordTransform is typically a memb
er field of the | 65 * function only stores a pointer). The GrCoordTransform is typically a memb
er field of the |
66 * GrProcessor subclass. When the matrix has perspective, the transformed co
ordinates will have | 66 * GrProcessor subclass. When the matrix has perspective, the transformed co
ordinates will have |
67 * 3 components. Otherwise they'll have 2. This must only be called from the
constructor because | 67 * 3 components. Otherwise they'll have 2. This must only be called from the
constructor because |
68 * GrProcessors are immutable. | 68 * GrProcessors are immutable. |
69 */ | 69 */ |
70 void addCoordTransform(const GrCoordTransform*); | 70 void addCoordTransform(const GrCoordTransform*); |
71 | 71 |
72 /** | 72 /** |
73 * If the prceossor subclass will read the destination pixel value then it m
ust call this function | 73 * If the prceossor subclass will read the destination pixel value then it m
ust call this |
74 * from its constructor. Otherwise, when its generated backend-specific prce
ossor class attempts | 74 * function from its constructor. Otherwise, when its generated backend-spec
ific prceossor class |
75 * to generate code that reads the destination pixel it will fail. | 75 * attempts to generate code that reads the destination pixel it will fail. |
76 */ | 76 */ |
77 void setWillReadDstColor() { fWillReadDstColor = true; } | 77 void setWillReadDstColor() { fWillReadDstColor = true; } |
78 | 78 |
79 /** | 79 /** |
80 * If the prceossor will generate a result that does not depend on the input
color value then it | 80 * If the prceossor will generate a result that does not depend on the input
color value then it |
81 * must call this function from its constructor. Otherwise, when its generat
ed backend-specific | 81 * must call this function from its constructor. Otherwise, when its generat
ed backend-specific |
82 * code might fail during variable binding due to unused variables. | 82 * code might fail during variable binding due to unused variables. |
83 */ | 83 */ |
84 void setWillNotUseInputColor() { fWillUseInputColor = false; } | 84 void setWillNotUseInputColor() { fWillUseInputColor = false; } |
85 | 85 |
86 private: | 86 private: |
87 /** Subclass implements this to support isEqual(). It will only be called if
it is known that | 87 /** Subclass implements this to support isEqual(). It will only be called if
it is known that |
88 the two prceossor are of the same subclass (i.e. they return the same ob
ject from | 88 the two prceossor are of the same subclass (i.e. they return the same ob
ject from |
89 getFactory()).*/ | 89 getFactory()).*/ |
90 virtual bool onIsEqual(const GrFragmentProcessor& other) const = 0; | 90 virtual bool onIsEqual(const GrFragmentProcessor& other) const = 0; |
91 | 91 |
92 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; | 92 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; |
93 bool fWillReadDstColor; | 93 bool fWillReadDstColor; |
94 bool fWillUseInputColor; | 94 bool fWillUseInputColor; |
95 | 95 |
96 typedef GrProcessor INHERITED; | 96 typedef GrProcessor INHERITED; |
97 }; | 97 }; |
98 | 98 |
99 /** | |
100 * This creates an effect outside of the effect memory pool. The effect's destru
ctor will be called | |
101 * at global destruction time. NAME will be the name of the created GrProcessor. | |
102 */ | |
103 #define GR_CREATE_STATIC_FRAGMENT_PROCESSOR(NAME, FP_CLASS, ARGS)
\ | |
104 static SkAlignedSStorage<sizeof(FP_CLASS)> g_##NAME##_Storage;
\ | |
105 static GrFragmentProcessor* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(),
FP_CLASS, ARGS); \ | |
106 static SkAutoTDestroy<GrFragmentProcessor> NAME##_ad(NAME); | |
107 | |
108 #endif | 99 #endif |
OLD | NEW |