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;
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) {
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;
}
mask->sampler_view = view;
}
- vg_context_add_object(ctx, VG_OBJECT_MASK, mask);
+ vg_context_add_object(ctx, &mask->base);
return mask;
}
{
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);
}
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,
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);
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;
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);
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;
}
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)) {
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);
}
}
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);