beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / poppler / OutputDev.cc
blobee3cf5a30ff46421e6726282df07005e1c8b8801
1 //========================================================================
2 //
3 // OutputDev.cc
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 //========================================================================
11 // Modified under the Poppler project - http://poppler.freedesktop.org
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
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>
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
26 //========================================================================
28 #include <config.h>
30 #ifdef USE_GCC_PRAGMAS
31 #pragma implementation
32 #endif
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"
41 //------------------------------------------------------------------------
42 // OutputDev
43 //------------------------------------------------------------------------
45 void OutputDev::setDefaultCTM(double *ctm) {
46 int i;
47 double det;
49 for (i = 0; i < 6; ++i) {
50 defCTM[i] = ctm[i];
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;
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];
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);
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);
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;
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;
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();
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);
119 void OutputDev::unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) {
120 return;
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;
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();
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);
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);
160 void OutputDev::endMarkedContent(GfxState *state) {
163 void OutputDev::beginMarkedContent(char *name, Dict *properties) {
166 void OutputDev::markPoint(char *name) {
169 void OutputDev::markPoint(char *name, Dict *properties) {
173 #if OPI_SUPPORT
174 void OutputDev::opiBegin(GfxState *state, Dict *opiDict) {
177 void OutputDev::opiEnd(GfxState *state, Dict *opiDict) {
179 #endif
181 void OutputDev::startProfile() {
182 if (profileHash)
183 delete profileHash;
185 profileHash = new GooHash (true);
188 GooHash *OutputDev::endProfile() {
189 GooHash *profile = profileHash;
191 profileHash = NULL;
193 return profile;
196 #ifdef USE_CMS
197 PopplerCache *OutputDev::getIccColorSpaceCache()
199 return &iccColorSpaceCache;
201 #endif