| 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 GrSingleTextureEffect_DEFINED | 8 #ifndef GrSingleTextureEffect_DEFINED |
| 9 #define GrSingleTextureEffect_DEFINED | 9 #define GrSingleTextureEffect_DEFINED |
| 10 | 10 |
| 11 #include "GrFragmentProcessor.h" | 11 #include "GrFragmentProcessor.h" |
| 12 #include "GrCoordTransform.h" | 12 #include "GrCoordTransform.h" |
| 13 #include "GrInvariantOutput.h" | 13 #include "GrInvariantOutput.h" |
| 14 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
| 15 | 15 |
| 16 class GrTexture; | 16 class GrTexture; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * A base class for effects that draw a single texture with a texture matrix. Th
is effect has no | 19 * A base class for effects that draw a single texture with a texture matrix. Th
is effect has no |
| 20 * backend implementations. One must be provided by the subclass. | 20 * backend implementations. One must be provided by the subclass. |
| 21 */ | 21 */ |
| 22 class GrSingleTextureEffect : public GrFragmentProcessor { | 22 class GrSingleTextureEffect : public GrFragmentProcessor { |
| 23 public: | 23 public: |
| 24 virtual ~GrSingleTextureEffect(); | 24 virtual ~GrSingleTextureEffect(); |
| 25 | 25 |
| 26 protected: | 26 protected: |
| 27 /** unfiltered, clamp mode */ | 27 /** unfiltered, clamp mode */ |
| 28 GrSingleTextureEffect(GrTexture*, const SkMatrix&, GrCoordSet = kLocal_GrCoo
rdSet); | 28 GrSingleTextureEffect(GrProcessorDataManager*, GrTexture*, const SkMatrix&, |
| 29 GrCoordSet = kLocal_GrCoordSet); |
| 29 /** clamp mode */ | 30 /** clamp mode */ |
| 30 GrSingleTextureEffect(GrTexture*, const SkMatrix&, GrTextureParams::FilterMo
de filterMode, | 31 GrSingleTextureEffect(GrProcessorDataManager*, GrTexture*, const SkMatrix&, |
| 32 GrTextureParams::FilterMode filterMode, |
| 31 GrCoordSet = kLocal_GrCoordSet); | 33 GrCoordSet = kLocal_GrCoordSet); |
| 32 GrSingleTextureEffect(GrTexture*, | 34 GrSingleTextureEffect(GrProcessorDataManager*, |
| 35 GrTexture*, |
| 33 const SkMatrix&, | 36 const SkMatrix&, |
| 34 const GrTextureParams&, | 37 const GrTextureParams&, |
| 35 GrCoordSet = kLocal_GrCoordSet); | 38 GrCoordSet = kLocal_GrCoordSet); |
| 36 | 39 |
| 37 /** | 40 /** |
| 38 * Can be used as a helper to implement subclass onComputeInvariantOutput().
It assumes that | 41 * Can be used as a helper to implement subclass onComputeInvariantOutput().
It assumes that |
| 39 * the subclass output color will be a modulation of the input color with a
value read from the | 42 * the subclass output color will be a modulation of the input color with a
value read from the |
| 40 * texture. | 43 * texture. |
| 41 */ | 44 */ |
| 42 void updateInvariantOutputForModulation(GrInvariantOutput* inout) const { | 45 void updateInvariantOutputForModulation(GrInvariantOutput* inout) const { |
| 43 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) { | 46 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) { |
| 44 inout->mulByUnknownSingleComponent(); | 47 inout->mulByUnknownSingleComponent(); |
| 45 } else if (GrPixelConfigIsOpaque(this->texture(0)->config())) { | 48 } else if (GrPixelConfigIsOpaque(this->texture(0)->config())) { |
| 46 inout->mulByUnknownOpaqueFourComponents(); | 49 inout->mulByUnknownOpaqueFourComponents(); |
| 47 } else { | 50 } else { |
| 48 inout->mulByUnknownFourComponents(); | 51 inout->mulByUnknownFourComponents(); |
| 49 } | 52 } |
| 50 } | 53 } |
| 51 | 54 |
| 52 private: | 55 private: |
| 53 GrCoordTransform fCoordTransform; | 56 GrCoordTransform fCoordTransform; |
| 54 GrTextureAccess fTextureAccess; | 57 GrTextureAccess fTextureAccess; |
| 55 | 58 |
| 56 typedef GrFragmentProcessor INHERITED; | 59 typedef GrFragmentProcessor INHERITED; |
| 57 }; | 60 }; |
| 58 | 61 |
| 59 #endif | 62 #endif |
| OLD | NEW |