1 //========================================================================
2 //
3 // OutputDev.cc
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 //========================================================================
10 //
11 // Modified under the Poppler project - http://poppler.freedesktop.org
12 //
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
15 //
16 // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com>
17 // Copyright (C) 2006 Thorkild Stray <thorkild@ifi.uio.no>
18 // Copyright (C) 2007 Adrian Johnson <ajohnson@redneon.com>
19 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
20 // Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
21 //
22 // To see a description of the changes please see the Changelog file that
23 // came with your tarball or type make ChangeLog if you are building from git
24 //
25 //========================================================================
26
27 #include <config.h>
28
29 #ifdef USE_GCC_PRAGMAS
30 #pragma implementation
31 #endif
32
33 #include <stddef.h>
34 #include "Object.h"
35 #include "Stream.h"
36 #include "GfxState.h"
37 #include "OutputDev.h"
38 #include "goo/GooHash.h"
39
40 //------------------------------------------------------------------------
41 // OutputDev
42 //------------------------------------------------------------------------
43
setDefaultCTM(double * ctm)44 void OutputDev::setDefaultCTM(double *ctm) {
45 int i;
46 double det;
47
48 for (i = 0; i < 6; ++i) {
49 defCTM[i] = ctm[i];
50 }
51 det = 1 / (defCTM[0] * defCTM[3] - defCTM[1] * defCTM[2]);
52 defICTM[0] = defCTM[3] * det;
53 defICTM[1] = -defCTM[1] * det;
54 defICTM[2] = -defCTM[2] * det;
55 defICTM[3] = defCTM[0] * det;
56 defICTM[4] = (defCTM[2] * defCTM[5] - defCTM[3] * defCTM[4]) * det;
57 defICTM[5] = (defCTM[1] * defCTM[4] - defCTM[0] * defCTM[5]) * det;
58 }
59
cvtDevToUser(double dx,double dy,double * ux,double * uy)60 void OutputDev::cvtDevToUser(double dx, double dy, double *ux, double *uy) {
61 *ux = defICTM[0] * dx + defICTM[2] * dy + defICTM[4];
62 *uy = defICTM[1] * dx + defICTM[3] * dy + defICTM[5];
63 }
64
cvtUserToDev(double ux,double uy,int * dx,int * dy)65 void OutputDev::cvtUserToDev(double ux, double uy, int *dx, int *dy) {
66 *dx = (int)(defCTM[0] * ux + defCTM[2] * uy + defCTM[4] + 0.5);
67 *dy = (int)(defCTM[1] * ux + defCTM[3] * uy + defCTM[5] + 0.5);
68 }
69
updateAll(GfxState * state)70 void OutputDev::updateAll(GfxState *state) {
71 updateLineDash(state);
72 updateFlatness(state);
73 updateLineJoin(state);
74 updateLineCap(state);
75 updateMiterLimit(state);
76 updateLineWidth(state);
77 updateStrokeAdjust(state);
78 updateFillColorSpace(state);
79 updateFillColor(state);
80 updateStrokeColorSpace(state);
81 updateStrokeColor(state);
82 updateBlendMode(state);
83 updateFillOpacity(state);
84 updateStrokeOpacity(state);
85 updateFillOverprint(state);
86 updateStrokeOverprint(state);
87 updateTransfer(state);
88 updateFont(state);
89 }
90
beginType3Char(GfxState * state,double x,double y,double dx,double dy,CharCode code,Unicode * u,int uLen)91 GBool OutputDev::beginType3Char(GfxState *state, double x, double y,
92 double dx, double dy,
93 CharCode code, Unicode *u, int uLen) {
94 return gFalse;
95 }
96
drawImageMask(GfxState * state,Object * ref,Stream * str,int width,int height,GBool invert,GBool interpolate,GBool inlineImg)97 void OutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
98 int width, int height, GBool invert,
99 GBool interpolate, GBool inlineImg) {
100 int i, j;
101
102 if (inlineImg) {
103 str->reset();
104 j = height * ((width + 7) / 8);
105 for (i = 0; i < j; ++i)
106 str->getChar();
107 str->close();
108 }
109 }
110
drawImage(GfxState * state,Object * ref,Stream * str,int width,int height,GfxImageColorMap * colorMap,GBool interpolate,int * maskColors,GBool inlineImg)111 void OutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
112 int width, int height, GfxImageColorMap *colorMap,
113 GBool interpolate, int *maskColors, GBool inlineImg) {
114 int i, j;
115
116 if (inlineImg) {
117 str->reset();
118 j = height * ((width * colorMap->getNumPixelComps() *
119 colorMap->getBits() + 7) / 8);
120 for (i = 0; i < j; ++i)
121 str->getChar();
122 str->close();
123 }
124 }
125
drawMaskedImage(GfxState * state,Object * ref,Stream * str,int width,int height,GfxImageColorMap * colorMap,GBool interpolate,Stream * maskStr,int maskWidth,int maskHeight,GBool maskInvert,GBool maskInterpolate)126 void OutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
127 int width, int height,
128 GfxImageColorMap *colorMap,
129 GBool interpolate,
130 Stream *maskStr,
131 int maskWidth, int maskHeight,
132 GBool maskInvert,
133 GBool maskInterpolate) {
134 drawImage(state, ref, str, width, height, colorMap, interpolate, NULL, gFalse);
135 }
136
drawSoftMaskedImage(GfxState * state,Object * ref,Stream * str,int width,int height,GfxImageColorMap * colorMap,GBool interpolate,Stream * maskStr,int maskWidth,int maskHeight,GfxImageColorMap * maskColorMap,GBool maskInterpolate)137 void OutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
138 int width, int height,
139 GfxImageColorMap *colorMap,
140 GBool interpolate,
141 Stream *maskStr,
142 int maskWidth, int maskHeight,
143 GfxImageColorMap *maskColorMap,
144 GBool maskInterpolate) {
145 drawImage(state, ref, str, width, height, colorMap, interpolate, NULL, gFalse);
146 }
147
endMarkedContent(GfxState * state)148 void OutputDev::endMarkedContent(GfxState *state) {
149 }
150
beginMarkedContent(char * name,Dict * properties)151 void OutputDev::beginMarkedContent(char *name, Dict *properties) {
152 }
153
markPoint(char * name)154 void OutputDev::markPoint(char *name) {
155 }
156
markPoint(char * name,Dict * properties)157 void OutputDev::markPoint(char *name, Dict *properties) {
158 }
159
160
161 #if OPI_SUPPORT
opiBegin(GfxState * state,Dict * opiDict)162 void OutputDev::opiBegin(GfxState *state, Dict *opiDict) {
163 }
164
opiEnd(GfxState * state,Dict * opiDict)165 void OutputDev::opiEnd(GfxState *state, Dict *opiDict) {
166 }
167 #endif
168
startProfile()169 void OutputDev::startProfile() {
170 if (profileHash)
171 delete profileHash;
172
173 profileHash = new GooHash (true);
174 }
175
endProfile()176 GooHash *OutputDev::endProfile() {
177 GooHash *profile = profileHash;
178
179 profileHash = NULL;
180
181 return profile;
182 }
183
184