OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "GrConfigConversionEffect.h" | 8 #include "GrConfigConversionEffect.h" |
9 #include "GrContext.h" | 9 #include "GrContext.h" |
10 #include "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
11 #include "GrInvariantOutput.h" | 11 #include "GrInvariantOutput.h" |
12 #include "GrSimpleTextureEffect.h" | 12 #include "GrSimpleTextureEffect.h" |
13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
14 #include "gl/GrGLFragmentProcessor.h" | 14 #include "glsl/GrGLSLFragmentProcessor.h" |
15 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 15 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
16 #include "glsl/GrGLSLProgramBuilder.h" | 16 #include "glsl/GrGLSLProgramBuilder.h" |
17 | 17 |
18 class GrGLConfigConversionEffect : public GrGLFragmentProcessor { | 18 class GrGLConfigConversionEffect : public GrGLSLFragmentProcessor { |
19 public: | 19 public: |
20 GrGLConfigConversionEffect(const GrProcessor& processor) { | 20 GrGLConfigConversionEffect(const GrProcessor& processor) { |
21 const GrConfigConversionEffect& configConversionEffect = | 21 const GrConfigConversionEffect& configConversionEffect = |
22 processor.cast<GrConfigConversionEffect>(); | 22 processor.cast<GrConfigConversionEffect>(); |
23 fSwapRedAndBlue = configConversionEffect.swapsRedAndBlue(); | 23 fSwapRedAndBlue = configConversionEffect.swapsRedAndBlue(); |
24 fPMConversion = configConversionEffect.pmConversion(); | 24 fPMConversion = configConversionEffect.pmConversion(); |
25 } | 25 } |
26 | 26 |
27 virtual void emitCode(EmitArgs& args) override { | 27 virtual void emitCode(EmitArgs& args) override { |
28 // Using highp for GLES here in order to avoid some precision issues on
specific GPUs. | 28 // Using highp for GLES here in order to avoid some precision issues on
specific GPUs. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 GrProcessorKeyBuilder* b) { | 84 GrProcessorKeyBuilder* b) { |
85 const GrConfigConversionEffect& conv = processor.cast<GrConfigConversion
Effect>(); | 85 const GrConfigConversionEffect& conv = processor.cast<GrConfigConversion
Effect>(); |
86 uint32_t key = (conv.swapsRedAndBlue() ? 0 : 1) | (conv.pmConversion() <
< 1); | 86 uint32_t key = (conv.swapsRedAndBlue() ? 0 : 1) | (conv.pmConversion() <
< 1); |
87 b->add32(key); | 87 b->add32(key); |
88 } | 88 } |
89 | 89 |
90 private: | 90 private: |
91 bool fSwapRedAndBlue; | 91 bool fSwapRedAndBlue; |
92 GrConfigConversionEffect::PMConversion fPMConversion; | 92 GrConfigConversionEffect::PMConversion fPMConversion; |
93 | 93 |
94 typedef GrGLFragmentProcessor INHERITED; | 94 typedef GrGLSLFragmentProcessor INHERITED; |
95 | 95 |
96 }; | 96 }; |
97 | 97 |
98 /////////////////////////////////////////////////////////////////////////////// | 98 /////////////////////////////////////////////////////////////////////////////// |
99 | 99 |
100 GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture, | 100 GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture, |
101 bool swapRedAndBlue, | 101 bool swapRedAndBlue, |
102 PMConversion pmConversion, | 102 PMConversion pmConversion, |
103 const SkMatrix& matrix) | 103 const SkMatrix& matrix) |
104 : INHERITED(texture, matrix) | 104 : INHERITED(texture, matrix) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 swapRB, pmConv, GrTest::TestMatrix(d->fR
andom)); | 140 swapRB, pmConv, GrTest::TestMatrix(d->fR
andom)); |
141 } | 141 } |
142 | 142 |
143 /////////////////////////////////////////////////////////////////////////////// | 143 /////////////////////////////////////////////////////////////////////////////// |
144 | 144 |
145 void GrConfigConversionEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 145 void GrConfigConversionEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |
146 GrProcessorKeyBuilder* b) con
st { | 146 GrProcessorKeyBuilder* b) con
st { |
147 GrGLConfigConversionEffect::GenKey(*this, caps, b); | 147 GrGLConfigConversionEffect::GenKey(*this, caps, b); |
148 } | 148 } |
149 | 149 |
150 GrGLFragmentProcessor* GrConfigConversionEffect::onCreateGLInstance() const { | 150 GrGLSLFragmentProcessor* GrConfigConversionEffect::onCreateGLInstance() const { |
151 return new GrGLConfigConversionEffect(*this); | 151 return new GrGLConfigConversionEffect(*this); |
152 } | 152 } |
153 | 153 |
154 | 154 |
155 | 155 |
156 void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
, | 156 void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
, |
157 PMConversion* pmTo
UPMRule, | 157 PMConversion* pmTo
UPMRule, |
158 PMConversion* upmT
oPMRule) { | 158 PMConversion* upmT
oPMRule) { |
159 *pmToUPMRule = kNone_PMConversion; | 159 *pmToUPMRule = kNone_PMConversion; |
160 *upmToPMRule = kNone_PMConversion; | 160 *upmToPMRule = kNone_PMConversion; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 } else { | 298 } else { |
299 if (kRGBA_8888_GrPixelConfig != texture->config() && | 299 if (kRGBA_8888_GrPixelConfig != texture->config() && |
300 kBGRA_8888_GrPixelConfig != texture->config() && | 300 kBGRA_8888_GrPixelConfig != texture->config() && |
301 kNone_PMConversion != pmConversion) { | 301 kNone_PMConversion != pmConversion) { |
302 // The PM conversions assume colors are 0..255 | 302 // The PM conversions assume colors are 0..255 |
303 return nullptr; | 303 return nullptr; |
304 } | 304 } |
305 return new GrConfigConversionEffect(texture, swapRedAndBlue, pmConversio
n, matrix); | 305 return new GrConfigConversionEffect(texture, swapRedAndBlue, pmConversio
n, matrix); |
306 } | 306 } |
307 } | 307 } |
OLD | NEW |