[poppler] poppler/poppler: CairoOutputDev.cc, 1.48, 1.49 CairoOutputDev.h, 1.17, 1.18
Albert Astals Cid
aacid at kemper.freedesktop.org
Mon May 21 14:35:12 PDT 2007
- Previous message: [poppler] poppler/glib: poppler-page.cc, 1.57, 1.58 poppler-page.h, 1.24, 1.25 poppler-private.h, 1.17, 1.18 poppler.h, 1.14, 1.15 test-poppler-glib.c, 1.20, 1.21
- Next message: [poppler] poppler: ChangeLog,1.517,1.518
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/poppler/poppler/poppler
In directory kemper:/tmp/cvs-serv6259/poppler
Modified Files:
CairoOutputDev.cc CairoOutputDev.h
Log Message:
* glib/poppler-page.cc:
* glib/poppler-page.h:
* glib/poppler-private.h:
* glib/poppler.h:
* glib/test-poppler-glib.c:
* poppler/CairoOutputDev.cc:
* poppler/CairoOutputDev.h: Extend CairoOutputdev to do
image caching when rendering
Index: CairoOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.cc,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- CairoOutputDev.cc 21 Dec 2006 01:01:30 -0000 1.48
+++ CairoOutputDev.cc 21 May 2007 21:35:10 -0000 1.49
@@ -41,6 +41,23 @@
#define LOG(x)
#endif
+//------------------------------------------------------------------------
+// CairoImage
+//------------------------------------------------------------------------
+
+CairoImage::CairoImage (cairo_surface_t *image,
+ double x1, double y1, double x2, double y2) {
+ this->image = cairo_surface_reference (image);
+ this->x1 = x1;
+ this->y1 = y1;
+ this->x2 = x2;
+ this->y2 = y2;
+}
+
+CairoImage::~CairoImage () {
+ if (image)
+ cairo_surface_destroy (image);
+}
//------------------------------------------------------------------------
// CairoOutputDev
@@ -871,3 +888,201 @@
free (buffer);
delete imgStr;
}
+
+
+//------------------------------------------------------------------------
+// ImageOutputDev
+//------------------------------------------------------------------------
+
+CairoImageOutputDev::CairoImageOutputDev()
+{
+ images = NULL;
+ numImages = 0;
+ size = 0;
+}
+
+CairoImageOutputDev::~CairoImageOutputDev()
+{
+ int i;
+
+ for (i = 0; i < numImages; i++)
+ delete images[i];
+ gfree (images);
+}
+
+void CairoImageOutputDev::saveImage(CairoImage *image)
+{
+ if (numImages >= size) {
+ size += 16;
+ images = (CairoImage **) greallocn (images, size, sizeof (CairoImage *));
+ }
+ images[numImages++] = image;
+}
+
+void CairoImageOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
+ int width, int height, GBool invert,
+ GBool inlineImg)
+{
+ cairo_t *cr;
+ cairo_surface_t *surface;
+ double x1, y1, x2, y2;
+ double *ctm;
+ double mat[6];
+ CairoImage *image;
+
+ ctm = state->getCTM();
+
+ mat[0] = ctm[0];
+ mat[1] = ctm[1];
+ mat[2] = -ctm[2];
+ mat[3] = -ctm[3];
+ mat[4] = ctm[2] + ctm[4];
+ mat[5] = ctm[3] + ctm[5];
+ x1 = mat[4];
+ y1 = mat[5];
+ x2 = x1 + width;
+ y2 = y1 + height;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+ cr = cairo_create (surface);
+ setCairo (cr);
+ cairo_translate (cr, 0, height);
+ cairo_scale (cr, width, -height);
+
+ CairoOutputDev::drawImageMask(state, ref, str, width, height, invert, inlineImg);
+
+ image = new CairoImage (surface, x1, y1, x2, y2);
+ saveImage (image);
+
+ setCairo (NULL);
+ cairo_surface_destroy (surface);
+ cairo_destroy (cr);
+}
+
+void CairoImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
+ int width, int height, GfxImageColorMap *colorMap,
+ int *maskColors, GBool inlineImg)
+{
+ cairo_t *cr;
+ cairo_surface_t *surface;
+ double x1, y1, x2, y2;
+ double *ctm;
+ double mat[6];
+ CairoImage *image;
+
+ ctm = state->getCTM();
+
+ mat[0] = ctm[0];
+ mat[1] = ctm[1];
+ mat[2] = -ctm[2];
+ mat[3] = -ctm[3];
+ mat[4] = ctm[2] + ctm[4];
+ mat[5] = ctm[3] + ctm[5];
+ x1 = mat[4];
+ y1 = mat[5];
+ x2 = x1 + width;
+ y2 = y1 + height;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+ cr = cairo_create (surface);
+ setCairo (cr);
+ cairo_translate (cr, 0, height);
+ cairo_scale (cr, width, -height);
+
+ CairoOutputDev::drawImage(state, ref, str, width, height, colorMap, maskColors, inlineImg);
+
+ image = new CairoImage (surface, x1, y1, x2, y2);
+ saveImage (image);
+
+ setCairo (NULL);
+ cairo_surface_destroy (surface);
+ cairo_destroy (cr);
+}
+
+void CairoImageOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
+ int width, int height,
+ GfxImageColorMap *colorMap,
+ Stream *maskStr,
+ int maskWidth, int maskHeight,
+ GfxImageColorMap *maskColorMap)
+{
+ cairo_t *cr;
+ cairo_surface_t *surface;
+ double x1, y1, x2, y2;
+ double *ctm;
+ double mat[6];
+ CairoImage *image;
+
+ ctm = state->getCTM();
+
+ mat[0] = ctm[0];
+ mat[1] = ctm[1];
+ mat[2] = -ctm[2];
+ mat[3] = -ctm[3];
+ mat[4] = ctm[2] + ctm[4];
+ mat[5] = ctm[3] + ctm[5];
+ x1 = mat[4];
+ y1 = mat[5];
+ x2 = x1 + width;
+ y2 = y1 + height;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+ cr = cairo_create (surface);
+ setCairo (cr);
+ cairo_translate (cr, 0, height);
+ cairo_scale (cr, width, -height);
+
+ CairoOutputDev::drawSoftMaskedImage(state, ref, str, width, height, colorMap,
+ maskStr, maskWidth, maskHeight, maskColorMap);
+
+ image = new CairoImage (surface, x1, y1, x2, y2);
+ saveImage (image);
+
+ setCairo (NULL);
+ cairo_surface_destroy (surface);
+ cairo_destroy (cr);
+}
+
+void CairoImageOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
+ int width, int height,
+ GfxImageColorMap *colorMap,
+ Stream *maskStr,
+ int maskWidth, int maskHeight,
+ GBool maskInvert)
+{
+ cairo_t *cr;
+ cairo_surface_t *surface;
+ double x1, y1, x2, y2;
+ double *ctm;
+ double mat[6];
+ CairoImage *image;
+
+ ctm = state->getCTM();
+
+ mat[0] = ctm[0];
+ mat[1] = ctm[1];
+ mat[2] = -ctm[2];
+ mat[3] = -ctm[3];
+ mat[4] = ctm[2] + ctm[4];
+ mat[5] = ctm[3] + ctm[5];
+ x1 = mat[4];
+ y1 = mat[5];
+ x2 = x1 + width;
+ y2 = y1 + height;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+ cr = cairo_create (surface);
+ setCairo (cr);
+ cairo_translate (cr, 0, height);
+ cairo_scale (cr, width, -height);
+
+ CairoOutputDev::drawMaskedImage(state, ref, str, width, height, colorMap,
+ maskStr, maskWidth, maskHeight, maskInvert);
+
+ image = new CairoImage (surface, x1, y1, x2, y2);
+ saveImage (image);
+
+ setCairo (NULL);
+ cairo_surface_destroy (surface);
+ cairo_destroy (cr);
+}
Index: CairoOutputDev.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- CairoOutputDev.h 31 May 2006 17:31:49 -0000 1.17
+++ CairoOutputDev.h 21 May 2007 21:35:10 -0000 1.18
@@ -29,6 +29,31 @@
//------------------------------------------------------------------------
//------------------------------------------------------------------------
+// CairoImage
+//------------------------------------------------------------------------
+class CairoImage {
+public:
+ // Constructor.
+ CairoImage (cairo_surface_t *image, double x1, double y1, double x2, double y2);
+
+ // Destructor.
+ ~CairoImage ();
+
+ // Get the image cairo surface
+ cairo_surface_t *getImage () const { return image; }
+
+ // Get the image rectangle
+ void getRect (double *xa1, double *ya1, double *xa2, double *ya2)
+ { *xa1 = x1; *ya1 = y1; *xa2 = x2; *ya2 = y2; }
+
+private:
+ cairo_surface_t *image; // image cairo surface
+ double x1, y1; // upper left corner
+ double x2, y2; // lower right corner
+};
+
+
+//------------------------------------------------------------------------
// CairoOutputDev
//------------------------------------------------------------------------
@@ -168,4 +193,101 @@
cairo_path_t *textClipPath;
};
+//------------------------------------------------------------------------
+// CairoImageOutputDev
+//------------------------------------------------------------------------
+
+class CairoImageOutputDev: public CairoOutputDev {
+public:
+
+ // Constructor.
+ CairoImageOutputDev();
+
+ // Destructor.
+ virtual ~CairoImageOutputDev();
+
+ //----- get info about output device
+
+ // Does this device use upside-down coordinates?
+ // (Upside-down means (0,0) is the top left corner of the page.)
+ virtual GBool upsideDown() { return gTrue; }
+
+ // Does this device use drawChar() or drawString()?
+ virtual GBool useDrawChar() { return gFalse; }
+
+ // Does this device use beginType3Char/endType3Char? Otherwise,
+ // text in Type 3 fonts will be drawn with drawChar/drawString.
+ virtual GBool interpretType3Chars() { return gFalse; }
+
+ // Does this device need non-text content?
+ virtual GBool needNonText() { return gTrue; }
+
+ //----- link borders
+ virtual void drawLink(Link *link, Catalog *catalog) { }
+
+ //----- save/restore graphics state
+ virtual void saveState(GfxState *state) { }
+ virtual void restoreState(GfxState *state) { }
+
+ //----- update graphics state
+ virtual void updateAll(GfxState *state) { }
+ virtual void setDefaultCTM(double *ctm) { }
+ virtual void updateCTM(GfxState *state, double m11, double m12,
+ double m21, double m22, double m31, double m32) { }
+ virtual void updateLineDash(GfxState *state) { }
+ virtual void updateFlatness(GfxState *state) { }
+ virtual void updateLineJoin(GfxState *state) { }
+ virtual void updateLineCap(GfxState *state) { }
+ virtual void updateMiterLimit(GfxState *state) { }
+ virtual void updateLineWidth(GfxState *state) { }
+ virtual void updateFillColor(GfxState *state) { }
+ virtual void updateStrokeColor(GfxState *state) { }
+ virtual void updateFillOpacity(GfxState *state) { }
+ virtual void updateStrokeOpacity(GfxState *state) { }
+
+ //----- update text state
+ virtual void updateFont(GfxState *state) { }
+
+ //----- path painting
+ virtual void stroke(GfxState *state) { }
+ virtual void fill(GfxState *state) { }
+ virtual void eoFill(GfxState *state) { }
+
+ //----- path clipping
+ virtual void clip(GfxState *state) { }
+ virtual void eoClip(GfxState *state) { }
+
+ //----- image drawing
+ virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
+ int width, int height, GBool invert,
+ GBool inlineImg);
+ virtual void drawImage(GfxState *state, Object *ref, Stream *str,
+ int width, int height, GfxImageColorMap *colorMap,
+ int *maskColors, GBool inlineImg);
+ virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
+ int width, int height,
+ GfxImageColorMap *colorMap,
+ Stream *maskStr,
+ int maskWidth, int maskHeight,
+ GfxImageColorMap *maskColorMap);
+ virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
+ int width, int height,
+ GfxImageColorMap *colorMap,
+ Stream *maskStr,
+ int maskWidth, int maskHeight,
+ GBool maskInvert);
+
+ //----- Image list
+ // Iterate through list of images.
+ int getNumImages() const { return numImages; }
+ CairoImage *getImage(int i) const { return images[i]; }
+
+private:
+ void saveImage(CairoImage *image);
+
+ CairoImage **images;
+ int numImages;
+ int size;
+};
+
#endif
- Previous message: [poppler] poppler/glib: poppler-page.cc, 1.57, 1.58 poppler-page.h, 1.24, 1.25 poppler-private.h, 1.17, 1.18 poppler.h, 1.14, 1.15 test-poppler-glib.c, 1.20, 1.21
- Next message: [poppler] poppler: ChangeLog,1.517,1.518
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the poppler
mailing list