gfx/skia/trunk/src/gpu/effects/GrConfigConversionEffect.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * Copyright 2012 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef GrConfigConversionEffect_DEFINED
michael@0 9 #define GrConfigConversionEffect_DEFINED
michael@0 10
michael@0 11 #include "GrSingleTextureEffect.h"
michael@0 12
michael@0 13 class GrEffectStage;
michael@0 14 class GrGLConfigConversionEffect;
michael@0 15
michael@0 16 /**
michael@0 17 * This class is used to perform config conversions. Clients may want to read/write data that is
michael@0 18 * unpremultiplied. Also on some systems reading/writing BGRA or RGBA is faster. In those cases we
michael@0 19 * read/write using the faster path and perform an R/B swap in the shader if the client data is in
michael@0 20 * the slower config.
michael@0 21 */
michael@0 22 class GrConfigConversionEffect : public GrSingleTextureEffect {
michael@0 23 public:
michael@0 24 /**
michael@0 25 * The PM->UPM or UPM->PM conversions to apply.
michael@0 26 */
michael@0 27 enum PMConversion {
michael@0 28 kNone_PMConversion = 0,
michael@0 29 kMulByAlpha_RoundUp_PMConversion,
michael@0 30 kMulByAlpha_RoundDown_PMConversion,
michael@0 31 kDivByAlpha_RoundUp_PMConversion,
michael@0 32 kDivByAlpha_RoundDown_PMConversion,
michael@0 33
michael@0 34 kPMConversionCnt
michael@0 35 };
michael@0 36
michael@0 37 // Installs an effect in the GrEffectStage to perform a config conversion.
michael@0 38 static const GrEffectRef* Create(GrTexture*,
michael@0 39 bool swapRedAndBlue,
michael@0 40 PMConversion pmConversion,
michael@0 41 const SkMatrix& matrix);
michael@0 42
michael@0 43 static const char* Name() { return "Config Conversion"; }
michael@0 44 typedef GrGLConfigConversionEffect GLEffect;
michael@0 45
michael@0 46 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
michael@0 47
michael@0 48 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
michael@0 49
michael@0 50 bool swapsRedAndBlue() const { return fSwapRedAndBlue; }
michael@0 51 PMConversion pmConversion() const { return fPMConversion; }
michael@0 52
michael@0 53 // This function determines whether it is possible to choose PM->UPM and UPM->PM conversions
michael@0 54 // for which in any PM->UPM->PM->UPM sequence the two UPM values are the same. This means that
michael@0 55 // if pixels are read back to a UPM buffer, written back to PM to the GPU, and read back again
michael@0 56 // both reads will produce the same result. This test is quite expensive and should not be run
michael@0 57 // multiple times for a given context.
michael@0 58 static void TestForPreservingPMConversions(GrContext* context,
michael@0 59 PMConversion* PMToUPMRule,
michael@0 60 PMConversion* UPMToPMRule);
michael@0 61
michael@0 62 private:
michael@0 63 GrConfigConversionEffect(GrTexture*,
michael@0 64 bool swapRedAndBlue,
michael@0 65 PMConversion pmConversion,
michael@0 66 const SkMatrix& matrix);
michael@0 67
michael@0 68 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
michael@0 69
michael@0 70 bool fSwapRedAndBlue;
michael@0 71 PMConversion fPMConversion;
michael@0 72
michael@0 73 GR_DECLARE_EFFECT_TEST;
michael@0 74
michael@0 75 typedef GrSingleTextureEffect INHERITED;
michael@0 76 };
michael@0 77
michael@0 78 #endif

mercurial