Chromium Code Reviews| Index: src/core/SkColorSpaceXform.h |
| diff --git a/src/core/SkColorSpaceXform.h b/src/core/SkColorSpaceXform.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8e58f0f42e40f5b10958602553411d0b22dd6364 |
| --- /dev/null |
| +++ b/src/core/SkColorSpaceXform.h |
| @@ -0,0 +1,58 @@ |
| +/* |
| + * 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. |
|
Brian Osman
2016/05/05 13:29:44
Should probably document that this assumes (requir
msarett
2016/05/05 15:49:05
Yes you're right!
I think it makes sense to start
|
| + */ |
| + 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 |