summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2006-06-10 11:20:21 -0700
committerCarl Worth <cworth@cworth.org>2006-06-10 11:20:21 -0700
commit2f4210d346d10a2bff9a1ba74e6e9279cd4dddc3 (patch)
treef877206a49b1959f8ac4a329c18ddbabbd49885d
parentd758d5104a09019b65c1b2e93fd5ab80b0e4d056 (diff)
downloadcairo-2f4210d346d10a2bff9a1ba74e6e9279cd4dddc3.tar.gz
Change _cairo_meta_surface_get_extents to return a bounded size.
The old behavior of returning "infinite" extents is inconsistent with the current usage of meta-surface where it is always created for replay against a particular (sized) target surface and that size is passed to _cairo_meta_surface_create. Also clarify documentation of _cairo_surface_get_extents to eliminate the possibility of inifinite extents.
-rw-r--r--src/cairo-meta-surface.c25
-rw-r--r--src/cairo-surface.c20
2 files changed, 27 insertions, 18 deletions
diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c
index 1ddeed05e..3fe6bc2df 100644
--- a/src/cairo-meta-surface.c
+++ b/src/cairo-meta-surface.c
@@ -59,6 +59,15 @@
static const cairo_surface_backend_t cairo_meta_surface_backend;
+/* Currently all meta surfaces do have a size which should be passed
+ * in as the maximum size of any target surface against which the
+ * meta-surface will ever be replayed.
+ *
+ * XXX: The naming of "pixels" in the size here is a misnomer. It's
+ * actually a size in whatever device-space units are desired (again,
+ * according to the intended replay target). This should likely also
+ * be changed to use doubles not ints.
+ */
cairo_surface_t *
_cairo_meta_surface_create (cairo_content_t content,
int width_pixels,
@@ -537,22 +546,20 @@ _cairo_meta_surface_intersect_clip_path (void *dst,
return CAIRO_STATUS_SUCCESS;
}
-/* A meta-surface is logically unbounded, but when it is used as a
- * source, the drawing code can optimize based on the extents of the
- * surface.
- *
- * XXX: The optimization being attempted here would only actually work
- * if the meta-surface kept track of its extents as commands were
- * added to it.
+/* Currently, we're using as the "size" of a meta surface the largest
+ * surface size against which the meta-surface is expected to be
+ * replayed, (as passed in to _cairo_meta_surface_create).
*/
static cairo_int_status_t
_cairo_meta_surface_get_extents (void *abstract_surface,
cairo_rectangle_int16_t *rectangle)
{
+ cairo_meta_surface_t *surface = abstract_surface;
+
rectangle->x = 0;
rectangle->y = 0;
- rectangle->width = INT16_MAX;
- rectangle->height = INT16_MAX;
+ rectangle->width = surface->width_pixels;
+ rectangle->height = surface->height_pixels;
return CAIRO_STATUS_SUCCESS;
}
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 0b245f887..5c0e69ba2 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1634,15 +1634,17 @@ _cairo_surface_set_clip (cairo_surface_t *surface, cairo_clip_t *clip)
* _cairo_surface_get_extents:
* @surface: the #cairo_surface_t to fetch extents for
*
- * This function returns a bounding box for the surface. The
- * surface bounds are defined as a region beyond which no
- * rendering will possibly be recorded, in otherwords,
- * it is the maximum extent of potentially usable
- * coordinates. For simple pixel-based surfaces,
- * it can be a close bound on the retained pixel
- * region. For virtual surfaces (PDF et al), it
- * cannot and must extend to the reaches of the
- * target system coordinate space.
+ * This function returns a bounding box for the surface. The surface
+ * bounds are defined as a region beyond which no rendering will
+ * possibly be recorded, in otherwords, it is the maximum extent of
+ * potentially usable coordinates.
+ *
+ * For simple pixel-based surfaces, it can be a close bound on the
+ * retained pixel region.
+ *
+ * For vector surfaces, (PDF, PS, SVG and meta-surfaces), the surface
+ * might be conceived as unbounded, but we force the user to provide a
+ * maximum size at the time of surface_create.
*/
cairo_status_t