comparison src/shape_image.c @ 448:16116d84bc5e

Replace Cairo with a abstract layer mb_graph_engine. mb_graph_engine is a layer to separate MadButterfly from Cairo. It is only a set of macro mapping to cairo implementation, now. But, it provides a oppotunities to replace cairo with other engines; likes skia.
author Thinker K.F. Li <thinker@branda.to>
date Tue, 04 Aug 2009 23:35:41 +0800
parents 3e84458968ec
children a417fd980228
comparison
equal deleted inserted replaced
447:38aae921243f 448:16116d84bc5e
1 #include <stdio.h> 1 #include <stdio.h>
2 #include <string.h> 2 #include <string.h>
3 #include <cairo.h> 3 #include "mb_graph_engine.h"
4 #include "mb_types.h" 4 #include "mb_types.h"
5 #include "mb_shapes.h" 5 #include "mb_shapes.h"
6 #include "mb_img_ldr.h" 6 #include "mb_img_ldr.h"
7 #include "mb_tools.h" 7 #include "mb_tools.h"
8 8
68 * \param img_data is image data whose owner-ship is transfered. 68 * \param img_data is image data whose owner-ship is transfered.
69 */ 69 */
70 shape_t *rdman_shape_image_new(redraw_man_t *rdman, 70 shape_t *rdman_shape_image_new(redraw_man_t *rdman,
71 co_aix x, co_aix y, co_aix w, co_aix h) { 71 co_aix x, co_aix y, co_aix w, co_aix h) {
72 sh_image_t *img; 72 sh_image_t *img;
73 cairo_format_t fmt; 73 mbe_format_t fmt;
74 int r; 74 int r;
75 75
76 img = O_ALLOC(sh_image_t); 76 img = O_ALLOC(sh_image_t);
77 if(img == NULL) 77 if(img == NULL)
78 return NULL; 78 return NULL;
102 paint_t *paint; 102 paint_t *paint;
103 co_aix (*poses)[2]; 103 co_aix (*poses)[2];
104 co_aix img_matrix[6]; 104 co_aix img_matrix[6];
105 co_aix x_factor, y_factor; 105 co_aix x_factor, y_factor;
106 int img_w, img_h; 106 int img_w, img_h;
107 cairo_matrix_t cmatrix; 107 mbe_matrix_t cmatrix;
108 int i; 108 int i;
109 109
110 poses = img->poses; 110 poses = img->poses;
111 poses[0][0] = img->x; 111 poses[0][0] = img->x;
112 poses[0][1] = img->y; 112 poses[0][1] = img->y;
153 153
154 /*! \brief Draw image for an image shape. 154 /*! \brief Draw image for an image shape.
155 * 155 *
156 * \note Image is not rescaled for size of the shape. 156 * \note Image is not rescaled for size of the shape.
157 */ 157 */
158 void sh_image_draw(shape_t *shape, cairo_t *cr) { 158 void sh_image_draw(shape_t *shape, mbe_t *cr) {
159 sh_image_t *img = (sh_image_t *)shape; 159 sh_image_t *img = (sh_image_t *)shape;
160 cairo_pattern_t *saved_source; 160 mbe_pattern_t *saved_source;
161 cairo_matrix_t matrix, saved_matrix; 161 mbe_matrix_t matrix, saved_matrix;
162 co_aix *aggr; 162 co_aix *aggr;
163 163
164 cairo_move_to(cr, img->poses[0][0], img->poses[0][1]); 164 mbe_move_to(cr, img->poses[0][0], img->poses[0][1]);
165 cairo_line_to(cr, img->poses[1][0], img->poses[1][1]); 165 mbe_line_to(cr, img->poses[1][0], img->poses[1][1]);
166 cairo_line_to(cr, img->poses[2][0], img->poses[2][1]); 166 mbe_line_to(cr, img->poses[2][0], img->poses[2][1]);
167 cairo_line_to(cr, img->poses[3][0], img->poses[3][1]); 167 mbe_line_to(cr, img->poses[3][0], img->poses[3][1]);
168 cairo_close_path(cr); 168 mbe_close_path(cr);
169 } 169 }
170 170
171 /*! \brief Change geometry of an image. 171 /*! \brief Change geometry of an image.
172 * 172 *
173 * Set position and size of an image. 173 * Set position and size of an image.