gfx/skia/trunk/include/utils/SkUnitMappers.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/utils/SkUnitMappers.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2008 The Android Open Source Project
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#ifndef SkUnitMappers_DEFINED
    1.14 +#define SkUnitMappers_DEFINED
    1.15 +
    1.16 +#include "SkUnitMapper.h"
    1.17 +
    1.18 +/** This discretizes the range [0...1) into N discret values.
    1.19 +*/
    1.20 +class SkDiscreteMapper : public SkUnitMapper {
    1.21 +public:
    1.22 +    SkDiscreteMapper(int segments);
    1.23 +    // override from SkUnitMapper
    1.24 +    virtual uint16_t mapUnit16(uint16_t x);
    1.25 +
    1.26 +    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscreteMapper)
    1.27 +
    1.28 +protected:
    1.29 +    SkDiscreteMapper(SkReadBuffer& );
    1.30 +    virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
    1.31 +
    1.32 +private:
    1.33 +    int     fSegments;
    1.34 +    int32_t fScale;    // computed from fSegments
    1.35 +
    1.36 +    typedef SkUnitMapper INHERITED;
    1.37 +};
    1.38 +
    1.39 +/** This returns cos(x), to simulate lighting a sphere, where 0 maps to the
    1.40 +    center of the sphere, and 1 maps to the edge.
    1.41 +*/
    1.42 +class SkCosineMapper : public SkUnitMapper {
    1.43 +public:
    1.44 +    SkCosineMapper() {}
    1.45 +    // override from SkUnitMapper
    1.46 +    virtual uint16_t mapUnit16(uint16_t x);
    1.47 +
    1.48 +    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCosineMapper)
    1.49 +
    1.50 +protected:
    1.51 +    SkCosineMapper(SkReadBuffer&);
    1.52 +
    1.53 +private:
    1.54 +
    1.55 +    typedef SkUnitMapper INHERITED;
    1.56 +};
    1.57 +
    1.58 +#endif

mercurial