mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
copied poppler-0.74.0 3rdparty files into master
This commit is contained in:
parent
8397de9b80
commit
67aa27232c
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,4 +23,3 @@ Testing/*
|
|||||||
DartConfiguration.tcl
|
DartConfiguration.tcl
|
||||||
test/test.py
|
test/test.py
|
||||||
*.swp
|
*.swp
|
||||||
|
|
||||||
|
114
3rdparty/poppler/git/CairoFontEngine.cc
vendored
114
3rdparty/poppler/git/CairoFontEngine.cc
vendored
@ -28,6 +28,8 @@
|
|||||||
// Copyright (C) 2012 Hib Eris <hib@hiberis.nl>
|
// Copyright (C) 2012 Hib Eris <hib@hiberis.nl>
|
||||||
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
|
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
|
||||||
// Copyright (C) 2015, 2016 Jason Crain <jason@aquaticape.us>
|
// Copyright (C) 2015, 2016 Jason Crain <jason@aquaticape.us>
|
||||||
|
// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
|
||||||
|
// Copyright (C) 2019 Christian Persch <chpe@src.gnome.org>
|
||||||
//
|
//
|
||||||
// To see a description of the changes please see the Changelog file that
|
// To see a description of the changes please see the Changelog file that
|
||||||
// came with your tarball or type make ChangeLog if you are building from git
|
// came with your tarball or type make ChangeLog if you are building from git
|
||||||
@ -55,16 +57,6 @@
|
|||||||
#define CAN_CHECK_OPEN_FACES 1
|
#define CAN_CHECK_OPEN_FACES 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_GCC_PRAGMAS
|
|
||||||
#pragma implementation
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MULTITHREADED
|
|
||||||
# define fontEngineLocker() MutexLocker locker(&mutex)
|
|
||||||
#else
|
|
||||||
# define fontEngineLocker()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// CairoFont
|
// CairoFont
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
@ -72,9 +64,9 @@
|
|||||||
CairoFont::CairoFont(Ref refA,
|
CairoFont::CairoFont(Ref refA,
|
||||||
cairo_font_face_t *cairo_font_faceA,
|
cairo_font_face_t *cairo_font_faceA,
|
||||||
int *codeToGIDA,
|
int *codeToGIDA,
|
||||||
Guint codeToGIDLenA,
|
unsigned int codeToGIDLenA,
|
||||||
GBool substituteA,
|
bool substituteA,
|
||||||
GBool printingA) : ref(refA),
|
bool printingA) : ref(refA),
|
||||||
cairo_font_face(cairo_font_faceA),
|
cairo_font_face(cairo_font_faceA),
|
||||||
codeToGID(codeToGIDA),
|
codeToGID(codeToGIDA),
|
||||||
codeToGIDLen(codeToGIDLenA),
|
codeToGIDLen(codeToGIDLenA),
|
||||||
@ -86,8 +78,8 @@ CairoFont::~CairoFont() {
|
|||||||
gfree(codeToGID);
|
gfree(codeToGID);
|
||||||
}
|
}
|
||||||
|
|
||||||
GBool
|
bool
|
||||||
CairoFont::matches(Ref &other, GBool printingA) {
|
CairoFont::matches(Ref &other, bool printingA) {
|
||||||
return (other.num == ref.num && other.gen == ref.gen);
|
return (other.num == ref.num && other.gen == ref.gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +106,7 @@ CairoFont::getSubstitutionCorrection(GfxFont *gfxFont)
|
|||||||
{
|
{
|
||||||
double w1, w2, w3;
|
double w1, w2, w3;
|
||||||
CharCode code;
|
CharCode code;
|
||||||
char *name;
|
const char *name;
|
||||||
|
|
||||||
// for substituted fonts: adjust the font matrix -- compare the
|
// for substituted fonts: adjust the font matrix -- compare the
|
||||||
// width of 'm' in the original font and the substituted font
|
// width of 'm' in the original font and the substituted font
|
||||||
@ -169,7 +161,7 @@ _ft_done_face_uncached (void *closure)
|
|||||||
FT_Done_Face (face);
|
FT_Done_Face (face);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GBool
|
static bool
|
||||||
_ft_new_face_uncached (FT_Library lib,
|
_ft_new_face_uncached (FT_Library lib,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
char *font_data,
|
char *font_data,
|
||||||
@ -182,10 +174,10 @@ _ft_new_face_uncached (FT_Library lib,
|
|||||||
|
|
||||||
if (font_data == nullptr) {
|
if (font_data == nullptr) {
|
||||||
if (FT_New_Face (lib, filename, 0, &face))
|
if (FT_New_Face (lib, filename, 0, &face))
|
||||||
return gFalse;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (FT_New_Memory_Face (lib, (unsigned char *)font_data, font_data_len, 0, &face))
|
if (FT_New_Memory_Face (lib, (unsigned char *)font_data, font_data_len, 0, &face))
|
||||||
return gFalse;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
font_face = cairo_ft_font_face_create_for_ft_face (face,
|
font_face = cairo_ft_font_face_create_for_ft_face (face,
|
||||||
@ -198,12 +190,12 @@ _ft_new_face_uncached (FT_Library lib,
|
|||||||
{
|
{
|
||||||
_ft_done_face_uncached (face);
|
_ft_done_face_uncached (face);
|
||||||
cairo_font_face_destroy (font_face);
|
cairo_font_face_destroy (font_face);
|
||||||
return gFalse;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*face_out = face;
|
*face_out = face;
|
||||||
*font_face_out = font_face;
|
*font_face_out = font_face;
|
||||||
return gTrue;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CAN_CHECK_OPEN_FACES
|
#ifdef CAN_CHECK_OPEN_FACES
|
||||||
@ -232,15 +224,15 @@ _djb_hash (const unsigned char *bytes, size_t len)
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GBool
|
static bool
|
||||||
_ft_face_data_equal (struct _ft_face_data *a, struct _ft_face_data *b)
|
_ft_face_data_equal (struct _ft_face_data *a, struct _ft_face_data *b)
|
||||||
{
|
{
|
||||||
if (a->lib != b->lib)
|
if (a->lib != b->lib)
|
||||||
return gFalse;
|
return false;
|
||||||
if (a->size != b->size)
|
if (a->size != b->size)
|
||||||
return gFalse;
|
return false;
|
||||||
if (a->hash != b->hash)
|
if (a->hash != b->hash)
|
||||||
return gFalse;
|
return false;
|
||||||
|
|
||||||
return memcmp (a->bytes, b->bytes, a->size) == 0;
|
return memcmp (a->bytes, b->bytes, a->size) == 0;
|
||||||
}
|
}
|
||||||
@ -272,7 +264,7 @@ _ft_done_face (void *closure)
|
|||||||
gfree (data);
|
gfree (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GBool
|
static bool
|
||||||
_ft_new_face (FT_Library lib,
|
_ft_new_face (FT_Library lib,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
char *font_data,
|
char *font_data,
|
||||||
@ -288,7 +280,7 @@ _ft_new_face (FT_Library lib,
|
|||||||
|
|
||||||
if (font_data == nullptr) {
|
if (font_data == nullptr) {
|
||||||
/* if we fail to mmap the file, just pass it to FreeType instead */
|
/* if we fail to mmap the file, just pass it to FreeType instead */
|
||||||
tmpl.fd = open (filename, O_RDONLY);
|
tmpl.fd = openFileDescriptor (filename, O_RDONLY);
|
||||||
if (tmpl.fd == -1)
|
if (tmpl.fd == -1)
|
||||||
return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out);
|
return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out);
|
||||||
|
|
||||||
@ -328,7 +320,7 @@ _ft_new_face (FT_Library lib,
|
|||||||
}
|
}
|
||||||
*face_out = l->face;
|
*face_out = l->face;
|
||||||
*font_face_out = cairo_font_face_reference (l->font_face);
|
*font_face_out = cairo_font_face_reference (l->font_face);
|
||||||
return gTrue;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,7 +338,7 @@ _ft_new_face (FT_Library lib,
|
|||||||
|
|
||||||
close (tmpl.fd);
|
close (tmpl.fd);
|
||||||
}
|
}
|
||||||
return gFalse;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
l = (struct _ft_face_data *) gmallocn (1, sizeof (struct _ft_face_data));
|
l = (struct _ft_face_data *) gmallocn (1, sizeof (struct _ft_face_data));
|
||||||
@ -367,12 +359,12 @@ _ft_new_face (FT_Library lib,
|
|||||||
{
|
{
|
||||||
cairo_font_face_destroy (l->font_face);
|
cairo_font_face_destroy (l->font_face);
|
||||||
_ft_done_face (l);
|
_ft_done_face (l);
|
||||||
return gFalse;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*face_out = l->face;
|
*face_out = l->face;
|
||||||
*font_face_out = l->font_face;
|
*font_face_out = l->font_face;
|
||||||
return gTrue;
|
return true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define _ft_new_face _ft_new_face_uncached
|
#define _ft_new_face _ft_new_face_uncached
|
||||||
@ -381,20 +373,20 @@ _ft_new_face (FT_Library lib,
|
|||||||
CairoFreeTypeFont::CairoFreeTypeFont(Ref refA,
|
CairoFreeTypeFont::CairoFreeTypeFont(Ref refA,
|
||||||
cairo_font_face_t *cairo_font_faceA,
|
cairo_font_face_t *cairo_font_faceA,
|
||||||
int *codeToGIDA,
|
int *codeToGIDA,
|
||||||
Guint codeToGIDLenA,
|
unsigned int codeToGIDLenA,
|
||||||
GBool substituteA) : CairoFont(refA,
|
bool substituteA) : CairoFont(refA,
|
||||||
cairo_font_faceA,
|
cairo_font_faceA,
|
||||||
codeToGIDA,
|
codeToGIDA,
|
||||||
codeToGIDLenA,
|
codeToGIDLenA,
|
||||||
substituteA,
|
substituteA,
|
||||||
gTrue) { }
|
true) { }
|
||||||
|
|
||||||
CairoFreeTypeFont::~CairoFreeTypeFont() { }
|
CairoFreeTypeFont::~CairoFreeTypeFont() { }
|
||||||
|
|
||||||
CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
||||||
FT_Library lib, GBool useCIDs) {
|
FT_Library lib, bool useCIDs) {
|
||||||
GooString *fileName;
|
GooString *fileName;
|
||||||
char *fileNameC;
|
const char *fileNameC;
|
||||||
char *font_data;
|
char *font_data;
|
||||||
int font_data_len;
|
int font_data_len;
|
||||||
int i, n;
|
int i, n;
|
||||||
@ -409,7 +401,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
cairo_font_face_t *font_face;
|
cairo_font_face_t *font_face;
|
||||||
|
|
||||||
int *codeToGID;
|
int *codeToGID;
|
||||||
Guint codeToGIDLen;
|
unsigned int codeToGIDLen;
|
||||||
|
|
||||||
codeToGID = nullptr;
|
codeToGID = nullptr;
|
||||||
codeToGIDLen = 0;
|
codeToGIDLen = 0;
|
||||||
@ -418,14 +410,14 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
fileName = nullptr;
|
fileName = nullptr;
|
||||||
fileNameC = nullptr;
|
fileNameC = nullptr;
|
||||||
|
|
||||||
GBool substitute = gFalse;
|
bool substitute = false;
|
||||||
|
|
||||||
ref = *gfxFont->getID();
|
ref = *gfxFont->getID();
|
||||||
fontType = gfxFont->getType();
|
fontType = gfxFont->getType();
|
||||||
|
|
||||||
if (!(fontLoc = gfxFont->locateFont(xref, nullptr))) {
|
if (!(fontLoc = gfxFont->locateFont(xref, nullptr))) {
|
||||||
error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'",
|
error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'",
|
||||||
gfxFont->getName() ? gfxFont->getName()->getCString()
|
gfxFont->getName() ? gfxFont->getName()->c_str()
|
||||||
: "(unnamed)");
|
: "(unnamed)");
|
||||||
goto err2;
|
goto err2;
|
||||||
}
|
}
|
||||||
@ -440,11 +432,11 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
} else { // gfxFontLocExternal
|
} else { // gfxFontLocExternal
|
||||||
fileName = fontLoc->path;
|
fileName = fontLoc->path;
|
||||||
fontType = fontLoc->fontType;
|
fontType = fontLoc->fontType;
|
||||||
substitute = gTrue;
|
substitute = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileName != nullptr) {
|
if (fileName != nullptr) {
|
||||||
fileNameC = fileName->getCString();
|
fileNameC = fileName->c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (fontType) {
|
switch (fontType) {
|
||||||
@ -615,7 +607,7 @@ typedef struct _type3_font_info {
|
|||||||
GfxFont *font;
|
GfxFont *font;
|
||||||
PDFDoc *doc;
|
PDFDoc *doc;
|
||||||
CairoFontEngine *fontEngine;
|
CairoFontEngine *fontEngine;
|
||||||
GBool printing;
|
bool printing;
|
||||||
XRef *xref;
|
XRef *xref;
|
||||||
} type3_font_info_t;
|
} type3_font_info_t;
|
||||||
|
|
||||||
@ -635,13 +627,12 @@ _init_type3_glyph (cairo_scaled_font_t *scaled_font,
|
|||||||
{
|
{
|
||||||
type3_font_info_t *info;
|
type3_font_info_t *info;
|
||||||
GfxFont *font;
|
GfxFont *font;
|
||||||
double *mat;
|
|
||||||
|
|
||||||
info = (type3_font_info_t *)
|
info = (type3_font_info_t *)
|
||||||
cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font),
|
cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font),
|
||||||
&type3_font_key);
|
&type3_font_key);
|
||||||
font = info->font;
|
font = info->font;
|
||||||
mat = font->getFontBBox();
|
const double *mat = font->getFontBBox();
|
||||||
extents->ascent = mat[3]; /* y2 */
|
extents->ascent = mat[3]; /* y2 */
|
||||||
extents->descent = -mat[3]; /* -y1 */
|
extents->descent = -mat[3]; /* -y1 */
|
||||||
extents->height = extents->ascent + extents->descent;
|
extents->height = extents->ascent + extents->descent;
|
||||||
@ -661,7 +652,7 @@ _render_type3_glyph (cairo_scaled_font_t *scaled_font,
|
|||||||
Object charProc;
|
Object charProc;
|
||||||
CairoOutputDev *output_dev;
|
CairoOutputDev *output_dev;
|
||||||
cairo_matrix_t matrix, invert_y_axis;
|
cairo_matrix_t matrix, invert_y_axis;
|
||||||
double *mat;
|
const double *mat;
|
||||||
double wx, wy;
|
double wx, wy;
|
||||||
PDFRectangle box;
|
PDFRectangle box;
|
||||||
type3_font_info_t *info;
|
type3_font_info_t *info;
|
||||||
@ -705,7 +696,7 @@ _render_type3_glyph (cairo_scaled_font_t *scaled_font,
|
|||||||
gfx = new Gfx(info->doc, output_dev, resDict, &box, nullptr);
|
gfx = new Gfx(info->doc, output_dev, resDict, &box, nullptr);
|
||||||
output_dev->startDoc(info->doc, info->fontEngine);
|
output_dev->startDoc(info->doc, info->fontEngine);
|
||||||
output_dev->startPage (1, gfx->getState(), gfx->getXRef());
|
output_dev->startPage (1, gfx->getState(), gfx->getXRef());
|
||||||
output_dev->setInType3Char(gTrue);
|
output_dev->setInType3Char(true);
|
||||||
charProc = charProcs->getVal(glyph);
|
charProc = charProcs->getVal(glyph);
|
||||||
gfx->display(&charProc);
|
gfx->display(&charProc);
|
||||||
|
|
||||||
@ -733,12 +724,12 @@ _render_type3_glyph (cairo_scaled_font_t *scaled_font,
|
|||||||
|
|
||||||
CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, PDFDoc *doc,
|
CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, PDFDoc *doc,
|
||||||
CairoFontEngine *fontEngine,
|
CairoFontEngine *fontEngine,
|
||||||
GBool printing, XRef *xref) {
|
bool printing, XRef *xref) {
|
||||||
type3_font_info_t *info;
|
type3_font_info_t *info;
|
||||||
cairo_font_face_t *font_face;
|
cairo_font_face_t *font_face;
|
||||||
Ref ref;
|
Ref ref;
|
||||||
int *codeToGID;
|
int *codeToGID;
|
||||||
Guint codeToGIDLen;
|
unsigned int codeToGIDLen;
|
||||||
int i, j;
|
int i, j;
|
||||||
char **enc;
|
char **enc;
|
||||||
Dict *charProcs;
|
Dict *charProcs;
|
||||||
@ -773,26 +764,25 @@ CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, PDFDoc *doc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CairoType3Font(ref, doc, font_face, codeToGID, codeToGIDLen, printing, xref);
|
return new CairoType3Font(ref, font_face, codeToGID, codeToGIDLen, printing, xref);
|
||||||
}
|
}
|
||||||
|
|
||||||
CairoType3Font::CairoType3Font(Ref refA,
|
CairoType3Font::CairoType3Font(Ref refA,
|
||||||
PDFDoc *docA,
|
|
||||||
cairo_font_face_t *cairo_font_faceA,
|
cairo_font_face_t *cairo_font_faceA,
|
||||||
int *codeToGIDA,
|
int *codeToGIDA,
|
||||||
Guint codeToGIDLenA,
|
unsigned int codeToGIDLenA,
|
||||||
GBool printingA, XRef *xref) : CairoFont(refA,
|
bool printingA, XRef *xref) : CairoFont(refA,
|
||||||
cairo_font_faceA,
|
cairo_font_faceA,
|
||||||
codeToGIDA,
|
codeToGIDA,
|
||||||
codeToGIDLenA,
|
codeToGIDLenA,
|
||||||
gFalse,
|
false,
|
||||||
printingA),
|
printingA)
|
||||||
doc(docA) { }
|
{ }
|
||||||
|
|
||||||
CairoType3Font::~CairoType3Font() { }
|
CairoType3Font::~CairoType3Font() { }
|
||||||
|
|
||||||
GBool
|
bool
|
||||||
CairoType3Font::matches(Ref &other, GBool printingA) {
|
CairoType3Font::matches(Ref &other, bool printingA) {
|
||||||
return (other.num == ref.num && other.gen == ref.gen && printing == printingA);
|
return (other.num == ref.num && other.gen == ref.gen && printing == printingA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -801,6 +791,8 @@ CairoType3Font::matches(Ref &other, GBool printingA) {
|
|||||||
// CairoFontEngine
|
// CairoFontEngine
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define fontEngineLocker() std::unique_lock<std::recursive_mutex> locker(mutex)
|
||||||
|
|
||||||
CairoFontEngine::CairoFontEngine(FT_Library libA) {
|
CairoFontEngine::CairoFontEngine(FT_Library libA) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -814,9 +806,6 @@ CairoFontEngine::CairoFontEngine(FT_Library libA) {
|
|||||||
FT_Library_Version(lib, &major, &minor, &patch);
|
FT_Library_Version(lib, &major, &minor, &patch);
|
||||||
useCIDs = major > 2 ||
|
useCIDs = major > 2 ||
|
||||||
(major == 2 && (minor > 1 || (minor == 1 && patch > 7)));
|
(major == 2 && (minor > 1 || (minor == 1 && patch > 7)));
|
||||||
#ifdef MULTITHREADED
|
|
||||||
gInitMutex(&mutex);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CairoFontEngine::~CairoFontEngine() {
|
CairoFontEngine::~CairoFontEngine() {
|
||||||
@ -826,13 +815,10 @@ CairoFontEngine::~CairoFontEngine() {
|
|||||||
if (fontCache[i])
|
if (fontCache[i])
|
||||||
delete fontCache[i];
|
delete fontCache[i];
|
||||||
}
|
}
|
||||||
#ifdef MULTITHREADED
|
|
||||||
gDestroyMutex(&mutex);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CairoFont *
|
CairoFont *
|
||||||
CairoFontEngine::getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing, XRef *xref) {
|
CairoFontEngine::getFont(GfxFont *gfxFont, PDFDoc *doc, bool printing, XRef *xref) {
|
||||||
int i, j;
|
int i, j;
|
||||||
Ref ref;
|
Ref ref;
|
||||||
CairoFont *font;
|
CairoFont *font;
|
||||||
|
45
3rdparty/poppler/git/CairoFontEngine.h
vendored
45
3rdparty/poppler/git/CairoFontEngine.h
vendored
@ -20,6 +20,7 @@
|
|||||||
// Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc@gnome.org>
|
// Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc@gnome.org>
|
||||||
// Copyright (C) 2008, 2017 Adrian Johnson <ajohnson@redneon.com>
|
// Copyright (C) 2008, 2017 Adrian Johnson <ajohnson@redneon.com>
|
||||||
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
|
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
|
||||||
|
// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
|
||||||
//
|
//
|
||||||
// To see a description of the changes please see the Changelog file that
|
// To see a description of the changes please see the Changelog file that
|
||||||
// came with your tarball or type make ChangeLog if you are building from git
|
// came with your tarball or type make ChangeLog if you are building from git
|
||||||
@ -29,12 +30,9 @@
|
|||||||
#ifndef CAIROFONTENGINE_H
|
#ifndef CAIROFONTENGINE_H
|
||||||
#define CAIROFONTENGINE_H
|
#define CAIROFONTENGINE_H
|
||||||
|
|
||||||
#ifdef USE_GCC_PRAGMAS
|
#include <mutex>
|
||||||
#pragma interface
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "poppler-config.h"
|
#include "poppler-config.h"
|
||||||
#include "goo/gtypes.h"
|
|
||||||
#include <cairo-ft.h>
|
#include <cairo-ft.h>
|
||||||
|
|
||||||
#include "GfxFont.h"
|
#include "GfxFont.h"
|
||||||
@ -47,40 +45,40 @@ public:
|
|||||||
CairoFont(Ref ref,
|
CairoFont(Ref ref,
|
||||||
cairo_font_face_t *face,
|
cairo_font_face_t *face,
|
||||||
int *codeToGID,
|
int *codeToGID,
|
||||||
Guint codeToGIDLen,
|
unsigned int codeToGIDLen,
|
||||||
GBool substitute,
|
bool substitute,
|
||||||
GBool printing);
|
bool printing);
|
||||||
virtual ~CairoFont();
|
virtual ~CairoFont();
|
||||||
CairoFont(const CairoFont &) = delete;
|
CairoFont(const CairoFont &) = delete;
|
||||||
CairoFont& operator=(const CairoFont &other) = delete;
|
CairoFont& operator=(const CairoFont &other) = delete;
|
||||||
|
|
||||||
virtual GBool matches(Ref &other, GBool printing);
|
virtual bool matches(Ref &other, bool printing);
|
||||||
cairo_font_face_t *getFontFace(void);
|
cairo_font_face_t *getFontFace(void);
|
||||||
unsigned long getGlyph(CharCode code, Unicode *u, int uLen);
|
unsigned long getGlyph(CharCode code, Unicode *u, int uLen);
|
||||||
double getSubstitutionCorrection(GfxFont *gfxFont);
|
double getSubstitutionCorrection(GfxFont *gfxFont);
|
||||||
|
|
||||||
GBool isSubstitute() { return substitute; }
|
bool isSubstitute() { return substitute; }
|
||||||
protected:
|
protected:
|
||||||
Ref ref;
|
Ref ref;
|
||||||
cairo_font_face_t *cairo_font_face;
|
cairo_font_face_t *cairo_font_face;
|
||||||
|
|
||||||
int *codeToGID;
|
int *codeToGID;
|
||||||
Guint codeToGIDLen;
|
unsigned int codeToGIDLen;
|
||||||
|
|
||||||
GBool substitute;
|
bool substitute;
|
||||||
GBool printing;
|
bool printing;
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
class CairoFreeTypeFont : public CairoFont {
|
class CairoFreeTypeFont : public CairoFont {
|
||||||
public:
|
public:
|
||||||
static CairoFreeTypeFont *create(GfxFont *gfxFont, XRef *xref, FT_Library lib, GBool useCIDs);
|
static CairoFreeTypeFont *create(GfxFont *gfxFont, XRef *xref, FT_Library lib, bool useCIDs);
|
||||||
~CairoFreeTypeFont();
|
~CairoFreeTypeFont();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CairoFreeTypeFont(Ref ref, cairo_font_face_t *cairo_font_face,
|
CairoFreeTypeFont(Ref ref, cairo_font_face_t *cairo_font_face,
|
||||||
int *codeToGID, Guint codeToGIDLen, GBool substitute);
|
int *codeToGID, unsigned int codeToGIDLen, bool substitute);
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
@ -89,17 +87,16 @@ class CairoType3Font : public CairoFont {
|
|||||||
public:
|
public:
|
||||||
static CairoType3Font *create(GfxFont *gfxFont, PDFDoc *doc,
|
static CairoType3Font *create(GfxFont *gfxFont, PDFDoc *doc,
|
||||||
CairoFontEngine *fontEngine,
|
CairoFontEngine *fontEngine,
|
||||||
GBool printing, XRef *xref);
|
bool printing, XRef *xref);
|
||||||
~CairoType3Font();
|
~CairoType3Font();
|
||||||
|
|
||||||
GBool matches(Ref &other, GBool printing) override;
|
bool matches(Ref &other, bool printing) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CairoType3Font(Ref ref, PDFDoc *doc,
|
CairoType3Font(Ref ref,
|
||||||
cairo_font_face_t *cairo_font_face,
|
cairo_font_face_t *cairo_font_face,
|
||||||
int *codeToGID, Guint codeToGIDLen,
|
int *codeToGID, unsigned int codeToGIDLen,
|
||||||
GBool printing, XRef *xref);
|
bool printing, XRef *xref);
|
||||||
PDFDoc *doc;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
@ -119,15 +116,13 @@ public:
|
|||||||
CairoFontEngine(const CairoFontEngine &) = delete;
|
CairoFontEngine(const CairoFontEngine &) = delete;
|
||||||
CairoFontEngine& operator=(const CairoFontEngine &other) = delete;
|
CairoFontEngine& operator=(const CairoFontEngine &other) = delete;
|
||||||
|
|
||||||
CairoFont *getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing, XRef *xref);
|
CairoFont *getFont(GfxFont *gfxFont, PDFDoc *doc, bool printing, XRef *xref);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CairoFont *fontCache[cairoFontCacheSize];
|
CairoFont *fontCache[cairoFontCacheSize];
|
||||||
FT_Library lib;
|
FT_Library lib;
|
||||||
GBool useCIDs;
|
bool useCIDs;
|
||||||
#ifdef MULTITHREADED
|
mutable std::recursive_mutex mutex;
|
||||||
GooMutex mutex;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
293
3rdparty/poppler/git/CairoOutputDev.cc
vendored
293
3rdparty/poppler/git/CairoOutputDev.cc
vendored
@ -16,11 +16,11 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net>
|
// Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net>
|
||||||
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
|
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
|
||||||
// Copyright (C) 2005, 2009, 2012, 2017, 2018 Albert Astals Cid <aacid@kde.org>
|
// Copyright (C) 2005, 2009, 2012, 2017-2019 Albert Astals Cid <aacid@kde.org>
|
||||||
// Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
|
// Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
|
||||||
// Copyright (C) 2006-2011, 2013, 2014, 2017, 2018 Carlos Garcia Campos <carlosgc@gnome.org>
|
// Copyright (C) 2006-2011, 2013, 2014, 2017, 2018 Carlos Garcia Campos <carlosgc@gnome.org>
|
||||||
// Copyright (C) 2008 Carl Worth <cworth@cworth.org>
|
// Copyright (C) 2008 Carl Worth <cworth@cworth.org>
|
||||||
// Copyright (C) 2008-2017 Adrian Johnson <ajohnson@redneon.com>
|
// Copyright (C) 2008-2018 Adrian Johnson <ajohnson@redneon.com>
|
||||||
// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
|
// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
|
||||||
// Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk>
|
// Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk>
|
||||||
// Copyright (C) 2008, 2012 Hib Eris <hib@hiberis.nl>
|
// Copyright (C) 2008, 2012 Hib Eris <hib@hiberis.nl>
|
||||||
@ -30,6 +30,7 @@
|
|||||||
// Copyright (C) 2012, 2015, 2016 Jason Crain <jason@aquaticape.us>
|
// Copyright (C) 2012, 2015, 2016 Jason Crain <jason@aquaticape.us>
|
||||||
// Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
|
// Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
|
||||||
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
|
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
|
||||||
|
// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
|
||||||
//
|
//
|
||||||
// To see a description of the changes please see the Changelog file that
|
// To see a description of the changes please see the Changelog file that
|
||||||
// came with your tarball or type make ChangeLog if you are building from git
|
// came with your tarball or type make ChangeLog if you are building from git
|
||||||
@ -38,10 +39,6 @@
|
|||||||
|
|
||||||
#include <poppler-config.h>
|
#include <poppler-config.h>
|
||||||
|
|
||||||
#ifdef USE_GCC_PRAGMAS
|
|
||||||
#pragma implementation
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -81,12 +78,6 @@
|
|||||||
#define LOG(x)
|
#define LOG(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void printMatrix(cairo_matrix_t *matrix){
|
|
||||||
printf("%f %f, %f %f (%f %f)\n", matrix->xx, matrix->yx,
|
|
||||||
matrix->xy, matrix->yy,
|
|
||||||
matrix->x0, matrix->y0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
@ -126,18 +117,18 @@ void CairoImage::setImage (cairo_surface_t *image) {
|
|||||||
// FT_Library instance; to avoid leaks, just use a single global instance
|
// FT_Library instance; to avoid leaks, just use a single global instance
|
||||||
// initialized the first time it is needed.
|
// initialized the first time it is needed.
|
||||||
FT_Library CairoOutputDev::ft_lib;
|
FT_Library CairoOutputDev::ft_lib;
|
||||||
GBool CairoOutputDev::ft_lib_initialized = gFalse;
|
bool CairoOutputDev::ft_lib_initialized = false;
|
||||||
|
|
||||||
CairoOutputDev::CairoOutputDev() {
|
CairoOutputDev::CairoOutputDev() {
|
||||||
doc = nullptr;
|
doc = nullptr;
|
||||||
|
|
||||||
if (!ft_lib_initialized) {
|
if (!ft_lib_initialized) {
|
||||||
FT_Init_FreeType(&ft_lib);
|
FT_Init_FreeType(&ft_lib);
|
||||||
ft_lib_initialized = gTrue;
|
ft_lib_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fontEngine = nullptr;
|
fontEngine = nullptr;
|
||||||
fontEngine_owner = gFalse;
|
fontEngine_owner = false;
|
||||||
glyphs = nullptr;
|
glyphs = nullptr;
|
||||||
fill_pattern = nullptr;
|
fill_pattern = nullptr;
|
||||||
fill_color.r = fill_color.g = fill_color.b = 0;
|
fill_color.r = fill_color.g = fill_color.b = 0;
|
||||||
@ -150,16 +141,16 @@ CairoOutputDev::CairoOutputDev() {
|
|||||||
cairo = nullptr;
|
cairo = nullptr;
|
||||||
currentFont = nullptr;
|
currentFont = nullptr;
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
||||||
prescaleImages = gFalse;
|
prescaleImages = false;
|
||||||
#else
|
#else
|
||||||
prescaleImages = gTrue;
|
prescaleImages = true;
|
||||||
#endif
|
#endif
|
||||||
printing = gTrue;
|
printing = true;
|
||||||
use_show_text_glyphs = gFalse;
|
use_show_text_glyphs = false;
|
||||||
inUncoloredPattern = gFalse;
|
inUncoloredPattern = false;
|
||||||
inType3Char = gFalse;
|
inType3Char = false;
|
||||||
t3_glyph_has_bbox = gFalse;
|
t3_glyph_has_bbox = false;
|
||||||
text_matrix_valid = gTrue;
|
text_matrix_valid = true;
|
||||||
antialias = CAIRO_ANTIALIAS_DEFAULT;
|
antialias = CAIRO_ANTIALIAS_DEFAULT;
|
||||||
|
|
||||||
groupColorSpaceStack = nullptr;
|
groupColorSpaceStack = nullptr;
|
||||||
@ -175,9 +166,9 @@ CairoOutputDev::CairoOutputDev() {
|
|||||||
|
|
||||||
// the SA parameter supposedly defaults to false, but Acrobat
|
// the SA parameter supposedly defaults to false, but Acrobat
|
||||||
// apparently hardwires it to true
|
// apparently hardwires it to true
|
||||||
stroke_adjust = gTrue;
|
stroke_adjust = true;
|
||||||
align_stroke_coords = gFalse;
|
align_stroke_coords = false;
|
||||||
adjusted_stroke_width = gFalse;
|
adjusted_stroke_width = false;
|
||||||
xref = nullptr;
|
xref = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +261,7 @@ void CairoOutputDev::startDoc(PDFDoc *docA,
|
|||||||
delete fontEngine;
|
delete fontEngine;
|
||||||
}
|
}
|
||||||
fontEngine = new CairoFontEngine(ft_lib);
|
fontEngine = new CairoFontEngine(ft_lib);
|
||||||
fontEngine_owner = gTrue;
|
fontEngine_owner = true;
|
||||||
}
|
}
|
||||||
xref = doc->getXRef();
|
xref = doc->getXRef();
|
||||||
}
|
}
|
||||||
@ -295,7 +286,7 @@ void CairoOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) {
|
|||||||
void CairoOutputDev::endPage() {
|
void CairoOutputDev::endPage() {
|
||||||
if (text) {
|
if (text) {
|
||||||
text->endPage();
|
text->endPage();
|
||||||
text->coalesce(gTrue, 0, gFalse);
|
text->coalesce(true, 0, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +312,7 @@ void CairoOutputDev::restoreState(GfxState *state) {
|
|||||||
if (cairo_shape)
|
if (cairo_shape)
|
||||||
cairo_restore (cairo_shape);
|
cairo_restore (cairo_shape);
|
||||||
|
|
||||||
text_matrix_valid = gTrue;
|
text_matrix_valid = true;
|
||||||
|
|
||||||
/* These aren't restored by cairo_restore() since we keep them in
|
/* These aren't restored by cairo_restore() since we keep them in
|
||||||
* the output device. */
|
* the output device. */
|
||||||
@ -362,12 +353,12 @@ void CairoOutputDev::updateAll(GfxState *state) {
|
|||||||
updateFillOpacity(state);
|
updateFillOpacity(state);
|
||||||
updateStrokeOpacity(state);
|
updateStrokeOpacity(state);
|
||||||
updateBlendMode(state);
|
updateBlendMode(state);
|
||||||
needFontUpdate = gTrue;
|
needFontUpdate = true;
|
||||||
if (text)
|
if (text)
|
||||||
text->updateFont(state);
|
text->updateFont(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::setDefaultCTM(double *ctm) {
|
void CairoOutputDev::setDefaultCTM(const double *ctm) {
|
||||||
cairo_matrix_t matrix;
|
cairo_matrix_t matrix;
|
||||||
matrix.xx = ctm[0];
|
matrix.xx = ctm[0];
|
||||||
matrix.yx = ctm[1];
|
matrix.yx = ctm[1];
|
||||||
@ -473,7 +464,7 @@ void CairoOutputDev::updateMiterLimit(GfxState *state) {
|
|||||||
|
|
||||||
void CairoOutputDev::updateLineWidth(GfxState *state) {
|
void CairoOutputDev::updateLineWidth(GfxState *state) {
|
||||||
LOG(printf ("line width: %f\n", state->getLineWidth()));
|
LOG(printf ("line width: %f\n", state->getLineWidth()));
|
||||||
adjusted_stroke_width = gFalse;
|
adjusted_stroke_width = false;
|
||||||
double width = state->getLineWidth();
|
double width = state->getLineWidth();
|
||||||
if (stroke_adjust && !printing) {
|
if (stroke_adjust && !printing) {
|
||||||
double x, y;
|
double x, y;
|
||||||
@ -486,7 +477,7 @@ void CairoOutputDev::updateLineWidth(GfxState *state) {
|
|||||||
x = y = 1.0;
|
x = y = 1.0;
|
||||||
cairo_device_to_user_distance(cairo, &x, &y);
|
cairo_device_to_user_distance(cairo, &x, &y);
|
||||||
width = MIN(fabs(x),fabs(y));
|
width = MIN(fabs(x),fabs(y));
|
||||||
adjusted_stroke_width = gTrue;
|
adjusted_stroke_width = true;
|
||||||
}
|
}
|
||||||
} else if (width == 0.0) {
|
} else if (width == 0.0) {
|
||||||
/* Cairo does not support 0 line width == 1 device pixel. Find out
|
/* Cairo does not support 0 line width == 1 device pixel. Find out
|
||||||
@ -663,9 +654,9 @@ void CairoOutputDev::updateFont(GfxState *state) {
|
|||||||
cairo_font_face_t *font_face;
|
cairo_font_face_t *font_face;
|
||||||
cairo_matrix_t matrix, invert_matrix;
|
cairo_matrix_t matrix, invert_matrix;
|
||||||
|
|
||||||
LOG(printf ("updateFont() font=%s\n", state->getFont()->getName()->getCString()));
|
LOG(printf ("updateFont() font=%s\n", state->getFont()->getName()->c_str()));
|
||||||
|
|
||||||
needFontUpdate = gFalse;
|
needFontUpdate = false;
|
||||||
|
|
||||||
//FIXME: use cairo font engine?
|
//FIXME: use cairo font engine?
|
||||||
if (text)
|
if (text)
|
||||||
@ -683,7 +674,7 @@ void CairoOutputDev::updateFont(GfxState *state) {
|
|||||||
cairo_surface_has_show_text_glyphs (cairo_get_target (cairo));
|
cairo_surface_has_show_text_glyphs (cairo_get_target (cairo));
|
||||||
|
|
||||||
double fontSize = state->getFontSize();
|
double fontSize = state->getFontSize();
|
||||||
double *m = state->getTextMat();
|
const double *m = state->getTextMat();
|
||||||
/* NOTE: adjusting by a constant is hack. The correct solution
|
/* NOTE: adjusting by a constant is hack. The correct solution
|
||||||
* is probably to use user-fonts and compute the scale on a per
|
* is probably to use user-fonts and compute the scale on a per
|
||||||
* glyph basis instead of for the entire font */
|
* glyph basis instead of for the entire font */
|
||||||
@ -706,12 +697,12 @@ void CairoOutputDev::updateFont(GfxState *state) {
|
|||||||
invert_matrix = matrix;
|
invert_matrix = matrix;
|
||||||
if (cairo_matrix_invert(&invert_matrix)) {
|
if (cairo_matrix_invert(&invert_matrix)) {
|
||||||
error(errSyntaxWarning, -1, "font matrix not invertible");
|
error(errSyntaxWarning, -1, "font matrix not invertible");
|
||||||
text_matrix_valid = gFalse;
|
text_matrix_valid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_set_font_matrix (cairo, &matrix);
|
cairo_set_font_matrix (cairo, &matrix);
|
||||||
text_matrix_valid = gTrue;
|
text_matrix_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tolerance in pixels for checking if strokes are horizontal or vertical
|
/* Tolerance in pixels for checking if strokes are horizontal or vertical
|
||||||
@ -723,7 +714,7 @@ void CairoOutputDev::updateFont(GfxState *state) {
|
|||||||
void CairoOutputDev::alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y)
|
void CairoOutputDev::alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y)
|
||||||
{
|
{
|
||||||
double x1, y1, x2, y2;
|
double x1, y1, x2, y2;
|
||||||
GBool align = gFalse;
|
bool align = false;
|
||||||
|
|
||||||
x1 = subpath->getX(i);
|
x1 = subpath->getX(i);
|
||||||
y1 = subpath->getY(i);
|
y1 = subpath->getY(i);
|
||||||
@ -735,7 +726,7 @@ void CairoOutputDev::alignStrokeCoords(GfxSubpath *subpath, int i, double *x, do
|
|||||||
y2 = subpath->getY(i - 1);
|
y2 = subpath->getY(i - 1);
|
||||||
cairo_user_to_device (cairo, &x2, &y2);
|
cairo_user_to_device (cairo, &x2, &y2);
|
||||||
if (fabs(x2 - x1) < STROKE_COORD_TOLERANCE || fabs(y2 - y1) < STROKE_COORD_TOLERANCE)
|
if (fabs(x2 - x1) < STROKE_COORD_TOLERANCE || fabs(y2 - y1) < STROKE_COORD_TOLERANCE)
|
||||||
align = gTrue;
|
align = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does the current coord and next coord form a horiz or vert line?
|
// Does the current coord and next coord form a horiz or vert line?
|
||||||
@ -744,7 +735,7 @@ void CairoOutputDev::alignStrokeCoords(GfxSubpath *subpath, int i, double *x, do
|
|||||||
y2 = subpath->getY(i + 1);
|
y2 = subpath->getY(i + 1);
|
||||||
cairo_user_to_device (cairo, &x2, &y2);
|
cairo_user_to_device (cairo, &x2, &y2);
|
||||||
if (fabs(x2 - x1) < STROKE_COORD_TOLERANCE || fabs(y2 - y1) < STROKE_COORD_TOLERANCE)
|
if (fabs(x2 - x1) < STROKE_COORD_TOLERANCE || fabs(y2 - y1) < STROKE_COORD_TOLERANCE)
|
||||||
align = gTrue;
|
align = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
*x = subpath->getX(i);
|
*x = subpath->getX(i);
|
||||||
@ -818,9 +809,9 @@ void CairoOutputDev::stroke(GfxState *state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (adjusted_stroke_width)
|
if (adjusted_stroke_width)
|
||||||
align_stroke_coords = gTrue;
|
align_stroke_coords = true;
|
||||||
doPath (cairo, state, state->getPath());
|
doPath (cairo, state, state->getPath());
|
||||||
align_stroke_coords = gFalse;
|
align_stroke_coords = false;
|
||||||
cairo_set_source (cairo, stroke_pattern);
|
cairo_set_source (cairo, stroke_pattern);
|
||||||
LOG(printf ("stroke\n"));
|
LOG(printf ("stroke\n"));
|
||||||
if (strokePathClip) {
|
if (strokePathClip) {
|
||||||
@ -896,9 +887,9 @@ void CairoOutputDev::eoFill(GfxState *state) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat, Object *str,
|
bool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat, Object *str,
|
||||||
double *pmat, int paintType, int /*tilingType*/, Dict *resDict,
|
const double *pmat, int paintType, int /*tilingType*/, Dict *resDict,
|
||||||
double *mat, double *bbox,
|
const double *mat, const double *bbox,
|
||||||
int x0, int y0, int x1, int y1,
|
int x0, int y0, int x1, int y1,
|
||||||
double xStep, double yStep)
|
double xStep, double yStep)
|
||||||
{
|
{
|
||||||
@ -914,14 +905,14 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat
|
|||||||
double scaleX, scaleY;
|
double scaleX, scaleY;
|
||||||
int surface_width, surface_height;
|
int surface_width, surface_height;
|
||||||
StrokePathClip *strokePathTmp;
|
StrokePathClip *strokePathTmp;
|
||||||
GBool adjusted_stroke_width_tmp;
|
bool adjusted_stroke_width_tmp;
|
||||||
cairo_pattern_t *maskTmp;
|
cairo_pattern_t *maskTmp;
|
||||||
|
|
||||||
width = bbox[2] - bbox[0];
|
width = bbox[2] - bbox[0];
|
||||||
height = bbox[3] - bbox[1];
|
height = bbox[3] - bbox[1];
|
||||||
|
|
||||||
if (xStep != width || yStep != height)
|
if (xStep != width || yStep != height)
|
||||||
return gFalse;
|
return false;
|
||||||
/* TODO: implement the other cases here too */
|
/* TODO: implement the other cases here too */
|
||||||
|
|
||||||
// Find the width and height of the transformed pattern
|
// Find the width and height of the transformed pattern
|
||||||
@ -943,7 +934,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat
|
|||||||
CAIRO_CONTENT_COLOR_ALPHA,
|
CAIRO_CONTENT_COLOR_ALPHA,
|
||||||
surface_width, surface_height);
|
surface_width, surface_height);
|
||||||
if (cairo_surface_status (surface))
|
if (cairo_surface_status (surface))
|
||||||
return gFalse;
|
return false;
|
||||||
|
|
||||||
old_cairo = cairo;
|
old_cairo = cairo;
|
||||||
cairo = cairo_create (surface);
|
cairo = cairo_create (surface);
|
||||||
@ -962,10 +953,10 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat
|
|||||||
mask = nullptr;
|
mask = nullptr;
|
||||||
gfx = new Gfx(doc, this, resDict, &box, nullptr, nullptr, nullptr, gfxA);
|
gfx = new Gfx(doc, this, resDict, &box, nullptr, nullptr, nullptr, gfxA);
|
||||||
if (paintType == 2)
|
if (paintType == 2)
|
||||||
inUncoloredPattern = gTrue;
|
inUncoloredPattern = true;
|
||||||
gfx->display(str);
|
gfx->display(str);
|
||||||
if (paintType == 2)
|
if (paintType == 2)
|
||||||
inUncoloredPattern = gFalse;
|
inUncoloredPattern = false;
|
||||||
delete gfx;
|
delete gfx;
|
||||||
strokePathClip = strokePathTmp;
|
strokePathClip = strokePathTmp;
|
||||||
adjusted_stroke_width = adjusted_stroke_width_tmp;
|
adjusted_stroke_width = adjusted_stroke_width_tmp;
|
||||||
@ -975,7 +966,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat
|
|||||||
cairo_destroy (cairo);
|
cairo_destroy (cairo);
|
||||||
cairo = old_cairo;
|
cairo = old_cairo;
|
||||||
if (cairo_pattern_status (pattern))
|
if (cairo_pattern_status (pattern))
|
||||||
return gFalse;
|
return false;
|
||||||
|
|
||||||
state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax);
|
state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax);
|
||||||
cairo_rectangle (cairo, xMin, yMin, xMax - xMin, yMax - yMin);
|
cairo_rectangle (cairo, xMin, yMin, xMax - xMin, yMax - yMin);
|
||||||
@ -995,11 +986,11 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat
|
|||||||
|
|
||||||
cairo_pattern_destroy (pattern);
|
cairo_pattern_destroy (pattern);
|
||||||
|
|
||||||
return gTrue;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
|
||||||
GBool CairoOutputDev::functionShadedFill(GfxState *state, GfxFunctionShading *shading)
|
bool CairoOutputDev::functionShadedFill(GfxState *state, GfxFunctionShading *shading)
|
||||||
{
|
{
|
||||||
// Function shaded fills are subdivided to rectangles that are the
|
// Function shaded fills are subdivided to rectangles that are the
|
||||||
// following size in device space. Note when printing this size is
|
// following size in device space. Note when printing this size is
|
||||||
@ -1012,10 +1003,9 @@ GBool CairoOutputDev::functionShadedFill(GfxState *state, GfxFunctionShading *sh
|
|||||||
double y_step;
|
double y_step;
|
||||||
GfxColor color;
|
GfxColor color;
|
||||||
GfxRGB rgb;
|
GfxRGB rgb;
|
||||||
double *matrix;
|
|
||||||
cairo_matrix_t mat;
|
cairo_matrix_t mat;
|
||||||
|
|
||||||
matrix = shading->getMatrix();
|
const double *matrix = shading->getMatrix();
|
||||||
mat.xx = matrix[0];
|
mat.xx = matrix[0];
|
||||||
mat.yx = matrix[1];
|
mat.yx = matrix[1];
|
||||||
mat.xy = matrix[2];
|
mat.xy = matrix[2];
|
||||||
@ -1024,7 +1014,7 @@ GBool CairoOutputDev::functionShadedFill(GfxState *state, GfxFunctionShading *sh
|
|||||||
mat.y0 = matrix[5];
|
mat.y0 = matrix[5];
|
||||||
if (cairo_matrix_invert(&mat)) {
|
if (cairo_matrix_invert(&mat)) {
|
||||||
error(errSyntaxWarning, -1, "matrix not invertible\n");
|
error(errSyntaxWarning, -1, "matrix not invertible\n");
|
||||||
return gFalse;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get cell size in pattern space
|
// get cell size in pattern space
|
||||||
@ -1095,11 +1085,11 @@ GBool CairoOutputDev::functionShadedFill(GfxState *state, GfxFunctionShading *sh
|
|||||||
fill(state);
|
fill(state);
|
||||||
state->clearPath();
|
state->clearPath();
|
||||||
|
|
||||||
return gTrue;
|
return true;
|
||||||
}
|
}
|
||||||
#endif /* CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) */
|
#endif /* CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) */
|
||||||
|
|
||||||
GBool CairoOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) {
|
bool CairoOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) {
|
||||||
double x0, y0, x1, y1;
|
double x0, y0, x1, y1;
|
||||||
double dx, dy;
|
double dx, dy;
|
||||||
|
|
||||||
@ -1119,15 +1109,15 @@ GBool CairoOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading,
|
|||||||
|
|
||||||
// TODO: use the actual stops in the shading in the case
|
// TODO: use the actual stops in the shading in the case
|
||||||
// of linear interpolation (Type 2 Exponential functions with N=1)
|
// of linear interpolation (Type 2 Exponential functions with N=1)
|
||||||
return gFalse;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GBool CairoOutputDev::axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading)
|
bool CairoOutputDev::axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading)
|
||||||
{
|
{
|
||||||
return (shading->getExtend0() == shading->getExtend1());
|
return (shading->getExtend0() == shading->getExtend1());
|
||||||
}
|
}
|
||||||
|
|
||||||
GBool CairoOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) {
|
bool CairoOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) {
|
||||||
double x0, y0, r0, x1, y1, r1;
|
double x0, y0, r0, x1, y1, r1;
|
||||||
double dx, dy, dr;
|
double dx, dy, dr;
|
||||||
cairo_matrix_t matrix;
|
cairo_matrix_t matrix;
|
||||||
@ -1163,16 +1153,16 @@ GBool CairoOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shadin
|
|||||||
|
|
||||||
LOG (printf ("radial-sh\n"));
|
LOG (printf ("radial-sh\n"));
|
||||||
|
|
||||||
return gFalse;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GBool CairoOutputDev::radialShadedSupportExtend(GfxState *state, GfxRadialShading *shading)
|
bool CairoOutputDev::radialShadedSupportExtend(GfxState *state, GfxRadialShading *shading)
|
||||||
{
|
{
|
||||||
return (shading->getExtend0() == shading->getExtend1());
|
return (shading->getExtend0() == shading->getExtend1());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
|
||||||
GBool CairoOutputDev::gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading)
|
bool CairoOutputDev::gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading)
|
||||||
{
|
{
|
||||||
double x0, y0, x1, y1, x2, y2;
|
double x0, y0, x1, y1, x2, y2;
|
||||||
GfxColor color[3];
|
GfxColor color[3];
|
||||||
@ -1227,10 +1217,10 @@ GBool CairoOutputDev::gouraudTriangleShadedFill(GfxState *state, GfxGouraudTrian
|
|||||||
fill(state);
|
fill(state);
|
||||||
state->clearPath();
|
state->clearPath();
|
||||||
|
|
||||||
return gTrue;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GBool CairoOutputDev::patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading)
|
bool CairoOutputDev::patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading)
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
|
||||||
@ -1238,7 +1228,7 @@ GBool CairoOutputDev::patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *
|
|||||||
fill_pattern = cairo_pattern_create_mesh ();
|
fill_pattern = cairo_pattern_create_mesh ();
|
||||||
|
|
||||||
for (i = 0; i < shading->getNPatches(); i++) {
|
for (i = 0; i < shading->getNPatches(); i++) {
|
||||||
GfxPatch *patch = shading->getPatch(i);
|
const GfxPatch *patch = shading->getPatch(i);
|
||||||
GfxColor color;
|
GfxColor color;
|
||||||
GfxRGB rgb;
|
GfxRGB rgb;
|
||||||
|
|
||||||
@ -1317,7 +1307,7 @@ GBool CairoOutputDev::patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *
|
|||||||
fill(state);
|
fill(state);
|
||||||
state->clearPath();
|
state->clearPath();
|
||||||
|
|
||||||
return gTrue;
|
return true;
|
||||||
}
|
}
|
||||||
#endif /* CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) */
|
#endif /* CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) */
|
||||||
|
|
||||||
@ -1519,15 +1509,14 @@ finish:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GBool CairoOutputDev::beginType3Char(GfxState *state, double x, double y,
|
bool CairoOutputDev::beginType3Char(GfxState *state, double x, double y,
|
||||||
double dx, double dy,
|
double dx, double dy,
|
||||||
CharCode code, Unicode *u, int uLen) {
|
CharCode code, Unicode *u, int uLen) {
|
||||||
|
|
||||||
cairo_save (cairo);
|
cairo_save (cairo);
|
||||||
double *ctm;
|
|
||||||
cairo_matrix_t matrix;
|
cairo_matrix_t matrix;
|
||||||
|
|
||||||
ctm = state->getCTM();
|
const double *ctm = state->getCTM();
|
||||||
matrix.xx = ctm[0];
|
matrix.xx = ctm[0];
|
||||||
matrix.yx = ctm[1];
|
matrix.yx = ctm[1];
|
||||||
matrix.xy = ctm[2];
|
matrix.xy = ctm[2];
|
||||||
@ -1546,7 +1535,7 @@ GBool CairoOutputDev::beginType3Char(GfxState *state, double x, double y,
|
|||||||
cairo_pattern_destroy(stroke_pattern);
|
cairo_pattern_destroy(stroke_pattern);
|
||||||
cairo_pattern_reference(fill_pattern);
|
cairo_pattern_reference(fill_pattern);
|
||||||
stroke_pattern = fill_pattern;
|
stroke_pattern = fill_pattern;
|
||||||
return gFalse;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::endType3Char(GfxState *state) {
|
void CairoOutputDev::endType3Char(GfxState *state) {
|
||||||
@ -1569,7 +1558,7 @@ void CairoOutputDev::type3D1(GfxState *state, double wx, double wy,
|
|||||||
t3_glyph_bbox[1] = lly;
|
t3_glyph_bbox[1] = lly;
|
||||||
t3_glyph_bbox[2] = urx;
|
t3_glyph_bbox[2] = urx;
|
||||||
t3_glyph_bbox[3] = ury;
|
t3_glyph_bbox[3] = ury;
|
||||||
t3_glyph_has_bbox = gTrue;
|
t3_glyph_has_bbox = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::beginTextObject(GfxState *state) {
|
void CairoOutputDev::beginTextObject(GfxState *state) {
|
||||||
@ -1629,10 +1618,10 @@ cairo_surface_t *cairo_surface_create_similar_clip (cairo_t *cairo, cairo_conten
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CairoOutputDev::beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/,
|
void CairoOutputDev::beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/,
|
||||||
GfxColorSpace * blendingColorSpace,
|
GfxColorSpace * blendingColorSpace,
|
||||||
GBool /*isolated*/, GBool knockout,
|
bool /*isolated*/, bool knockout,
|
||||||
GBool forSoftMask) {
|
bool forSoftMask) {
|
||||||
/* push color space */
|
/* push color space */
|
||||||
ColorSpaceStack* css = new ColorSpaceStack;
|
ColorSpaceStack* css = new ColorSpaceStack;
|
||||||
css->cs = blendingColorSpace;
|
css->cs = blendingColorSpace;
|
||||||
@ -1656,7 +1645,6 @@ void CairoOutputDev::beginTransparencyGroup(GfxState * /*state*/, double * /*bbo
|
|||||||
cairo_set_source_rgb (cairo_shape, 0, 0, 0);
|
cairo_set_source_rgb (cairo_shape, 0, 0, 0);
|
||||||
cairo_matrix_t matrix;
|
cairo_matrix_t matrix;
|
||||||
cairo_get_matrix (cairo, &matrix);
|
cairo_get_matrix (cairo, &matrix);
|
||||||
//printMatrix(&matrix);
|
|
||||||
cairo_set_matrix (cairo_shape, &matrix);
|
cairo_set_matrix (cairo_shape, &matrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1692,7 +1680,7 @@ void CairoOutputDev::endTransparencyGroup(GfxState * /*state*/) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) {
|
void CairoOutputDev::paintTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/) {
|
||||||
LOG(printf ("paint transparency group\n"));
|
LOG(printf ("paint transparency group\n"));
|
||||||
|
|
||||||
cairo_save (cairo);
|
cairo_save (cairo);
|
||||||
@ -1758,7 +1746,7 @@ static int luminocity(uint32_t x)
|
|||||||
|
|
||||||
|
|
||||||
/* XXX: do we need to deal with shape here? */
|
/* XXX: do we need to deal with shape here? */
|
||||||
void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha,
|
void CairoOutputDev::setSoftMask(GfxState * state, const double * bbox, bool alpha,
|
||||||
Function * transferFunc, GfxColor * backdropColor) {
|
Function * transferFunc, GfxColor * backdropColor) {
|
||||||
cairo_pattern_destroy(mask);
|
cairo_pattern_destroy(mask);
|
||||||
|
|
||||||
@ -1838,7 +1826,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha,
|
|||||||
cairo_destroy(maskCtx);
|
cairo_destroy(maskCtx);
|
||||||
|
|
||||||
/* convert to a luminocity map */
|
/* convert to a luminocity map */
|
||||||
uint32_t *source_data = (uint32_t*)cairo_image_surface_get_data(source);
|
uint32_t *source_data = reinterpret_cast<uint32_t *>(cairo_image_surface_get_data(source));
|
||||||
/* get stride in units of 32 bits */
|
/* get stride in units of 32 bits */
|
||||||
ptrdiff_t stride = cairo_image_surface_get_stride(source)/4;
|
ptrdiff_t stride = cairo_image_surface_get_stride(source)/4;
|
||||||
for (int y=0; y<height; y++) {
|
for (int y=0; y<height; y++) {
|
||||||
@ -1937,7 +1925,7 @@ void CairoOutputDev::getScaledSize(const cairo_matrix_t *matrix,
|
|||||||
else
|
else
|
||||||
get_singular_values (matrix, &yScale, &xScale);
|
get_singular_values (matrix, &yScale, &xScale);
|
||||||
|
|
||||||
int tx, tx2, ty, ty2; /* the integer co-oridinates of the resulting image */
|
int tx, tx2, ty, ty2; /* the integer co-ordinates of the resulting image */
|
||||||
if (xScale >= 0) {
|
if (xScale >= 0) {
|
||||||
tx = splashRound(matrix->x0 - 0.01);
|
tx = splashRound(matrix->x0 - 0.01);
|
||||||
tx2 = splashRound(matrix->x0 + xScale + 0.01) - 1;
|
tx2 = splashRound(matrix->x0 + xScale + 0.01) - 1;
|
||||||
@ -1968,7 +1956,7 @@ void CairoOutputDev::getScaledSize(const cairo_matrix_t *matrix,
|
|||||||
|
|
||||||
cairo_filter_t
|
cairo_filter_t
|
||||||
CairoOutputDev::getFilterForSurface(cairo_surface_t *image,
|
CairoOutputDev::getFilterForSurface(cairo_surface_t *image,
|
||||||
GBool interpolate)
|
bool interpolate)
|
||||||
{
|
{
|
||||||
if (interpolate)
|
if (interpolate)
|
||||||
return CAIRO_FILTER_GOOD;
|
return CAIRO_FILTER_GOOD;
|
||||||
@ -1995,8 +1983,8 @@ CairoOutputDev::getFilterForSurface(cairo_surface_t *image,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
|
void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GBool invert,
|
int width, int height, bool invert,
|
||||||
GBool interpolate, GBool inlineImg) {
|
bool interpolate, bool inlineImg) {
|
||||||
|
|
||||||
/* FIXME: Doesn't the image mask support any colorspace? */
|
/* FIXME: Doesn't the image mask support any colorspace? */
|
||||||
cairo_set_source (cairo, fill_pattern);
|
cairo_set_source (cairo, fill_pattern);
|
||||||
@ -2004,7 +1992,7 @@ void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
|
|||||||
/* work around a cairo bug when scaling 1x1 surfaces */
|
/* work around a cairo bug when scaling 1x1 surfaces */
|
||||||
if (width == 1 && height == 1) {
|
if (width == 1 && height == 1) {
|
||||||
ImageStream *imgStr;
|
ImageStream *imgStr;
|
||||||
Guchar pix;
|
unsigned char pix;
|
||||||
int invert_bit;
|
int invert_bit;
|
||||||
|
|
||||||
imgStr = new ImageStream(str, width, 1, 1);
|
imgStr = new ImageStream(str, width, 1, 1);
|
||||||
@ -2049,8 +2037,8 @@ void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str,
|
void CairoOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GBool invert,
|
int width, int height, bool invert,
|
||||||
GBool inlineImg, double *baseMatrix) {
|
bool inlineImg, double *baseMatrix) {
|
||||||
|
|
||||||
/* FIXME: Doesn't the image mask support any colorspace? */
|
/* FIXME: Doesn't the image mask support any colorspace? */
|
||||||
cairo_set_source (cairo, fill_pattern);
|
cairo_set_source (cairo, fill_pattern);
|
||||||
@ -2058,7 +2046,7 @@ void CairoOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stre
|
|||||||
/* work around a cairo bug when scaling 1x1 surfaces */
|
/* work around a cairo bug when scaling 1x1 surfaces */
|
||||||
if (width == 1 && height == 1) {
|
if (width == 1 && height == 1) {
|
||||||
ImageStream *imgStr;
|
ImageStream *imgStr;
|
||||||
Guchar pix;
|
unsigned char pix;
|
||||||
int invert_bit;
|
int invert_bit;
|
||||||
|
|
||||||
imgStr = new ImageStream(str, width, 1, 1);
|
imgStr = new ImageStream(str, width, 1, 1);
|
||||||
@ -2090,9 +2078,9 @@ void CairoOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stre
|
|||||||
//XXX: it is possible that we should only do sub pixel positioning if
|
//XXX: it is possible that we should only do sub pixel positioning if
|
||||||
// we are rendering fonts */
|
// we are rendering fonts */
|
||||||
if (!printing && prescaleImages && matrix.xy == 0.0 && matrix.yx == 0.0) {
|
if (!printing && prescaleImages && matrix.xy == 0.0 && matrix.yx == 0.0) {
|
||||||
drawImageMaskPrescaled(state, ref, str, width, height, invert, gFalse, inlineImg);
|
drawImageMaskPrescaled(state, ref, str, width, height, invert, false, inlineImg);
|
||||||
} else {
|
} else {
|
||||||
drawImageMaskRegular(state, ref, str, width, height, invert, gFalse, inlineImg);
|
drawImageMaskRegular(state, ref, str, width, height, invert, false, inlineImg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->getFillColorSpace()->getMode() == csPattern) {
|
if (state->getFillColorSpace()->getMode() == csPattern) {
|
||||||
@ -2109,7 +2097,7 @@ void CairoOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stre
|
|||||||
saveState(state);
|
saveState(state);
|
||||||
double bbox[4] = {0,0,1,1}; // dummy
|
double bbox[4] = {0,0,1,1}; // dummy
|
||||||
beginTransparencyGroup(state, bbox, state->getFillColorSpace(),
|
beginTransparencyGroup(state, bbox, state->getFillColorSpace(),
|
||||||
gTrue, gFalse, gFalse);
|
true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) {
|
void CairoOutputDev::unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) {
|
||||||
@ -2122,15 +2110,15 @@ void CairoOutputDev::unsetSoftMaskFromImageMask(GfxState *state, double *baseMat
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *str,
|
void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GBool invert,
|
int width, int height, bool invert,
|
||||||
GBool interpolate, GBool inlineImg) {
|
bool interpolate, bool inlineImg) {
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
unsigned char *dest;
|
unsigned char *dest;
|
||||||
cairo_surface_t *image;
|
cairo_surface_t *image;
|
||||||
cairo_pattern_t *pattern;
|
cairo_pattern_t *pattern;
|
||||||
int x, y, i, bit;
|
int x, y, i, bit;
|
||||||
ImageStream *imgStr;
|
ImageStream *imgStr;
|
||||||
Guchar *pix;
|
unsigned char *pix;
|
||||||
cairo_matrix_t matrix;
|
cairo_matrix_t matrix;
|
||||||
int invert_bit;
|
int invert_bit;
|
||||||
ptrdiff_t row_stride;
|
ptrdiff_t row_stride;
|
||||||
@ -2231,13 +2219,13 @@ cleanup:
|
|||||||
|
|
||||||
|
|
||||||
void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream *str,
|
void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GBool invert,
|
int width, int height, bool invert,
|
||||||
GBool interpolate, GBool inlineImg) {
|
bool interpolate, bool inlineImg) {
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
cairo_surface_t *image;
|
cairo_surface_t *image;
|
||||||
cairo_pattern_t *pattern;
|
cairo_pattern_t *pattern;
|
||||||
ImageStream *imgStr;
|
ImageStream *imgStr;
|
||||||
Guchar *pix;
|
unsigned char *pix;
|
||||||
cairo_matrix_t matrix;
|
cairo_matrix_t matrix;
|
||||||
int invert_bit;
|
int invert_bit;
|
||||||
ptrdiff_t row_stride;
|
ptrdiff_t row_stride;
|
||||||
@ -2254,7 +2242,7 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream
|
|||||||
/* this whole computation should be factored out */
|
/* this whole computation should be factored out */
|
||||||
double xScale = matrix.xx;
|
double xScale = matrix.xx;
|
||||||
double yScale = matrix.yy;
|
double yScale = matrix.yy;
|
||||||
int tx, tx2, ty, ty2; /* the integer co-oridinates of the resulting image */
|
int tx, tx2, ty, ty2; /* the integer co-ordinates of the resulting image */
|
||||||
int scaledHeight;
|
int scaledHeight;
|
||||||
int scaledWidth;
|
int scaledWidth;
|
||||||
if (xScale >= 0) {
|
if (xScale >= 0) {
|
||||||
@ -2527,10 +2515,10 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream
|
|||||||
void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
|
void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
|
||||||
Stream *str, int width, int height,
|
Stream *str, int width, int height,
|
||||||
GfxImageColorMap *colorMap,
|
GfxImageColorMap *colorMap,
|
||||||
GBool interpolate,
|
bool interpolate,
|
||||||
Stream *maskStr, int maskWidth,
|
Stream *maskStr, int maskWidth,
|
||||||
int maskHeight, GBool maskInvert,
|
int maskHeight, bool maskInvert,
|
||||||
GBool maskInterpolate)
|
bool maskInterpolate)
|
||||||
{
|
{
|
||||||
ImageStream *maskImgStr, *imgStr;
|
ImageStream *maskImgStr, *imgStr;
|
||||||
ptrdiff_t row_stride;
|
ptrdiff_t row_stride;
|
||||||
@ -2541,7 +2529,7 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
|
|||||||
cairo_pattern_t *maskPattern, *pattern;
|
cairo_pattern_t *maskPattern, *pattern;
|
||||||
cairo_matrix_t matrix;
|
cairo_matrix_t matrix;
|
||||||
cairo_matrix_t maskMatrix;
|
cairo_matrix_t maskMatrix;
|
||||||
Guchar *pix;
|
unsigned char *pix;
|
||||||
int x, y;
|
int x, y;
|
||||||
int invert_bit;
|
int invert_bit;
|
||||||
cairo_filter_t filter;
|
cairo_filter_t filter;
|
||||||
@ -2606,7 +2594,7 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
|
|||||||
buffer = cairo_image_surface_get_data (image);
|
buffer = cairo_image_surface_get_data (image);
|
||||||
row_stride = cairo_image_surface_get_stride (image);
|
row_stride = cairo_image_surface_get_stride (image);
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
dest = (unsigned int *) (buffer + y * row_stride);
|
dest = reinterpret_cast<unsigned int *>(buffer + y * row_stride);
|
||||||
pix = imgStr->getLine();
|
pix = imgStr->getLine();
|
||||||
colorMap->getRGBLine (pix, dest, width);
|
colorMap->getRGBLine (pix, dest, width);
|
||||||
}
|
}
|
||||||
@ -2684,11 +2672,11 @@ cleanup:
|
|||||||
void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
|
void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
GfxImageColorMap *colorMap,
|
GfxImageColorMap *colorMap,
|
||||||
GBool interpolate,
|
bool interpolate,
|
||||||
Stream *maskStr,
|
Stream *maskStr,
|
||||||
int maskWidth, int maskHeight,
|
int maskWidth, int maskHeight,
|
||||||
GfxImageColorMap *maskColorMap,
|
GfxImageColorMap *maskColorMap,
|
||||||
GBool maskInterpolate)
|
bool maskInterpolate)
|
||||||
{
|
{
|
||||||
ImageStream *maskImgStr, *imgStr;
|
ImageStream *maskImgStr, *imgStr;
|
||||||
ptrdiff_t row_stride;
|
ptrdiff_t row_stride;
|
||||||
@ -2698,7 +2686,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
|
|||||||
cairo_surface_t *maskImage, *image;
|
cairo_surface_t *maskImage, *image;
|
||||||
cairo_pattern_t *maskPattern, *pattern;
|
cairo_pattern_t *maskPattern, *pattern;
|
||||||
cairo_matrix_t maskMatrix, matrix;
|
cairo_matrix_t maskMatrix, matrix;
|
||||||
Guchar *pix;
|
unsigned char *pix;
|
||||||
int y;
|
int y;
|
||||||
cairo_filter_t filter;
|
cairo_filter_t filter;
|
||||||
cairo_filter_t maskFilter;
|
cairo_filter_t maskFilter;
|
||||||
@ -2758,7 +2746,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
|
|||||||
buffer = cairo_image_surface_get_data (image);
|
buffer = cairo_image_surface_get_data (image);
|
||||||
row_stride = cairo_image_surface_get_stride (image);
|
row_stride = cairo_image_surface_get_stride (image);
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
dest = (unsigned int *) (buffer + y * row_stride);
|
dest = reinterpret_cast<unsigned int *>(buffer + y * row_stride);
|
||||||
pix = imgStr->getLine();
|
pix = imgStr->getLine();
|
||||||
colorMap->getRGBLine (pix, dest, width);
|
colorMap->getRGBLine (pix, dest, width);
|
||||||
}
|
}
|
||||||
@ -2845,7 +2833,7 @@ cleanup:
|
|||||||
delete imgStr;
|
delete imgStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GBool CairoOutputDev::getStreamData (Stream *str, char **buffer, int *length)
|
bool CairoOutputDev::getStreamData (Stream *str, char **buffer, int *length)
|
||||||
{
|
{
|
||||||
int len, i;
|
int len, i;
|
||||||
char *strBuffer;
|
char *strBuffer;
|
||||||
@ -2855,7 +2843,7 @@ GBool CairoOutputDev::getStreamData (Stream *str, char **buffer, int *length)
|
|||||||
str->reset();
|
str->reset();
|
||||||
while (str->getChar() != EOF) len++;
|
while (str->getChar() != EOF) len++;
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return gFalse;
|
return false;
|
||||||
|
|
||||||
strBuffer = (char *)gmalloc (len);
|
strBuffer = (char *)gmalloc (len);
|
||||||
|
|
||||||
@ -2867,16 +2855,16 @@ GBool CairoOutputDev::getStreamData (Stream *str, char **buffer, int *length)
|
|||||||
*buffer = strBuffer;
|
*buffer = strBuffer;
|
||||||
*length = len;
|
*length = len;
|
||||||
|
|
||||||
return gTrue;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GBool colorMapHasIdentityDecodeMap(GfxImageColorMap *colorMap)
|
static bool colorMapHasIdentityDecodeMap(GfxImageColorMap *colorMap)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < colorMap->getNumPixelComps(); i++) {
|
for (int i = 0; i < colorMap->getNumPixelComps(); i++) {
|
||||||
if (colorMap->getDecodeLow(i) != 0.0 || colorMap->getDecodeHigh(i) != 1.0)
|
if (colorMap->getDecodeLow(i) != 0.0 || colorMap->getDecodeHigh(i) != 1.0)
|
||||||
return gFalse;
|
return false;
|
||||||
}
|
}
|
||||||
return gTrue;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)
|
||||||
@ -2896,7 +2884,7 @@ static cairo_status_t setMimeIdFromRef(cairo_surface_t *surface,
|
|||||||
|
|
||||||
mime_id->appendf("{0:d}-{1:d}", ref.gen, ref.num);
|
mime_id->appendf("{0:d}-{1:d}", ref.gen, ref.num);
|
||||||
|
|
||||||
idBuffer = copyString(mime_id->getCString());
|
idBuffer = copyString(mime_id->c_str());
|
||||||
status = cairo_surface_set_mime_data (surface, mime_type,
|
status = cairo_surface_set_mime_data (surface, mime_type,
|
||||||
(const unsigned char *)idBuffer,
|
(const unsigned char *)idBuffer,
|
||||||
mime_id->getLength(),
|
mime_id->getLength(),
|
||||||
@ -2909,7 +2897,7 @@ static cairo_status_t setMimeIdFromRef(cairo_surface_t *surface,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
||||||
GBool CairoOutputDev::setMimeDataForJBIG2Globals(Stream *str,
|
bool CairoOutputDev::setMimeDataForJBIG2Globals(Stream *str,
|
||||||
cairo_surface_t *image)
|
cairo_surface_t *image)
|
||||||
{
|
{
|
||||||
JBIG2Stream *jb2Str = static_cast<JBIG2Stream *>(str);
|
JBIG2Stream *jb2Str = static_cast<JBIG2Stream *>(str);
|
||||||
@ -2919,14 +2907,14 @@ GBool CairoOutputDev::setMimeDataForJBIG2Globals(Stream *str,
|
|||||||
|
|
||||||
// nothing to do for JBIG2 stream without Globals
|
// nothing to do for JBIG2 stream without Globals
|
||||||
if (!globalsStr->isStream())
|
if (!globalsStr->isStream())
|
||||||
return gTrue;
|
return true;
|
||||||
|
|
||||||
if (setMimeIdFromRef(image, CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID, nullptr,
|
if (setMimeIdFromRef(image, CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID, nullptr,
|
||||||
jb2Str->getGlobalsStreamRef()))
|
jb2Str->getGlobalsStreamRef()))
|
||||||
return gFalse;
|
return false;
|
||||||
|
|
||||||
if (!getStreamData(globalsStr->getStream(), &globalsBuffer, &globalsLength))
|
if (!getStreamData(globalsStr->getStream(), &globalsBuffer, &globalsLength))
|
||||||
return gFalse;
|
return false;
|
||||||
|
|
||||||
if (cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_JBIG2_GLOBAL,
|
if (cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_JBIG2_GLOBAL,
|
||||||
(const unsigned char*)globalsBuffer,
|
(const unsigned char*)globalsBuffer,
|
||||||
@ -2934,15 +2922,15 @@ GBool CairoOutputDev::setMimeDataForJBIG2Globals(Stream *str,
|
|||||||
gfree, (void*)globalsBuffer))
|
gfree, (void*)globalsBuffer))
|
||||||
{
|
{
|
||||||
gfree (globalsBuffer);
|
gfree (globalsBuffer);
|
||||||
return gFalse;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gTrue;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
|
||||||
GBool CairoOutputDev::setMimeDataForCCITTParams(Stream *str,
|
bool CairoOutputDev::setMimeDataForCCITTParams(Stream *str,
|
||||||
cairo_surface_t *image, int height)
|
cairo_surface_t *image, int height)
|
||||||
{
|
{
|
||||||
CCITTFaxStream *ccittStr = static_cast<CCITTFaxStream *>(str);
|
CCITTFaxStream *ccittStr = static_cast<CCITTFaxStream *>(str);
|
||||||
@ -2957,17 +2945,17 @@ GBool CairoOutputDev::setMimeDataForCCITTParams(Stream *str,
|
|||||||
params.appendf(" BlackIs1={0:d}", ccittStr->getBlackIs1() ? 1 : 0);
|
params.appendf(" BlackIs1={0:d}", ccittStr->getBlackIs1() ? 1 : 0);
|
||||||
params.appendf(" DamagedRowsBeforeError={0:d}", ccittStr->getDamagedRowsBeforeError());
|
params.appendf(" DamagedRowsBeforeError={0:d}", ccittStr->getDamagedRowsBeforeError());
|
||||||
|
|
||||||
char *p = strdup(params.getCString());
|
char *p = strdup(params.c_str());
|
||||||
if (cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_CCITT_FAX_PARAMS,
|
if (cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_CCITT_FAX_PARAMS,
|
||||||
(const unsigned char*)p,
|
(const unsigned char*)p,
|
||||||
params.getLength(),
|
params.getLength(),
|
||||||
gfree, (void*)p))
|
gfree, (void*)p))
|
||||||
{
|
{
|
||||||
gfree (p);
|
gfree (p);
|
||||||
return gFalse;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gTrue;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -3052,9 +3040,14 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref,
|
|||||||
cairo_status_t status = CAIRO_STATUS_SUCCESS;
|
cairo_status_t status = CAIRO_STATUS_SUCCESS;
|
||||||
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)
|
||||||
if (ref && ref->isRef()) {
|
// Since 1.5.10 the cairo PS backend stores images with UNIQUE_ID in PS memory so the
|
||||||
status = setMimeIdFromRef(image, CAIRO_MIME_TYPE_UNIQUE_ID,
|
// image can be re-used multiple times. As we don't know how large the images are or
|
||||||
"poppler-surface-", ref->getRef());
|
// how many times they are used, there is no benefit in enabling this. Issue #106
|
||||||
|
if (cairo_surface_get_type (cairo_get_target (cairo)) != CAIRO_SURFACE_TYPE_PS) {
|
||||||
|
if (ref && ref->isRef()) {
|
||||||
|
status = setMimeIdFromRef(image, CAIRO_MIME_TYPE_UNIQUE_ID,
|
||||||
|
"poppler-surface-", ref->getRef());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!status) {
|
if (!status) {
|
||||||
@ -3076,13 +3069,13 @@ private:
|
|||||||
GfxImageColorMap *colorMap;
|
GfxImageColorMap *colorMap;
|
||||||
int *maskColors;
|
int *maskColors;
|
||||||
int current_row;
|
int current_row;
|
||||||
GBool imageError;
|
bool imageError;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cairo_surface_t *getSourceImage(Stream *str,
|
cairo_surface_t *getSourceImage(Stream *str,
|
||||||
int widthA, int height,
|
int widthA, int height,
|
||||||
int scaledWidth, int scaledHeight,
|
int scaledWidth, int scaledHeight,
|
||||||
GBool printing,
|
bool printing,
|
||||||
GfxImageColorMap *colorMapA,
|
GfxImageColorMap *colorMapA,
|
||||||
int *maskColorsA) {
|
int *maskColorsA) {
|
||||||
cairo_surface_t *image = nullptr;
|
cairo_surface_t *image = nullptr;
|
||||||
@ -3093,7 +3086,7 @@ public:
|
|||||||
maskColors = maskColorsA;
|
maskColors = maskColorsA;
|
||||||
width = widthA;
|
width = widthA;
|
||||||
current_row = -1;
|
current_row = -1;
|
||||||
imageError = gFalse;
|
imageError = false;
|
||||||
|
|
||||||
/* TODO: Do we want to cache these? */
|
/* TODO: Do we want to cache these? */
|
||||||
imgStr = new ImageStream(str, width,
|
imgStr = new ImageStream(str, width,
|
||||||
@ -3114,12 +3107,12 @@ public:
|
|||||||
// build a lookup table here
|
// build a lookup table here
|
||||||
if (colorMap->getNumPixelComps() == 1) {
|
if (colorMap->getNumPixelComps() == 1) {
|
||||||
int n;
|
int n;
|
||||||
Guchar pix;
|
unsigned char pix;
|
||||||
|
|
||||||
n = 1 << colorMap->getBits();
|
n = 1 << colorMap->getBits();
|
||||||
lookup = (GfxRGB *)gmallocn(n, sizeof(GfxRGB));
|
lookup = (GfxRGB *)gmallocn(n, sizeof(GfxRGB));
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
pix = (Guchar)i;
|
pix = (unsigned char)i;
|
||||||
|
|
||||||
colorMap->getRGB(&pix, &lookup[i]);
|
colorMap->getRGB(&pix, &lookup[i]);
|
||||||
}
|
}
|
||||||
@ -3161,7 +3154,7 @@ public:
|
|||||||
buffer = cairo_image_surface_get_data (image);
|
buffer = cairo_image_surface_get_data (image);
|
||||||
stride = cairo_image_surface_get_stride (image);
|
stride = cairo_image_surface_get_stride (image);
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
uint32_t *dest = (uint32_t *) (buffer + y * stride);
|
uint32_t *dest = reinterpret_cast<uint32_t *>(buffer + y * stride);
|
||||||
getRow(y, dest);
|
getRow(y, dest);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -3194,7 +3187,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void getRow(int row_num, uint32_t *row_data) override {
|
void getRow(int row_num, uint32_t *row_data) override {
|
||||||
Guchar *pix;
|
unsigned char *pix;
|
||||||
|
|
||||||
if (row_num <= current_row)
|
if (row_num <= current_row)
|
||||||
return;
|
return;
|
||||||
@ -3208,10 +3201,10 @@ public:
|
|||||||
memset(row_data, 0, width*4);
|
memset(row_data, 0, width*4);
|
||||||
if (!imageError) {
|
if (!imageError) {
|
||||||
error(errInternal, -1, "Bad image stream");
|
error(errInternal, -1, "Bad image stream");
|
||||||
imageError = gTrue;
|
imageError = true;
|
||||||
}
|
}
|
||||||
} else if (lookup) {
|
} else if (lookup) {
|
||||||
Guchar *p = pix;
|
unsigned char *p = pix;
|
||||||
GfxRGB rgb;
|
GfxRGB rgb;
|
||||||
|
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
@ -3251,8 +3244,8 @@ public:
|
|||||||
void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
|
void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
|
||||||
int widthA, int heightA,
|
int widthA, int heightA,
|
||||||
GfxImageColorMap *colorMap,
|
GfxImageColorMap *colorMap,
|
||||||
GBool interpolate,
|
bool interpolate,
|
||||||
int *maskColors, GBool inlineImg)
|
int *maskColors, bool inlineImg)
|
||||||
{
|
{
|
||||||
cairo_surface_t *image;
|
cairo_surface_t *image;
|
||||||
cairo_pattern_t *pattern, *maskPattern;
|
cairo_pattern_t *pattern, *maskPattern;
|
||||||
@ -3383,7 +3376,7 @@ void CairoImageOutputDev::saveImage(CairoImage *image)
|
|||||||
void CairoImageOutputDev::getBBox(GfxState *state, int width, int height,
|
void CairoImageOutputDev::getBBox(GfxState *state, int width, int height,
|
||||||
double *x1, double *y1, double *x2, double *y2)
|
double *x1, double *y1, double *x2, double *y2)
|
||||||
{
|
{
|
||||||
double *ctm = state->getCTM();
|
const double *ctm = state->getCTM();
|
||||||
cairo_matrix_t matrix;
|
cairo_matrix_t matrix;
|
||||||
cairo_matrix_init(&matrix,
|
cairo_matrix_init(&matrix,
|
||||||
ctm[0], ctm[1],
|
ctm[0], ctm[1],
|
||||||
@ -3409,8 +3402,8 @@ void CairoImageOutputDev::getBBox(GfxState *state, int width, int height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CairoImageOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
|
void CairoImageOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GBool invert,
|
int width, int height, bool invert,
|
||||||
GBool interpolate, GBool inlineImg)
|
bool interpolate, bool inlineImg)
|
||||||
{
|
{
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
@ -3439,8 +3432,8 @@ void CairoImageOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *st
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CairoImageOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str,
|
void CairoImageOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GBool invert,
|
int width, int height, bool invert,
|
||||||
GBool inlineImg, double *baseMatrix)
|
bool inlineImg, double *baseMatrix)
|
||||||
{
|
{
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
@ -3459,7 +3452,7 @@ void CairoImageOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref,
|
|||||||
cairo_translate (cr, 0, height);
|
cairo_translate (cr, 0, height);
|
||||||
cairo_scale (cr, width, -height);
|
cairo_scale (cr, width, -height);
|
||||||
|
|
||||||
CairoOutputDev::drawImageMask(state, ref, str, width, height, invert, inlineImg, gFalse);
|
CairoOutputDev::drawImageMask(state, ref, str, width, height, invert, inlineImg, false);
|
||||||
if (state->getFillColorSpace()->getMode() == csPattern) {
|
if (state->getFillColorSpace()->getMode() == csPattern) {
|
||||||
cairo_mask (cairo, mask);
|
cairo_mask (cairo, mask);
|
||||||
}
|
}
|
||||||
@ -3473,7 +3466,7 @@ void CairoImageOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref,
|
|||||||
|
|
||||||
void CairoImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
|
void CairoImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GfxImageColorMap *colorMap,
|
int width, int height, GfxImageColorMap *colorMap,
|
||||||
GBool interpolate, int *maskColors, GBool inlineImg)
|
bool interpolate, int *maskColors, bool inlineImg)
|
||||||
{
|
{
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
@ -3504,11 +3497,11 @@ void CairoImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
|
|||||||
void CairoImageOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
|
void CairoImageOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
GfxImageColorMap *colorMap,
|
GfxImageColorMap *colorMap,
|
||||||
GBool interpolate,
|
bool interpolate,
|
||||||
Stream *maskStr,
|
Stream *maskStr,
|
||||||
int maskWidth, int maskHeight,
|
int maskWidth, int maskHeight,
|
||||||
GfxImageColorMap *maskColorMap,
|
GfxImageColorMap *maskColorMap,
|
||||||
GBool maskInterpolate)
|
bool maskInterpolate)
|
||||||
{
|
{
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
@ -3540,10 +3533,10 @@ void CairoImageOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stre
|
|||||||
void CairoImageOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
|
void CairoImageOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
GfxImageColorMap *colorMap,
|
GfxImageColorMap *colorMap,
|
||||||
GBool interpolate,
|
bool interpolate,
|
||||||
Stream *maskStr,
|
Stream *maskStr,
|
||||||
int maskWidth, int maskHeight,
|
int maskWidth, int maskHeight,
|
||||||
GBool maskInvert, GBool maskInterpolate)
|
bool maskInvert, bool maskInterpolate)
|
||||||
{
|
{
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
|
193
3rdparty/poppler/git/CairoOutputDev.h
vendored
193
3rdparty/poppler/git/CairoOutputDev.h
vendored
@ -34,11 +34,6 @@
|
|||||||
#ifndef CAIROOUTPUTDEV_H
|
#ifndef CAIROOUTPUTDEV_H
|
||||||
#define CAIROOUTPUTDEV_H
|
#define CAIROOUTPUTDEV_H
|
||||||
|
|
||||||
#ifdef USE_GCC_PRAGMAS
|
|
||||||
#pragma interface
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "goo/gtypes.h"
|
|
||||||
#include <cairo-ft.h>
|
#include <cairo-ft.h>
|
||||||
#include "OutputDev.h"
|
#include "OutputDev.h"
|
||||||
#include "TextOutputDev.h"
|
#include "TextOutputDev.h"
|
||||||
@ -102,35 +97,35 @@ public:
|
|||||||
|
|
||||||
// Does this device use upside-down coordinates?
|
// Does this device use upside-down coordinates?
|
||||||
// (Upside-down means (0,0) is the top left corner of the page.)
|
// (Upside-down means (0,0) is the top left corner of the page.)
|
||||||
GBool upsideDown() override { return gTrue; }
|
bool upsideDown() override { return true; }
|
||||||
|
|
||||||
// Does this device use drawChar() or drawString()?
|
// Does this device use drawChar() or drawString()?
|
||||||
GBool useDrawChar() override { return gTrue; }
|
bool useDrawChar() override { return true; }
|
||||||
|
|
||||||
// Does this device use tilingPatternFill()? If this returns false,
|
// Does this device use tilingPatternFill()? If this returns false,
|
||||||
// tiling pattern fills will be reduced to a series of other drawing
|
// tiling pattern fills will be reduced to a series of other drawing
|
||||||
// operations.
|
// operations.
|
||||||
GBool useTilingPatternFill() override { return gTrue; }
|
bool useTilingPatternFill() override { return true; }
|
||||||
|
|
||||||
// Does this device use functionShadedFill(), axialShadedFill(), and
|
// Does this device use functionShadedFill(), axialShadedFill(), and
|
||||||
// radialShadedFill()? If this returns false, these shaded fills
|
// radialShadedFill()? If this returns false, these shaded fills
|
||||||
// will be reduced to a series of other drawing operations.
|
// will be reduced to a series of other drawing operations.
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
|
||||||
GBool useShadedFills(int type) override { return type <= 7; }
|
bool useShadedFills(int type) override { return type <= 7; }
|
||||||
#else
|
#else
|
||||||
GBool useShadedFills(int type) override { return type > 1 && type < 4; }
|
bool useShadedFills(int type) override { return type > 1 && type < 4; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Does this device use FillColorStop()?
|
// Does this device use FillColorStop()?
|
||||||
GBool useFillColorStop() override { return gTrue; }
|
bool useFillColorStop() override { return true; }
|
||||||
|
|
||||||
// Does this device use beginType3Char/endType3Char? Otherwise,
|
// Does this device use beginType3Char/endType3Char? Otherwise,
|
||||||
// text in Type 3 fonts will be drawn with drawChar/drawString.
|
// text in Type 3 fonts will be drawn with drawChar/drawString.
|
||||||
GBool interpretType3Chars() override { return gFalse; }
|
bool interpretType3Chars() override { return false; }
|
||||||
|
|
||||||
// Does this device need to clip pages to the crop box even when the
|
// Does this device need to clip pages to the crop box even when the
|
||||||
// box is the crop box?
|
// box is the crop box?
|
||||||
GBool needClipToCropBox() override { return gTrue; }
|
bool needClipToCropBox() override { return true; }
|
||||||
|
|
||||||
//----- initialization and control
|
//----- initialization and control
|
||||||
|
|
||||||
@ -146,7 +141,7 @@ public:
|
|||||||
|
|
||||||
//----- update graphics state
|
//----- update graphics state
|
||||||
void updateAll(GfxState *state) override;
|
void updateAll(GfxState *state) override;
|
||||||
void setDefaultCTM(double *ctm) override;
|
void setDefaultCTM(const double *ctm) override;
|
||||||
void updateCTM(GfxState *state, double m11, double m12,
|
void updateCTM(GfxState *state, double m11, double m12,
|
||||||
double m21, double m22, double m31, double m32) override;
|
double m21, double m22, double m31, double m32) override;
|
||||||
void updateLineDash(GfxState *state) override;
|
void updateLineDash(GfxState *state) override;
|
||||||
@ -170,21 +165,21 @@ public:
|
|||||||
void fill(GfxState *state) override;
|
void fill(GfxState *state) override;
|
||||||
void eoFill(GfxState *state) override;
|
void eoFill(GfxState *state) override;
|
||||||
void clipToStrokePath(GfxState *state) override;
|
void clipToStrokePath(GfxState *state) override;
|
||||||
GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str,
|
bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str,
|
||||||
double *pmat, int paintType, int tilingType, Dict *resDict,
|
const double *pmat, int paintType, int tilingType, Dict *resDict,
|
||||||
double *mat, double *bbox,
|
const double *mat, const double *bbox,
|
||||||
int x0, int y0, int x1, int y1,
|
int x0, int y0, int x1, int y1,
|
||||||
double xStep, double yStep) override;
|
double xStep, double yStep) override;
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
|
||||||
GBool functionShadedFill(GfxState *state, GfxFunctionShading *shading) override;
|
bool functionShadedFill(GfxState *state, GfxFunctionShading *shading) override;
|
||||||
#endif
|
#endif
|
||||||
GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override;
|
bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override;
|
||||||
GBool axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading) override;
|
bool axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading) override;
|
||||||
GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) override;
|
bool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) override;
|
||||||
GBool radialShadedSupportExtend(GfxState *state, GfxRadialShading *shading) override;
|
bool radialShadedSupportExtend(GfxState *state, GfxRadialShading *shading) override;
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
|
||||||
GBool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) override;
|
bool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) override;
|
||||||
GBool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) override;
|
bool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----- path clipping
|
//----- path clipping
|
||||||
@ -201,7 +196,7 @@ public:
|
|||||||
void beginActualText(GfxState *state, const GooString *text) override;
|
void beginActualText(GfxState *state, const GooString *text) override;
|
||||||
void endActualText(GfxState *state) override;
|
void endActualText(GfxState *state) override;
|
||||||
|
|
||||||
GBool beginType3Char(GfxState *state, double x, double y,
|
bool beginType3Char(GfxState *state, double x, double y,
|
||||||
double dx, double dy,
|
double dx, double dy,
|
||||||
CharCode code, Unicode *u, int uLen) override;
|
CharCode code, Unicode *u, int uLen) override;
|
||||||
void endType3Char(GfxState *state) override;
|
void endType3Char(GfxState *state) override;
|
||||||
@ -210,49 +205,49 @@ public:
|
|||||||
|
|
||||||
//----- image drawing
|
//----- image drawing
|
||||||
void drawImageMask(GfxState *state, Object *ref, Stream *str,
|
void drawImageMask(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GBool invert, GBool interpolate,
|
int width, int height, bool invert, bool interpolate,
|
||||||
GBool inlineImg) override;
|
bool inlineImg) override;
|
||||||
void setSoftMaskFromImageMask(GfxState *state,
|
void setSoftMaskFromImageMask(GfxState *state,
|
||||||
Object *ref, Stream *str,
|
Object *ref, Stream *str,
|
||||||
int width, int height, GBool invert,
|
int width, int height, bool invert,
|
||||||
GBool inlineImg, double *baseMatrix) override;
|
bool inlineImg, double *baseMatrix) override;
|
||||||
void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override;
|
void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override;
|
||||||
void drawImageMaskPrescaled(GfxState *state, Object *ref, Stream *str,
|
void drawImageMaskPrescaled(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GBool invert, GBool interpolate,
|
int width, int height, bool invert, bool interpolate,
|
||||||
GBool inlineImg);
|
bool inlineImg);
|
||||||
void drawImageMaskRegular(GfxState *state, Object *ref, Stream *str,
|
void drawImageMaskRegular(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GBool invert, GBool interpolate,
|
int width, int height, bool invert, bool interpolate,
|
||||||
GBool inlineImg);
|
bool inlineImg);
|
||||||
|
|
||||||
void drawImage(GfxState *state, Object *ref, Stream *str,
|
void drawImage(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GfxImageColorMap *colorMap,
|
int width, int height, GfxImageColorMap *colorMap,
|
||||||
GBool interpolate, int *maskColors, GBool inlineImg) override;
|
bool interpolate, int *maskColors, bool inlineImg) override;
|
||||||
void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
|
void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
GfxImageColorMap *colorMap,
|
GfxImageColorMap *colorMap,
|
||||||
GBool interpolate,
|
bool interpolate,
|
||||||
Stream *maskStr,
|
Stream *maskStr,
|
||||||
int maskWidth, int maskHeight,
|
int maskWidth, int maskHeight,
|
||||||
GfxImageColorMap *maskColorMap,
|
GfxImageColorMap *maskColorMap,
|
||||||
GBool maskInterpolate) override;
|
bool maskInterpolate) override;
|
||||||
|
|
||||||
void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
|
void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
GfxImageColorMap *colorMap,
|
GfxImageColorMap *colorMap,
|
||||||
GBool interpolate,
|
bool interpolate,
|
||||||
Stream *maskStr,
|
Stream *maskStr,
|
||||||
int maskWidth, int maskHeight,
|
int maskWidth, int maskHeight,
|
||||||
GBool maskInvert, GBool maskInterpolate) override;
|
bool maskInvert, bool maskInterpolate) override;
|
||||||
|
|
||||||
//----- transparency groups and soft masks
|
//----- transparency groups and soft masks
|
||||||
void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/,
|
void beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/,
|
||||||
GfxColorSpace * /*blendingColorSpace*/,
|
GfxColorSpace * /*blendingColorSpace*/,
|
||||||
GBool /*isolated*/, GBool /*knockout*/,
|
bool /*isolated*/, bool /*knockout*/,
|
||||||
GBool /*forSoftMask*/) override;
|
bool /*forSoftMask*/) override;
|
||||||
void endTransparencyGroup(GfxState * /*state*/) override;
|
void endTransparencyGroup(GfxState * /*state*/) override;
|
||||||
void popTransparencyGroup();
|
void popTransparencyGroup();
|
||||||
void paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) override;
|
void paintTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/) override;
|
||||||
void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/,
|
void setSoftMask(GfxState * /*state*/, const double * /*bbox*/, bool /*alpha*/,
|
||||||
Function * /*transferFunc*/, GfxColor * /*backdropColor*/) override;
|
Function * /*transferFunc*/, GfxColor * /*backdropColor*/) override;
|
||||||
void clearSoftMask(GfxState * /*state*/) override;
|
void clearSoftMask(GfxState * /*state*/) override;
|
||||||
|
|
||||||
@ -264,18 +259,18 @@ public:
|
|||||||
//----- special access
|
//----- special access
|
||||||
|
|
||||||
// Called to indicate that a new PDF document has been loaded.
|
// Called to indicate that a new PDF document has been loaded.
|
||||||
void startDoc(PDFDoc *docA, CairoFontEngine *fontEngine = NULL);
|
void startDoc(PDFDoc *docA, CairoFontEngine *fontEngine = nullptr);
|
||||||
|
|
||||||
GBool isReverseVideo() { return gFalse; }
|
bool isReverseVideo() { return false; }
|
||||||
|
|
||||||
void setCairo (cairo_t *cr);
|
void setCairo (cairo_t *cr);
|
||||||
void setTextPage (TextPage *text);
|
void setTextPage (TextPage *text);
|
||||||
void setPrinting (GBool printingA) { printing = printingA; needFontUpdate = gTrue; }
|
void setPrinting (bool printingA) { printing = printingA; needFontUpdate = true; }
|
||||||
void setAntialias(cairo_antialias_t antialias);
|
void setAntialias(cairo_antialias_t antialias);
|
||||||
|
|
||||||
void setInType3Char(GBool inType3CharA) { inType3Char = inType3CharA; }
|
void setInType3Char(bool inType3CharA) { inType3Char = inType3CharA; }
|
||||||
void getType3GlyphWidth (double *wx, double *wy) { *wx = t3_glyph_wx; *wy = t3_glyph_wy; }
|
void getType3GlyphWidth (double *wx, double *wy) { *wx = t3_glyph_wx; *wy = t3_glyph_wy; }
|
||||||
GBool hasType3GlyphBBox () { return t3_glyph_has_bbox; }
|
bool hasType3GlyphBBox () { return t3_glyph_has_bbox; }
|
||||||
double *getType3GlyphBBox () { return t3_glyph_bbox; }
|
double *getType3GlyphBBox () { return t3_glyph_bbox; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -285,17 +280,17 @@ protected:
|
|||||||
int orig_width, int orig_height,
|
int orig_width, int orig_height,
|
||||||
int *scaledWidth, int *scaledHeight);
|
int *scaledWidth, int *scaledHeight);
|
||||||
cairo_filter_t getFilterForSurface(cairo_surface_t *image,
|
cairo_filter_t getFilterForSurface(cairo_surface_t *image,
|
||||||
GBool interpolate);
|
bool interpolate);
|
||||||
GBool getStreamData (Stream *str, char **buffer, int *length);
|
bool getStreamData (Stream *str, char **buffer, int *length);
|
||||||
void setMimeData(GfxState *state, Stream *str, Object *ref,
|
void setMimeData(GfxState *state, Stream *str, Object *ref,
|
||||||
GfxImageColorMap *colorMap, cairo_surface_t *image, int height);
|
GfxImageColorMap *colorMap, cairo_surface_t *image, int height);
|
||||||
void fillToStrokePathClip(GfxState *state);
|
void fillToStrokePathClip(GfxState *state);
|
||||||
void alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y);
|
void alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y);
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
||||||
GBool setMimeDataForJBIG2Globals (Stream *str, cairo_surface_t *image);
|
bool setMimeDataForJBIG2Globals (Stream *str, cairo_surface_t *image);
|
||||||
#endif
|
#endif
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
|
||||||
GBool setMimeDataForCCITTParams(Stream *str, cairo_surface_t *image, int height);
|
bool setMimeDataForCCITTParams(Stream *str, cairo_surface_t *image, int height);
|
||||||
#endif
|
#endif
|
||||||
static void setContextAntialias(cairo_t *cr, cairo_antialias_t antialias);
|
static void setContextAntialias(cairo_t *cr, cairo_antialias_t antialias);
|
||||||
|
|
||||||
@ -303,9 +298,9 @@ protected:
|
|||||||
cairo_pattern_t *fill_pattern, *stroke_pattern;
|
cairo_pattern_t *fill_pattern, *stroke_pattern;
|
||||||
double fill_opacity;
|
double fill_opacity;
|
||||||
double stroke_opacity;
|
double stroke_opacity;
|
||||||
GBool stroke_adjust;
|
bool stroke_adjust;
|
||||||
GBool adjusted_stroke_width;
|
bool adjusted_stroke_width;
|
||||||
GBool align_stroke_coords;
|
bool align_stroke_coords;
|
||||||
CairoFont *currentFont;
|
CairoFont *currentFont;
|
||||||
XRef *xref;
|
XRef *xref;
|
||||||
|
|
||||||
@ -325,17 +320,17 @@ protected:
|
|||||||
PDFDoc *doc; // the current document
|
PDFDoc *doc; // the current document
|
||||||
|
|
||||||
static FT_Library ft_lib;
|
static FT_Library ft_lib;
|
||||||
static GBool ft_lib_initialized;
|
static bool ft_lib_initialized;
|
||||||
|
|
||||||
CairoFontEngine *fontEngine;
|
CairoFontEngine *fontEngine;
|
||||||
GBool fontEngine_owner;
|
bool fontEngine_owner;
|
||||||
|
|
||||||
cairo_t *cairo;
|
cairo_t *cairo;
|
||||||
cairo_matrix_t orig_matrix;
|
cairo_matrix_t orig_matrix;
|
||||||
GBool needFontUpdate; // set when the font needs to be updated
|
bool needFontUpdate; // set when the font needs to be updated
|
||||||
GBool printing;
|
bool printing;
|
||||||
GBool use_show_text_glyphs;
|
bool use_show_text_glyphs;
|
||||||
GBool text_matrix_valid;
|
bool text_matrix_valid;
|
||||||
cairo_glyph_t *glyphs;
|
cairo_glyph_t *glyphs;
|
||||||
int glyphCount;
|
int glyphCount;
|
||||||
cairo_text_cluster_t *clusters;
|
cairo_text_cluster_t *clusters;
|
||||||
@ -344,13 +339,13 @@ protected:
|
|||||||
int utf8Count;
|
int utf8Count;
|
||||||
int utf8Max;
|
int utf8Max;
|
||||||
cairo_path_t *textClipPath;
|
cairo_path_t *textClipPath;
|
||||||
GBool inUncoloredPattern; // inside a uncolored pattern (PaintType = 2)
|
bool inUncoloredPattern; // inside a uncolored pattern (PaintType = 2)
|
||||||
GBool inType3Char; // inside a Type 3 CharProc
|
bool inType3Char; // inside a Type 3 CharProc
|
||||||
double t3_glyph_wx, t3_glyph_wy;
|
double t3_glyph_wx, t3_glyph_wy;
|
||||||
GBool t3_glyph_has_bbox;
|
bool t3_glyph_has_bbox;
|
||||||
double t3_glyph_bbox[4];
|
double t3_glyph_bbox[4];
|
||||||
cairo_antialias_t antialias;
|
cairo_antialias_t antialias;
|
||||||
GBool prescaleImages;
|
bool prescaleImages;
|
||||||
|
|
||||||
TextPage *text; // text for the current page
|
TextPage *text; // text for the current page
|
||||||
ActualText *actualText;
|
ActualText *actualText;
|
||||||
@ -362,7 +357,7 @@ protected:
|
|||||||
cairo_t *cairo_shape;
|
cairo_t *cairo_shape;
|
||||||
int knockoutCount;
|
int knockoutCount;
|
||||||
struct ColorSpaceStack {
|
struct ColorSpaceStack {
|
||||||
GBool knockout;
|
bool knockout;
|
||||||
GfxColorSpace *cs;
|
GfxColorSpace *cs;
|
||||||
cairo_matrix_t group_matrix;
|
cairo_matrix_t group_matrix;
|
||||||
struct ColorSpaceStack *next;
|
struct ColorSpaceStack *next;
|
||||||
@ -394,34 +389,34 @@ public:
|
|||||||
|
|
||||||
// Does this device use upside-down coordinates?
|
// Does this device use upside-down coordinates?
|
||||||
// (Upside-down means (0,0) is the top left corner of the page.)
|
// (Upside-down means (0,0) is the top left corner of the page.)
|
||||||
GBool upsideDown() override { return gTrue; }
|
bool upsideDown() override { return true; }
|
||||||
|
|
||||||
// Does this device use drawChar() or drawString()?
|
// Does this device use drawChar() or drawString()?
|
||||||
GBool useDrawChar() override { return gFalse; }
|
bool useDrawChar() override { return false; }
|
||||||
|
|
||||||
// Does this device use tilingPatternFill()? If this returns false,
|
// Does this device use tilingPatternFill()? If this returns false,
|
||||||
// tiling pattern fills will be reduced to a series of other drawing
|
// tiling pattern fills will be reduced to a series of other drawing
|
||||||
// operations.
|
// operations.
|
||||||
GBool useTilingPatternFill() override { return gTrue; }
|
bool useTilingPatternFill() override { return true; }
|
||||||
|
|
||||||
// Does this device use functionShadedFill(), axialShadedFill(), and
|
// Does this device use functionShadedFill(), axialShadedFill(), and
|
||||||
// radialShadedFill()? If this returns false, these shaded fills
|
// radialShadedFill()? If this returns false, these shaded fills
|
||||||
// will be reduced to a series of other drawing operations.
|
// will be reduced to a series of other drawing operations.
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)
|
||||||
GBool useShadedFills(int type) override { return type <= 7; }
|
bool useShadedFills(int type) override { return type <= 7; }
|
||||||
#else
|
#else
|
||||||
GBool useShadedFills(int type) override { return type < 4; }
|
bool useShadedFills(int type) override { return type < 4; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Does this device use FillColorStop()?
|
// Does this device use FillColorStop()?
|
||||||
GBool useFillColorStop() override { return gFalse; }
|
bool useFillColorStop() override { return false; }
|
||||||
|
|
||||||
// Does this device use beginType3Char/endType3Char? Otherwise,
|
// Does this device use beginType3Char/endType3Char? Otherwise,
|
||||||
// text in Type 3 fonts will be drawn with drawChar/drawString.
|
// text in Type 3 fonts will be drawn with drawChar/drawString.
|
||||||
GBool interpretType3Chars() override { return gFalse; }
|
bool interpretType3Chars() override { return false; }
|
||||||
|
|
||||||
// Does this device need non-text content?
|
// Does this device need non-text content?
|
||||||
GBool needNonText() override { return gTrue; }
|
bool needNonText() override { return true; }
|
||||||
|
|
||||||
//----- save/restore graphics state
|
//----- save/restore graphics state
|
||||||
void saveState(GfxState *state) override { }
|
void saveState(GfxState *state) override { }
|
||||||
@ -429,7 +424,7 @@ public:
|
|||||||
|
|
||||||
//----- update graphics state
|
//----- update graphics state
|
||||||
void updateAll(GfxState *state) override { }
|
void updateAll(GfxState *state) override { }
|
||||||
void setDefaultCTM(double *ctm) override { }
|
void setDefaultCTM(const double *ctm) override { }
|
||||||
void updateCTM(GfxState *state, double m11, double m12,
|
void updateCTM(GfxState *state, double m11, double m12,
|
||||||
double m21, double m22, double m31, double m32) override { }
|
double m21, double m22, double m31, double m32) override { }
|
||||||
void updateLineDash(GfxState *state) override { }
|
void updateLineDash(GfxState *state) override { }
|
||||||
@ -452,17 +447,17 @@ public:
|
|||||||
void fill(GfxState *state) override { }
|
void fill(GfxState *state) override { }
|
||||||
void eoFill(GfxState *state) override { }
|
void eoFill(GfxState *state) override { }
|
||||||
void clipToStrokePath(GfxState *state) override { }
|
void clipToStrokePath(GfxState *state) override { }
|
||||||
GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str,
|
bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str,
|
||||||
double *pmat, int paintType, int tilingType, Dict *resDict,
|
const double *pmat, int paintType, int tilingType, Dict *resDict,
|
||||||
double *mat, double *bbox,
|
const double *mat, const double *bbox,
|
||||||
int x0, int y0, int x1, int y1,
|
int x0, int y0, int x1, int y1,
|
||||||
double xStep, double yStep) override { return gTrue; }
|
double xStep, double yStep) override { return true; }
|
||||||
GBool axialShadedFill(GfxState *state,
|
bool axialShadedFill(GfxState *state,
|
||||||
GfxAxialShading *shading,
|
GfxAxialShading *shading,
|
||||||
double tMin, double tMax) override { return gTrue; }
|
double tMin, double tMax) override { return true; }
|
||||||
GBool radialShadedFill(GfxState *state,
|
bool radialShadedFill(GfxState *state,
|
||||||
GfxRadialShading *shading,
|
GfxRadialShading *shading,
|
||||||
double sMin, double sMax) override { return gTrue; }
|
double sMin, double sMax) override { return true; }
|
||||||
|
|
||||||
//----- path clipping
|
//----- path clipping
|
||||||
void clip(GfxState *state) override { }
|
void clip(GfxState *state) override { }
|
||||||
@ -470,46 +465,46 @@ public:
|
|||||||
|
|
||||||
//----- image drawing
|
//----- image drawing
|
||||||
void drawImageMask(GfxState *state, Object *ref, Stream *str,
|
void drawImageMask(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GBool invert,
|
int width, int height, bool invert,
|
||||||
GBool interpolate, GBool inlineImg) override;
|
bool interpolate, bool inlineImg) override;
|
||||||
void drawImage(GfxState *state, Object *ref, Stream *str,
|
void drawImage(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GfxImageColorMap *colorMap,
|
int width, int height, GfxImageColorMap *colorMap,
|
||||||
GBool interpolate, int *maskColors, GBool inlineImg) override;
|
bool interpolate, int *maskColors, bool inlineImg) override;
|
||||||
void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
|
void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
GfxImageColorMap *colorMap,
|
GfxImageColorMap *colorMap,
|
||||||
GBool interpolate,
|
bool interpolate,
|
||||||
Stream *maskStr,
|
Stream *maskStr,
|
||||||
int maskWidth, int maskHeight,
|
int maskWidth, int maskHeight,
|
||||||
GfxImageColorMap *maskColorMap,
|
GfxImageColorMap *maskColorMap,
|
||||||
GBool maskInterpolate) override;
|
bool maskInterpolate) override;
|
||||||
void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
|
void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
GfxImageColorMap *colorMap,
|
GfxImageColorMap *colorMap,
|
||||||
GBool interpolate,
|
bool interpolate,
|
||||||
Stream *maskStr,
|
Stream *maskStr,
|
||||||
int maskWidth, int maskHeight,
|
int maskWidth, int maskHeight,
|
||||||
GBool maskInvert, GBool maskInterpolate) override;
|
bool maskInvert, bool maskInterpolate) override;
|
||||||
void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str,
|
void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str,
|
||||||
int width, int height, GBool invert,
|
int width, int height, bool invert,
|
||||||
GBool inlineImg, double *baseMatrix) override;
|
bool inlineImg, double *baseMatrix) override;
|
||||||
void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override {}
|
void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override {}
|
||||||
|
|
||||||
|
|
||||||
//----- transparency groups and soft masks
|
//----- transparency groups and soft masks
|
||||||
void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/,
|
void beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/,
|
||||||
GfxColorSpace * /*blendingColorSpace*/,
|
GfxColorSpace * /*blendingColorSpace*/,
|
||||||
GBool /*isolated*/, GBool /*knockout*/,
|
bool /*isolated*/, bool /*knockout*/,
|
||||||
GBool /*forSoftMask*/) override {}
|
bool /*forSoftMask*/) override {}
|
||||||
void endTransparencyGroup(GfxState * /*state*/) override {}
|
void endTransparencyGroup(GfxState * /*state*/) override {}
|
||||||
void paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) override {}
|
void paintTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/) override {}
|
||||||
void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/,
|
void setSoftMask(GfxState * /*state*/, const double * /*bbox*/, bool /*alpha*/,
|
||||||
Function * /*transferFunc*/, GfxColor * /*backdropColor*/) override {}
|
Function * /*transferFunc*/, GfxColor * /*backdropColor*/) override {}
|
||||||
void clearSoftMask(GfxState * /*state*/) override {}
|
void clearSoftMask(GfxState * /*state*/) override {}
|
||||||
|
|
||||||
//----- Image list
|
//----- Image list
|
||||||
// By default images are not rendred
|
// By default images are not rendred
|
||||||
void setImageDrawDecideCbk(GBool (*cbk)(int img_id, void *data),
|
void setImageDrawDecideCbk(bool (*cbk)(int img_id, void *data),
|
||||||
void *data) { imgDrawCbk = cbk; imgDrawCbkData = data; }
|
void *data) { imgDrawCbk = cbk; imgDrawCbkData = data; }
|
||||||
// Iterate through list of images.
|
// Iterate through list of images.
|
||||||
int getNumImages() const { return numImages; }
|
int getNumImages() const { return numImages; }
|
||||||
@ -523,7 +518,7 @@ private:
|
|||||||
CairoImage **images;
|
CairoImage **images;
|
||||||
int numImages;
|
int numImages;
|
||||||
int size;
|
int size;
|
||||||
GBool (*imgDrawCbk)(int img_id, void *data);
|
bool (*imgDrawCbk)(int img_id, void *data);
|
||||||
void *imgDrawCbkData;
|
void *imgDrawCbkData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
20
3rdparty/poppler/git/CairoRescaleBox.cc
vendored
20
3rdparty/poppler/git/CairoRescaleBox.cc
vendored
@ -32,6 +32,8 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) 2012 Hib Eris <hib@hiberis.nl>
|
// Copyright (C) 2012 Hib Eris <hib@hiberis.nl>
|
||||||
// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com>
|
// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com>
|
||||||
|
// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
|
||||||
|
// Copyright (C) 2019 Albert Astals Cid <aacid@kde.org>
|
||||||
//
|
//
|
||||||
// To see a description of the changes please see the Changelog file that
|
// To see a description of the changes please see the Changelog file that
|
||||||
// came with your tarball or type make ChangeLog if you are building from git
|
// came with your tarball or type make ChangeLog if you are building from git
|
||||||
@ -76,7 +78,7 @@ static void downsample_row_box_filter (
|
|||||||
box size is constant
|
box size is constant
|
||||||
|
|
||||||
|
|
||||||
value = a * contribtion_a * 1/box_size + b * contribution_b * 1/box_size
|
value = a * contribution_a * 1/box_size + b * contribution_b * 1/box_size
|
||||||
contribution_b = (1 - contribution_a)
|
contribution_b = (1 - contribution_a)
|
||||||
= (1 - contribution_a_next)
|
= (1 - contribution_a_next)
|
||||||
*/
|
*/
|
||||||
@ -253,7 +255,7 @@ static int compute_coverage (int coverage[], int src_length, int dest_length)
|
|||||||
/* compute how much the right-most pixel contributes */
|
/* compute how much the right-most pixel contributes */
|
||||||
overage = ratio*(right_fract);
|
overage = ratio*(right_fract);
|
||||||
|
|
||||||
/* the remainder is the the amount that the left-most pixel
|
/* the remainder is the amount that the left-most pixel
|
||||||
* contributes */
|
* contributes */
|
||||||
coverage[i] = (1<<24) - (count * ratio + overage);
|
coverage[i] = (1<<24) - (count * ratio + overage);
|
||||||
}
|
}
|
||||||
@ -262,7 +264,7 @@ static int compute_coverage (int coverage[], int src_length, int dest_length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GBool CairoRescaleBox::downScaleImage(unsigned orig_width, unsigned orig_height,
|
bool CairoRescaleBox::downScaleImage(unsigned orig_width, unsigned orig_height,
|
||||||
signed scaled_width, signed scaled_height,
|
signed scaled_width, signed scaled_height,
|
||||||
unsigned short int start_column, unsigned short int start_row,
|
unsigned short int start_column, unsigned short int start_row,
|
||||||
unsigned short int width, unsigned short int height,
|
unsigned short int width, unsigned short int height,
|
||||||
@ -274,17 +276,17 @@ GBool CairoRescaleBox::downScaleImage(unsigned orig_width, unsigned orig_height,
|
|||||||
int *x_coverage = nullptr;
|
int *x_coverage = nullptr;
|
||||||
int *y_coverage = nullptr;
|
int *y_coverage = nullptr;
|
||||||
uint32_t *temp_buf = nullptr;
|
uint32_t *temp_buf = nullptr;
|
||||||
GBool retval = gFalse;
|
bool retval = false;
|
||||||
unsigned int *dest;
|
unsigned int *dest;
|
||||||
int dst_stride;
|
int dst_stride;
|
||||||
|
|
||||||
dest = (unsigned int *)cairo_image_surface_get_data (dest_surface);
|
dest = reinterpret_cast<unsigned int *>(cairo_image_surface_get_data (dest_surface));
|
||||||
dst_stride = cairo_image_surface_get_stride (dest_surface);
|
dst_stride = cairo_image_surface_get_stride (dest_surface);
|
||||||
|
|
||||||
scanline = (uint32_t*)gmallocn3 (orig_width, 1, sizeof(int));
|
scanline = (uint32_t*)gmallocn (orig_width, sizeof(int));
|
||||||
|
|
||||||
x_coverage = (int *)gmallocn3 (orig_width, 1, sizeof(int));
|
x_coverage = (int *)gmallocn (orig_width, sizeof(int));
|
||||||
y_coverage = (int *)gmallocn3 (orig_height, 1, sizeof(int));
|
y_coverage = (int *)gmallocn (orig_height, sizeof(int));
|
||||||
|
|
||||||
/* we need to allocate enough room for ceil(src_height/dest_height)+1
|
/* we need to allocate enough room for ceil(src_height/dest_height)+1
|
||||||
Example:
|
Example:
|
||||||
@ -364,7 +366,7 @@ GBool CairoRescaleBox::downScaleImage(unsigned orig_width, unsigned orig_height,
|
|||||||
}
|
}
|
||||||
// assert (src_y<=orig_height);
|
// assert (src_y<=orig_height);
|
||||||
|
|
||||||
retval = gTrue;
|
retval = true;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
free (x_coverage);
|
free (x_coverage);
|
||||||
|
3
3rdparty/poppler/git/CairoRescaleBox.h
vendored
3
3rdparty/poppler/git/CairoRescaleBox.h
vendored
@ -40,7 +40,6 @@
|
|||||||
#ifndef CAIRO_RESCALE_BOX_H
|
#ifndef CAIRO_RESCALE_BOX_H
|
||||||
#define CAIRO_RESCALE_BOX_H
|
#define CAIRO_RESCALE_BOX_H
|
||||||
|
|
||||||
#include "goo/gtypes.h"
|
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
|
||||||
class CairoRescaleBox {
|
class CairoRescaleBox {
|
||||||
@ -52,7 +51,7 @@ public:
|
|||||||
CairoRescaleBox(const CairoRescaleBox &) = delete;
|
CairoRescaleBox(const CairoRescaleBox &) = delete;
|
||||||
CairoRescaleBox& operator=(const CairoRescaleBox &) = delete;
|
CairoRescaleBox& operator=(const CairoRescaleBox &) = delete;
|
||||||
|
|
||||||
virtual GBool downScaleImage(unsigned orig_width, unsigned orig_height,
|
virtual bool downScaleImage(unsigned orig_width, unsigned orig_height,
|
||||||
signed scaled_width, signed scaled_height,
|
signed scaled_width, signed scaled_height,
|
||||||
unsigned short int start_column, unsigned short int start_row,
|
unsigned short int start_column, unsigned short int start_row,
|
||||||
unsigned short int width, unsigned short int height,
|
unsigned short int width, unsigned short int height,
|
||||||
|
Loading…
Reference in New Issue
Block a user