1 | // LAF OS Library |
2 | // Copyright (C) 2018-2020 Igara Studio S.A. |
3 | // |
4 | // This file is released under the terms of the MIT license. |
5 | // Read LICENSE.txt for more information. |
6 | |
7 | #ifndef OS_SKIA_SKIA_COLOR_SPACE_INCLUDED |
8 | #define OS_SKIA_SKIA_COLOR_SPACE_INCLUDED |
9 | #pragma once |
10 | |
11 | #include "base/disable_copying.h" |
12 | #include "os/color_space.h" |
13 | |
14 | #include "include/core/SkColorSpace.h" |
15 | |
16 | namespace os { |
17 | |
18 | class SkiaColorSpace : public ColorSpace { |
19 | public: |
20 | SkiaColorSpace(const gfx::ColorSpaceRef& gfxcs); |
21 | |
22 | const gfx::ColorSpaceRef& gfxColorSpace() const override { return m_gfxcs; } |
23 | sk_sp<SkColorSpace> skColorSpace() const { return m_skcs; } |
24 | |
25 | const bool isSRGB() const override { return m_skcs->isSRGB(); } |
26 | |
27 | private: |
28 | gfx::ColorSpaceRef m_gfxcs; |
29 | sk_sp<SkColorSpace> m_skcs; |
30 | |
31 | DISABLE_COPYING(SkiaColorSpace); |
32 | }; |
33 | |
34 | class SkiaColorSpaceConversion : public ColorSpaceConversion { |
35 | public: |
36 | SkiaColorSpaceConversion(const os::ColorSpaceRef& srcColorSpace, |
37 | const os::ColorSpaceRef& dstColorSpace); |
38 | |
39 | bool convertRgba(uint32_t* dst, const uint32_t* src, int n) override; |
40 | bool convertGray(uint8_t* dst, const uint8_t* src, int n) override; |
41 | |
42 | private: |
43 | os::ColorSpaceRef m_srcCS; |
44 | os::ColorSpaceRef m_dstCS; |
45 | }; |
46 | |
47 | } // namespace os |
48 | |
49 | #endif |
50 | |