1
//========================================================================
5
// Copyright 2005 Glyph & Cog, LLC
7
//========================================================================
11
#ifdef USE_GCC_PRAGMAS
12
#pragma implementation
16
#include "GlobalParams.h"
19
#include "PreScanOutputDev.h"
21
//------------------------------------------------------------------------
23
//------------------------------------------------------------------------
25
PreScanOutputDev::PreScanOutputDev() {
29
PreScanOutputDev::~PreScanOutputDev() {
32
void PreScanOutputDev::startPage(int pageNum, GfxState *state) {
35
void PreScanOutputDev::endPage() {
38
void PreScanOutputDev::stroke(GfxState *state) {
43
check(state->getStrokeColorSpace(), state->getStrokeColor(),
44
state->getStrokeOpacity(), state->getBlendMode());
45
state->getLineDash(&dash, &dashLen, &dashStart);
51
void PreScanOutputDev::fill(GfxState *state) {
52
check(state->getFillColorSpace(), state->getFillColor(),
53
state->getFillOpacity(), state->getBlendMode());
56
void PreScanOutputDev::eoFill(GfxState *state) {
57
check(state->getFillColorSpace(), state->getFillColor(),
58
state->getFillOpacity(), state->getBlendMode());
61
void PreScanOutputDev::clip(GfxState *state) {
62
//~ check for a rectangle "near" the edge of the page;
63
//~ else set gdi to false
66
void PreScanOutputDev::eoClip(GfxState *state) {
70
void PreScanOutputDev::beginStringOp(GfxState *state) {
73
double m11, m12, m21, m22;
75
DisplayFontParam *dfp;
78
render = state->getRender();
80
check(state->getFillColorSpace(), state->getFillColor(),
81
state->getFillOpacity(), state->getBlendMode());
83
if ((render & 3) == 1 || (render & 3) == 2) {
84
check(state->getStrokeColorSpace(), state->getStrokeColor(),
85
state->getStrokeOpacity(), state->getBlendMode());
88
font = state->getFont();
89
state->getFontTransMat(&m11, &m12, &m21, &m22);
90
simpleTTF = fabs(m11 + m22) < 0.01 &&
94
fabs(state->getHorizScaling() - 1) < 0.001 &&
95
(font->getType() == fontTrueType ||
96
font->getType() == fontTrueTypeOT) &&
97
(font->getEmbeddedFontID(&embRef) ||
98
font->getExtFontFile() ||
100
(dfp = globalParams->getDisplayFont(font->getName())) &&
101
dfp->kind == displayFontTT));
103
//~ need to create a FoFiTrueType object, and check for a Unicode cmap
105
if (state->getRender() != 0 || !simpleTTF) {
110
void PreScanOutputDev::endStringOp(GfxState *state) {
113
GBool PreScanOutputDev::beginType3Char(GfxState *state, double x, double y,
114
double dx, double dy,
115
CharCode code, Unicode *u, int uLen) {
116
// return false so all Type 3 chars get rendered (no caching)
120
void PreScanOutputDev::endType3Char(GfxState *state) {
123
void PreScanOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
124
int width, int height, GBool invert,
128
check(state->getFillColorSpace(), state->getFillColor(),
129
state->getFillOpacity(), state->getBlendMode());
134
j = height * ((width + 7) / 8);
135
for (i = 0; i < j; ++i)
141
void PreScanOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
142
int width, int height,
143
GfxImageColorMap *colorMap,
144
int *maskColors, GBool inlineImg) {
145
GfxColorSpace *colorSpace;
148
colorSpace = colorMap->getColorSpace();
149
if (colorSpace->getMode() == csIndexed) {
150
colorSpace = ((GfxIndexedColorSpace *)colorSpace)->getBase();
152
if (colorSpace->getMode() != csDeviceGray &&
153
colorSpace->getMode() != csCalGray) {
157
if (state->getBlendMode() != gfxBlendNormal) {
158
transparency = gTrue;
164
j = height * ((width * colorMap->getNumPixelComps() *
165
colorMap->getBits() + 7) / 8);
166
for (i = 0; i < j; ++i)
172
void PreScanOutputDev::drawMaskedImage(GfxState *state, Object *ref,
174
int width, int height,
175
GfxImageColorMap *colorMap,
177
int maskWidth, int maskHeight,
179
GfxColorSpace *colorSpace;
181
colorSpace = colorMap->getColorSpace();
182
if (colorSpace->getMode() == csIndexed) {
183
colorSpace = ((GfxIndexedColorSpace *)colorSpace)->getBase();
185
if (colorSpace->getMode() != csDeviceGray &&
186
colorSpace->getMode() != csCalGray) {
190
if (state->getBlendMode() != gfxBlendNormal) {
191
transparency = gTrue;
196
void PreScanOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref,
198
int width, int height,
199
GfxImageColorMap *colorMap,
201
int maskWidth, int maskHeight,
202
GfxImageColorMap *maskColorMap) {
203
GfxColorSpace *colorSpace;
205
colorSpace = colorMap->getColorSpace();
206
if (colorSpace->getMode() == csIndexed) {
207
colorSpace = ((GfxIndexedColorSpace *)colorSpace)->getBase();
209
if (colorSpace->getMode() != csDeviceGray &&
210
colorSpace->getMode() != csCalGray) {
214
transparency = gTrue;
218
void PreScanOutputDev::beginTransparencyGroup(
219
GfxState *state, double *bbox,
220
GfxColorSpace *blendingColorSpace,
221
GBool isolated, GBool knockout,
223
transparency = gTrue;
227
void PreScanOutputDev::check(GfxColorSpace *colorSpace, GfxColor *color,
228
double opacity, GfxBlendMode blendMode) {
231
if (colorSpace->getMode() == csPattern) {
236
colorSpace->getRGB(color, &rgb);
237
if (rgb.r != rgb.g || rgb.g != rgb.b || rgb.b != rgb.r) {
240
} else if (!((rgb.r == 0 && rgb.g == 0 && rgb.b == 0) ||
241
(rgb.r == gfxColorComp1 &&
242
rgb.g == gfxColorComp1 &&
243
rgb.b == gfxColorComp1))) {
247
if (opacity != 1 || blendMode != gfxBlendNormal) {
248
transparency = gTrue;
252
void PreScanOutputDev::clearStats() {
255
transparency = gFalse;