Пример #1
0
void image_destroy(struct vg_image *img)
{
   struct vg_context *ctx = vg_current_context();
   vg_context_remove_object(ctx, VG_OBJECT_IMAGE, img);


   if (img->parent) {
      /* remove img from the parent child array */
      int idx;
      struct vg_image **array =
         (struct vg_image **)img->parent->children_array->data;

      for (idx = 0; idx < img->parent->children_array->num_elements; ++idx) {
         struct vg_image *child = array[idx];
         if (child == img) {
            break;
         }
      }
      debug_assert(idx < img->parent->children_array->num_elements);
      array_remove_element(img->parent->children_array, idx);
   }

   if (img->children_array && img->children_array->num_elements) {
      /* reparent the children */
      VGint i;
      struct vg_image *parent = img->parent;
      struct vg_image **children =
         (struct vg_image **)img->children_array->data;
      if (!parent) {
         VGint min_x = children[0]->x;
         parent = children[0];

         for (i = 1; i < img->children_array->num_elements; ++i) {
            struct vg_image *child = children[i];
            if (child->x < min_x) {
               parent = child;
            }
         }
      }

      for (i = 0; i < img->children_array->num_elements; ++i) {
         struct vg_image *child = children[i];
         if (child != parent) {
            child->parent = parent;
            if (!parent->children_array) {
               parent->children_array = array_create(
                  sizeof(struct vg_image*));
            }
            array_append_data(parent->children_array,
                              &child, 1);
         } else
            child->parent = NULL;
      }
      array_destroy(img->children_array);
   }

   pipe_texture_reference(&img->texture, NULL);
   free(img);
}
Пример #2
0
void vgDestroyFont(VGFont f)
{
   struct vg_font *font = (struct vg_font *)f;
   struct vg_context *ctx = vg_current_context();

   if (f == VG_INVALID_HANDLE) {
      vg_set_error(ctx, VG_BAD_HANDLE_ERROR);
      return;
   }

   vg_context_remove_object(ctx, VG_OBJECT_FONT, font);
   /*free(font);*/
}
Пример #3
0
void font_destroy(struct vg_font *font)
{
   struct vg_context *ctx = vg_current_context();
   struct cso_hash_iter iter;

   vg_context_remove_object(ctx, &font->base);

   iter = cso_hash_first_node(font->glyphs);
   while (!cso_hash_iter_is_null(iter)) {
      struct vg_glyph *glyph = (struct vg_glyph *) cso_hash_iter_data(iter);
      FREE(glyph);
      iter = cso_hash_iter_next(iter);
   }
   cso_hash_delete(font->glyphs);

   vg_free_object(&font->base);

   FREE(font);
}