OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef GrPaint_DEFINED | 10 #ifndef GrPaint_DEFINED |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 void setColor(GrColor color) { fColor = color; } | 50 void setColor(GrColor color) { fColor = color; } |
51 GrColor getColor() const { return fColor; } | 51 GrColor getColor() const { return fColor; } |
52 | 52 |
53 /** | 53 /** |
54 * Should primitives be anti-aliased or not. Defaults to false. | 54 * Should primitives be anti-aliased or not. Defaults to false. |
55 */ | 55 */ |
56 void setAntiAlias(bool aa) { fAntiAlias = aa; } | 56 void setAntiAlias(bool aa) { fAntiAlias = aa; } |
57 bool isAntiAlias() const { return fAntiAlias; } | 57 bool isAntiAlias() const { return fAntiAlias; } |
58 | 58 |
59 const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) { | 59 const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) { |
60 fXPFactory.reset(SkRef(xpFactory)); | 60 fXPFactory.reset(SkSafeRef(xpFactory)); |
61 return xpFactory; | 61 return xpFactory; |
62 } | 62 } |
63 | 63 |
64 void setPorterDuffXPFactory(SkXfermode::Mode mode) { | 64 void setPorterDuffXPFactory(SkXfermode::Mode mode) { |
65 fXPFactory.reset(GrPorterDuffXPFactory::Create(mode)); | 65 fXPFactory.reset(GrPorterDuffXPFactory::Create(mode)); |
66 } | 66 } |
67 | 67 |
68 void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage =
false); | 68 void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage =
false); |
69 | 69 |
70 /** | 70 /** |
(...skipping 22 matching lines...) Expand all Loading... |
93 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&); | 93 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&); |
94 void addColorTextureProcessor(GrTexture*, const SkMatrix&, const GrTexturePa
rams&); | 94 void addColorTextureProcessor(GrTexture*, const SkMatrix&, const GrTexturePa
rams&); |
95 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&, const GrTextur
eParams&); | 95 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&, const GrTextur
eParams&); |
96 | 96 |
97 int numColorFragmentProcessors() const { return fColorFragmentProcessors.cou
nt(); } | 97 int numColorFragmentProcessors() const { return fColorFragmentProcessors.cou
nt(); } |
98 int numCoverageFragmentProcessors() const { return fCoverageFragmentProcesso
rs.count(); } | 98 int numCoverageFragmentProcessors() const { return fCoverageFragmentProcesso
rs.count(); } |
99 int numTotalFragmentProcessors() const { return this->numColorFragmentProces
sors() + | 99 int numTotalFragmentProcessors() const { return this->numColorFragmentProces
sors() + |
100 this->numCoverageFragmentProcessor
s(); } | 100 this->numCoverageFragmentProcessor
s(); } |
101 | 101 |
102 const GrXPFactory* getXPFactory() const { | 102 const GrXPFactory* getXPFactory() const { |
103 if (!fXPFactory) { | 103 return fXPFactory; |
104 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode
)); | |
105 } | |
106 return fXPFactory.get(); | |
107 } | 104 } |
108 | 105 |
109 const GrFragmentProcessor* getColorFragmentProcessor(int i) const { | 106 const GrFragmentProcessor* getColorFragmentProcessor(int i) const { |
110 return fColorFragmentProcessors[i]; | 107 return fColorFragmentProcessors[i]; |
111 } | 108 } |
112 const GrFragmentProcessor* getCoverageFragmentProcessor(int i) const { | 109 const GrFragmentProcessor* getCoverageFragmentProcessor(int i) const { |
113 return fCoverageFragmentProcessors[i]; | 110 return fCoverageFragmentProcessors[i]; |
114 } | 111 } |
115 | 112 |
116 GrPaint& operator=(const GrPaint& paint) { | 113 GrPaint& operator=(const GrPaint& paint) { |
117 fAntiAlias = paint.fAntiAlias; | 114 fAntiAlias = paint.fAntiAlias; |
118 | 115 |
119 fColor = paint.fColor; | 116 fColor = paint.fColor; |
120 this->resetFragmentProcessors(); | 117 this->resetFragmentProcessors(); |
121 fColorFragmentProcessors = paint.fColorFragmentProcessors; | 118 fColorFragmentProcessors = paint.fColorFragmentProcessors; |
122 fCoverageFragmentProcessors = paint.fCoverageFragmentProcessors; | 119 fCoverageFragmentProcessors = paint.fCoverageFragmentProcessors; |
123 for (int i = 0; i < fColorFragmentProcessors.count(); ++i) { | 120 for (int i = 0; i < fColorFragmentProcessors.count(); ++i) { |
124 fColorFragmentProcessors[i]->ref(); | 121 fColorFragmentProcessors[i]->ref(); |
125 } | 122 } |
126 for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) { | 123 for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) { |
127 fCoverageFragmentProcessors[i]->ref(); | 124 fCoverageFragmentProcessors[i]->ref(); |
128 } | 125 } |
129 | 126 |
130 fXPFactory.reset(SkRef(paint.getXPFactory())); | 127 fXPFactory.reset(SkSafeRef(paint.getXPFactory())); |
131 | 128 |
132 return *this; | 129 return *this; |
133 } | 130 } |
134 | 131 |
135 /** | 132 /** |
136 * Returns true if the paint's output color will be constant after blending.
If the result is | 133 * Returns true if the paint's output color will be constant after blending.
If the result is |
137 * true, constantColor will be updated to contain the constant color. Note t
hat we can conflate | 134 * true, constantColor will be updated to contain the constant color. Note t
hat we can conflate |
138 * coverage and color, so the actual values written to pixels with partial c
overage may still | 135 * coverage and color, so the actual values written to pixels with partial c
overage may still |
139 * not seem constant, even if this function returns true. | 136 * not seem constant, even if this function returns true. |
140 */ | 137 */ |
(...skipping 14 matching lines...) Expand all Loading... |
155 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; | 152 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; |
156 SkSTArray<4, const GrFragmentProcessor*, true> fColorFragmentProcessors; | 153 SkSTArray<4, const GrFragmentProcessor*, true> fColorFragmentProcessors; |
157 SkSTArray<2, const GrFragmentProcessor*, true> fCoverageFragmentProcessors; | 154 SkSTArray<2, const GrFragmentProcessor*, true> fCoverageFragmentProcessors; |
158 | 155 |
159 bool fAntiAlias; | 156 bool fAntiAlias; |
160 | 157 |
161 GrColor fColor; | 158 GrColor fColor; |
162 }; | 159 }; |
163 | 160 |
164 #endif | 161 #endif |
OLD | NEW |