filters
XPixmapOutputDev.cc00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <aconf.h>
00010
00011 #ifdef USE_GCC_PRAGMAS
00012 #pragma implementation
00013 #endif
00014
00015 #include "Object.h"
00016 #include "GfxState.h"
00017 #include "XPixmapOutputDev.h"
00018
00019
00020
00021 #define xoutRound(x) ((int)(x + 0.5))
00022
00023
00024
00025 XPixmapOutputDev::XPixmapOutputDev(Display *displayA, int screenNumA,
00026 Visual *visualA, Colormap colormapA,
00027 GBool reverseVideoA, Gulong paperColorA,
00028 GBool installCmapA, int rgbCubeSizeA,
00029 GBool incrementalUpdateA,
00030 void (*redrawCbkA)(void *data),
00031 void *redrawCbkDataA):
00032 XOutputDev(displayA, screenNumA, visualA, colormapA,
00033 reverseVideoA, paperColorA, installCmapA, rgbCubeSizeA)
00034 {
00035 incrementalUpdate = incrementalUpdateA;
00036 redrawCbk = redrawCbkA;
00037 redrawCbkData = redrawCbkDataA;
00038 }
00039
00040 XPixmapOutputDev::~XPixmapOutputDev() {
00041 if (getPixmapWidth() > 0) {
00042 XFreePixmap(getDisplay(), getPixmap());
00043 }
00044 }
00045
00046 void XPixmapOutputDev::clear() {
00047 startDoc(NULL);
00048 startPage(0, NULL);
00049 }
00050
00051 void XPixmapOutputDev::startPage(int pageNum, GfxState *state) {
00052 int oldPixmapW, oldPixmapH, newPixmapW, newPixmapH;
00053
00054
00055 oldPixmapW = getPixmapWidth();
00056 oldPixmapH = getPixmapHeight();
00057 newPixmapW = xoutRound(state ? state->getPageWidth() : 1);
00058 newPixmapH = xoutRound(state ? state->getPageHeight() : 1);
00059 if (oldPixmapW == 0 ||
00060 newPixmapW != oldPixmapW || newPixmapH != oldPixmapH) {
00061 if (oldPixmapW > 0) {
00062 XFreePixmap(getDisplay(), getPixmap());
00063 }
00064 setPixmap(XCreatePixmap(getDisplay(), win, newPixmapW, newPixmapH,
00065 getDepth()),
00066 newPixmapW, newPixmapH);
00067 }
00068
00069 XOutputDev::startPage(pageNum, state);
00070 }
00071
00072 void XPixmapOutputDev::endPage() {
00073 if (!incrementalUpdate) {
00074 (*redrawCbk)(redrawCbkData);
00075 }
00076 XOutputDev::endPage();
00077 }
00078
00079 void XPixmapOutputDev::dump() {
00080 if (incrementalUpdate) {
00081 (*redrawCbk)(redrawCbkData);
00082 }
00083 XOutputDev::dump();
00084 }
|