| Index: src/core/SkColorSpaceXform.h
|
| diff --git a/src/core/SkColorSpaceXform.h b/src/core/SkColorSpaceXform.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ed6825757dcfd57fb3af80a9a4f2920aa88fbf8d
|
| --- /dev/null
|
| +++ b/src/core/SkColorSpaceXform.h
|
| @@ -0,0 +1,60 @@
|
| +/*
|
| + * Copyright 2016 Google Inc.
|
| + *
|
| + * Use of this source code is governed by a BSD-style license that can be
|
| + * found in the LICENSE file.
|
| + */
|
| +
|
| +#ifndef SkColorSpaceXform_DEFINED
|
| +#define SkColorSpaceXform_DEFINED
|
| +
|
| +#include "SkColorSpace.h"
|
| +
|
| +class SkColorSpaceXform {
|
| +public:
|
| +
|
| + enum Op {
|
| + kSrcToLinear_Op, // Apply src gamma
|
| + kSrcToLinearDstGamut_Op, // Apply src gamma and matrix
|
| + kSrcToDst_Op, // Apply src gamma, matrix, and dst gamma
|
| + };
|
| +
|
| + /**
|
| + * Create an object to handle color space conversions.
|
| + *
|
| + * @param srcSpace The encoded color space. This is required if the conversion op
|
| + * will begin in the encoded gamut. Otherwise it may be nullptr.
|
| + * @param dstSpace The destination color space. This is required if the conversion op
|
| + * will finish in the destination gamut. Otherwise it may be nullptr.
|
| + * @param op Indicates the start and end point of the conversion.
|
| + *
|
| + */
|
| + static SkColorSpaceXform* New(sk_sp<SkColorSpace> srcSpace, sk_sp<SkColorSpace> dstSpace,
|
| + Op op);
|
| +
|
| + /**
|
| + * Apply the color conversion to a src buffer, storing the output in the dst buffer.
|
| + *
|
| + * Assumes that src is stored in RGBA 8888 format and outputs to dst as RGBA F16.
|
| + */
|
| + virtual void apply(void* dst, const void* src, const SkISize& size, size_t dstRowBytes,
|
| + size_t srcRowBytes) const = 0;
|
| +
|
| + virtual ~SkColorSpaceXform() {}
|
| +};
|
| +
|
| +class SkGammaByValueXform : public SkColorSpaceXform {
|
| +public:
|
| +
|
| + void apply(void* dst, const void* src, const SkISize& size, size_t dstRowBytes,
|
| + size_t srcRowBytes) const override;
|
| +
|
| +private:
|
| + SkGammaByValueXform(const SkFloat3& gammas);
|
| +
|
| + const SkFloat3 fGammas;
|
| +
|
| + friend class SkColorSpaceXform;
|
| +};
|
| +
|
| +#endif
|
|
|