~ubuntu-branches/ubuntu/natty/luatex/natty

« back to all changes in this revision

Viewing changes to source/libs/xpdf/xpdf-3.02/xpdf/PreScanOutputDev.cc

  • Committer: Package Import Robot
  • Author(s): Norbert Preining
  • Date: 2010-12-13 23:22:59 UTC
  • mfrom: (0.2.1) (1.5.4) (4.3.12 experimental)
  • Revision ID: package-import@ubuntu.com-20101213232259-nqq2mq5z5x6qldw3
Tags: 0.65.0-1
* new upstream release
* ship two source packages as they are distributed by upstream, only
  renamed to match source package requirements. Fix debian/rules
  to install the manual pdf from the right place

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//========================================================================
2
 
//
3
 
// PreScanOutputDev.cc
4
 
//
5
 
// Copyright 2005 Glyph & Cog, LLC
6
 
//
7
 
//========================================================================
8
 
 
9
 
#include <aconf.h>
10
 
 
11
 
#ifdef USE_GCC_PRAGMAS
12
 
#pragma implementation
13
 
#endif
14
 
 
15
 
#include <math.h>
16
 
#include "GlobalParams.h"
17
 
#include "GfxFont.h"
18
 
#include "Link.h"
19
 
#include "PreScanOutputDev.h"
20
 
 
21
 
//------------------------------------------------------------------------
22
 
// PreScanOutputDev
23
 
//------------------------------------------------------------------------
24
 
 
25
 
PreScanOutputDev::PreScanOutputDev() {
26
 
  clearStats();
27
 
}
28
 
 
29
 
PreScanOutputDev::~PreScanOutputDev() {
30
 
}
31
 
 
32
 
void PreScanOutputDev::startPage(int pageNum, GfxState *state) {
33
 
}
34
 
 
35
 
void PreScanOutputDev::endPage() {
36
 
}
37
 
 
38
 
void PreScanOutputDev::stroke(GfxState *state) {
39
 
  double *dash;
40
 
  int dashLen;
41
 
  double dashStart;
42
 
 
43
 
  check(state->getStrokeColorSpace(), state->getStrokeColor(),
44
 
        state->getStrokeOpacity(), state->getBlendMode());
45
 
  state->getLineDash(&dash, &dashLen, &dashStart);
46
 
  if (dashLen != 0) {
47
 
    gdi = gFalse;
48
 
  }
49
 
}
50
 
 
51
 
void PreScanOutputDev::fill(GfxState *state) {
52
 
  check(state->getFillColorSpace(), state->getFillColor(),
53
 
        state->getFillOpacity(), state->getBlendMode());
54
 
}
55
 
 
56
 
void PreScanOutputDev::eoFill(GfxState *state) {
57
 
  check(state->getFillColorSpace(), state->getFillColor(),
58
 
        state->getFillOpacity(), state->getBlendMode());
59
 
}
60
 
 
61
 
void PreScanOutputDev::clip(GfxState *state) {
62
 
  //~ check for a rectangle "near" the edge of the page;
63
 
  //~   else set gdi to false
64
 
}
65
 
 
66
 
void PreScanOutputDev::eoClip(GfxState *state) {
67
 
  //~ see clip()
68
 
}
69
 
 
70
 
void PreScanOutputDev::beginStringOp(GfxState *state) {
71
 
  int render;
72
 
  GfxFont *font;
73
 
  double m11, m12, m21, m22;
74
 
  Ref embRef;
75
 
  DisplayFontParam *dfp;
76
 
  GBool simpleTTF;
77
 
 
78
 
  render = state->getRender();
79
 
  if (!(render & 1)) {
80
 
    check(state->getFillColorSpace(), state->getFillColor(),
81
 
          state->getFillOpacity(), state->getBlendMode());
82
 
  }
83
 
  if ((render & 3) == 1 || (render & 3) == 2) {
84
 
    check(state->getStrokeColorSpace(), state->getStrokeColor(),
85
 
          state->getStrokeOpacity(), state->getBlendMode());
86
 
  }
87
 
 
88
 
  font = state->getFont();
89
 
  state->getFontTransMat(&m11, &m12, &m21, &m22);
90
 
  simpleTTF = fabs(m11 + m22) < 0.01 &&
91
 
              m11 > 0 &&
92
 
              fabs(m12) < 0.01 &&
93
 
              fabs(m21) < 0.01 &&
94
 
              fabs(state->getHorizScaling() - 1) < 0.001 &&
95
 
              (font->getType() == fontTrueType ||
96
 
               font->getType() == fontTrueTypeOT) &&
97
 
              (font->getEmbeddedFontID(&embRef) ||
98
 
               font->getExtFontFile() ||
99
 
               (font->getName() &&
100
 
                (dfp = globalParams->getDisplayFont(font->getName())) &&
101
 
                dfp->kind == displayFontTT));
102
 
  if (simpleTTF) {
103
 
    //~ need to create a FoFiTrueType object, and check for a Unicode cmap
104
 
  }
105
 
  if (state->getRender() != 0 || !simpleTTF) {
106
 
    gdi = gFalse;
107
 
  }
108
 
}
109
 
 
110
 
void PreScanOutputDev::endStringOp(GfxState *state) {
111
 
}
112
 
 
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)
117
 
  return gFalse;
118
 
}
119
 
 
120
 
void PreScanOutputDev::endType3Char(GfxState *state) {
121
 
}
122
 
 
123
 
void PreScanOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
124
 
                                     int width, int height, GBool invert,
125
 
                                     GBool inlineImg) {
126
 
  int i, j;
127
 
 
128
 
  check(state->getFillColorSpace(), state->getFillColor(),
129
 
        state->getFillOpacity(), state->getBlendMode());
130
 
  gdi = gFalse;
131
 
 
132
 
  if (inlineImg) {
133
 
    str->reset();
134
 
    j = height * ((width + 7) / 8);
135
 
    for (i = 0; i < j; ++i)
136
 
      str->getChar();
137
 
    str->close();
138
 
  }
139
 
}
140
 
 
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;
146
 
  int i, j;
147
 
 
148
 
  colorSpace = colorMap->getColorSpace();
149
 
  if (colorSpace->getMode() == csIndexed) {
150
 
    colorSpace = ((GfxIndexedColorSpace *)colorSpace)->getBase();
151
 
  }
152
 
  if (colorSpace->getMode() != csDeviceGray &&
153
 
      colorSpace->getMode() != csCalGray) {
154
 
    gray = gFalse;
155
 
  }
156
 
  mono = gFalse;
157
 
  if (state->getBlendMode() != gfxBlendNormal) {
158
 
    transparency = gTrue;
159
 
  }
160
 
  gdi = gFalse;
161
 
 
162
 
  if (inlineImg) {
163
 
    str->reset();
164
 
    j = height * ((width * colorMap->getNumPixelComps() *
165
 
                   colorMap->getBits() + 7) / 8);
166
 
    for (i = 0; i < j; ++i)
167
 
      str->getChar();
168
 
    str->close();
169
 
  }
170
 
}
171
 
 
172
 
void PreScanOutputDev::drawMaskedImage(GfxState *state, Object *ref,
173
 
                                       Stream *str,
174
 
                                       int width, int height,
175
 
                                       GfxImageColorMap *colorMap,
176
 
                                       Stream *maskStr,
177
 
                                       int maskWidth, int maskHeight,
178
 
                                       GBool maskInvert) {
179
 
  GfxColorSpace *colorSpace;
180
 
 
181
 
  colorSpace = colorMap->getColorSpace();
182
 
  if (colorSpace->getMode() == csIndexed) {
183
 
    colorSpace = ((GfxIndexedColorSpace *)colorSpace)->getBase();
184
 
  }
185
 
  if (colorSpace->getMode() != csDeviceGray &&
186
 
      colorSpace->getMode() != csCalGray) {
187
 
    gray = gFalse;
188
 
  }
189
 
  mono = gFalse;
190
 
  if (state->getBlendMode() != gfxBlendNormal) {
191
 
    transparency = gTrue;
192
 
  }
193
 
  gdi = gFalse;
194
 
}
195
 
 
196
 
void PreScanOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref,
197
 
                                           Stream *str,
198
 
                                           int width, int height,
199
 
                                           GfxImageColorMap *colorMap,
200
 
                                           Stream *maskStr,
201
 
                                           int maskWidth, int maskHeight,
202
 
                                           GfxImageColorMap *maskColorMap) {
203
 
  GfxColorSpace *colorSpace;
204
 
 
205
 
  colorSpace = colorMap->getColorSpace();
206
 
  if (colorSpace->getMode() == csIndexed) {
207
 
    colorSpace = ((GfxIndexedColorSpace *)colorSpace)->getBase();
208
 
  }
209
 
  if (colorSpace->getMode() != csDeviceGray &&
210
 
      colorSpace->getMode() != csCalGray) {
211
 
    gray = gFalse;
212
 
  }
213
 
  mono = gFalse;
214
 
  transparency = gTrue;
215
 
  gdi = gFalse;
216
 
}
217
 
 
218
 
void PreScanOutputDev::beginTransparencyGroup(
219
 
                           GfxState *state, double *bbox,
220
 
                           GfxColorSpace *blendingColorSpace,
221
 
                           GBool isolated, GBool knockout,
222
 
                           GBool forSoftMask) {
223
 
  transparency = gTrue;
224
 
  gdi = gFalse;
225
 
}
226
 
 
227
 
void PreScanOutputDev::check(GfxColorSpace *colorSpace, GfxColor *color,
228
 
                             double opacity, GfxBlendMode blendMode) {
229
 
  GfxRGB rgb;
230
 
 
231
 
  if (colorSpace->getMode() == csPattern) {
232
 
    mono = gFalse;
233
 
    gray = gFalse;
234
 
    gdi = gFalse;
235
 
  } else {
236
 
    colorSpace->getRGB(color, &rgb);
237
 
    if (rgb.r != rgb.g || rgb.g != rgb.b || rgb.b != rgb.r) {
238
 
      mono = gFalse;
239
 
      gray = gFalse;
240
 
    } else if (!((rgb.r == 0 && rgb.g == 0 && rgb.b == 0) ||
241
 
                 (rgb.r == gfxColorComp1 &&
242
 
                  rgb.g == gfxColorComp1 &&
243
 
                  rgb.b == gfxColorComp1))) {
244
 
      mono = gFalse;
245
 
    }
246
 
  }
247
 
  if (opacity != 1 || blendMode != gfxBlendNormal) {
248
 
    transparency = gTrue;
249
 
  }
250
 
}
251
 
 
252
 
void PreScanOutputDev::clearStats() {
253
 
  mono = gTrue;
254
 
  gray = gTrue;
255
 
  transparency = gFalse;
256
 
  gdi = gTrue;
257
 
}