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, 2012, 2013 Albert Astals Cid <aacid@kde.org>
21 // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
22 //
23 // To see a description of the changes please see the Changelog file that
24 // came with your tarball or type make ChangeLog if you are building from git
25 //
26 //========================================================================
27
28 #include <config.h>
29
30 #ifdef USE_GCC_PRAGMAS
31 #pragma implementation
32 #endif
33
34 #include <stddef.h>
35 #include "Object.h"
36 #include "Stream.h"
37 #include "GfxState.h"
38 #include "OutputDev.h"
39 #include "goo/GooHash.h"
40
41 //------------------------------------------------------------------------
42 // OutputDev
43 //------------------------------------------------------------------------
44
setDefaultCTM(double * ctm)45 void OutputDev::setDefaultCTM(double *ctm) {
46 int i;
47 double det;
48
49 for (i = 0; i < 6; ++i) {
50 defCTM[i] = ctm[i];
51 }
52 det = 1 / (defCTM[0] * defCTM[3] - defCTM[1] * defCTM[2]);
53 defICTM[0] = defCTM[3] * det;
54 defICTM[1] = -defCTM[1] * det;
55 defICTM[2] = -defCTM[2] * det;
56 defICTM[3] = defCTM[0] * det;
57 defICTM[4] = (defCTM[2] * defCTM[5] - defCTM[3] * defCTM[4]) * det;
58 defICTM[5] = (defCTM[1] * defCTM[4] - defCTM[0] * defCTM[5]) * det;
59 }
60
cvtDevToUser(double dx,double dy,double * ux,double * uy)61 void OutputDev::cvtDevToUser(double dx, double dy, double *ux, double *uy) {
62 *ux = defICTM[0] * dx + defICTM[2] * dy + defICTM[4];
63 *uy = defICTM[1] * dx + defICTM[3] * dy + defICTM[5];
64 }
65
cvtUserToDev(double ux,double uy,int * dx,int * dy)66 void OutputDev::cvtUserToDev(double ux, double uy, int *dx, int *dy) {
67 *dx = (int)(defCTM[0] * ux + defCTM[2] * uy + defCTM[4] + 0.5);
68 *dy = (int)(defCTM[1] * ux + defCTM[3] * uy + defCTM[5] + 0.5);
69 }
70
updateAll(GfxState * state)71 void OutputDev::updateAll(GfxState *state) {
72 updateLineDash(state);
73 updateFlatness(state);
74 updateLineJoin(state);
75 updateLineCap(state);
76 updateMiterLimit(state);
77 updateLineWidth(state);
78 updateStrokeAdjust(state);
79 updateFillColorSpace(state);
80 updateFillColor(state);
81 updateStrokeColorSpace(state);
82 updateStrokeColor(state);
83 updateBlendMode(state);
84 updateFillOpacity(state);
85 updateStrokeOpacity(state);
86 updateFillOverprint(state);
87 updateStrokeOverprint(state);
88 updateTransfer(state);
89 updateFont(state);
90 }
91
beginType3Char(GfxState * state,double x,double y,double dx,double dy,CharCode code,Unicode * u,int uLen)92 GBool OutputDev::beginType3Char(GfxState *state, double x, double y,
93 double dx, double dy,
94 CharCode code, Unicode *u, int uLen) {
95 return gFalse;
96 }
97
drawImageMask(GfxState * state,Object * ref,Stream * str,int width,int height,GBool invert,GBool interpolate,GBool inlineImg)98 void OutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
99 int width, int height, GBool invert,
100 GBool interpolate, GBool inlineImg) {
101 int i, j;
102
103 if (inlineImg) {
104 str->reset();
105 j = height * ((width + 7) / 8);
106 for (i = 0; i < j; ++i)
107 str->getChar();
108 str->close();
109 }
110 }
111
setSoftMaskFromImageMask(GfxState * state,Object * ref,Stream * str,int width,int height,GBool invert,GBool inlineImg,double * baseMatrix)112 void OutputDev::setSoftMaskFromImageMask(GfxState *state,
113 Object *ref, Stream *str,
114 int width, int height, GBool invert,
115 GBool inlineImg, double *baseMatrix) {
116 drawImageMask(state, ref, str, width, height, invert, gFalse, inlineImg);
117 }
118
unsetSoftMaskFromImageMask(GfxState * state,double * baseMatrix)119 void OutputDev::unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) {
120 return;
121 }
122
drawImage(GfxState * state,Object * ref,Stream * str,int width,int height,GfxImageColorMap * colorMap,GBool interpolate,int * maskColors,GBool inlineImg)123 void OutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
124 int width, int height, GfxImageColorMap *colorMap,
125 GBool interpolate, int *maskColors, GBool inlineImg) {
126 int i, j;
127
128 if (inlineImg) {
129 str->reset();
130 j = height * ((width * colorMap->getNumPixelComps() *
131 colorMap->getBits() + 7) / 8);
132 for (i = 0; i < j; ++i)
133 str->getChar();
134 str->close();
135 }
136 }
137
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)138 void OutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
139 int width, int height,
140 GfxImageColorMap *colorMap,
141 GBool interpolate,
142 Stream *maskStr,
143 int maskWidth, int maskHeight,
144 GBool maskInvert,
145 GBool maskInterpolate) {
146 drawImage(state, ref, str, width, height, colorMap, interpolate, NULL, gFalse);
147 }
148
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)149 void OutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
150 int width, int height,
151 GfxImageColorMap *colorMap,
152 GBool interpolate,
153 Stream *maskStr,
154 int maskWidth, int maskHeight,
155 GfxImageColorMap *maskColorMap,
156 GBool maskInterpolate) {
157 drawImage(state, ref, str, width, height, colorMap, interpolate, NULL, gFalse);
158 }
159
endMarkedContent(GfxState * state)160 void OutputDev::endMarkedContent(GfxState *state) {
161 }
162
beginMarkedContent(char * name,Dict * properties)163 void OutputDev::beginMarkedContent(char *name, Dict *properties) {
164 }
165
markPoint(char * name)166 void OutputDev::markPoint(char *name) {
167 }
168
markPoint(char * name,Dict * properties)169 void OutputDev::markPoint(char *name, Dict *properties) {
170 }
171
172
173 #if OPI_SUPPORT
opiBegin(GfxState * state,Dict * opiDict)174 void OutputDev::opiBegin(GfxState *state, Dict *opiDict) {
175 }
176
opiEnd(GfxState * state,Dict * opiDict)177 void OutputDev::opiEnd(GfxState *state, Dict *opiDict) {
178 }
179 #endif
180
startProfile()181 void OutputDev::startProfile() {
182 if (profileHash)
183 delete profileHash;
184
185 profileHash = new GooHash (true);
186 }
187
endProfile()188 GooHash *OutputDev::endProfile() {
189 GooHash *profile = profileHash;
190
191 profileHash = NULL;
192
193 return profile;
194 }
195
196 #ifdef USE_CMS
getIccColorSpaceCache()197 PopplerCache *OutputDev::getIccColorSpaceCache()
198 {
199 return &iccColorSpaceCache;
200 }
201 #endif
202