1
//========================================================================
5
// Copyright 2005 Glyph & Cog, LLC
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) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
17
// Copyright (C) 2010 Albert Astals Cid <aacid@kde.org>
18
// Copyright (C) 2011 William Bader <williambader@hotmail.com>
20
// To see a description of the changes please see the Changelog file that
21
// came with your tarball or type make ChangeLog if you are building from git
23
//========================================================================
25
#ifdef USE_GCC_PRAGMAS
26
#pragma implementation
30
#include "GlobalParams.h"
33
#include "PreScanOutputDev.h"
35
//------------------------------------------------------------------------
37
//------------------------------------------------------------------------
39
PreScanOutputDev::PreScanOutputDev() {
40
level = globalParams->getPSLevel();
44
PreScanOutputDev::~PreScanOutputDev() {
47
void PreScanOutputDev::startPage(int /*pageNum*/, GfxState * /*state*/) {
50
void PreScanOutputDev::endPage() {
53
void PreScanOutputDev::stroke(GfxState *state) {
58
check(state->getStrokeColorSpace(), state->getStrokeColor(),
59
state->getStrokeOpacity(), state->getBlendMode());
60
state->getLineDash(&dash, &dashLen, &dashStart);
66
void PreScanOutputDev::fill(GfxState *state) {
67
check(state->getFillColorSpace(), state->getFillColor(),
68
state->getFillOpacity(), state->getBlendMode());
71
void PreScanOutputDev::eoFill(GfxState *state) {
72
check(state->getFillColorSpace(), state->getFillColor(),
73
state->getFillOpacity(), state->getBlendMode());
76
void PreScanOutputDev::clip(GfxState * /*state*/) {
77
//~ check for a rectangle "near" the edge of the page;
78
//~ else set gdi to false
81
void PreScanOutputDev::eoClip(GfxState * /*state*/) {
85
void PreScanOutputDev::beginStringOp(GfxState *state) {
88
double m11, m12, m21, m22;
90
DisplayFontParam *dfp;
93
render = state->getRender();
95
check(state->getFillColorSpace(), state->getFillColor(),
96
state->getFillOpacity(), state->getBlendMode());
98
if ((render & 3) == 1 || (render & 3) == 2) {
99
check(state->getStrokeColorSpace(), state->getStrokeColor(),
100
state->getStrokeOpacity(), state->getBlendMode());
103
font = state->getFont();
104
state->getFontTransMat(&m11, &m12, &m21, &m22);
105
simpleTTF = fabs(m11 + m22) < 0.01 &&
109
fabs(state->getHorizScaling() - 1) < 0.001 &&
110
(font->getType() == fontTrueType ||
111
font->getType() == fontTrueTypeOT) &&
112
(font->getEmbeddedFontID(&embRef) ||
113
font->getExtFontFile() ||
115
(dfp = globalParams->getDisplayFont(font)) &&
116
dfp->kind == displayFontTT));
118
//~ need to create a FoFiTrueType object, and check for a Unicode cmap
120
if (state->getRender() != 0 || !simpleTTF) {
125
void PreScanOutputDev::endStringOp(GfxState * /*state*/) {
128
GBool PreScanOutputDev::beginType3Char(GfxState * /*state*/, double /*x*/, double /*y*/,
129
double /*dx*/, double /*dy*/,
130
CharCode /*code*/, Unicode * /*u*/, int /*uLen*/) {
131
// return false so all Type 3 chars get rendered (no caching)
135
void PreScanOutputDev::endType3Char(GfxState * /*state*/) {
138
void PreScanOutputDev::drawImageMask(GfxState *state, Object * /*ref*/, Stream *str,
139
int width, int height, GBool /*invert*/,
140
GBool /*interpolate*/, GBool inlineImg) {
143
check(state->getFillColorSpace(), state->getFillColor(),
144
state->getFillOpacity(), state->getBlendMode());
146
if ((level == psLevel1 || level == psLevel1Sep) &&
147
state->getFillColorSpace()->getMode() == csPattern) {
153
j = height * ((width + 7) / 8);
154
for (i = 0; i < j; ++i)
160
void PreScanOutputDev::drawImage(GfxState *state, Object * /*ref*/, Stream *str,
161
int width, int height,
162
GfxImageColorMap *colorMap,
163
GBool /*interpolate*/, int * /*maskColors*/, GBool inlineImg) {
164
GfxColorSpace *colorSpace;
167
colorSpace = colorMap->getColorSpace();
168
if (colorSpace->getMode() == csIndexed) {
169
colorSpace = ((GfxIndexedColorSpace *)colorSpace)->getBase();
171
if (colorSpace->getMode() != csDeviceGray &&
172
colorSpace->getMode() != csCalGray) {
176
if (state->getBlendMode() != gfxBlendNormal) {
177
transparency = gTrue;
183
j = height * ((width * colorMap->getNumPixelComps() *
184
colorMap->getBits() + 7) / 8);
185
for (i = 0; i < j; ++i)
191
void PreScanOutputDev::drawMaskedImage(GfxState *state, Object * /*ref*/,
193
int /*width*/, int /*height*/,
194
GfxImageColorMap *colorMap,
195
GBool /*interpolate*/,
196
Stream * /*maskStr*/,
197
int /*maskWidth*/, int /*maskHeight*/,
198
GBool /*maskInvert*/, GBool /*maskInterpolate*/) {
199
GfxColorSpace *colorSpace;
201
colorSpace = colorMap->getColorSpace();
202
if (colorSpace->getMode() == csIndexed) {
203
colorSpace = ((GfxIndexedColorSpace *)colorSpace)->getBase();
205
if (colorSpace->getMode() != csDeviceGray &&
206
colorSpace->getMode() != csCalGray) {
210
if (state->getBlendMode() != gfxBlendNormal) {
211
transparency = gTrue;
216
void PreScanOutputDev::drawSoftMaskedImage(GfxState * /*state*/, Object * /*ref*/,
218
int /*width*/, int /*height*/,
219
GfxImageColorMap *colorMap,
220
GBool /*interpolate*/,
221
Stream * /*maskStr*/,
222
int /*maskWidth*/, int /*maskHeight*/,
223
GfxImageColorMap * /*maskColorMap*/,
224
GBool /*maskInterpolate*/) {
225
GfxColorSpace *colorSpace;
227
colorSpace = colorMap->getColorSpace();
228
if (colorSpace->getMode() == csIndexed) {
229
colorSpace = ((GfxIndexedColorSpace *)colorSpace)->getBase();
231
if (colorSpace->getMode() != csDeviceGray &&
232
colorSpace->getMode() != csCalGray) {
236
transparency = gTrue;
240
void PreScanOutputDev::beginTransparencyGroup(
241
GfxState * /*state*/, double * /*bbox*/,
242
GfxColorSpace * /*blendingColorSpace*/,
243
GBool /*isolated*/, GBool /*knockout*/,
244
GBool /*forSoftMask*/) {
248
void PreScanOutputDev::paintTransparencyGroup(GfxState *state, double * /*bbox*/)
250
check(state->getFillColorSpace(), state->getFillColor(),
251
state->getFillOpacity(), state->getBlendMode());
254
void PreScanOutputDev::setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/,
255
Function * /*transferFunc*/, GfxColor * /*backdropColor*/)
257
transparency = gTrue;
260
void PreScanOutputDev::check(GfxColorSpace *colorSpace, GfxColor *color,
261
double opacity, GfxBlendMode blendMode) {
264
if (colorSpace->getMode() == csPattern) {
269
colorSpace->getRGB(color, &rgb);
270
if (rgb.r != rgb.g || rgb.g != rgb.b || rgb.b != rgb.r) {
273
} else if (!((rgb.r == 0 && rgb.g == 0 && rgb.b == 0) ||
274
(rgb.r == gfxColorComp1 &&
275
rgb.g == gfxColorComp1 &&
276
rgb.b == gfxColorComp1))) {
280
if (opacity != 1 || blendMode != gfxBlendNormal) {
281
transparency = gTrue;
285
void PreScanOutputDev::clearStats() {
288
transparency = gFalse;
290
level1PSBug = gFalse;