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 #ifndef GrConfigConversionEffect_DEFINED | 8 #ifndef GrConfigConversionEffect_DEFINED |
9 #define GrConfigConversionEffect_DEFINED | 9 #define GrConfigConversionEffect_DEFINED |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 enum PMConversion { | 27 enum PMConversion { |
28 kNone_PMConversion = 0, | 28 kNone_PMConversion = 0, |
29 kMulByAlpha_RoundUp_PMConversion, | 29 kMulByAlpha_RoundUp_PMConversion, |
30 kMulByAlpha_RoundDown_PMConversion, | 30 kMulByAlpha_RoundDown_PMConversion, |
31 kDivByAlpha_RoundUp_PMConversion, | 31 kDivByAlpha_RoundUp_PMConversion, |
32 kDivByAlpha_RoundDown_PMConversion, | 32 kDivByAlpha_RoundDown_PMConversion, |
33 | 33 |
34 kPMConversionCnt | 34 kPMConversionCnt |
35 }; | 35 }; |
36 | 36 |
37 static const GrFragmentProcessor* Create(GrTexture*, bool swapRedAndBlue, PM
Conversion, | 37 static const GrFragmentProcessor* Create(GrProcessorDataManager*, GrTexture*
, |
38 const SkMatrix&); | 38 bool swapRedAndBlue, PMConversion,
const SkMatrix&); |
39 | 39 |
40 const char* name() const override { return "Config Conversion"; } | 40 const char* name() const override { return "Config Conversion"; } |
41 | 41 |
42 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over
ride; | 42 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over
ride; |
43 | 43 |
44 GrGLFragmentProcessor* createGLInstance() const override; | 44 GrGLFragmentProcessor* createGLInstance() const override; |
45 | 45 |
46 bool swapsRedAndBlue() const { return fSwapRedAndBlue; } | 46 bool swapsRedAndBlue() const { return fSwapRedAndBlue; } |
47 PMConversion pmConversion() const { return fPMConversion; } | 47 PMConversion pmConversion() const { return fPMConversion; } |
48 | 48 |
49 // This function determines whether it is possible to choose PM->UPM and UPM
->PM conversions | 49 // This function determines whether it is possible to choose PM->UPM and UPM
->PM conversions |
50 // for which in any PM->UPM->PM->UPM sequence the two UPM values are the sam
e. This means that | 50 // for which in any PM->UPM->PM->UPM sequence the two UPM values are the sam
e. This means that |
51 // if pixels are read back to a UPM buffer, written back to PM to the GPU, a
nd read back again | 51 // if pixels are read back to a UPM buffer, written back to PM to the GPU, a
nd read back again |
52 // both reads will produce the same result. This test is quite expensive and
should not be run | 52 // both reads will produce the same result. This test is quite expensive and
should not be run |
53 // multiple times for a given context. | 53 // multiple times for a given context. |
54 static void TestForPreservingPMConversions(GrContext* context, | 54 static void TestForPreservingPMConversions(GrContext* context, |
55 PMConversion* PMToUPMRule, | 55 PMConversion* PMToUPMRule, |
56 PMConversion* UPMToPMRule); | 56 PMConversion* UPMToPMRule); |
57 | 57 |
58 private: | 58 private: |
59 GrConfigConversionEffect(GrTexture*, | 59 GrConfigConversionEffect(GrProcessorDataManager*, |
60 bool swapRedAndBlue, | 60 GrTexture*, |
61 PMConversion pmConversion, | 61 bool swapRedAndBlue, |
62 const SkMatrix& matrix); | 62 PMConversion pmConversion, |
| 63 const SkMatrix& matrix); |
63 | 64 |
64 bool onIsEqual(const GrFragmentProcessor&) const override; | 65 bool onIsEqual(const GrFragmentProcessor&) const override; |
65 | 66 |
66 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 67 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
67 | 68 |
68 bool fSwapRedAndBlue; | 69 bool fSwapRedAndBlue; |
69 PMConversion fPMConversion; | 70 PMConversion fPMConversion; |
70 | 71 |
71 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 72 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
72 | 73 |
73 typedef GrSingleTextureEffect INHERITED; | 74 typedef GrSingleTextureEffect INHERITED; |
74 }; | 75 }; |
75 | 76 |
76 #endif | 77 #endif |
OLD | NEW |