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