[cairo-commit] cairo/src cairo-paginated-surface-private.h, 1.1,
1.2 cairo-paginated-surface.c, 1.4, 1.5 cairo-pdf-surface.c,
1.71, 1.72
Carl Worth
commit at pdx.freedesktop.org
Wed Jan 11 11:53:36 PST 2006
Committed by: cworth
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv14638/src
Modified Files:
cairo-paginated-surface-private.h cairo-paginated-surface.c
cairo-pdf-surface.c
Log Message:
2006-01-11 Carl Worth <cworth at cworth.org>
* ROADMAP: Note that from here on out, the PDF output should
always pass the entire test suite!
* src/cairo-paginated-surface-private.h:
* src/cairo-paginated-surface.c: (_cairo_surface_is_paginated),
(_cairo_paginated_surface_get_target): Add new functions needed by
users of cairo_paginated_surface_t.
* src/cairo-paginated-surface.c:
(_cairo_paginated_surface_snapshot): Always snapshot a paginated
surface to an image surface, rather than a surface similar to the
target. We do this since paginated target surfaces are allowed to
not be complete surfaces, (such as not implementing
acquire_source_surface).
* src/cairo-pdf-surface.c:
(_cairo_pdf_surface_create_for_stream_internal),
(_cairo_surface_is_pdf), (cairo_pdf_surface_set_dpi): Switch the
implementation of cairo_pdf_surface_t to use
cairo_paginated_surface_t. For now this means that all PDF output
is fallback images, but this can change incrementally as we go
forward.
Index: cairo-paginated-surface-private.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-paginated-surface-private.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cairo-paginated-surface-private.h 22 Dec 2005 00:46:44 -0000 1.1
+++ cairo-paginated-surface-private.h 11 Jan 2006 19:53:33 -0000 1.2
@@ -43,4 +43,10 @@
int width,
int height);
+cairo_private cairo_surface_t *
+_cairo_paginated_surface_get_target (cairo_surface_t *surface);
+
+cairo_bool_t
+_cairo_surface_is_paginated (cairo_surface_t *surface);
+
#endif /* CAIRO_PAGINATED_SURFACE_H */
Index: cairo-paginated-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-paginated-surface.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cairo-paginated-surface.c 6 Jan 2006 22:24:56 -0000 1.4
+++ cairo-paginated-surface.c 11 Jan 2006 19:53:33 -0000 1.5
@@ -126,6 +126,23 @@
return (cairo_surface_t*) &_cairo_surface_nil;
}
+cairo_bool_t
+_cairo_surface_is_paginated (cairo_surface_t *surface)
+{
+ return surface->backend == &cairo_paginated_surface_backend;
+}
+
+cairo_surface_t *
+_cairo_paginated_surface_get_target (cairo_surface_t *surface)
+{
+ assert (_cairo_surface_is_paginated (surface));
+
+ cairo_paginated_surface_t *paginated_surface =
+ (cairo_paginated_surface_t *) surface;
+
+ return paginated_surface->target;
+}
+
static cairo_status_t
_cairo_paginated_surface_finish (void *abstract_surface)
{
@@ -358,10 +375,9 @@
_cairo_surface_get_extents (other->target, &extents);
- surface = cairo_surface_create_similar (other->target,
- CAIRO_CONTENT_COLOR_ALPHA,
- extents.width,
- extents.height);
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ extents.width,
+ extents.height);
_cairo_meta_surface_replay (other->meta, surface);
Index: cairo-pdf-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-pdf-surface.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- cairo-pdf-surface.c 5 Jan 2006 23:00:37 -0000 1.71
+++ cairo-pdf-surface.c 11 Jan 2006 19:53:33 -0000 1.72
@@ -38,6 +38,7 @@
#include "cairo-pdf.h"
#include "cairo-font-subset-private.h"
#include "cairo-ft-private.h"
+#include "cairo-paginated-surface-private.h"
#include <time.h>
#include <zlib.h>
@@ -290,7 +291,7 @@
double height)
{
cairo_pdf_document_t *document;
- cairo_surface_t *surface;
+ cairo_surface_t *target;
document = _cairo_pdf_document_create (stream, width, height);
if (document == NULL) {
@@ -298,12 +299,12 @@
return (cairo_surface_t*) &_cairo_surface_nil;
}
- surface = _cairo_pdf_surface_create_for_document (document, width, height);
+ target = _cairo_pdf_surface_create_for_document (document, width, height);
- document->owner = surface;
+ document->owner = target;
_cairo_pdf_document_destroy (document);
- return surface;
+ return _cairo_paginated_surface_create (target, width, height);
}
cairo_surface_t *
@@ -339,6 +340,12 @@
return _cairo_pdf_surface_create_for_stream_internal (stream, width, height);
}
+static cairo_bool_t
+_cairo_surface_is_pdf (cairo_surface_t *surface)
+{
+ return surface->backend == &cairo_pdf_surface_backend;
+}
+
/**
* cairo__surface_set_dpi:
* @surface: a postscript cairo_surface_t
@@ -354,7 +361,22 @@
double x_dpi,
double y_dpi)
{
- cairo_pdf_surface_t *pdf_surface = (cairo_pdf_surface_t *) surface;
+ cairo_surface_t *target;
+ cairo_pdf_surface_t *pdf_surface;
+
+ if (! _cairo_surface_is_paginated (surface)) {
+ _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ return;
+ }
+
+ target = _cairo_paginated_surface_get_target (surface);
+
+ if (! _cairo_surface_is_pdf (surface)) {
+ _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+ return;
+ }
+
+ pdf_surface = (cairo_pdf_surface_t *) target;
pdf_surface->document->x_dpi = x_dpi;
pdf_surface->document->y_dpi = y_dpi;
More information about the cairo-commit
mailing list