Mercurial > MadButterfly
comparison include/mb_graph_engine_cairo.h @ 633:6f71f1b8e4e7
Let compilation on SMP8655 succeeded.
author | Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com> |
---|---|
date | Sat, 24 Jul 2010 16:13:06 +0800 |
parents | d186d1e24458 |
children | 058945dff7bd |
comparison
equal
deleted
inserted
replaced
623:ae787bcb475a | 633:6f71f1b8e4e7 |
---|---|
1 #ifndef __MB_GE_CAIRO_H_ | 1 #ifndef __MB_GE_CAIRO_H_ |
2 #define __MB_GE_CAIRO_H_ | 2 #define __MB_GE_CAIRO_H_ |
3 | 3 |
4 #include <stdio.h> | 4 #include <stdio.h> |
5 #include <cairo.h> | 5 #include <cairo.h> |
6 #include <cairo-xlib.h> | 6 #include <cairo-directfb.h> |
7 #include "mb_basic_types.h" | 7 #include "mb_basic_types.h" |
8 #include "mb_img_ldr.h" | 8 #include "mb_img_ldr.h" |
9 | 9 |
10 /*! \defgroup mb_ge_cairo MadButterfly Graphic Engine with Cairo | 10 /*! \defgroup mb_ge_cairo MadButterfly Graphic Engine with Cairo |
11 * @{ | 11 * @{ |
97 cairo_pattern_set_matrix(ptn, &cmtx); | 97 cairo_pattern_set_matrix(ptn, &cmtx); |
98 } | 98 } |
99 | 99 |
100 static void mbe_clear(mbe_t *canvas) { | 100 static void mbe_clear(mbe_t *canvas) { |
101 cairo_operator_t old_op; | 101 cairo_operator_t old_op; |
102 | 102 |
103 old_op = cairo_get_operator(canvas); | 103 old_op = cairo_get_operator(canvas); |
104 cairo_set_operator(canvas, CAIRO_OPERATOR_CLEAR); | 104 cairo_set_operator(canvas, CAIRO_OPERATOR_CLEAR); |
105 cairo_paint(canvas); | 105 cairo_paint(canvas); |
106 cairo_set_operator(canvas, old_op); | 106 cairo_set_operator(canvas, old_op); |
107 } | 107 } |
108 | 108 |
109 static void mbe_copy_source(mbe_t *src, mbe_t *dst) { | 109 static void mbe_copy_source(mbe_t *src, mbe_t *dst) { |
110 cairo_operator_t saved_op; | 110 cairo_operator_t saved_op; |
111 cairo_surface_t *surf; | 111 cairo_surface_t *surf; |
112 cairo_pattern_t *ptn; | 112 cairo_pattern_t *ptn; |
113 | 113 |
114 surf = cairo_get_target(src); | 114 surf = cairo_get_target(src); |
115 ptn = cairo_pattern_create_for_surface(surf); | 115 ptn = cairo_pattern_create_for_surface(surf); |
116 cairo_set_source(src, ptn); | 116 cairo_set_source(src, ptn); |
117 cairo_pattern_destroy(ptn); | 117 cairo_pattern_destroy(ptn); |
118 saved_op = cairo_get_operator(dst); | 118 saved_op = cairo_get_operator(dst); |
129 cairo_matrix_t cfnt_mtx, cctm; | 129 cairo_matrix_t cfnt_mtx, cctm; |
130 | 130 |
131 options = cairo_font_options_create(); | 131 options = cairo_font_options_create(); |
132 if(options == NULL) | 132 if(options == NULL) |
133 return NULL; | 133 return NULL; |
134 | 134 |
135 MB_MATRIX_2_CAIRO(cfnt_mtx, fnt_mtx); | 135 MB_MATRIX_2_CAIRO(cfnt_mtx, fnt_mtx); |
136 MB_MATRIX_2_CAIRO(cctm, ctm); | 136 MB_MATRIX_2_CAIRO(cctm, ctm); |
137 scaled = cairo_scaled_font_create(face, &cfnt_mtx, &cctm, options); | 137 scaled = cairo_scaled_font_create(face, &cfnt_mtx, &cctm, options); |
138 | 138 |
139 cairo_font_options_destroy(options); | 139 cairo_font_options_destroy(options); |
140 | 140 |
141 return scaled; | 141 return scaled; |
142 } | 142 } |
143 | 143 |
144 static mbe_surface_t * | 144 static mbe_surface_t * |
145 mbe_image_surface_create_for_data(unsigned char *data, | 145 mbe_image_surface_create_for_data(unsigned char *data, |
146 mb_img_fmt_t fmt, | 146 mb_img_fmt_t fmt, |
147 int width, int height, | 147 int width, int height, |
148 int stride) { | 148 int stride) { |
149 cairo_format_t _fmt; | 149 cairo_format_t _fmt; |
150 | 150 |
151 switch(fmt) { | 151 switch(fmt) { |
152 case MB_IFMT_ARGB32: | 152 case MB_IFMT_ARGB32: |
153 _fmt = CAIRO_FORMAT_ARGB32; | 153 _fmt = CAIRO_FORMAT_ARGB32; |
154 break; | 154 break; |
155 case MB_IFMT_RGB24: | 155 case MB_IFMT_RGB24: |
196 } | 196 } |
197 | 197 |
198 static mbe_surface_t * | 198 static mbe_surface_t * |
199 mbe_image_surface_create(mb_img_fmt_t fmt, int width, int height) { | 199 mbe_image_surface_create(mb_img_fmt_t fmt, int width, int height) { |
200 cairo_format_t _fmt; | 200 cairo_format_t _fmt; |
201 | 201 |
202 switch(fmt) { | 202 switch(fmt) { |
203 case MB_IFMT_ARGB32: | 203 case MB_IFMT_ARGB32: |
204 _fmt = CAIRO_FORMAT_ARGB32; | 204 _fmt = CAIRO_FORMAT_ARGB32; |
205 break; | 205 break; |
206 case MB_IFMT_RGB24: | 206 case MB_IFMT_RGB24: |
213 _fmt = CAIRO_FORMAT_A1; | 213 _fmt = CAIRO_FORMAT_A1; |
214 break; | 214 break; |
215 default: | 215 default: |
216 return NULL; | 216 return NULL; |
217 } | 217 } |
218 | 218 |
219 return cairo_image_surface_create(_fmt, width, height); | 219 return cairo_image_surface_create(_fmt, width, height); |
220 } | 220 } |
221 | 221 |
222 static void | 222 static void |
223 mbe_transform(mbe_t *mbe, const co_aix matrix[6]) { | 223 mbe_transform(mbe_t *mbe, const co_aix matrix[6]) { |