Line data Source code
1 : /*
2 : * Copyright 2016 Google Inc.
3 : *
4 : * Use of this source code is governed by a BSD-style license that can be
5 : * found in the LICENSE file.
6 : */
7 :
8 : #ifndef SkColorSpaceXform_DEFINED
9 : #define SkColorSpaceXform_DEFINED
10 :
11 : #include "SkImageInfo.h"
12 :
13 : class SkColorSpace;
14 :
15 : class SK_API SkColorSpaceXform : SkNoncopyable {
16 : public:
17 :
18 : /**
19 : * Create an object to handle color space conversions.
20 : *
21 : * @param srcSpace The encoded color space.
22 : * @param dstSpace The destination color space.
23 : *
24 : */
25 : static std::unique_ptr<SkColorSpaceXform> New(SkColorSpace* srcSpace, SkColorSpace* dstSpace);
26 :
27 : enum ColorFormat {
28 : kRGBA_8888_ColorFormat,
29 : kBGRA_8888_ColorFormat,
30 :
31 : // Unsigned, big-endian, 16-bit integer
32 : kRGB_U16_BE_ColorFormat, // Src only
33 : kRGBA_U16_BE_ColorFormat, // Src only
34 :
35 : kRGBA_F16_ColorFormat,
36 : kRGBA_F32_ColorFormat,
37 :
38 : kBGR_565_ColorFormat, // Dst only, kOpaque only
39 : };
40 :
41 : /**
42 : * Apply the color conversion to a |src| buffer, storing the output in the |dst| buffer.
43 : *
44 : * F16 and F32 are only supported when the color space is linear. This function will return
45 : * false in unsupported cases.
46 : *
47 : * @param dst Stored in the format described by |dstColorFormat|
48 : * @param src Stored in the format described by |srcColorFormat|
49 : * @param len Number of pixels in the buffers
50 : * @param dstColorFormat Describes color format of |dst|
51 : * @param srcColorFormat Describes color format of |src|
52 : * @param alphaType Describes alpha properties of the |dst| (and |src|)
53 : * kUnpremul preserves input alpha values
54 : * kPremul performs a premultiplication and also preserves alpha values
55 : * kOpaque optimization hint, |dst| alphas set to 1
56 : *
57 : */
58 : bool apply(ColorFormat dstFormat, void* dst, ColorFormat srcFormat, const void* src, int count,
59 : SkAlphaType alphaType) const;
60 :
61 0 : virtual ~SkColorSpaceXform() {}
62 :
63 : protected:
64 0 : SkColorSpaceXform() {}
65 : };
66 :
67 : #endif
|