Browse Source

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
99c67f27d3.
tags/mesa-8.0-rc1
Chia-I Wu 14 years ago
parent
commit
ceb6d34906

+ 3
- 3
src/gallium/state_trackers/vega/image.c View File

@@ -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;
}

+ 2
- 2
src/gallium/state_trackers/vega/mask.c View File

@@ -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);
}

+ 2
- 2
src/gallium/state_trackers/vega/paint.c View File

@@ -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);

+ 2
- 2
src/gallium/state_trackers/vega/path.c View File

@@ -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);

+ 2
- 2
src/gallium/state_trackers/vega/text.c View File

@@ -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)) {

+ 8
- 10
src/gallium/state_trackers/vega/vg_context.c View File

@@ -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);
}
}


+ 2
- 4
src/gallium/state_trackers/vega/vg_context.h View File

@@ -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);


Loading…
Cancel
Save