1 //========================================================================
5 // Copyright 2002 Glyph & Cog, LLC
7 //========================================================================
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
17 #include "XPixmapOutputDev.h"
19 //------------------------------------------------------------------------
21 #define xoutRound(x) ((int)(x + 0.5))
23 //------------------------------------------------------------------------
25 XPixmapOutputDev::XPixmapOutputDev(Display *displayA, int screenNumA,
26 Visual *visualA, Colormap colormapA,
27 GBool reverseVideoA, Gulong paperColorA,
28 GBool installCmapA, int rgbCubeSizeA,
29 GBool incrementalUpdateA,
30 void (*redrawCbkA)(void *data),
31 void *redrawCbkDataA):
32 XOutputDev(displayA, screenNumA, visualA, colormapA,
33 reverseVideoA, paperColorA, installCmapA, rgbCubeSizeA)
35 incrementalUpdate = incrementalUpdateA;
36 redrawCbk = redrawCbkA;
37 redrawCbkData = redrawCbkDataA;
40 XPixmapOutputDev::~XPixmapOutputDev() {
41 if (getPixmapWidth() > 0) {
42 XFreePixmap(getDisplay(), getPixmap());
46 void XPixmapOutputDev::clear() {
51 void XPixmapOutputDev::startPage(int pageNum, GfxState *state) {
52 int oldPixmapW, oldPixmapH, newPixmapW, newPixmapH;
54 // resize the off-screen pixmap (if needed)
55 oldPixmapW = getPixmapWidth();
56 oldPixmapH = getPixmapHeight();
57 newPixmapW = xoutRound(state ? state->getPageWidth() : 1);
58 newPixmapH = xoutRound(state ? state->getPageHeight() : 1);
59 if (oldPixmapW == 0 ||
60 newPixmapW != oldPixmapW || newPixmapH != oldPixmapH) {
62 XFreePixmap(getDisplay(), getPixmap());
64 setPixmap(XCreatePixmap(getDisplay(), win, newPixmapW, newPixmapH,
66 newPixmapW, newPixmapH);
69 XOutputDev::startPage(pageNum, state);
72 void XPixmapOutputDev::endPage() {
73 if (!incrementalUpdate) {
74 (*redrawCbk)(redrawCbkData);
76 XOutputDev::endPage();
79 void XPixmapOutputDev::dump() {
80 if (incrementalUpdate) {
81 (*redrawCbk)(redrawCbkData);