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_BLIMAGE_P_H |
8 | #define BLEND2D_BLIMAGE_P_H |
9 | |
10 | #include "./blapi-internal_p.h" |
11 | #include "./blimage.h" |
12 | #include "./blsupport_p.h" |
13 | |
14 | //! \cond INTERNAL |
15 | //! \addtogroup blend2d_internal |
16 | //! \{ |
17 | |
18 | // ============================================================================ |
19 | // [BLImage - Internal] |
20 | // ============================================================================ |
21 | |
22 | enum : uint32_t { BL_INTERNAL_IMAGE_DATA_ALIGNMENT = 8 }; |
23 | |
24 | //! Internal implementation that extends `BLImagetImpl`. |
25 | struct BLInternalImageImpl : public BLImageImpl { |
26 | //! Count of writers that write to this image. |
27 | //! |
28 | //! Writers don't increase the reference count of the image to keep it |
29 | //! mutable. However, we must keep a counter that would tell the BLImage |
30 | //! destructor that it's not the time if `writerCount > 0`. |
31 | volatile size_t writerCount; |
32 | }; |
33 | |
34 | template<> |
35 | struct BLInternalCastImpl<BLImageImpl> { typedef BLInternalImageImpl Type; }; |
36 | |
37 | static BL_INLINE size_t blImageStrideForWidth(uint32_t width, uint32_t depth) noexcept { |
38 | return depth <= 8 ? (size_t(width) * depth + 7u) / 8u |
39 | : blAlignUp<size_t>(size_t(width) * (depth / 8u), (depth <= 32) ? 4 : 8); |
40 | } |
41 | |
42 | BL_HIDDEN BLResult blImageImplDelete(BLImageImpl* impl) noexcept; |
43 | |
44 | //! \} |
45 | //! \endcond |
46 | |
47 | #endif // BLEND2D_BLIMAGE_P_H |
48 | |