예제 #1
0
void image_draw(struct vg_image *img, struct matrix *matrix)
{
   struct vg_context *ctx = vg_current_context();
   struct matrix paint_matrix;
   VGfloat x1, y1;
   VGfloat x2, y2;
   VGfloat x3, y3;
   VGfloat x4, y4;

   if (!vg_get_paint_matrix(ctx,
                            &ctx->state.vg.fill_paint_to_user_matrix,
                            matrix,
                            &paint_matrix))
      return;

   x1 = 0;
   y1 = 0;
   x2 = img->width;
   y2 = 0;
   x3 = img->width;
   y3 = img->height;
   x4 = 0;
   y4 = img->height;

   shader_set_surface_matrix(ctx->shader, matrix);
   shader_set_drawing_image(ctx->shader, VG_TRUE);
   shader_set_paint(ctx->shader, ctx->state.vg.fill_paint);
   shader_set_paint_matrix(ctx->shader, &paint_matrix);
   shader_set_image(ctx->shader, img);
   shader_bind(ctx->shader);

   renderer_texture_quad(ctx->renderer, image_texture(img),
                         img->x, img->y, img->x + img->width, img->y + img->height,
                         x1, y1, x2, y2, x3, y3, x4, y4);
}
예제 #2
0
void image_draw(struct vg_image *img)
{
   struct vg_context *ctx = vg_current_context();
   VGfloat x1, y1;
   VGfloat x2, y2;
   VGfloat x3, y3;
   VGfloat x4, y4;
   struct matrix *matrix;

   x1 = 0;
   y1 = 0;
   x2 = img->width;
   y2 = 0;
   x3 = img->width;
   y3 = img->height;
   x4 = 0;
   y4 = img->height;

   matrix = &ctx->state.vg.image_user_to_surface_matrix;

   matrix_map_point(matrix, x1, y1, &x1, &y1);
   matrix_map_point(matrix, x2, y2, &x2, &y2);
   matrix_map_point(matrix, x3, y3, &x3, &y3);
   matrix_map_point(matrix, x4, y4, &x4, &y4);

   shader_set_drawing_image(ctx->shader, VG_TRUE);
   shader_set_paint(ctx->shader, ctx->state.vg.fill_paint);
   shader_set_image(ctx->shader, img);
   shader_bind(ctx->shader);

   renderer_texture_quad(ctx->renderer, image_texture(img),
                         img->x, img->y, img->x + img->width, img->y + img->height,
                         x1, y1, x2, y2, x3, y3, x4, y4);
}