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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 bool getDisableOutputConversionToSRGB() const { return fDisableOutputConvers
ionToSRGB; } | 71 bool getDisableOutputConversionToSRGB() const { return fDisableOutputConvers
ionToSRGB; } |
72 | 72 |
73 /** | 73 /** |
74 * Should sRGB inputs be allowed to perform sRGB to linear conversion. With
this flag | 74 * Should sRGB inputs be allowed to perform sRGB to linear conversion. With
this flag |
75 * set to false, sRGB textures will be treated as linear (including filterin
g). | 75 * set to false, sRGB textures will be treated as linear (including filterin
g). |
76 */ | 76 */ |
77 void setAllowSRGBInputs(bool allowSRGBInputs) { fAllowSRGBInputs = allowSRGB
Inputs; } | 77 void setAllowSRGBInputs(bool allowSRGBInputs) { fAllowSRGBInputs = allowSRGB
Inputs; } |
78 bool getAllowSRGBInputs() const { return fAllowSRGBInputs; } | 78 bool getAllowSRGBInputs() const { return fAllowSRGBInputs; } |
79 | 79 |
80 /** | 80 /** |
| 81 * Does one of the fragment processors need a field of distance vectors to t
he nearest edge? |
| 82 */ |
| 83 bool usesDistanceVectorField() const { return fUsesDistanceVectorField; } |
| 84 |
| 85 /** |
81 * Should rendering be gamma-correct, end-to-end. Causes sRGB render targets
to behave | 86 * Should rendering be gamma-correct, end-to-end. Causes sRGB render targets
to behave |
82 * as such (with linear blending), and sRGB inputs to be filtered and decode
d correctly. | 87 * as such (with linear blending), and sRGB inputs to be filtered and decode
d correctly. |
83 */ | 88 */ |
84 void setGammaCorrect(bool gammaCorrect) { | 89 void setGammaCorrect(bool gammaCorrect) { |
85 setDisableOutputConversionToSRGB(!gammaCorrect); | 90 setDisableOutputConversionToSRGB(!gammaCorrect); |
86 setAllowSRGBInputs(gammaCorrect); | 91 setAllowSRGBInputs(gammaCorrect); |
87 } | 92 } |
88 | 93 |
89 void setXPFactory(sk_sp<GrXPFactory> xpFactory) { | 94 void setXPFactory(sk_sp<GrXPFactory> xpFactory) { |
90 fXPFactory = std::move(xpFactory); | 95 fXPFactory = std::move(xpFactory); |
91 } | 96 } |
92 | 97 |
93 void setPorterDuffXPFactory(SkXfermode::Mode mode) { | 98 void setPorterDuffXPFactory(SkXfermode::Mode mode) { |
94 fXPFactory = GrPorterDuffXPFactory::Make(mode); | 99 fXPFactory = GrPorterDuffXPFactory::Make(mode); |
95 } | 100 } |
96 | 101 |
97 void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage =
false); | 102 void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage =
false); |
98 | 103 |
99 /** | 104 /** |
100 * Appends an additional color processor to the color computation. | 105 * Appends an additional color processor to the color computation. |
101 */ | 106 */ |
102 void addColorFragmentProcessor(sk_sp<GrFragmentProcessor> fp) { | 107 void addColorFragmentProcessor(sk_sp<GrFragmentProcessor> fp) { |
103 SkASSERT(fp); | 108 SkASSERT(fp); |
| 109 fUsesDistanceVectorField |= fp->usesDistanceVectorField(); |
104 fColorFragmentProcessors.push_back(std::move(fp)); | 110 fColorFragmentProcessors.push_back(std::move(fp)); |
105 } | 111 } |
106 | 112 |
107 /** | 113 /** |
108 * Appends an additional coverage processor to the coverage computation. | 114 * Appends an additional coverage processor to the coverage computation. |
109 */ | 115 */ |
110 void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> fp) { | 116 void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> fp) { |
111 SkASSERT(fp); | 117 SkASSERT(fp); |
| 118 fUsesDistanceVectorField |= fp->usesDistanceVectorField(); |
112 fCoverageFragmentProcessors.push_back(std::move(fp)); | 119 fCoverageFragmentProcessors.push_back(std::move(fp)); |
113 } | 120 } |
114 | 121 |
115 /** | 122 /** |
116 * Helpers for adding color or coverage effects that sample a texture. The m
atrix is applied | 123 * Helpers for adding color or coverage effects that sample a texture. The m
atrix is applied |
117 * to the src space position to compute texture coordinates. | 124 * to the src space position to compute texture coordinates. |
118 */ | 125 */ |
119 void addColorTextureProcessor(GrTexture*, sk_sp<GrColorSpaceXform>, const Sk
Matrix&); | 126 void addColorTextureProcessor(GrTexture*, sk_sp<GrColorSpaceXform>, const Sk
Matrix&); |
120 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&); | 127 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&); |
121 void addColorTextureProcessor(GrTexture*, sk_sp<GrColorSpaceXform>, const Sk
Matrix&, | 128 void addColorTextureProcessor(GrTexture*, sk_sp<GrColorSpaceXform>, const Sk
Matrix&, |
(...skipping 13 matching lines...) Expand all Loading... |
135 return fColorFragmentProcessors[i].get(); | 142 return fColorFragmentProcessors[i].get(); |
136 } | 143 } |
137 GrFragmentProcessor* getCoverageFragmentProcessor(int i) const { | 144 GrFragmentProcessor* getCoverageFragmentProcessor(int i) const { |
138 return fCoverageFragmentProcessors[i].get(); | 145 return fCoverageFragmentProcessors[i].get(); |
139 } | 146 } |
140 | 147 |
141 GrPaint& operator=(const GrPaint& paint) { | 148 GrPaint& operator=(const GrPaint& paint) { |
142 fAntiAlias = paint.fAntiAlias; | 149 fAntiAlias = paint.fAntiAlias; |
143 fDisableOutputConversionToSRGB = paint.fDisableOutputConversionToSRGB; | 150 fDisableOutputConversionToSRGB = paint.fDisableOutputConversionToSRGB; |
144 fAllowSRGBInputs = paint.fAllowSRGBInputs; | 151 fAllowSRGBInputs = paint.fAllowSRGBInputs; |
| 152 fUsesDistanceVectorField = paint.fUsesDistanceVectorField; |
145 | 153 |
146 fColor = paint.fColor; | 154 fColor = paint.fColor; |
147 fColorFragmentProcessors = paint.fColorFragmentProcessors; | 155 fColorFragmentProcessors = paint.fColorFragmentProcessors; |
148 fCoverageFragmentProcessors = paint.fCoverageFragmentProcessors; | 156 fCoverageFragmentProcessors = paint.fCoverageFragmentProcessors; |
149 | 157 |
150 fXPFactory = paint.fXPFactory; | 158 fXPFactory = paint.fXPFactory; |
151 | 159 |
152 return *this; | 160 return *this; |
153 } | 161 } |
154 | 162 |
155 /** | 163 /** |
156 * Returns true if the paint's output color will be constant after blending.
If the result is | 164 * Returns true if the paint's output color will be constant after blending.
If the result is |
157 * true, constantColor will be updated to contain the constant color. Note t
hat we can conflate | 165 * true, constantColor will be updated to contain the constant color. Note t
hat we can conflate |
158 * coverage and color, so the actual values written to pixels with partial c
overage may still | 166 * coverage and color, so the actual values written to pixels with partial c
overage may still |
159 * not seem constant, even if this function returns true. | 167 * not seem constant, even if this function returns true. |
160 */ | 168 */ |
161 bool isConstantBlendedColor(GrColor* constantColor) const; | 169 bool isConstantBlendedColor(GrColor* constantColor) const; |
162 | 170 |
163 private: | 171 private: |
164 mutable sk_sp<GrXPFactory> fXPFactory; | 172 mutable sk_sp<GrXPFactory> fXPFactory; |
165 SkSTArray<4, sk_sp<GrFragmentProcessor>> fColorFragmentProcessors; | 173 SkSTArray<4, sk_sp<GrFragmentProcessor>> fColorFragmentProcessors; |
166 SkSTArray<2, sk_sp<GrFragmentProcessor>> fCoverageFragmentProcessors; | 174 SkSTArray<2, sk_sp<GrFragmentProcessor>> fCoverageFragmentProcessors; |
167 | 175 |
168 bool fAntiAlias; | 176 bool fAntiAlias; |
169 bool fDisableOutputConversionToSRGB; | 177 bool fDisableOutputConversionToSRGB; |
170 bool fAllowSRGBInputs; | 178 bool fAllowSRGBInputs; |
| 179 bool fUsesDistanceVectorField; |
171 | 180 |
172 GrColor4f fColor; | 181 GrColor4f fColor; |
173 }; | 182 }; |
174 | 183 |
175 #endif | 184 #endif |
OLD | NEW |