diff options
author | Martin Kretzschmar <mkretzschmar@src.gnome.org> | 2004-05-17 18:12:38 (GMT) |
---|---|---|
committer | Martin Kretzschmar <mkretzschmar@src.gnome.org> | 2004-05-17 18:12:38 (GMT) |
commit | bace4ea18c03bfcaadab55300bc15290f87540c7 (patch) | |
tree | 48c9c670e4dde608d50fe68e00e783f18af8697b /pdf/splash/SplashState.cc | |
parent | ad63666daeeda50acc7630132d61fe044634fddd (diff) |
Initial revision
Diffstat (limited to 'pdf/splash/SplashState.cc')
-rw-r--r-- | pdf/splash/SplashState.cc | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/pdf/splash/SplashState.cc b/pdf/splash/SplashState.cc new file mode 100644 index 0000000..7d5dc83 --- /dev/null +++ b/pdf/splash/SplashState.cc @@ -0,0 +1,99 @@ +//======================================================================== +// +// SplashState.cc +// +//======================================================================== + +#include <aconf.h> + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include <string.h> +#include "gmem.h" +#include "SplashPattern.h" +#include "SplashScreen.h" +#include "SplashClip.h" +#include "SplashState.h" + +//------------------------------------------------------------------------ +// SplashState +//------------------------------------------------------------------------ + +SplashState::SplashState(int width, int height) { + SplashColor color; + + memset(&color, 0, sizeof(SplashColor)); + strokePattern = new SplashSolidColor(color); + fillPattern = new SplashSolidColor(color); + screen = new SplashScreen(10); + lineWidth = 0; + lineCap = splashLineCapButt; + lineJoin = splashLineJoinMiter; + miterLimit = 10; + flatness = 1; + lineDash = NULL; + lineDashLength = 0; + lineDashPhase = 0; + clip = new SplashClip(0, 0, width - 1, height - 1); + next = NULL; +} + +SplashState::SplashState(SplashState *state) { + strokePattern = state->strokePattern->copy(); + fillPattern = state->fillPattern->copy(); + screen = state->screen->copy(); + lineWidth = state->lineWidth; + lineCap = state->lineCap; + lineJoin = state->lineJoin; + miterLimit = state->miterLimit; + flatness = state->flatness; + if (state->lineDash) { + lineDashLength = state->lineDashLength; + lineDash = (SplashCoord *)gmalloc(lineDashLength * sizeof(SplashCoord)); + memcpy(lineDash, state->lineDash, lineDashLength * sizeof(SplashCoord)); + } else { + lineDash = NULL; + lineDashLength = 0; + } + lineDashPhase = state->lineDashPhase; + clip = state->clip->copy(); + next = NULL; +} + +SplashState::~SplashState() { + delete strokePattern; + delete fillPattern; + delete screen; + gfree(lineDash); + delete clip; +} + +void SplashState::setStrokePattern(SplashPattern *strokePatternA) { + delete strokePattern; + strokePattern = strokePatternA; +} + +void SplashState::setFillPattern(SplashPattern *fillPatternA) { + delete fillPattern; + fillPattern = fillPatternA; +} + +void SplashState::setScreen(SplashScreen *screenA) { + delete screen; + screen = screenA; +} + +void SplashState::setLineDash(SplashCoord *lineDashA, int lineDashLengthA, + SplashCoord lineDashPhaseA) { + gfree(lineDash); + lineDashLength = lineDashLengthA; + if (lineDashLength > 0) { + lineDash = (SplashCoord *)gmalloc(lineDashLength * sizeof(SplashCoord)); + memcpy(lineDash, lineDashA, lineDashLength * sizeof(SplashCoord)); + } else { + lineDash = NULL; + } + lineDashPhase = lineDashPhaseA; +} |