| 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 |
| 11 #include "GrSingleTextureEffect.h" | 11 #include "GrSingleTextureEffect.h" |
| 12 | 12 |
| 13 class GrFragmentStage; | 13 class GrFragmentStage; |
| 14 class GrGLConfigConversionEffect; | |
| 15 class GrInvariantOutput; | 14 class GrInvariantOutput; |
| 16 | 15 |
| 17 /** | 16 /** |
| 18 * This class is used to perform config conversions. Clients may want to read/wr
ite data that is | 17 * This class is used to perform config conversions. Clients may want to read/wr
ite data that is |
| 19 * unpremultiplied. Also on some systems reading/writing BGRA or RGBA is faster.
In those cases we | 18 * unpremultiplied. Also on some systems reading/writing BGRA or RGBA is faster.
In those cases we |
| 20 * read/write using the faster path and perform an R/B swap in the shader if the
client data is in | 19 * read/write using the faster path and perform an R/B swap in the shader if the
client data is in |
| 21 * the slower config. | 20 * the slower config. |
| 22 */ | 21 */ |
| 23 class GrConfigConversionEffect : public GrSingleTextureEffect { | 22 class GrConfigConversionEffect : public GrSingleTextureEffect { |
| 24 public: | 23 public: |
| 25 /** | 24 /** |
| 26 * The PM->UPM or UPM->PM conversions to apply. | 25 * The PM->UPM or UPM->PM conversions to apply. |
| 27 */ | 26 */ |
| 28 enum PMConversion { | 27 enum PMConversion { |
| 29 kNone_PMConversion = 0, | 28 kNone_PMConversion = 0, |
| 30 kMulByAlpha_RoundUp_PMConversion, | 29 kMulByAlpha_RoundUp_PMConversion, |
| 31 kMulByAlpha_RoundDown_PMConversion, | 30 kMulByAlpha_RoundDown_PMConversion, |
| 32 kDivByAlpha_RoundUp_PMConversion, | 31 kDivByAlpha_RoundUp_PMConversion, |
| 33 kDivByAlpha_RoundDown_PMConversion, | 32 kDivByAlpha_RoundDown_PMConversion, |
| 34 | 33 |
| 35 kPMConversionCnt | 34 kPMConversionCnt |
| 36 }; | 35 }; |
| 37 | 36 |
| 38 static const GrFragmentProcessor* Create(GrTexture*, bool swapRedAndBlue, PM
Conversion, | 37 static const GrFragmentProcessor* Create(GrTexture*, bool swapRedAndBlue, PM
Conversion, |
| 39 const SkMatrix&); | 38 const SkMatrix&); |
| 40 | 39 |
| 41 static const char* Name() { return "Config Conversion"; } | 40 virtual const char* name() const SK_OVERRIDE { return "Config Conversion"; } |
| 42 typedef GrGLConfigConversionEffect GLProcessor; | |
| 43 | 41 |
| 44 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; | 42 virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) cons
t SK_OVERRIDE; |
| 43 |
| 44 virtual GrGLFragmentProcessor* createGLInstance() const SK_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, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 67 | 67 |
| 68 bool fSwapRedAndBlue; | 68 bool fSwapRedAndBlue; |
| 69 PMConversion fPMConversion; | 69 PMConversion fPMConversion; |
| 70 | 70 |
| 71 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 71 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 72 | 72 |
| 73 typedef GrSingleTextureEffect INHERITED; | 73 typedef GrSingleTextureEffect INHERITED; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 #endif | 76 #endif |
| OLD | NEW |