[Pixman] [PATCH 1/2] Always return a valid function from lookup_composite()
Chris Wilson
chris at chris-wilson.co.uk
Sat Jan 12 09:00:40 PST 2013
We never expect to fail to find the appropriate function as the
general_composite_rect should always match. So if somehow we fallthrough
the search, emit a _pixman_log_error() and return a dummy function.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
pixman/pixman-fast-path.c | 16 ++++++----------
pixman/pixman-glyph.c | 26 ++++++++++++--------------
pixman/pixman-implementation.c | 16 ++++++++++++----
pixman/pixman-private.h | 4 ++--
pixman/pixman.c | 8 ++++----
5 files changed, 36 insertions(+), 34 deletions(-)
diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c
index c625e0c..4c6435a 100644
--- a/pixman/pixman-fast-path.c
+++ b/pixman/pixman-fast-path.c
@@ -1258,12 +1258,12 @@ fast_composite_tiled_repeat (pixman_implementation_t *imp,
mask_flags = FAST_PATH_IS_OPAQUE;
}
- if (_pixman_implementation_lookup_composite (
- imp->toplevel, info->op,
- src_image->common.extended_format_code, src_flags,
- mask_format, mask_flags,
- dest_image->common.extended_format_code, info->dest_flags,
- &imp, &func))
+ _pixman_implementation_lookup_composite (
+ imp->toplevel, info->op,
+ src_image->common.extended_format_code, src_flags,
+ mask_format, mask_flags,
+ dest_image->common.extended_format_code, info->dest_flags,
+ &imp, &func);
{
int32_t sx, sy;
int32_t width_remain;
@@ -1397,10 +1397,6 @@ fast_composite_tiled_repeat (pixman_implementation_t *imp,
if (need_src_extension)
_pixman_image_fini (&extended_src_image);
}
- else
- {
- _pixman_log_error (FUNC, "Didn't find a suitable function ");
- }
}
/* Use more unrolling for src_0565_0565 because it is typically CPU bound */
diff --git a/pixman/pixman-glyph.c b/pixman/pixman-glyph.c
index 5451f42..5a271b6 100644
--- a/pixman/pixman-glyph.c
+++ b/pixman/pixman-glyph.c
@@ -464,13 +464,12 @@ pixman_composite_glyphs_no_mask (pixman_op_t op,
glyph_format = glyph_img->common.extended_format_code;
glyph_flags = glyph_img->common.flags;
- if (! _pixman_implementation_lookup_composite (
- get_implementation(), op,
- src->common.extended_format_code, src->common.flags,
- glyph_format, glyph_flags | extra,
- dest_format, dest_flags,
- &implementation, &func))
- goto out;
+ _pixman_implementation_lookup_composite (
+ get_implementation(), op,
+ src->common.extended_format_code, src->common.flags,
+ glyph_format, glyph_flags | extra,
+ dest_format, dest_flags,
+ &implementation, &func);
}
info.src_x = src_x + composite_box.x1 - dest_x;
@@ -574,13 +573,12 @@ add_glyphs (pixman_glyph_cache_t *cache,
white_src = TRUE;
}
- if (! _pixman_implementation_lookup_composite (
- get_implementation(), PIXMAN_OP_ADD,
- src_format, info.src_flags,
- mask_format, info.mask_flags,
- dest_format, dest_flags,
- &implementation, &func))
- goto out;
+ _pixman_implementation_lookup_composite (
+ get_implementation(), PIXMAN_OP_ADD,
+ src_format, info.src_flags,
+ mask_format, info.mask_flags,
+ dest_format, dest_flags,
+ &implementation, &func);
}
glyph_box.x1 = glyphs[i].x - glyph->origin_x + off_x;
diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c
index ec467a6..05cb5ea 100644
--- a/pixman/pixman-implementation.c
+++ b/pixman/pixman-implementation.c
@@ -65,7 +65,13 @@ typedef struct
PIXMAN_DEFINE_THREAD_LOCAL (cache_t, fast_path_cache);
-pixman_bool_t
+static void
+dummy_composite_rect (pixman_implementation_t *imp,
+ pixman_composite_info_t *info)
+{
+}
+
+void
_pixman_implementation_lookup_composite (pixman_implementation_t *toplevel,
pixman_op_t op,
pixman_format_code_t src_format,
@@ -142,7 +148,11 @@ _pixman_implementation_lookup_composite (pixman_implementation_t *toplevel,
++info;
}
}
- return FALSE;
+
+ /* We should never reach this point */
+ _pixman_log_error (FUNC, "No known composite function\n");
+ *out_imp = NULL;
+ *out_func = dummy_composite_rect;
update_cache:
if (i)
@@ -160,8 +170,6 @@ update_cache:
cache->cache[0].fast_path.dest_flags = dest_flags;
cache->cache[0].fast_path.func = *out_func;
}
-
- return TRUE;
}
pixman_combine_32_func_t
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index e5ab873..3981873 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -497,7 +497,7 @@ pixman_implementation_t *
_pixman_implementation_create (pixman_implementation_t *fallback,
const pixman_fast_path_t *fast_paths);
-pixman_bool_t
+void
_pixman_implementation_lookup_composite (pixman_implementation_t *toplevel,
pixman_op_t op,
pixman_format_code_t src_format,
@@ -1052,7 +1052,7 @@ _pixman_log_error (const char *function, const char *message);
#else
-#define _pixman_log_error(f,m) do { } while (0) \
+#define _pixman_log_error(f,m) do { } while (0)
#define return_if_fail(expr) \
do \
diff --git a/pixman/pixman.c b/pixman/pixman.c
index 3fabed1..24c93c5 100644
--- a/pixman/pixman.c
+++ b/pixman/pixman.c
@@ -678,10 +678,10 @@ pixman_image_composite32 (pixman_op_t op,
*/
op = optimize_operator (op, src_flags, mask_flags, dest_flags);
- if (_pixman_implementation_lookup_composite (
- get_implementation (), op,
- src_format, src_flags, mask_format, mask_flags, dest_format, dest_flags,
- &imp, &func))
+ _pixman_implementation_lookup_composite (
+ get_implementation (), op,
+ src_format, src_flags, mask_format, mask_flags, dest_format, dest_flags,
+ &imp, &func);
{
pixman_composite_info_t info;
const pixman_box32_t *pbox;
--
1.7.10.4
More information about the Pixman
mailing list