[cairo-commit] 5 commits - src/cairo-analysis-surface.c src/cairo.c src/cairo-clip.c src/cairo-clip-private.h src/cairo-gstate.c src/cairo-image-surface.c src/cairoint.h src/cairo-pattern.c src/cairo-pdf-surface.c src/drm util/cairo-trace
Andrea Canciani
ranma42 at kemper.freedesktop.org
Sat Mar 19 07:24:52 PDT 2011
src/cairo-analysis-surface.c | 21 +++++++--------------
src/cairo-clip-private.h | 3 +++
src/cairo-clip.c | 15 ++++++---------
src/cairo-gstate.c | 12 ++++++++----
src/cairo-image-surface.c | 3 ++-
src/cairo-pattern.c | 7 +------
src/cairo-pdf-surface.c | 8 ++------
src/cairo.c | 22 +---------------------
src/cairoint.h | 2 +-
src/drm/cairo-drm-i915-shader.c | 8 ++------
util/cairo-trace/trace.c | 7 ++++---
11 files changed, 37 insertions(+), 71 deletions(-)
New commits:
commit ab8c108b88edf49959b95a8d7cc12edb239d361c
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Fri Mar 18 16:57:04 2011 +0100
Do not warn when ignoring the return value of _cairo_rectangle_intersect()
gcc complains that
cairo-surface-wrapper.c:647: warning: ignoring return value of
â_cairo_rectangle_intersectâ, declared with attribute warn_unused_result
It can be silenced by making _cairo_rectangle_intersect()
cairo_private_no_warn. This makes it possible to avoid unused
temporary variables in other places and reduces the dead assignments
reported by clang static analyzer from 114 to 98.
diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index 6bec205..5468eac 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -272,14 +272,13 @@ static void
_rectangle_intersect_clip (cairo_rectangle_int_t *extents, cairo_clip_t *clip)
{
const cairo_rectangle_int_t *clip_extents;
- cairo_bool_t is_empty;
clip_extents = NULL;
if (clip != NULL)
clip_extents = _cairo_clip_get_extents (clip);
if (clip_extents != NULL)
- is_empty = _cairo_rectangle_intersect (extents, clip_extents);
+ _cairo_rectangle_intersect (extents, clip_extents);
}
static void
@@ -297,7 +296,7 @@ _cairo_analysis_surface_operation_extents (cairo_analysis_surface_t *surface,
cairo_rectangle_int_t source_extents;
_cairo_pattern_get_extents (source, &source_extents);
- is_empty = _cairo_rectangle_intersect (extents, &source_extents);
+ _cairo_rectangle_intersect (extents, &source_extents);
}
_rectangle_intersect_clip (extents, clip);
@@ -343,7 +342,6 @@ _cairo_analysis_surface_mask (void *abstract_surface,
cairo_analysis_surface_t *surface = abstract_surface;
cairo_int_status_t backend_status;
cairo_rectangle_int_t extents;
- cairo_bool_t is_empty;
if (surface->target->backend->mask == NULL) {
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
@@ -392,8 +390,7 @@ _cairo_analysis_surface_mask (void *abstract_surface,
cairo_rectangle_int_t mask_extents;
_cairo_pattern_get_extents (mask, &mask_extents);
- is_empty = _cairo_rectangle_intersect (&extents, &mask_extents);
-
+ _cairo_rectangle_intersect (&extents, &mask_extents);
}
return _add_operation (surface, &extents, backend_status);
@@ -414,7 +411,6 @@ _cairo_analysis_surface_stroke (void *abstract_surface,
cairo_analysis_surface_t *surface = abstract_surface;
cairo_status_t backend_status;
cairo_rectangle_int_t extents;
- cairo_bool_t is_empty;
if (surface->target->backend->stroke == NULL) {
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
@@ -447,7 +443,7 @@ _cairo_analysis_surface_stroke (void *abstract_surface,
if (unlikely (status))
return status;
- is_empty = _cairo_rectangle_intersect (&extents, &mask_extents);
+ _cairo_rectangle_intersect (&extents, &mask_extents);
}
return _add_operation (surface, &extents, backend_status);
@@ -466,7 +462,6 @@ _cairo_analysis_surface_fill (void *abstract_surface,
cairo_analysis_surface_t *surface = abstract_surface;
cairo_status_t backend_status;
cairo_rectangle_int_t extents;
- cairo_bool_t is_empty;
if (surface->target->backend->fill == NULL) {
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
@@ -493,7 +488,7 @@ _cairo_analysis_surface_fill (void *abstract_surface,
_cairo_path_fixed_fill_extents (path, fill_rule, tolerance,
&mask_extents);
- is_empty = _cairo_rectangle_intersect (&extents, &mask_extents);
+ _cairo_rectangle_intersect (&extents, &mask_extents);
}
return _add_operation (surface, &extents, backend_status);
@@ -512,7 +507,6 @@ _cairo_analysis_surface_show_glyphs (void *abstract_surface,
cairo_analysis_surface_t *surface = abstract_surface;
cairo_status_t status, backend_status;
cairo_rectangle_int_t extents, glyph_extents;
- cairo_bool_t is_empty;
/* Adapted from _cairo_surface_show_glyphs */
if (surface->target->backend->show_glyphs != NULL) {
@@ -561,7 +555,7 @@ _cairo_analysis_surface_show_glyphs (void *abstract_surface,
if (unlikely (status))
return status;
- is_empty = _cairo_rectangle_intersect (&extents, &glyph_extents);
+ _cairo_rectangle_intersect (&extents, &glyph_extents);
}
return _add_operation (surface, &extents, backend_status);
@@ -592,7 +586,6 @@ _cairo_analysis_surface_show_text_glyphs (void *abstract_surface,
cairo_analysis_surface_t *surface = abstract_surface;
cairo_status_t status, backend_status;
cairo_rectangle_int_t extents, glyph_extents;
- cairo_bool_t is_empty;
/* Adapted from _cairo_surface_show_glyphs */
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
@@ -645,7 +638,7 @@ _cairo_analysis_surface_show_text_glyphs (void *abstract_surface,
if (unlikely (status))
return status;
- is_empty = _cairo_rectangle_intersect (&extents, &glyph_extents);
+ _cairo_rectangle_intersect (&extents, &glyph_extents);
}
return _add_operation (surface, &extents, backend_status);
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index c76beee..a695cd7 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -368,7 +368,6 @@ _cairo_clip_path_reapply_clip_path_transform (cairo_clip_t *clip,
{
cairo_status_t status;
cairo_clip_path_t *clip_path;
- cairo_bool_t is_empty;
if (other_path->prev != NULL) {
status = _cairo_clip_path_reapply_clip_path_transform (clip,
@@ -394,8 +393,8 @@ _cairo_clip_path_reapply_clip_path_transform (cairo_clip_t *clip,
_cairo_path_fixed_approximate_clip_extents (&clip_path->path,
&clip_path->extents);
if (clip_path->prev != NULL) {
- is_empty = _cairo_rectangle_intersect (&clip_path->extents,
- &clip_path->prev->extents);
+ _cairo_rectangle_intersect (&clip_path->extents,
+ &clip_path->prev->extents);
}
clip_path->fill_rule = other_path->fill_rule;
@@ -1399,7 +1398,6 @@ intersect_with_boxes (cairo_composite_rectangles_t *extents,
{
cairo_rectangle_int_t rect;
cairo_box_t box;
- cairo_bool_t is_empty;
box.p1.x = box.p1.y = INT_MIN;
box.p2.x = box.p2.y = INT_MAX;
@@ -1416,8 +1414,8 @@ intersect_with_boxes (cairo_composite_rectangles_t *extents,
}
_cairo_box_round_to_rectangle (&box, &rect);
- is_empty = _cairo_rectangle_intersect (&extents->bounded, &rect);
- is_empty = _cairo_rectangle_intersect (&extents->unbounded, &rect);
+ _cairo_rectangle_intersect (&extents->bounded, &rect);
+ _cairo_rectangle_intersect (&extents->unbounded, &rect);
}
cairo_status_t
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 9fd3600..ac73ca9 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -1511,9 +1511,7 @@ _cairo_gstate_int_clip_extents (cairo_gstate_t *gstate,
clip_extents = _cairo_clip_get_extents (&gstate->clip);
if (clip_extents != NULL) {
- cairo_bool_t is_empty;
-
- is_empty = _cairo_rectangle_intersect (extents, clip_extents);
+ _cairo_rectangle_intersect (extents, clip_extents);
is_bounded = TRUE;
}
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 5663a9b..8531aa5 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -3782,7 +3782,6 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t *pat
int tx, ty;
double pad;
cairo_bool_t is_identity;
- cairo_bool_t is_empty;
cairo_bool_t is_bounded;
cairo_int_status_t status;
@@ -3953,7 +3952,7 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t *pat
if ( _cairo_surface_get_extents (surface, &extents)) {
if (attr->extend == CAIRO_EXTEND_NONE) {
/* Never acquire a larger area than the source itself */
- is_empty = _cairo_rectangle_intersect (&extents, &sampled_area);
+ _cairo_rectangle_intersect (&extents, &sampled_area);
} else {
int trim = 0;
@@ -3979,13 +3978,9 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t *pat
/* source is wholly contained within extents, drop the REPEAT */
attr->extend = CAIRO_EXTEND_NONE;
}
-
- is_empty = extents.width == 0 || extents.height == 0;
}
}
- /* XXX can we use is_empty? */
-
status = _cairo_surface_clone_similar (dst, surface,
extents.x, extents.y,
extents.width, extents.height,
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index c915b3f..b4b2981 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -6309,14 +6309,12 @@ _cairo_pdf_surface_fill_stroke (void *abstract_surface,
/* use the more accurate extents */
if (extents.is_bounded) {
- cairo_bool_t is_empty;
-
_cairo_path_fixed_fill_extents (path,
fill_rule,
fill_tolerance,
&extents.mask);
- is_empty = ! _cairo_rectangle_intersect (&extents.bounded, &extents.mask);
+ _cairo_rectangle_intersect (&extents.bounded, &extents.mask);
}
fill_pattern_res.id = 0;
@@ -6343,8 +6341,6 @@ _cairo_pdf_surface_fill_stroke (void *abstract_surface,
/* use the more accurate extents */
if (extents.is_bounded) {
- cairo_bool_t is_empty;
-
status = _cairo_path_fixed_stroke_extents (path, stroke_style,
stroke_ctm, stroke_ctm_inverse,
stroke_tolerance,
@@ -6352,7 +6348,7 @@ _cairo_pdf_surface_fill_stroke (void *abstract_surface,
if (unlikely (status))
return status;
- is_empty = ! _cairo_rectangle_intersect (&extents.bounded, &extents.mask);
+ _cairo_rectangle_intersect (&extents.bounded, &extents.mask);
}
stroke_pattern_res.id = 0;
diff --git a/src/cairo.c b/src/cairo.c
index 5969fe5..e1a8e91 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -694,7 +694,7 @@ cairo_push_group_with_content (cairo_t *cr, cairo_content_t content)
is_empty = _cairo_surface_get_extents (parent_surface, &extents);
clip_extents = _cairo_clip_get_extents (_cairo_gstate_get_clip (cr->gstate));
if (clip_extents != NULL)
- is_empty = _cairo_rectangle_intersect (&extents, clip_extents);
+ _cairo_rectangle_intersect (&extents, clip_extents);
group_surface = _cairo_surface_create_similar_solid (parent_surface,
content,
diff --git a/src/cairoint.h b/src/cairoint.h
index 0bfea8f..afd7de2 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -283,7 +283,7 @@ _cairo_unbounded_rectangle_init (cairo_rectangle_int_t *rect)
rect->height = CAIRO_RECT_INT_MAX - CAIRO_RECT_INT_MIN;
}
-cairo_private cairo_bool_t
+cairo_private_no_warn cairo_bool_t
_cairo_rectangle_intersect (cairo_rectangle_int_t *dst,
const cairo_rectangle_int_t *src);
diff --git a/src/drm/cairo-drm-i915-shader.c b/src/drm/cairo-drm-i915-shader.c
index 84e501f..b67608a 100644
--- a/src/drm/cairo-drm-i915-shader.c
+++ b/src/drm/cairo-drm-i915-shader.c
@@ -1502,12 +1502,8 @@ sampled_area (const cairo_surface_pattern_t *pattern,
sample->width = ceil (x2 + pad) - sample->x;
sample->height = ceil (y2 + pad) - sample->y;
- if (_cairo_surface_get_extents (pattern->surface, &surface_extents)) {
- cairo_bool_t is_empty;
-
- is_empty = _cairo_rectangle_intersect (sample,
- &surface_extents);
- }
+ if (_cairo_surface_get_extents (pattern->surface, &surface_extents))
+ _cairo_rectangle_intersect (sample, &surface_extents);
return filter;
}
commit 628ef17aca98ea3b0816a7dfa9e990275af6c791
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Fri Mar 18 16:46:24 2011 +0100
image: Silence gcc warning
gcc does not know thta num_glyph is guaranteed to be strictly
positive, so it complains that:
cairo-image-surface.c:3787: warning: âstatusâ may be used uninitialized in this function
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 10bd898..2a421b7 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -3785,7 +3785,7 @@ _composite_glyphs_via_mask (void *closure,
pixman_image_t *src;
pixman_image_t *white;
pixman_format_code_t mask_format = 0; /* silence gcc */
- cairo_status_t status;
+ cairo_status_t status = CAIRO_STATUS_SUCCESS; /* silence gcc */
int src_x, src_y;
int i;
commit e0444a458a2a03077e88ce326fb316530204276b
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Fri Mar 18 16:39:58 2011 +0100
image: Silence missing enum value warning
cairo-image-surface.c:101: warning: enumeration value âPIXMAN_x14r6g6b6â not handled in switch
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index bf22cb5..10bd898 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -126,6 +126,7 @@ _cairo_format_from_pixman_format (pixman_format_code_t pixman_format)
case PIXMAN_a2b10g10r10:
case PIXMAN_x2r10g10b10:
case PIXMAN_a2r10g10b10:
+ case PIXMAN_x14r6g6b6:
default:
return CAIRO_FORMAT_INVALID;
}
commit ad458d816a60613ee408d96bee8b77c64e6633e3
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Fri Mar 18 16:36:12 2011 +0100
trace: Always emit a function name for write-to-png-stream
By emitting an empty function name when it it impossible to perform
the lookup, we can get rid of the warning:
trace.c:3714: warning: unused variable âsymbolâ
Additionally, this makes the syntax (or, rather, the parameter count)
for write-to-png-stream the same on every configuration.
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index ff2bc81..9bdeb01 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -3715,10 +3715,11 @@ cairo_surface_write_to_png_stream (cairo_surface_t *surface,
_trace_printf ("%% s%ld ", _get_surface_id (surface));
#if CAIRO_HAS_SYMBOL_LOOKUP
- _emit_string_literal (lookup_symbol (symbol, sizeof (symbol),
- write_func),
- -1);
+ lookup_symbol (symbol, sizeof (symbol), write_func);
+#else
+ symbol[0] = '\0';
#endif
+ _emit_string_literal (symbol, -1);
_trace_printf (" write-to-png-stream\n");
_write_unlock ();
}
commit f2eb3f2178b6b7a75da4fb5e5bd880b769b69e62
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Fri Mar 18 16:10:39 2011 +0100
Improve cairo_rectangle_list_t error handling
Unify the _cairo_rectangle_list_create_in_error() functions, keeping
the best features from both (the one in cairo-clip.c statically
allocates the most common cases, the one in cairo.c throws a NO_MEMORY
error when it cannot malloc() instead of rethrowing the same error).
The same function can be used to return an error-list in
_cairo_gstate_copy_clip_rectangle_list() when _cairo_clip_rectangle()
fails (for example becaouse of an OOM).
diff --git a/src/cairo-clip-private.h b/src/cairo-clip-private.h
index faf4864..bfbb539 100644
--- a/src/cairo-clip-private.h
+++ b/src/cairo-clip-private.h
@@ -148,4 +148,7 @@ _cairo_clip_drop_cache (cairo_clip_t *clip);
cairo_private cairo_rectangle_list_t*
_cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate);
+cairo_private cairo_rectangle_list_t *
+_cairo_rectangle_list_create_in_error (cairo_status_t status);
+
#endif /* CAIRO_CLIP_PRIVATE_H */
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 696c5b1..c76beee 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -1465,8 +1465,7 @@ _cairo_clip_to_boxes (cairo_clip_t **clip,
return status;
}
-
-static cairo_rectangle_list_t *
+cairo_rectangle_list_t *
_cairo_rectangle_list_create_in_error (cairo_status_t status)
{
cairo_rectangle_list_t *list;
@@ -1478,7 +1477,7 @@ _cairo_rectangle_list_create_in_error (cairo_status_t status)
list = malloc (sizeof (*list));
if (unlikely (list == NULL)) {
- _cairo_error_throw (status);
+ status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
}
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index eaf7a56..9fd3600 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -1560,11 +1560,17 @@ _cairo_gstate_copy_clip_rectangle_list (cairo_gstate_t *gstate)
cairo_clip_t clip;
cairo_rectangle_int_t extents;
cairo_rectangle_list_t *list;
+ cairo_status_t status;
_cairo_clip_init_copy (&clip, &gstate->clip);
if (_cairo_surface_get_extents (gstate->target, &extents))
- _cairo_clip_rectangle (&clip, &extents);
+ status = _cairo_clip_rectangle (&clip, &extents);
+ else
+ status = CAIRO_STATUS_SUCCESS;
+
+ if (unlikely (status))
+ return _cairo_rectangle_list_create_in_error (status);
list = _cairo_clip_copy_rectangle_list (&clip, gstate);
_cairo_clip_fini (&clip);
diff --git a/src/cairo.c b/src/cairo.c
index 9e12c6e..5969fe5 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -2843,26 +2843,6 @@ cairo_in_clip (cairo_t *cr, double x, double y)
return _cairo_gstate_in_clip (cr->gstate, x, y);
}
-static cairo_rectangle_list_t *
-_cairo_rectangle_list_create_in_error (cairo_status_t status)
-{
- cairo_rectangle_list_t *list;
-
- if (status == CAIRO_STATUS_NO_MEMORY)
- return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
-
- list = malloc (sizeof (cairo_rectangle_list_t));
- if (unlikely (list == NULL)) {
- status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
- }
-
- list->status = status;
- list->rectangles = NULL;
- list->num_rectangles = 0;
- return list;
-}
-
/**
* cairo_copy_clip_rectangle_list:
* @cr: a cairo context
More information about the cairo-commit
mailing list