diff options
author | Chia-I Wu <[email protected]> | 2011-09-21 10:48:21 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2011-09-21 12:01:03 +0800 |
commit | ceb6d34906c7c03c102c7e78dd02f5b0ebab4ca9 (patch) | |
tree | 061792f65d8f8c0daffeabd24ee0be8531fba533 /src/gallium/state_trackers/vega | |
parent | bdddf1cc26541d730bac309bd63dfdcaf4aea513 (diff) |
st/vega: fix vg_context_is_object_valid()
vg_context_is_object_valid() checks if a handle is valid by checking if
the handle is a valid key of the object hash table. However, the keys
of the object hash table were object pointers.
Fix vg_context_add_object() to use the handles as the keys so that
vg_context_is_object_valid() works. This bug was introduced by
99c67f27d35a4bbbbefada8117d5972c7583cf42.
Diffstat (limited to 'src/gallium/state_trackers/vega')
-rw-r--r-- | src/gallium/state_trackers/vega/image.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/mask.c | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/paint.c | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/path.c | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/text.c | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/vg_context.c | 18 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/vg_context.h | 6 |
7 files changed, 21 insertions, 25 deletions
diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c index 44480876b6e..c42315e4bba 100644 --- a/src/gallium/state_trackers/vega/image.c +++ b/src/gallium/state_trackers/vega/image.c @@ -287,7 +287,7 @@ struct vg_image * image_create(VGImageFormat format, image->sampler_view = view; - vg_context_add_object(ctx, VG_OBJECT_IMAGE, image); + vg_context_add_object(ctx, &image->base); image_cleari(image, 0, 0, 0, image->width, image->height); return image; @@ -296,7 +296,7 @@ struct vg_image * image_create(VGImageFormat format, void image_destroy(struct vg_image *img) { struct vg_context *ctx = vg_current_context(); - vg_context_remove_object(ctx, VG_OBJECT_IMAGE, img); + vg_context_remove_object(ctx, &img->base); if (img->parent) { @@ -502,7 +502,7 @@ struct vg_image * image_child_image(struct vg_image *parent, array_append_data(parent->children_array, &image, 1); - vg_context_add_object(ctx, VG_OBJECT_IMAGE, image); + vg_context_add_object(ctx, &image->base); return image; } diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c index 10590e29cd2..1280ea9dc8e 100644 --- a/src/gallium/state_trackers/vega/mask.c +++ b/src/gallium/state_trackers/vega/mask.c @@ -365,7 +365,7 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height) mask->sampler_view = view; } - vg_context_add_object(ctx, VG_OBJECT_MASK, mask); + vg_context_add_object(ctx, &mask->base); return mask; } @@ -374,7 +374,7 @@ void mask_layer_destroy(struct vg_mask_layer *layer) { struct vg_context *ctx = vg_current_context(); - vg_context_remove_object(ctx, VG_OBJECT_MASK, layer); + vg_context_remove_object(ctx, &layer->base); pipe_sampler_view_reference(&layer->sampler_view, NULL); FREE(layer); } diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c index 6e5348a1ff2..ea551811fcd 100644 --- a/src/gallium/state_trackers/vega/paint.c +++ b/src/gallium/state_trackers/vega/paint.c @@ -199,7 +199,7 @@ struct vg_paint * paint_create(struct vg_context *ctx) const VGfloat def_ling[] = {0.0f, 0.0f, 1.0f, 0.0f}; const VGfloat def_radg[] = {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; vg_init_object(&paint->base, ctx, VG_OBJECT_PAINT); - vg_context_add_object(ctx, VG_OBJECT_PAINT, paint); + vg_context_add_object(ctx, &paint->base); paint->type = VG_PAINT_TYPE_COLOR; memcpy(paint->solid.color, default_color, @@ -230,7 +230,7 @@ void paint_destroy(struct vg_paint *paint) if (paint->pattern.sampler_view) pipe_sampler_view_reference(&paint->pattern.sampler_view, NULL); if (ctx) - vg_context_remove_object(ctx, VG_OBJECT_PAINT, paint); + vg_context_remove_object(ctx, &paint->base); free(paint->gradient.ramp_stopsi); free(paint->gradient.ramp_stops); diff --git a/src/gallium/state_trackers/vega/path.c b/src/gallium/state_trackers/vega/path.c index d7253befd03..e62d1e32288 100644 --- a/src/gallium/state_trackers/vega/path.c +++ b/src/gallium/state_trackers/vega/path.c @@ -192,7 +192,7 @@ struct path * path_create(VGPathDatatype dt, VGfloat scale, VGfloat bias, vg_init_object(&path->base, vg_current_context(), VG_OBJECT_PATH); path->caps = capabilities & VG_PATH_CAPABILITY_ALL; - vg_context_add_object(vg_current_context(), VG_OBJECT_PATH, path); + vg_context_add_object(vg_current_context(), &path->base); path->datatype = dt; path->scale = scale; @@ -224,7 +224,7 @@ static void polygon_array_cleanup(struct polygon_array *polyarray) void path_destroy(struct path *p) { - vg_context_remove_object(vg_current_context(), VG_OBJECT_PATH, p); + vg_context_remove_object(vg_current_context(), &p->base); array_destroy(p->segments); array_destroy(p->control_points); diff --git a/src/gallium/state_trackers/vega/text.c b/src/gallium/state_trackers/vega/text.c index 6714ee9ad35..a183933c364 100644 --- a/src/gallium/state_trackers/vega/text.c +++ b/src/gallium/state_trackers/vega/text.c @@ -138,7 +138,7 @@ struct vg_font *font_create(VGint glyphCapacityHint) vg_init_object(&font->base, ctx, VG_OBJECT_FONT); font->glyphs = cso_hash_create(); - vg_context_add_object(ctx, VG_OBJECT_FONT, font); + vg_context_add_object(ctx, &font->base); return font; } @@ -148,7 +148,7 @@ void font_destroy(struct vg_font *font) struct vg_context *ctx = vg_current_context(); struct cso_hash_iter iter; - vg_context_remove_object(ctx, VG_OBJECT_FONT, font); + vg_context_remove_object(ctx, &font->base); iter = cso_hash_first_node(font->glyphs); while (!cso_hash_iter_is_null(iter)) { diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index c2ab56455b1..8d22bb27cf7 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -196,38 +196,36 @@ void vg_free_object(struct vg_object *obj) VGboolean vg_context_is_object_valid(struct vg_context *ctx, enum vg_object_type type, - VGHandle object) + VGHandle handle) { if (ctx) { struct cso_hash *hash = ctx->owned_objects[type]; if (!hash) return VG_FALSE; - return cso_hash_contains(hash, (unsigned)(long)object); + return cso_hash_contains(hash, (unsigned) handle); } return VG_FALSE; } void vg_context_add_object(struct vg_context *ctx, - enum vg_object_type type, - void *ptr) + struct vg_object *obj) { if (ctx) { - struct cso_hash *hash = ctx->owned_objects[type]; + struct cso_hash *hash = ctx->owned_objects[obj->type]; if (!hash) return; - cso_hash_insert(hash, (unsigned)(long)ptr, ptr); + cso_hash_insert(hash, (unsigned) obj->handle, obj); } } void vg_context_remove_object(struct vg_context *ctx, - enum vg_object_type type, - void *ptr) + struct vg_object *obj) { if (ctx) { - struct cso_hash *hash = ctx->owned_objects[type]; + struct cso_hash *hash = ctx->owned_objects[obj->type]; if (!hash) return; - cso_hash_take(hash, (unsigned)(long)ptr); + cso_hash_take(hash, (unsigned) obj->handle); } } diff --git a/src/gallium/state_trackers/vega/vg_context.h b/src/gallium/state_trackers/vega/vg_context.h index d91ee9797f1..d61c7cfeff1 100644 --- a/src/gallium/state_trackers/vega/vg_context.h +++ b/src/gallium/state_trackers/vega/vg_context.h @@ -161,11 +161,9 @@ VGboolean vg_context_is_object_valid(struct vg_context *ctx, enum vg_object_type type, VGHandle object); void vg_context_add_object(struct vg_context *ctx, - enum vg_object_type type, - void *ptr); + struct vg_object *obj); void vg_context_remove_object(struct vg_context *ctx, - enum vg_object_type type, - void *ptr); + struct vg_object *obj); void vg_validate_state(struct vg_context *ctx); |