diff options
author | Zeno Albisser <zeno.albisser@digia.com> | 2013-08-15 21:46:11 +0200 |
---|---|---|
committer | Zeno Albisser <zeno.albisser@digia.com> | 2013-08-15 21:46:11 +0200 |
commit | 679147eead574d186ebf3069647b4c23e8ccace6 (patch) | |
tree | fc247a0ac8ff119f7c8550879ebb6d3dd8d1ff69 /chromium/third_party/skia/include/utils/SkUnitMappers.h |
Initial import.
Diffstat (limited to 'chromium/third_party/skia/include/utils/SkUnitMappers.h')
-rw-r--r-- | chromium/third_party/skia/include/utils/SkUnitMappers.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/chromium/third_party/skia/include/utils/SkUnitMappers.h b/chromium/third_party/skia/include/utils/SkUnitMappers.h new file mode 100644 index 00000000000..64aab5ddee7 --- /dev/null +++ b/chromium/third_party/skia/include/utils/SkUnitMappers.h @@ -0,0 +1,55 @@ + +/* + * Copyright 2008 The Android Open Source Project + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + +#ifndef SkUnitMappers_DEFINED +#define SkUnitMappers_DEFINED + +#include "SkUnitMapper.h" + +/** This discretizes the range [0...1) into N discret values. +*/ +class SkDiscreteMapper : public SkUnitMapper { +public: + SkDiscreteMapper(int segments); + // override from SkUnitMapper + virtual uint16_t mapUnit16(uint16_t x); + + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscreteMapper) + +protected: + SkDiscreteMapper(SkFlattenableReadBuffer& ); + virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; + +private: + int fSegments; + SkFract fScale; // computed from fSegments + + typedef SkUnitMapper INHERITED; +}; + +/** This returns cos(x), to simulate lighting a sphere, where 0 maps to the + center of the sphere, and 1 maps to the edge. +*/ +class SkCosineMapper : public SkUnitMapper { +public: + SkCosineMapper() {} + // override from SkUnitMapper + virtual uint16_t mapUnit16(uint16_t x); + + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCosineMapper) + +protected: + SkCosineMapper(SkFlattenableReadBuffer&); + +private: + + typedef SkUnitMapper INHERITED; +}; + +#endif |