annotate src/graph_engine_openvg.c @ 612:b1d1b6c5af90 openvg

Implements setting pattern matrix for OpenVG
author Thinker K.F. Li <thinker@branda.to>
date Wed, 07 Jul 2010 18:44:17 +0800
parents e78bff7d23d3
children 6a0be737a3f3
rev   line source
582
dd546c4da180 deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 #include "mb_graph_engine_openvg.h"
604
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
2 #include "mb_tools.h"
582
dd546c4da180 deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3
dd546c4da180 deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 EGLNativeDisplayType _ge_openvg_disp_id = EGL_DEFAULT_DISPLAY;
584
543a2a8523fb Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents: 582
diff changeset
5 mbe_t *_ge_openvg_current_canvas = NULL;
588
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
6
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
7 #ifndef ASSERT
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
8 #define ASSERT(x)
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
9 #endif
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
10
598
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
11 #define MB_2_VG_COLOR(r, g, b, a) ((((int)(0xf * r) & 0xf) << 24) | \
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
12 (((int)(0xf * g) & 0xf) << 16) | \
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
13 (((int)(0xf * b) & 0xf) << 16) | \
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
14 ((int)(0xf * a) & 0xf))
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
15
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
16 #define MK_ID(mtx) \
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
17 do { \
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
18 (mtx)[0] = 1; \
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
19 (mtx)[1] = 0; \
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
20 (mtx)[2] = 0; \
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
21 (mtx)[3] = 0; \
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
22 (mtx)[4] = 1; \
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
23 (mtx)[5] = 0; \
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
24 (mtx)[6] = 0; \
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
25 (mtx)[7] = 0; \
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
26 (mtx)[8] = 1; \
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
27 } while(0)
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
28
610
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
29 /*
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
30 * This implementation supports only from image surface.
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
31 */
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
32 mbe_pattern_t *
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
33 mbe_pattern_create_for_surface(mbe_surface_t *surface) {
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
34 mbe_pattern_t *pattern;
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
35 _ge_openvg_img_t *ge_img;
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
36 VGfloat *mtx;
610
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
37 VGPaint paint;
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
38
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
39 /* Support only from image surface */
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
40 if(surface->asso_img == NULL)
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
41 return NULL;
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
42
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
43 paint = vgCreatePaint();
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
44 if(paint == VG_INVALID_HANDLE)
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
45 return NULL;
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
46
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
47 ge_img = surface->asso_img;
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
48 pattern = O_ALLOC(mbe_pattern_t);
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
49 pattern->asso_img = ge_img;
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
50 pattern->paint = paint;
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
51
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
52 mtx = pattern->mtx;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
53 MK_ID(mtx);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
54
610
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
55 return pattern;
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
56 }
e78bff7d23d3 create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 608
diff changeset
57
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
58 void
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
59 _mbe_load_pattern_mtx(VGfloat *mtx1, VGfloat *mtx2, int mode) {
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
60 VGfloat affine;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
61
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
62 vgSeti(VG_MATRIX_MODE, mode);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
63 vgLoadMatrix(mtx1);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
64 if(mtx2)
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
65 vgMultMatrix(mtx2);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
66 }
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
67
606
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
68 static mbe_pattern_t *
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
69 _mbe_pattern_create_gradient(VGfloat *gradient, int grad_len,
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
70 int grad_type,
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
71 grad_stop_t *stops, int stop_cnt) {
604
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
72 VGPaint paint;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
73 mbe_pattern_t *pattern;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
74 static VGfloat *ov_stops = 0;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
75 static int max_stop_cnt = 0;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
76 VGfloat *cur_ov_stop;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
77 grad_stop_t *cur_stop;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
78 int i;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
79
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
80 /* Make sure there is enough space */
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
81 if(max_stop_cnt < stop_cnt) {
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
82 max_stop_cnt = (stop_cnt + 0xf) & ~0xf;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
83 cur_ov_stop = (VGfloat *)realloc(stops,
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
84 max_stop_cnt * sizeof(VGfloat) * 5);
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
85 if(cur_ov_stop == NULL) {
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
86 max_stop_cnt = 0;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
87 return NULL;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
88 }
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
89 ov_stops = cur_ov_stop;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
90 }
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
91 cur_ov_stop = ov_stops;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
92
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
93 cur_stop = stops;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
94 for(i = 0; i < stop_cnt; i++) {
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
95 *cur_ov_stop++ = cur_stop->offset;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
96 *cur_ov_stop++ = cur_stop->r;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
97 *cur_ov_stop++ = cur_stop->g;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
98 *cur_ov_stop++ = cur_stop->b;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
99 *cur_ov_stop++ = cur_stop->a;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
100 }
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
101
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
102 paint = vgCreatePaint();
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
103 if(paint == VG_INVALID_HANDLE)
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
104 return NULL;
606
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
105 vgSetParameteri(paint, VG_PAINT_TYPE, grad_type);
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
106 vgSetParameterfv(paint, VG_PAINT_RADIAL_GRADIENT, grad_len, gradient);
604
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
107 vgSetParameterfv(paint, VG_PAINT_COLOR_RAMP_STOPS, 5 * stop_cnt, ov_stops);
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
108
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
109 pattern = O_ALLOC(mbe_pattern_t);
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
110 if(pattern == NULL) {
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
111 vgPaintDestroy(paint);
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
112 return NULL;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
113 }
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
114
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
115 pattern->paint = paint;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
116 pattern->asso_img = NULL;
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
117
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
118 MK_ID(pattern->mtx);
604
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
119
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
120 return pattern;
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
121 }
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
122
606
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
123 /*
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
124 * \note OpenVG does not support start circle, it supports only focal
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
125 * point. It means radius0 is not working.
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
126 */
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
127 mbe_pattern_t *
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
128 mbe_pattern_create_radial(co_aix cx0, co_aix cy0,
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
129 co_aix radius0,
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
130 co_aix cx1, co_aix cy1,
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
131 co_aix radius1, grad_stop_t *stops,
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
132 int stop_cnt) {
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
133 mbe_pattern_t *pattern;
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
134 VGfloat gradient[] = {cx0, cy0, cx1, cy1, radius1};
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
135
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
136 pattern = _mbe_pattern_create_gradient(gradient, 5,
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
137 VG_PAINT_TYPE_RADIAL_GRADIENT,
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
138 stops, stop_cnt);
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
139 return pattern;
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
140 }
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
141
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
142 mbe_pattern_t *
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
143 mbe_pattern_create_linear(co_aix x0, co_aix y0,
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
144 co_aix x1, co_aix y1,
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
145 grad_stop_t *stops, int stop_cnt) {
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
146 mbe_pattern_t *pattern;
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
147 VGfloat gradient[] = {x0, y0, x1, y1};
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
148
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
149 pattern = _mbe_pattern_create_gradient(gradient, 4,
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
150 VG_PAINT_TYPE_LINEAR_GRADIENT,
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
151 stops, stop_cnt);
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
152 return pattern;
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
153 }
e21eb54c7d9c Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents: 605
diff changeset
154
607
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
155 mbe_pattern_t *
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
156 mbe_pattern_create_image(mb_img_data_t *img) {
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
157 VGPaint paint;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
158 mbe_pattern_t *pattern;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
159 _ge_openvg_img_t *ge_img;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
160 VGImage vg_img;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
161 VGImageFormat fmt = VG_sARGB_8888;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
162
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
163 /* \note OpenVG implementation supports one \ref MB_IFMT_ARGB32
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
164 * image.
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
165 */
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
166 if(img->fmt != MB_IFMT_ARGB32)
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
167 return NULL;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
168
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
169 /* Create and copy pixels into VGImage */
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
170 vg_img = vgCreateImage(fmt, img->w, img->h,
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
171 VG_IMAGE_QUALITY_NONANTIALIASED);
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
172 if(vg_img == VG_INVALID_HANDLE)
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
173 return NULL;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
174 vgImageSubData(vg_img, img->content, img->stride, fmt,
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
175 0, 0, img->w, img->h);
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
176
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
177 /* Allocate objects */
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
178 ge_img = O_ALLOC(_ge_openvg_img_t);
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
179 pattern = O_ALLOC(mbe_pattern_t);
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
180 paint = vgCreatePaint();
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
181 if(ge_img == NULL || pattern == NULL || paint == VG_INVALID_HANDLE)
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
182 goto err;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
183
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
184
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
185 /* Initialize objects */
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
186 ge_img->img = vg_img;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
187 ge_img->asso_pattern = NULL;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
188 ge_img->asso_surface = NULL;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
189
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
190 pattern->paint = paint;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
191 pattern->asso_img = ge_img;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
192
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
193 return pattern;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
194
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
195 err:
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
196 if(ge_img) free(ge_img);
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
197 if(pattern) free(pattern);
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
198 if(paint != VG_INVALID_HANDLE) vgDestroyPaint(paint);
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
199 vgDestroyImage(vg_img);
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
200 return NULL;
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
201 }
51dc49fd34a8 Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents: 606
diff changeset
202
600
20b396c09c23 Integrate pattern source with paint model of canvas
Thinker K.F. Li <thinker@branda.to>
parents: 598
diff changeset
203 void
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
204 mbe_pattern_set_matrix(mbe_pattern_t *ptn, co_aix *mtx) {
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
205 co_aix rev[6];
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
206
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
207 compute_reverse(mtx, rev);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
208 ptn->mtx[0] = rev[0];
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
209 ptn->mtx[1] = rev[3];
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
210 ptn->mtx[2] = 0;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
211 ptn->mtx[3] = rev[1];
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
212 ptn->mtx[4] = rev[4];
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
213 ptn->mtx[5] = 0;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
214 ptn->mtx[6] = rev[2];
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
215 ptn->mtx[7] = rev[5];
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
216 ptn->mtx[8] = 1;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
217 }
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
218
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
219 void
600
20b396c09c23 Integrate pattern source with paint model of canvas
Thinker K.F. Li <thinker@branda.to>
parents: 598
diff changeset
220 mbe_set_source_rgba(mbe_t *canvas, co_comp_t r, co_comp_t g,
20b396c09c23 Integrate pattern source with paint model of canvas
Thinker K.F. Li <thinker@branda.to>
parents: 598
diff changeset
221 co_comp_t b, co_comp_t a) {
598
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
222 VGPaint paint;
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
223 VGuint color;
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
224
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
225 if(paint != VG_INVALID_HANDLE && canvas->src == NULL)
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
226 paint = canvas->paint; /* previous one is also a color paint */
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
227 else {
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
228 paint = vgCreatePaint();
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
229 ASSERT(paint != VG_INVALID_HANDLE);
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
230 canvas->paint = paint;
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
231 canvas->src = NULL;
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
232 }
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
233
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
234 color = MB_2_VG_COLOR(r, g, b, a);
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
235 vgSetColor(paint, color);
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
236 canvas->paint_installed = 0;
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
237 }
aba62eb9362d define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents: 597
diff changeset
238
588
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
239 void
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
240 mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas) {
595
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
241 static VGint *scissors = NULL;
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
242 static int n_scissors = 0;
588
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
243 VGint *coord;
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
244 area_t *area;
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
245 int i;
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
246
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
247 _MK_CURRENT_CTX(canvas);
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
248
595
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
249 if(n_areas > n_scissors) {
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
250 if(scissors) free(scissors);
604
38514a7c6b26 Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 600
diff changeset
251 n_scissors = (n_areas + 0xf) & ~0xf;
595
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
252 scissors = (VGint *)malloc(sizeof(VGint) * n_scissors * 4);
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
253 ASSERT(scissors != NULL);
588
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
254 }
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
255
595
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
256 coord = scissors;
588
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
257 for(i = 0; i < n_areas; i++) {
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
258 area = areas[i];
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
259 *coord++ = area->x;
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
260 *coord++ = area->y;
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
261 *coord++ = area->w;
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
262 *coord++ = area->h;
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
263 }
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
264
595
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
265 vgSetiv(VG_SCISSOR_RECTS, n_areas * 4, scissors);
588
e9923024f65e Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 584
diff changeset
266 }
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
267
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
268 static int
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
269 _openvg_find_config(mb_img_fmt_t fmt, int w, int h,
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
270 EGLConfig *config) {
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
271 EGLDisplay display;
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
272 EGLint attrib_list[32];
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
273 EGLConfig configs[1];
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
274 EGLint nconfigs;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
275 int i = 0;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
276 EGLBoolean r;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
277
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
278 switch(fmt) {
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
279 case MB_IFMT_ARGB32:
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
280 attrib_list[i++] = EGL_RED_SIZE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
281 attrib_list[i++] = 8;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
282 attrib_list[i++] = EGL_GREEN_SIZE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
283 attrib_list[i++] = 8;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
284 attrib_list[i++] = EGL_BLUE_SIZE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
285 attrib_list[i++] = 8;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
286 attrib_list[i++] = EGL_ALPHA_SIZE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
287 attrib_list[i++] = 8;
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
288 attrib_list[i++] = EGL_ALPHA_MASK_SIZE;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
289 attrib_list[i++] = 8;
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
290 break;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
291
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
292 case MB_IFMT_RGB24:
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
293 attrib_list[i++] = EGL_RED_SIZE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
294 attrib_list[i++] = 8;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
295 attrib_list[i++] = EGL_GREEN_SIZE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
296 attrib_list[i++] = 8;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
297 attrib_list[i++] = EGL_BLUE_SIZE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
298 attrib_list[i++] = 8;
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
299 attrib_list[i++] = EGL_ALPHA_MASK_SIZE;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
300 attrib_list[i++] = 8;
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
301 break;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
302
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
303 case MB_IFMT_A8:
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
304 attrib_list[i++] = EGL_ALPHA_SIZE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
305 attrib_list[i++] = 8;
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
306 attrib_list[i++] = EGL_ALPHA_MASK_SIZE;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
307 attrib_list[i++] = 8;
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
308 break;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
309
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
310 case MB_IFMT_A1:
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
311 attrib_list[i++] = EGL_ALPHA_SIZE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
312 attrib_list[i++] = 1;
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
313 attrib_list[i++] = EGL_ALPHA_MASK_SIZE;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
314 attrib_list[i++] = 1;
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
315 break;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
316
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
317 case MB_IFMT_RGB16_565:
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
318 attrib_list[i++] = EGL_RED_SIZE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
319 attrib_list[i++] = 5;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
320 attrib_list[i++] = EGL_GREEN_SIZE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
321 attrib_list[i++] = 6;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
322 attrib_list[i++] = EGL_BLUE_SIZE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
323 attrib_list[i++] = 5;
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
324 attrib_list[i++] = EGL_ALPHA_MASK_SIZE;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
325 attrib_list[i++] = 5;
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
326 break;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
327
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
328 default:
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
329 return -1;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
330 }
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
331
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
332 attrib_list[i++] = EGL_SURFACE_TYPE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
333 attrib_list[i++] = EGL_PBUFFER_BIT;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
334 #if 0
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
335 attrib_list[i++] = EGL_MAX_PBUFFER_WIDTH;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
336 attrib_list[i++] = w;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
337 attrib_list[i++] = EGL_MAX_PBUFFER_HEIGHT;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
338 attrib_list[i++] = h;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
339 #endif
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
340
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
341 attrib_list[i++] = EGL_NONE;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
342
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
343 display = _VG_DISPLAY();
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
344 r = eglChooseConfig(display, attrib_list, configs, 1, &nconfigs);
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
345 if(!r)
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
346 return -1;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
347
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
348 *config = configs[0];
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
349
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
350 return 0;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
351 }
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
352
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
353 #ifdef EGL_GLX
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
354 #include <X11/Xlib.h>
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
355 #include <X11/Xutil.h>
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
356
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
357 static int
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
358 _get_img_fmt_from_xvisual(Display *display, Visual *visual) {
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
359 VisualID visual_id;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
360 XVisualInfo temp;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
361 XVisualInfo *infos;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
362 int n;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
363 int fmt = -1;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
364
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
365 visual_id = XVisualIDFromVisual(visual);
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
366 temp.visualid = visual_id;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
367 infos = XGetVisualInfo(display, VisualIDMask, &temp, &n);
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
368 if(n != 1)
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
369 return -1;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
370
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
371 switch(infos->depth) {
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
372 case 32:
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
373 fmt = MB_IFMT_ARGB32;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
374 break;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
375
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
376 case 24:
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
377 fmt = MB_IFMT_RGB24;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
378 break;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
379
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
380 case 16:
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
381 fmt = MB_IFMT_RGB16_565;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
382 break;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
383
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
384 case 8:
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
385 fmt = MB_IFMT_A8;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
386 break;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
387
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
388 case 1:
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
389 fmt = MB_IFMT_A1;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
390 break;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
391 }
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
392
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
393 return fmt;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
394 }
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
395
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
396 /*! \brief Create an EGL window surface for X11.
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
397 *
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
398 * This function is compiled only for GLX enabled.
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
399 */
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
400 mbe_surface_t *
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
401 mbe_vg_win_surface_create(Display *display, Drawable drawable,
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
402 Visual *visual, int width, int height) {
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
403 EGLDisplay egl_disp;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
404 EGLSurface egl_surface;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
405 mbe_surface_t *surface;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
406 EGLConfig config;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
407 EGLint attrib_list[2] = {EGL_NONE};
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
408 int fmt;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
409 int r;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
410
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
411 fmt = _get_img_fmt_from_xvisual(display, visual);
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
412 if(fmt == -1)
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
413 return NULL;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
414
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
415 r = _openvg_find_config(fmt, width, height, &config);
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
416 if(r != 0)
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
417 return NULL;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
418
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
419 egl_disp = eglGetDisplay(display);
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
420 if(egl_disp == EGL_NO_DISPLAY || egl_disp != _VG_DISPLAY())
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
421 return NULL;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
422
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
423 egl_surface = eglCreateWindowSurface(egl_disp, config, drawable,
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
424 attrib_list);
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
425
605
a8fa4c550fe5 use O_ALLOC() to make code clear
Thinker K.F. Li <thinker@branda.to>
parents: 604
diff changeset
426 surface = O_ALLOC(mbe_surface_t);
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
427 if(surface == NULL) {
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
428 eglDestroySurface(egl_disp, egl_surface);
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
429 return NULL;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
430 }
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
431
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
432 surface->surface = egl_surface;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
433
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
434 return surface;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
435 }
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
436
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
437 #endif
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
438
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
439 mbe_surface_t *
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
440 mbe_image_surface_create(mb_img_fmt_t fmt, int w, int h) {
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
441 EGLSurface surface;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
442 EGLDisplay display;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
443 EGLConfig config;
592
de9d210e9c38 Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents: 591
diff changeset
444 EGLint attrib_list[5];
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
445 mbe_surface_t *mbe_surface;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
446 int r;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
447
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
448
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
449 r = _openvg_find_config(fmt, w, h, &config);
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
450 if(r != 0)
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
451 return NULL;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
452
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
453 display = _VG_DISPLAY();
592
de9d210e9c38 Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents: 591
diff changeset
454 attrib_list[0] = EGL_WIDTH;
de9d210e9c38 Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents: 591
diff changeset
455 attrib_list[1] = w;
de9d210e9c38 Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents: 591
diff changeset
456 attrib_list[2] = EGL_HEIGHT;
de9d210e9c38 Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents: 591
diff changeset
457 attrib_list[3] = h;
de9d210e9c38 Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents: 591
diff changeset
458 attrib_list[4] = EGL_NONE;
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
459 /* Some implementation does not support pbuffer.
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
460 * We need use some other surface to replace this one.
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
461 */
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
462 surface = eglCreatePbufferSurface(display, config, attrib_list);
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
463 if(surface == EGL_NO_SURFACE)
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
464 return NULL;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
465
605
a8fa4c550fe5 use O_ALLOC() to make code clear
Thinker K.F. Li <thinker@branda.to>
parents: 604
diff changeset
466 mbe_surface = O_ALLOC(mbe_surface_t);
590
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
467 if(mbe_surface == NULL) {
591
71df2896877c build graph_engine_openvg.c in makefile
Thinker K.F. Li <thinker@branda.to>
parents: 590
diff changeset
468 eglDestroySurface(display, surface);
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
469 return NULL;
590
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
470 }
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
471 mbe_surface->surface = surface;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
472 mbe_surface->asso_mbe = NULL;
592
de9d210e9c38 Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents: 591
diff changeset
473 mbe_surface->w = w;
de9d210e9c38 Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents: 591
diff changeset
474 mbe_surface->h = h;
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
475
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
476 return mbe_surface;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
477 }
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
478
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
479 mbe_t *
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
480 mbe_create(mbe_surface_t *surface) {
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
481 EGLDisplay display;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
482 EGLConfig config;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
483 EGLContext ctx, shared;
590
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
484 VGPath path;
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
485 EGLint attrib_list[2] = {EGL_NONE};
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
486 mbe_t *canvas;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
487
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
488 display = _VG_DISPLAY();
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
489 ctx = eglCreateContext(display, config, shared, attrib_list);
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
490 if(ctx == EGL_NO_CONTEXT)
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
491 return NULL;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
492
590
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
493 path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
494 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL);
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
495 if(path == VG_INVALID_HANDLE) {
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
496 eglDestroyContext(display, ctx);
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
497 return NULL;
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
498 }
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
499
605
a8fa4c550fe5 use O_ALLOC() to make code clear
Thinker K.F. Li <thinker@branda.to>
parents: 604
diff changeset
500 canvas = O_ALLOC(mbe_t);
590
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
501 if(canvas == NULL) {
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
502 eglDestroyContext(display, ctx);
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
503 vgDestroyPath(path);
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
504 return NULL;
590
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
505 }
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
506
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
507 canvas->src = NULL;
595
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
508 canvas->paint = VG_INVALID_HANDLE;
597
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
509 canvas->paint_installed = 0;
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
510 canvas->tgt = surface;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
511 canvas->ctx = ctx;
590
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
512 canvas->path = path;
589
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
513
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
514 return canvas;
d733e198bb25 Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents: 588
diff changeset
515 }
590
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
516
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
517 void
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
518 mbe_destroy(mbe_t *canvas) {
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
519 EGLDisplay display;
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
520
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
521 display = _VG_DISPLAY();
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
522
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
523 vgDestroyPath(canvas->path);
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
524 eglDestroyContext(display, canvas->ctx);
591
71df2896877c build graph_engine_openvg.c in makefile
Thinker K.F. Li <thinker@branda.to>
parents: 590
diff changeset
525 canvas->tgt->asso_mbe = NULL; /* remove association */
71df2896877c build graph_engine_openvg.c in makefile
Thinker K.F. Li <thinker@branda.to>
parents: 590
diff changeset
526 free(canvas);
590
b714f0c9992e include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents: 589
diff changeset
527 }
593
ac942664fe86 stroke and fill for VG
Thinker K.F. Li <thinker@branda.to>
parents: 592
diff changeset
528
608
6c74bc371e37 paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 607
diff changeset
529 void
6c74bc371e37 paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 607
diff changeset
530 mbe_paint_with_alpha(mbe_t *canvas, co_comp_t alpha) {
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
531 EGLDisplay display;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
532 VGHandle mask;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
533 EGLint w, h;
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
534 EGLBoolean r;
608
6c74bc371e37 paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 607
diff changeset
535
6c74bc371e37 paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 607
diff changeset
536 _MK_CURRENT_CTX(canvas);
6c74bc371e37 paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 607
diff changeset
537
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
538 display = _VG_DISPLAY();
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
539
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
540 r = eglQuerySurface(display, canvas->tgt, EGL_WIDTH, &w);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
541 ASSERT(r == EGL_TRUE);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
542 r = eglQuerySurface(display, canvas->tgt, EGL_HEIGHT, &h);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
543 ASSERT(r == EGL_TRUE);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
544
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
545 /* enable and fill mask layer with alpha value */
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
546 vgSeti(VG_MASKING, VG_TRUE);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
547 mask = vgCreateMaskLayer(w, h);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
548 ASSERT(mask != VG_INVALID_HANDLE);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
549 vgFillMaskLayer(mask, 0, 0, w, h, alpha);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
550 vgMask(mask, VG_SET_MASK, 0, 0, w, h);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
551 vgDestroyMaskLayer(mask);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
552
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
553 mbe_paint(canvas);
608
6c74bc371e37 paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 607
diff changeset
554
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
555 vgSeti(VG_MASKING, VG_FALSE);
608
6c74bc371e37 paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 607
diff changeset
556 }
6c74bc371e37 paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 607
diff changeset
557
595
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
558 void
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
559 mbe_paint(mbe_t *canvas) {
596
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
560 EGLDisplay display;
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
561 EGLint w, h;
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
562 EGLBoolean r;
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
563 VGPath path;
595
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
564
596
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
565 _MK_CURRENT_CTX(canvas);
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
566 _MK_CURRENT_PAINT(canvas);
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
567 if(canvas->src)
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
568 _mbe_load_pattern_mtx(canvas->src->mtx, NULL,
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
569 VG_MATRIX_FILL_PAINT_TO_USER);
596
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
570
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
571 display = _VG_DISPLAY();
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
572
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
573 r = eglQuerySurface(display, canvas->tgt, EGL_WIDTH, &w);
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
574 ASSERT(r == EGL_TRUE);
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
575 r = eglQuerySurface(display, canvas->tgt, EGL_HEIGHT, &h);
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
576 ASSERT(r == EGL_TRUE);
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
577
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
578 /* disable scissoring and identity transform matrix */
596
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
579 vgSeti(VG_SCISSORING, VG_FALSE);
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
580 vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
581 vgLoadIdentity();
596
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
582
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
583 path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
584 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL);
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
585 vguRect(path, 0, 0, w, h);
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
586 vgDrawPath(path, VG_FILL_PATH);
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
587 vgDestroyPath(path);
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
588
612
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
589 /* re-enable scissoring and restore transform matrix */
b1d1b6c5af90 Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents: 610
diff changeset
590 vgLoadMatrix(canvas->mtx);
596
aaab76730beb Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 595
diff changeset
591 vgSeti(VG_SCISSORING, VG_TRUE);
595
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
592 }
aaaaa03af04d Set VGPaint for canvas
Thinker K.F. Li <thinker@branda.to>
parents: 593
diff changeset
593
597
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
594 void
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
595 mbe_clear(mbe_t *canvas) {
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
596 VGPaint paint;
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
597
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
598 _MK_CURRENT_CTX(canvas);
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
599
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
600 paint = vgCreatePaint();
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
601 ASSERT(paint != VG_INVALID_HANDLE);
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
602 vgSetColor(paint, 0);
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
603
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
604 vgSetPaint(paint, VG_FILL_PATH);
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
605 vgSeti(VG_BLEND_MODE, VG_BLEND_SRC);
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
606 vgDrawPath(canvas->path, VG_FILL_PATH);
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
607 vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
608
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
609 vgDestroyPaint(paint);
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
610
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
611 canvas->paint_installed = 0;
3300992b29ff Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents: 596
diff changeset
612 }