source: trunk/poppler/mypoppler/splash/SplashState.cc @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 15 years ago

First import

File size: 2.8 KB
Line 
1//========================================================================
2//
3// SplashState.cc
4//
5//========================================================================
6
7#include <config.h>
8
9#ifdef USE_GCC_PRAGMAS
10#pragma implementation
11#endif
12
13#include <string.h>
14#include "goo/gmem.h"
15#include "SplashPattern.h"
16#include "SplashScreen.h"
17#include "SplashClip.h"
18#include "SplashState.h"
19
20//------------------------------------------------------------------------
21// SplashState
22//------------------------------------------------------------------------
23
24// number of components in each color mode
25int splashColorModeNComps[] = {
26  1, 1, 2, 3, 3, 4, 4
27};
28
29SplashState::SplashState(int width, int height) {
30  SplashColor color;
31
32  memset(&color, 0, sizeof(SplashColor));
33  strokePattern = new SplashSolidColor(color);
34  fillPattern = new SplashSolidColor(color);
35  screen = new SplashScreen(10);
36  blendFunc = NULL;
37  strokeAlpha = 1;
38  fillAlpha = 1;
39  lineWidth = 0;
40  lineCap = splashLineCapButt;
41  lineJoin = splashLineJoinMiter;
42  miterLimit = 10;
43  flatness = 1;
44  lineDash = NULL;
45  lineDashLength = 0;
46  lineDashPhase = 0;
47  clip = new SplashClip(0, 0, width - 1, height - 1);
48  next = NULL;
49}
50
51SplashState::SplashState(SplashState *state) {
52  strokePattern = state->strokePattern->copy();
53  fillPattern = state->fillPattern->copy();
54  screen = state->screen->copy();
55  blendFunc = state->blendFunc;
56  strokeAlpha = state->strokeAlpha;
57  fillAlpha = state->fillAlpha;
58  lineWidth = state->lineWidth;
59  lineCap = state->lineCap;
60  lineJoin = state->lineJoin;
61  miterLimit = state->miterLimit;
62  flatness = state->flatness;
63  if (state->lineDash) {
64    lineDashLength = state->lineDashLength;
65    lineDash = (SplashCoord *)gmallocn(lineDashLength, sizeof(SplashCoord));
66    memcpy(lineDash, state->lineDash, lineDashLength * sizeof(SplashCoord));
67  } else {
68    lineDash = NULL;
69    lineDashLength = 0;
70  }
71  lineDashPhase = state->lineDashPhase;
72  clip = state->clip->copy();
73  next = NULL;
74}
75
76SplashState::~SplashState() {
77  delete strokePattern;
78  delete fillPattern;
79  delete screen;
80  gfree(lineDash);
81  delete clip;
82}
83
84void SplashState::setStrokePattern(SplashPattern *strokePatternA) {
85  delete strokePattern;
86  strokePattern = strokePatternA;
87}
88
89void SplashState::setFillPattern(SplashPattern *fillPatternA) {
90  delete fillPattern;
91  fillPattern = fillPatternA;
92}
93
94void SplashState::setScreen(SplashScreen *screenA) {
95  delete screen;
96  screen = screenA;
97}
98
99void SplashState::setLineDash(SplashCoord *lineDashA, int lineDashLengthA,
100                              SplashCoord lineDashPhaseA) {
101  gfree(lineDash);
102  lineDashLength = lineDashLengthA;
103  if (lineDashLength > 0) {
104    lineDash = (SplashCoord *)gmallocn(lineDashLength, sizeof(SplashCoord));
105    memcpy(lineDash, lineDashA, lineDashLength * sizeof(SplashCoord));
106  } else {
107    lineDash = NULL;
108  }
109  lineDashPhase = lineDashPhaseA;
110}
Note: See TracBrowser for help on using the repository browser.