[cairo-commit] 8 commits - src/cairo-clip.c src/cairo-pattern.c src/drm test/clip-empty-save.c test/clip-empty-save.ref.png test/linear-step-function.c test/linear-step-function.xfail.png test/Makefile.am test/Makefile.sources util/cairo-script
Chris Wilson
ickle at kemper.freedesktop.org
Tue Feb 2 08:31:50 PST 2010
src/cairo-clip.c | 7 +--
src/cairo-pattern.c | 6 +--
src/drm/cairo-drm-i915-surface.c | 4 +-
src/drm/cairo-drm.c | 2 -
test/Makefile.am | 2 +
test/Makefile.sources | 2 +
test/clip-empty-save.c | 68 ++++++++++++++++++++++++++++++++++++
test/clip-empty-save.ref.png |binary
test/linear-step-function.c | 60 +++++++++++++++++++++++++++++++
test/linear-step-function.xfail.png |binary
util/cairo-script/csi-replay.c | 32 +++++++++++-----
11 files changed, 161 insertions(+), 22 deletions(-)
New commits:
commit e9b07d194630f3f5e31eef3606f8e4c188a01d5f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Feb 2 16:28:30 2010 +0000
drm/i915: Don't tile page sized bo.
Minor tweak from < to <= so that a page sized bo is also not tiled for
those 32x32 pixmaps...
diff --git a/src/drm/cairo-drm-i915-surface.c b/src/drm/cairo-drm-i915-surface.c
index c921727..7db1222 100644
--- a/src/drm/cairo-drm-i915-surface.c
+++ b/src/drm/cairo-drm-i915-surface.c
@@ -1522,7 +1522,7 @@ i915_surface_create_internal (cairo_drm_device_t *base_dev,
surface->intel.drm.stride = cairo_format_stride_for_width (surface->intel.drm.format,
width);
/* check for tiny surfaces for which tiling is irrelevant */
- if (height * surface->intel.drm.stride < 4096)
+ if (height * surface->intel.drm.stride <= 4096)
tiling = I915_TILING_NONE;
surface->intel.drm.stride = i915_tiling_stride (tiling,
commit 70ca9dd170ce1cf8941311ec1f3dc117aef141b6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Feb 2 16:28:09 2010 +0000
drm/i915: Pass the correct length to dump the batchbuffer.
diff --git a/src/drm/cairo-drm-i915-surface.c b/src/drm/cairo-drm-i915-surface.c
index 2079ac9..c921727 100644
--- a/src/drm/cairo-drm-i915-surface.c
+++ b/src/drm/cairo-drm-i915-surface.c
@@ -267,7 +267,7 @@ i915_bo_exec (i915_device_t *device, intel_bo_t *bo, uint32_t offset)
}
intel_dump_batchbuffer (device->batch_header,
- device->batch.used,
+ execbuf.batch_len,
device->intel.base.chip_id);
}
commit 3266a1a72be9c0a6b6c0014c4b64098507b6d385
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Feb 2 16:27:52 2010 +0000
drm: Handle absence of PCI_ID
diff --git a/src/drm/cairo-drm.c b/src/drm/cairo-drm.c
index 9ccb10d..f79a1bf 100644
--- a/src/drm/cairo-drm.c
+++ b/src/drm/cairo-drm.c
@@ -201,7 +201,7 @@ cairo_drm_device_get (struct udev_device *device)
parent = udev_device_get_parent (device);
pci_id = get_udev_property (parent, "PCI_ID");
- if (sscanf (pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {
+ if (pci_id == NULL || sscanf (pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {
dev = (cairo_drm_device_t *)
_cairo_device_create_in_error (CAIRO_STATUS_DEVICE_ERROR);
goto DONE;
commit 1ecefc53a1d370d9fffb323952dcabeef5b872c6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Feb 2 16:26:54 2010 +0000
pattern: Zero-length gradients are not necessary empty
Fixes: test/linear-step-function
If the extend mode is unbounded, then the gradient is also unbound.
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index aae1aa5..a1c8162 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -2526,12 +2526,12 @@ _cairo_pattern_get_extents (const cairo_pattern_t *pattern,
const cairo_linear_pattern_t *linear =
(const cairo_linear_pattern_t *) pattern;
- if (linear->p1.x == linear->p2.x && linear->p1.y == linear->p2.y)
- goto EMPTY;
-
if (pattern->extend != CAIRO_EXTEND_NONE)
goto UNBOUNDED;
+ if (linear->p1.x == linear->p2.x && linear->p1.y == linear->p2.y)
+ goto EMPTY;
+
if (pattern->matrix.xy != 0. || pattern->matrix.yx != 0.)
goto UNBOUNDED;
commit 2a59220aa448cd7416f1851c4c62ca6ac396302d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Feb 2 16:24:30 2010 +0000
test: Add linear-step-function
Another bug identified by Jeff Muizelaar was that the bounds for a
zero-length (i.e. it started and stopped at the same point) were
miscomputed. This test case exercises that bug.
Note: I believe the output is wrong here when padding a zero-length
gradient. On the left it should be red, and on the right it should be
blue.
diff --git a/test/Makefile.am b/test/Makefile.am
index 72882e8..1ac79fa 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -602,6 +602,7 @@ REFERENCE_IMAGES = \
linear-gradient.quartz.ref.png \
linear-gradient.ref.png \
linear-gradient.xlib.ref.png \
+ linear-step-function.xfail.png \
linear-uniform.ref.png \
long-dashed-lines.ps2.ref.png \
long-dashed-lines.ps3.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 763e0f1..f0f90a9 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -128,6 +128,7 @@ test_sources = \
line-width-zero.c \
linear-gradient.c \
linear-gradient-reflect.c \
+ linear-step-function.c \
linear-uniform.c \
long-dashed-lines.c \
long-lines.c \
diff --git a/test/linear-step-function.c b/test/linear-step-function.c
new file mode 100644
index 0000000..da7e8ca
--- /dev/null
+++ b/test/linear-step-function.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright © 2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Author: Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_paint (cr);
+
+ pattern = cairo_pattern_create_linear (width/2, 0, width/2, 0);
+ cairo_pattern_add_color_stop_rgb (pattern, 0, 1, 0, 0);
+ cairo_pattern_add_color_stop_rgb (pattern, 1, 0, 0, 1);
+ cairo_set_source (cr, pattern);
+
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_NONE); /* nothing */
+ cairo_rectangle (cr, 0, 0, width, height/2);
+ cairo_fill (cr);
+
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); /* step */
+ cairo_rectangle (cr, 0, height/2, width, height/2);
+ cairo_fill (cr);
+
+ cairo_pattern_destroy (pattern);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (linear_step_function,
+ "Tests creating a step function using a linear gradient",
+ "gradient, linear", /* keywords */
+ NULL, /* requirements */
+ 40, 40,
+ NULL, draw)
diff --git a/test/linear-step-function.xfail.png b/test/linear-step-function.xfail.png
new file mode 100644
index 0000000..b8afd21
Binary files /dev/null and b/test/linear-step-function.xfail.png differ
commit 7b37ba8a49dca39a42b5395e0715d3d0a5a89972
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Feb 2 16:17:13 2010 +0000
clip: Propagate all-clipped when copying
Fixes test/clip-empty-save.
The all-clipped flag was not being copied to the new clip, which occurs
for instance when an empty clip is pushed via a gstate save.
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 74af5d8..abcf659 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -78,9 +78,6 @@ _cairo_clip_path_create (cairo_clip_t *clip)
static cairo_clip_path_t *
_cairo_clip_path_reference (cairo_clip_path_t *clip_path)
{
- if (clip_path == NULL)
- return NULL;
-
assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&clip_path->ref_count));
_cairo_reference_count_inc (&clip_path->ref_count);
@@ -200,11 +197,11 @@ cairo_clip_t *
_cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other)
{
if (other != NULL) {
+ clip->all_clipped = other->all_clipped;
if (other->path == NULL) {
- _cairo_clip_init (clip);
+ clip->path = NULL;
clip = NULL;
} else {
- clip->all_clipped = other->all_clipped;
clip->path = _cairo_clip_path_reference (other->path);
}
} else {
commit 7dc464bb2bd64d1469b7b03afaf2191ee6d9e28b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Feb 2 16:15:32 2010 +0000
test: Add clip-empty-save
Jeff Muizelaar found a bug in _cairo_clip_init_copy() which was not
correctly propagating the all-clipped status when an empty clip was
saved in the gstate. This test case exercises that bug.
diff --git a/test/Makefile.am b/test/Makefile.am
index 6dd734f..72882e8 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -171,6 +171,7 @@ REFERENCE_IMAGES = \
clip-disjoint.ref.png \
clip-disjoint.xlib.ref.png \
clip-empty.ref.png \
+ clip-empty-save.ref.png \
clip-fill.ref.png \
clip-fill.ps.xfail.png \
clip-fill.xlib.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index caff447..763e0f1 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -18,6 +18,7 @@ test_sources = \
clip-disjoint.c \
clip-device-offset.c \
clip-empty.c \
+ clip-empty-save.c \
clip-fill.c \
clip-fill-no-op.c \
clip-fill-rule.c \
diff --git a/test/clip-empty-save.c b/test/clip-empty-save.c
new file mode 100644
index 0000000..9f8fd69
--- /dev/null
+++ b/test/clip-empty-save.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2007 Chris Wilson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Chris Wilson not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Chris Wilson makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-test.h"
+
+#define SIZE 10
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_set_source_rgb (cr, 0, 0, 1);
+ cairo_paint (cr);
+
+ cairo_reset_clip (cr);
+ cairo_clip (cr);
+
+ cairo_save (cr);
+
+ cairo_translate (cr, .5, .5);
+
+ cairo_set_source_rgb (cr, 0, 1, 0);
+ cairo_rectangle (cr, 0, 0, SIZE, SIZE);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgb (cr, 1, 0, 0);
+ cairo_stroke (cr);
+
+ /* https://bugs.freedesktop.org/show_bug.cgi?id=13084 */
+ cairo_select_font_face (cr,
+ "Bitstream Vera Sans",
+ CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_NORMAL);
+
+ cairo_move_to (cr, 0., SIZE);
+ cairo_show_text (cr, "cairo");
+
+ cairo_restore (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (clip_empty_save,
+ "Test clipping with an empty clip path",
+ "clip", /* keywords */
+ NULL, /* requirements */
+ SIZE, SIZE,
+ NULL, draw)
diff --git a/test/clip-empty-save.ref.png b/test/clip-empty-save.ref.png
new file mode 100644
index 0000000..6c14df5
Binary files /dev/null and b/test/clip-empty-save.ref.png differ
commit ab3dc7bb31f7f8b8c4d87c1ae62bd946b260c77e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sun Jan 31 16:59:07 2010 +0000
csi-replay: compile fix
diff --git a/util/cairo-script/csi-replay.c b/util/cairo-script/csi-replay.c
index 297f16c..67fed3b 100644
--- a/util/cairo-script/csi-replay.c
+++ b/util/cairo-script/csi-replay.c
@@ -13,7 +13,8 @@ static const cairo_user_data_key_t _key;
static cairo_surface_t *
_similar_surface_create (void *closure,
cairo_content_t content,
- double width, double height)
+ double width, double height,
+ long uid)
{
return cairo_surface_create_similar (closure, content, width, height);
}
@@ -87,8 +88,9 @@ _destroy_window (void *closure)
static cairo_surface_t *
_xlib_surface_create (void *closure,
- cairo_content_t content,
- double width, double height)
+ cairo_content_t content,
+ double width, double height,
+ long uid)
{
Display *dpy;
XSetWindowAttributes attr;
@@ -127,7 +129,8 @@ _destroy_pixmap (void *closure)
static cairo_surface_t *
_xrender_surface_create (void *closure,
cairo_content_t content,
- double width, double height)
+ double width, double height,
+ long uid)
{
Display *dpy;
Pixmap pixmap;
@@ -210,7 +213,8 @@ _glx_get_context (cairo_content_t content)
static cairo_surface_t *
_glx_surface_create (void *closure,
cairo_content_t content,
- double width, double height)
+ double width, double height,
+ long uid)
{
if (width == 0)
width = 1;
@@ -227,7 +231,8 @@ _glx_surface_create (void *closure,
static cairo_surface_t *
_pdf_surface_create (void *closure,
cairo_content_t content,
- double width, double height)
+ double width, double height,
+ long uid)
{
return cairo_pdf_surface_create_for_stream (NULL, NULL, width, height);
}
@@ -238,7 +243,8 @@ _pdf_surface_create (void *closure,
static cairo_surface_t *
_ps_surface_create (void *closure,
cairo_content_t content,
- double width, double height)
+ double width, double height,
+ long uid)
{
return cairo_ps_surface_create_for_stream (NULL, NULL, width, height);
}
@@ -249,7 +255,8 @@ _ps_surface_create (void *closure,
static cairo_surface_t *
_svg_surface_create (void *closure,
cairo_content_t content,
- double width, double height)
+ double width, double height,
+ long uid)
{
return cairo_svg_surface_create_for_stream (NULL, NULL, width, height);
}
@@ -258,7 +265,8 @@ _svg_surface_create (void *closure,
static cairo_surface_t *
_image_surface_create (void *closure,
cairo_content_t content,
- double width, double height)
+ double width, double height,
+ long uid)
{
return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
}
@@ -316,7 +324,8 @@ main (int argc, char **argv)
#if SINGLE_SURFACE
hooks.closure = backends[0].create (NULL,
CAIRO_CONTENT_COLOR_ALPHA,
- 512, 512);
+ 512, 512,
+ 0);
#endif
@@ -332,7 +341,8 @@ main (int argc, char **argv)
cairo_surface_destroy (hooks.closure);
hooks.closure = b->create (NULL,
CAIRO_CONTENT_COLOR_ALPHA,
- 512, 512);
+ 512, 512,
+ 0);
#else
hooks.surface_create = b->create;
#endif
More information about the cairo-commit
mailing list