[cairo-commit] 6 commits - src/cairo-paginated-private.h src/cairo-paginated-surface.c src/cairo-pdf-operators.c src/cairo-pdf-surface.c src/cairo-ps-surface.c
Adrian Johnson
ajohnson at kemper.freedesktop.org
Tue Jul 8 05:15:58 PDT 2008
src/cairo-paginated-private.h | 8 ++++++++
src/cairo-paginated-surface.c | 9 +++++++++
src/cairo-pdf-operators.c | 6 ++++++
src/cairo-pdf-surface.c | 37 ++++++++++++++++++++++++-------------
src/cairo-ps-surface.c | 2 ++
5 files changed, 49 insertions(+), 13 deletions(-)
New commits:
commit 50eb1e71f3199922f50992e53f045614177365f8
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Tue Jul 8 21:36:19 2008 +0930
PS: Ensure the color is re-emitted after resetting the clip path
because the graphics state has been restored.
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index a64ddae..aa93f1e 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -2900,6 +2900,8 @@ _cairo_ps_surface_intersect_clip_path (void *abstract_surface,
return status;
_cairo_output_stream_printf (stream, "Q q\n");
+ surface->current_pattern_is_solid_color = FALSE;
+
return CAIRO_STATUS_SUCCESS;
}
commit b082c15df649467e2bd51535802f27c762eee257
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Tue Jul 8 21:18:45 2008 +0930
PDF: Don't use a Form dictionary for the content stream
because pdfTeX (and maybe other PDF consumers) can not handle it.
Previously the content stream was an Form dictionary because at the
time the content is written it is not known whether the content stream
will be belong to the page or be an XObject in a knockout group. With
the additional of the paginated surface function
set_fallback_images_required() this information is now known at the
time the content is emitted.
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index ab9b24e..ae6236a 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1266,12 +1266,22 @@ _cairo_pdf_surface_finish (void *abstract_surface)
static cairo_int_status_t
_cairo_pdf_surface_start_page (void *abstract_surface)
{
- cairo_status_t status;
cairo_pdf_surface_t *surface = abstract_surface;
- surface->has_fallback_images = FALSE;
_cairo_pdf_group_resources_clear (&surface->resources);
- status = _cairo_pdf_surface_open_content_stream (surface, TRUE);
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_int_status_t
+_cairo_pdf_surface_has_fallback_images (void *abstract_surface,
+ cairo_bool_t has_fallbacks)
+{
+ cairo_status_t status;
+ cairo_pdf_surface_t *surface = abstract_surface;
+
+ surface->has_fallback_images = has_fallbacks;
+ status = _cairo_pdf_surface_open_content_stream (surface, has_fallbacks);
if (status)
return status;
@@ -4309,7 +4319,6 @@ _cairo_pdf_surface_start_fallback (cairo_pdf_surface_t *surface)
if (status)
return status;
- surface->has_fallback_images = TRUE;
_cairo_pdf_group_resources_clear (&surface->resources);
return _cairo_pdf_surface_open_content_stream (surface, TRUE);
}
@@ -4907,5 +4916,7 @@ static const cairo_surface_backend_t cairo_pdf_surface_backend = {
static const cairo_paginated_surface_backend_t cairo_pdf_surface_paginated_backend = {
_cairo_pdf_surface_start_page,
- _cairo_pdf_surface_set_paginated_mode
+ _cairo_pdf_surface_set_paginated_mode,
+ NULL, /* set_bounding_box */
+ _cairo_pdf_surface_has_fallback_images,
};
commit 4fcdc364cd3f9d7d5cd8026adac23a651b608781
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Tue Jul 8 21:12:54 2008 +0930
Add paginated surface backend function _set_fallback_images_required
diff --git a/src/cairo-paginated-private.h b/src/cairo-paginated-private.h
index f2f80db..0c04274 100644
--- a/src/cairo-paginated-private.h
+++ b/src/cairo-paginated-private.h
@@ -67,6 +67,14 @@ struct _cairo_paginated_surface_backend {
cairo_warn cairo_int_status_t
(*set_bounding_box) (void *surface,
cairo_box_t *bbox);
+
+ /* Optional. Indicates whether the page requires fallback images.
+ * Will be called at the end of the ANALYZE phase but before the
+ * mode is changed to RENDER.
+ */
+ cairo_warn cairo_int_status_t
+ (*set_fallback_images_required)(void *surface,
+ cairo_bool_t fallbacks_required);
};
/* A #cairo_paginated_surface_t provides a very convenient wrapper that
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index 9deefc6..248edb4 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -316,6 +316,15 @@ _paint_page (cairo_paginated_surface_t *surface)
goto FAIL;
}
+ if (surface->backend->set_fallback_images_required) {
+ cairo_bool_t has_fallbacks = _cairo_analysis_surface_has_unsupported (analysis);
+
+ status = surface->backend->set_fallback_images_required (surface->target,
+ has_fallbacks);
+ if (status)
+ goto FAIL;
+ }
+
surface->backend->set_paginated_mode (surface->target, CAIRO_PAGINATED_MODE_RENDER);
/* Finer grained fallbacks are currently only supported for some
commit 0c05aa60f5bfa4b6f280aedec684c20aed793a90
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Tue Jul 8 21:12:28 2008 +0930
PDF: Limit precision of Td operands
As the translation is in text space, the full precision of a double
for numbers close to zero is not required. Limit the precision to the
same as for numbers > 1.
diff --git a/src/cairo-pdf-operators.c b/src/cairo-pdf-operators.c
index 4aec095..da01919 100644
--- a/src/cairo-pdf-operators.c
+++ b/src/cairo-pdf-operators.c
@@ -985,6 +985,8 @@ _cairo_pdf_operators_set_text_matrix (cairo_pdf_operators_t *pdf_operators,
return _cairo_output_stream_get_status (pdf_operators->stream);
}
+#define TEXT_MATRIX_TOLERANCE 1e-6
+
/* Set the translation components of the PDF text matrix to x, y. The
* 'Td' operator is used to transform the text matrix.
*/
@@ -1009,6 +1011,10 @@ _cairo_pdf_operators_set_text_position (cairo_pdf_operators_t *pdf_operators,
pdf_operators->text_matrix.x0 = x;
pdf_operators->text_matrix.y0 = y;
cairo_matrix_multiply (&translate, &pdf_operators->text_matrix, &inverse);
+ if (fabs(translate.x0) < TEXT_MATRIX_TOLERANCE)
+ translate.x0 = 0.0;
+ if (fabs(translate.y0) < TEXT_MATRIX_TOLERANCE)
+ translate.y0 = 0.0;
_cairo_output_stream_printf (pdf_operators->stream,
"%f %f Td\n",
translate.x0,
commit d5c7b87ca989d3b4b5faeafc6e579b6c63d1e8dc
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Tue Jul 8 20:57:57 2008 +0930
PDF: Ensure clip is not emitted outside of stream
Sylvain Munaut discovered a bug in
_cairo_pdf_surface_emit_meta_surface() where the clip may be emitted
after the stream is closed. Fix this by moving the call to
_cairo_surface_set_clip() to before the stream is closed.
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 1489887..ab9b24e 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1531,7 +1531,7 @@ _cairo_pdf_surface_emit_meta_surface (cairo_pdf_surface_t *surface,
cairo_paginated_mode_t old_paginated_mode;
cairo_clip_t *old_clip;
cairo_rectangle_int_t meta_extents;
- cairo_status_t status, status2;
+ cairo_status_t status;
int alpha = 0;
status = _cairo_surface_get_extents (meta_surface, &meta_extents);
@@ -1574,15 +1574,16 @@ _cairo_pdf_surface_emit_meta_surface (cairo_pdf_surface_t *surface,
if (status)
return status;
+ status = _cairo_surface_set_clip (&surface->base, old_clip);
+ if (status)
+ return status;
+
status = _cairo_pdf_surface_close_content_stream (surface);
_cairo_pdf_surface_set_size_internal (surface,
old_width,
old_height);
surface->paginated_mode = old_paginated_mode;
- status2 = _cairo_surface_set_clip (&surface->base, old_clip);
- if (status == CAIRO_STATUS_SUCCESS)
- status = status2;
return status;
}
commit 130cd29a700c858ef3c8a839479bd02b70403569
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Tue Jul 8 20:55:38 2008 +0930
PDF: remove meta surface group clean
The group that was being cleaned up was removed in
099810b6c39cc6b5529f740282b64185cf56c8d7
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 3f4c17b..1489887 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -271,7 +271,7 @@ _cairo_pdf_surface_create_for_stream_internal (cairo_output_stream_t *output,
goto BAIL1;
}
- surface->compress_content = TRUE;
+ surface->compress_content = 0;
surface->pdf_stream.active = FALSE;
surface->pdf_stream.old_output = NULL;
surface->group_stream.active = FALSE;
@@ -1559,7 +1559,7 @@ _cairo_pdf_surface_emit_meta_surface (cairo_pdf_surface_t *surface,
if (cairo_surface_get_content (meta_surface) == CAIRO_CONTENT_COLOR) {
status = _cairo_pdf_surface_add_alpha (surface, 1.0, &alpha);
if (status)
- goto CLEANUP_GROUP;
+ return status;
_cairo_output_stream_printf (surface->output,
"q /a%d gs 0 0 0 rg 0 0 %f %f re f Q\n",
@@ -1572,11 +1572,10 @@ _cairo_pdf_surface_emit_meta_surface (cairo_pdf_surface_t *surface,
CAIRO_META_REGION_NATIVE);
assert (status != CAIRO_INT_STATUS_UNSUPPORTED);
if (status)
- goto CLEANUP_GROUP;
+ return status;
status = _cairo_pdf_surface_close_content_stream (surface);
- CLEANUP_GROUP:
_cairo_pdf_surface_set_size_internal (surface,
old_width,
old_height);
More information about the cairo-commit
mailing list