michael@0: michael@0: /* michael@0: * Copyright 2008 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #ifndef SkUnitMappers_DEFINED michael@0: #define SkUnitMappers_DEFINED michael@0: michael@0: #include "SkUnitMapper.h" michael@0: michael@0: /** This discretizes the range [0...1) into N discret values. michael@0: */ michael@0: class SkDiscreteMapper : public SkUnitMapper { michael@0: public: michael@0: SkDiscreteMapper(int segments); michael@0: // override from SkUnitMapper michael@0: virtual uint16_t mapUnit16(uint16_t x); michael@0: michael@0: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscreteMapper) michael@0: michael@0: protected: michael@0: SkDiscreteMapper(SkReadBuffer& ); michael@0: virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; michael@0: michael@0: private: michael@0: int fSegments; michael@0: int32_t fScale; // computed from fSegments michael@0: michael@0: typedef SkUnitMapper INHERITED; michael@0: }; michael@0: michael@0: /** This returns cos(x), to simulate lighting a sphere, where 0 maps to the michael@0: center of the sphere, and 1 maps to the edge. michael@0: */ michael@0: class SkCosineMapper : public SkUnitMapper { michael@0: public: michael@0: SkCosineMapper() {} michael@0: // override from SkUnitMapper michael@0: virtual uint16_t mapUnit16(uint16_t x); michael@0: michael@0: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCosineMapper) michael@0: michael@0: protected: michael@0: SkCosineMapper(SkReadBuffer&); michael@0: michael@0: private: michael@0: michael@0: typedef SkUnitMapper INHERITED; michael@0: }; michael@0: michael@0: #endif