Wed, 31 Dec 2014 06:09:35 +0100
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 GrSingleTextureEffect_DEFINED |
michael@0 | 9 | #define GrSingleTextureEffect_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "GrEffect.h" |
michael@0 | 12 | #include "SkMatrix.h" |
michael@0 | 13 | #include "GrCoordTransform.h" |
michael@0 | 14 | |
michael@0 | 15 | class GrTexture; |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * A base class for effects that draw a single texture with a texture matrix. This effect has no |
michael@0 | 19 | * backend implementations. One must be provided by the subclass. |
michael@0 | 20 | */ |
michael@0 | 21 | class GrSingleTextureEffect : public GrEffect { |
michael@0 | 22 | public: |
michael@0 | 23 | virtual ~GrSingleTextureEffect(); |
michael@0 | 24 | |
michael@0 | 25 | protected: |
michael@0 | 26 | /** unfiltered, clamp mode */ |
michael@0 | 27 | GrSingleTextureEffect(GrTexture*, const SkMatrix&, GrCoordSet = kLocal_GrCoordSet); |
michael@0 | 28 | /** clamp mode */ |
michael@0 | 29 | GrSingleTextureEffect(GrTexture*, const SkMatrix&, GrTextureParams::FilterMode filterMode, |
michael@0 | 30 | GrCoordSet = kLocal_GrCoordSet); |
michael@0 | 31 | GrSingleTextureEffect(GrTexture*, |
michael@0 | 32 | const SkMatrix&, |
michael@0 | 33 | const GrTextureParams&, |
michael@0 | 34 | GrCoordSet = kLocal_GrCoordSet); |
michael@0 | 35 | |
michael@0 | 36 | /** |
michael@0 | 37 | * Helper for subclass onIsEqual() functions. |
michael@0 | 38 | */ |
michael@0 | 39 | bool hasSameTextureParamsMatrixAndSourceCoords(const GrSingleTextureEffect& other) const { |
michael@0 | 40 | // We don't have to check the accesses' swizzles because they are inferred from the texture. |
michael@0 | 41 | return fTextureAccess == other.fTextureAccess && |
michael@0 | 42 | fCoordTransform.getMatrix().cheapEqualTo(other.fCoordTransform.getMatrix()) && |
michael@0 | 43 | fCoordTransform.sourceCoords() == other.fCoordTransform.sourceCoords(); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | /** |
michael@0 | 47 | * Can be used as a helper to implement subclass getConstantColorComponents(). It assumes that |
michael@0 | 48 | * the subclass output color will be a modulation of the input color with a value read from the |
michael@0 | 49 | * texture. |
michael@0 | 50 | */ |
michael@0 | 51 | void updateConstantColorComponentsForModulation(GrColor* color, uint32_t* validFlags) const { |
michael@0 | 52 | if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color) && |
michael@0 | 53 | GrPixelConfigIsOpaque(this->texture(0)->config())) { |
michael@0 | 54 | *validFlags = kA_GrColorComponentFlag; |
michael@0 | 55 | } else { |
michael@0 | 56 | *validFlags = 0; |
michael@0 | 57 | } |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | private: |
michael@0 | 61 | GrCoordTransform fCoordTransform; |
michael@0 | 62 | GrTextureAccess fTextureAccess; |
michael@0 | 63 | |
michael@0 | 64 | typedef GrEffect INHERITED; |
michael@0 | 65 | }; |
michael@0 | 66 | |
michael@0 | 67 | #endif |