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_BLCONTEXT_P_H
8#define BLEND2D_BLCONTEXT_P_H
9
10#include "./blapi-internal_p.h"
11#include "./blarray_p.h"
12#include "./blcontext.h"
13#include "./blpath_p.h"
14#include "./blsupport_p.h"
15#include "./blthreading_p.h"
16
17//! \cond INTERNAL
18//! \addtogroup blend2d_internal
19//! \{
20
21// ============================================================================
22// [Constants]
23// ============================================================================
24
25static constexpr const double BL_CONTEXT_MINIMUM_TOLERANCE = 0.01;
26static constexpr const double BL_CONTEXT_MAXIMUM_TOLERANCE = 0.50;
27
28// ============================================================================
29// [Utilities]
30// ============================================================================
31
32static BL_INLINE void blContextStateInit(BLContextState* self) noexcept {
33 self->hints.reset();
34 self->compOp = uint8_t(BL_COMP_OP_SRC_OVER);
35 self->fillRule = uint8_t(BL_FILL_RULE_NON_ZERO);
36 self->styleType[BL_CONTEXT_OP_TYPE_FILL] = uint8_t(BL_STYLE_TYPE_NONE);
37 self->styleType[BL_CONTEXT_OP_TYPE_STROKE] = uint8_t(BL_STYLE_TYPE_NONE);
38 memset(self->reserved, 0, sizeof(self->reserved));
39
40 self->approximationOptions = blMakeDefaultApproximationOptions();
41 self->globalAlpha = 1.0;
42 self->styleAlpha[BL_CONTEXT_OP_TYPE_FILL] = 1.0;
43 self->styleAlpha[BL_CONTEXT_OP_TYPE_STROKE] = 1.0;
44
45 blStrokeOptionsInit(&self->strokeOptions);
46 self->metaMatrix.reset();
47 self->userMatrix.reset();
48 self->savedStateCount = 0;
49}
50
51static BL_INLINE void blContextStateDestroy(BLContextState* self) noexcept {
52 blArrayReset(&self->strokeOptions.dashArray);
53}
54
55BL_HIDDEN extern BLWrap<BLContextState> blNullContextState;
56BL_HIDDEN extern BLAtomicUInt64Generator blContextIdGenerator;
57
58//! \}
59//! \endcond
60
61#endif // BLEND2D_BLCONTEXT_P_H
62