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