# use AROS_LIB/INCLUDES
[AROS-Contrib.git] / arospdf / splash / SplashState.cc
blobe2c34c442747f3ae1789b7e4b92b6000307e787c
1 //========================================================================
2 //
3 // SplashState.cc
4 //
5 //========================================================================
7 #include <aconf.h>
9 #ifdef USE_GCC_PRAGMAS
10 #pragma implementation
11 #endif
13 #include <string.h>
14 #include "gmem.h"
15 #include "SplashPattern.h"
16 #include "SplashScreen.h"
17 #include "SplashClip.h"
18 #include "SplashBitmap.h"
19 #include "SplashState.h"
21 //------------------------------------------------------------------------
22 // SplashState
23 //------------------------------------------------------------------------
25 // number of components in each color mode
26 int splashColorModeNComps[] = {
27 1, 1, 3, 3, 4
30 SplashState::SplashState(int width, int height, GBool vectorAntialias,
31 SplashScreenParams *screenParams) {
32 SplashColor color;
34 matrix[0] = 1; matrix[1] = 0;
35 matrix[2] = 0; matrix[3] = 1;
36 matrix[4] = 0; matrix[5] = 0;
37 memset(&color, 0, sizeof(SplashColor));
38 strokePattern = new SplashSolidColor(color);
39 fillPattern = new SplashSolidColor(color);
40 screen = new SplashScreen(screenParams);
41 blendFunc = NULL;
42 strokeAlpha = 1;
43 fillAlpha = 1;
44 lineWidth = 0;
45 lineCap = splashLineCapButt;
46 lineJoin = splashLineJoinMiter;
47 miterLimit = 10;
48 flatness = 1;
49 lineDash = NULL;
50 lineDashLength = 0;
51 lineDashPhase = 0;
52 strokeAdjust = gFalse;
53 clip = new SplashClip(0, 0, width - 0.001, height - 0.001, vectorAntialias);
54 softMask = NULL;
55 deleteSoftMask = gFalse;
56 inNonIsolatedGroup = gFalse;
57 next = NULL;
60 SplashState::SplashState(int width, int height, GBool vectorAntialias,
61 SplashScreen *screenA) {
62 SplashColor color;
64 matrix[0] = 1; matrix[1] = 0;
65 matrix[2] = 0; matrix[3] = 1;
66 matrix[4] = 0; matrix[5] = 0;
67 memset(&color, 0, sizeof(SplashColor));
68 strokePattern = new SplashSolidColor(color);
69 fillPattern = new SplashSolidColor(color);
70 screen = screenA->copy();
71 blendFunc = NULL;
72 strokeAlpha = 1;
73 fillAlpha = 1;
74 lineWidth = 0;
75 lineCap = splashLineCapButt;
76 lineJoin = splashLineJoinMiter;
77 miterLimit = 10;
78 flatness = 1;
79 lineDash = NULL;
80 lineDashLength = 0;
81 lineDashPhase = 0;
82 strokeAdjust = gFalse;
83 clip = new SplashClip(0, 0, width - 0.001, height - 0.001, vectorAntialias);
84 softMask = NULL;
85 deleteSoftMask = gFalse;
86 inNonIsolatedGroup = gFalse;
87 next = NULL;
90 SplashState::SplashState(SplashState *state) {
91 memcpy(matrix, state->matrix, 6 * sizeof(SplashCoord));
92 strokePattern = state->strokePattern->copy();
93 fillPattern = state->fillPattern->copy();
94 screen = state->screen->copy();
95 blendFunc = state->blendFunc;
96 strokeAlpha = state->strokeAlpha;
97 fillAlpha = state->fillAlpha;
98 lineWidth = state->lineWidth;
99 lineCap = state->lineCap;
100 lineJoin = state->lineJoin;
101 miterLimit = state->miterLimit;
102 flatness = state->flatness;
103 if (state->lineDash) {
104 lineDashLength = state->lineDashLength;
105 lineDash = (SplashCoord *)gmallocn(lineDashLength, sizeof(SplashCoord));
106 memcpy(lineDash, state->lineDash, lineDashLength * sizeof(SplashCoord));
107 } else {
108 lineDash = NULL;
109 lineDashLength = 0;
111 lineDashPhase = state->lineDashPhase;
112 strokeAdjust = state->strokeAdjust;
113 clip = state->clip->copy();
114 softMask = state->softMask;
115 deleteSoftMask = gFalse;
116 inNonIsolatedGroup = state->inNonIsolatedGroup;
117 next = NULL;
120 SplashState::~SplashState() {
121 delete strokePattern;
122 delete fillPattern;
123 delete screen;
124 gfree(lineDash);
125 delete clip;
126 if (deleteSoftMask && softMask) {
127 delete softMask;
131 void SplashState::setStrokePattern(SplashPattern *strokePatternA) {
132 delete strokePattern;
133 strokePattern = strokePatternA;
136 void SplashState::setFillPattern(SplashPattern *fillPatternA) {
137 delete fillPattern;
138 fillPattern = fillPatternA;
141 void SplashState::setScreen(SplashScreen *screenA) {
142 delete screen;
143 screen = screenA;
146 void SplashState::setLineDash(SplashCoord *lineDashA, int lineDashLengthA,
147 SplashCoord lineDashPhaseA) {
148 gfree(lineDash);
149 lineDashLength = lineDashLengthA;
150 if (lineDashLength > 0) {
151 lineDash = (SplashCoord *)gmallocn(lineDashLength, sizeof(SplashCoord));
152 memcpy(lineDash, lineDashA, lineDashLength * sizeof(SplashCoord));
153 } else {
154 lineDash = NULL;
156 lineDashPhase = lineDashPhaseA;
159 void SplashState::setSoftMask(SplashBitmap *softMaskA) {
160 if (deleteSoftMask) {
161 delete softMask;
163 softMask = softMaskA;
164 deleteSoftMask = gTrue;