comparison include/mb_graph_engine_openvg.h @ 595:aaaaa03af04d openvg

Set VGPaint for canvas
author Thinker K.F. Li <thinker@branda.to>
date Thu, 01 Jul 2010 14:24:02 +0800
parents ac942664fe86
children 3300992b29ff
comparison
equal deleted inserted replaced
594:d416e1fff71a 595:aaaaa03af04d
61 #define mbe_restore(canvas) 61 #define mbe_restore(canvas)
62 #define mbe_move_to(canvas, x, y) 62 #define mbe_move_to(canvas, x, y)
63 #define mbe_line_to(canvas, x, y) 63 #define mbe_line_to(canvas, x, y)
64 #define mbe_in_fill(canvas, x, y) (0) 64 #define mbe_in_fill(canvas, x, y) (0)
65 #define mbe_clear(canvas) 65 #define mbe_clear(canvas)
66 #define mbe_paint(canvas)
67 #define mbe_save(canvas) 66 #define mbe_save(canvas)
68 #define mbe_arc(canvas, x, y, radius, angle_start, angle_stop) 67 #define mbe_arc(canvas, x, y, radius, angle_start, angle_stop)
69 68
70 typedef struct _mbe_text_extents_t mbe_text_extents_t; 69 typedef struct _mbe_text_extents_t mbe_text_extents_t;
71 typedef int mbe_scaled_font_t; 70 typedef int mbe_scaled_font_t;
83 co_aix y_advance; 82 co_aix y_advance;
84 }; 83 };
85 84
86 struct _ge_openvg_mbe { 85 struct _ge_openvg_mbe {
87 mbe_pattern_t *src; 86 mbe_pattern_t *src;
87 VGPaint paint; /*!< \brief The paint associated with
88 * the src pattern */
89 int paint_installed;
88 mbe_surface_t *tgt; 90 mbe_surface_t *tgt;
89 EGLContext ctx; 91 EGLContext ctx;
90 VGPath path; 92 VGPath path;
91 }; 93 };
92 94
98 }; 100 };
99 101
100 struct _ge_openvg_pattern { 102 struct _ge_openvg_pattern {
101 void *pattern; 103 void *pattern;
102 void *asso_img; 104 void *asso_img;
105 VGPaint paint;
103 }; 106 };
104 107
105 #define MB_MATRIX_2_OPENVG(vgmtx, mtx) do { \ 108 #define MB_MATRIX_2_OPENVG(vgmtx, mtx) do { \
106 (vgmtx)[0] = (mtx)[0]; \ 109 (vgmtx)[0] = (mtx)[0]; \
107 (vgmtx)[1] = (mtx)[1]; \ 110 (vgmtx)[1] = (mtx)[1]; \
129 _ge_openvg_current_canvas = canvas; \ 132 _ge_openvg_current_canvas = canvas; \
130 eglMakeCurrent(_VG_DISPLAY(), (canvas)->tgt, \ 133 eglMakeCurrent(_VG_DISPLAY(), (canvas)->tgt, \
131 (canvas)->tgt, (canvas)->ctx); \ 134 (canvas)->tgt, (canvas)->ctx); \
132 } \ 135 } \
133 } while(0) 136 } while(0)
137 #define _MK_CURRENT_PAINT(canvas) \
138 if((canvas)->paint_installed) \
139 vgSetPaint((canvas)->paint, VG_FILL_PATH|VG_STROKE_PATH)
134 140
135 static void 141 static void
136 mbe_transform(mbe_t *canvas, co_aix *mtx) { 142 mbe_transform(mbe_t *canvas, co_aix *mtx) {
137 VGfloat vg_mtx[9]; 143 VGfloat vg_mtx[9];
138 144
168 free(surface); 174 free(surface);
169 } 175 }
170 176
171 extern mbe_t *mbe_create(mbe_surface_t *surface); 177 extern mbe_t *mbe_create(mbe_surface_t *surface);
172 extern void mbe_destroy(mbe_t *canvas); 178 extern void mbe_destroy(mbe_t *canvas);
179 extern void mbe_paint(mbe_t *canvas);
180
173 static void 181 static void
174 mbe_stroke(mbe_t *canvas) { 182 mbe_stroke(mbe_t *canvas) {
175 _MK_CURRENT_CTX(canvas); 183 _MK_CURRENT_CTX(canvas);
184 _MK_CURRENT_PAINT(canvas);
176 185
177 vgDrawPath(canvas->path, VG_STROKE_PATH); 186 vgDrawPath(canvas->path, VG_STROKE_PATH);
178 vgClearPath(canvas->path, VG_PATH_CAPABILITY_ALL); 187 vgClearPath(canvas->path, VG_PATH_CAPABILITY_ALL);
179 } 188 }
180 189
181 static void 190 static void
182 mbe_fill(mbe_t *canvas) { 191 mbe_fill(mbe_t *canvas) {
183 _MK_CURRENT_CTX(canvas); 192 _MK_CURRENT_CTX(canvas);
193 _MK_CURRENT_PAINT(canvas);
184 194
185 vgDrawPath(canvas->path, VG_FILL_PATH); 195 vgDrawPath(canvas->path, VG_FILL_PATH);
186 vgClearPath(canvas->path, VG_PATH_CAPABILITY_ALL); 196 vgClearPath(canvas->path, VG_PATH_CAPABILITY_ALL);
187 } 197 }
188 198