1 | // [Blend2D] |
2 | // 2D Vector Graphics Powered by a JIT Compiler. |
3 | // |
4 | // [License] |
5 | // Zlib - See LICENSE.md file in the package. |
6 | |
7 | #ifndef BLEND2D_BLIMAGESCALE_P_H |
8 | #define BLEND2D_BLIMAGESCALE_P_H |
9 | |
10 | #include "./blgeometry.h" |
11 | #include "./blimage.h" |
12 | |
13 | //! \cond INTERNAL |
14 | //! \addtogroup blend2d_internal |
15 | //! \{ |
16 | |
17 | // ============================================================================ |
18 | // [BLImageScaleContext] |
19 | // ============================================================================ |
20 | |
21 | //! Low-level image scaling context. |
22 | class BLImageScaleContext { |
23 | public: |
24 | enum Dir : uint32_t { |
25 | kDirHorz = 0, |
26 | kDirVert = 1 |
27 | }; |
28 | |
29 | struct Record { |
30 | uint32_t pos; |
31 | uint32_t count; |
32 | }; |
33 | |
34 | struct Data { |
35 | int dstSize[2]; |
36 | int srcSize[2]; |
37 | int kernelSize[2]; |
38 | int isUnbound[2]; |
39 | |
40 | double scale[2]; |
41 | double factor[2]; |
42 | double radius[2]; |
43 | |
44 | int32_t* weightList[2]; |
45 | Record* recordList[2]; |
46 | }; |
47 | |
48 | Data* data; |
49 | |
50 | BL_INLINE BLImageScaleContext() noexcept |
51 | : data(nullptr) {} |
52 | |
53 | BL_INLINE ~BLImageScaleContext() noexcept { reset(); } |
54 | |
55 | BL_INLINE bool isInitialized() const noexcept { return data != nullptr; } |
56 | |
57 | BL_INLINE int dstWidth() const noexcept { return data->dstSize[kDirHorz]; } |
58 | BL_INLINE int dstHeight() const noexcept { return data->dstSize[kDirVert]; } |
59 | |
60 | BL_INLINE int srcWidth() const noexcept { return data->srcSize[kDirHorz]; } |
61 | BL_INLINE int srcHeight() const noexcept { return data->srcSize[kDirVert]; } |
62 | |
63 | BL_HIDDEN BLResult reset() noexcept; |
64 | BL_HIDDEN BLResult create(const BLSizeI& to, const BLSizeI& from, uint32_t filter, const BLImageScaleOptions* options) noexcept; |
65 | |
66 | BL_HIDDEN BLResult processHorzData(uint8_t* dstLine, intptr_t dstStride, const uint8_t* srcLine, intptr_t srcStride, uint32_t format) const noexcept; |
67 | BL_HIDDEN BLResult processVertData(uint8_t* dstLine, intptr_t dstStride, const uint8_t* srcLine, intptr_t srcStride, uint32_t format) const noexcept; |
68 | }; |
69 | |
70 | //! \} |
71 | //! \endcond |
72 | |
73 | #endif // BLEND2D_BLIMAGESCALE_P_H |
74 | |