Mercurial > MadButterfly
annotate src/graph_engine_openvg.c @ 622:39bd74da7f92 openvg
mbe_copy_source() for OpenVG
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 09 Jul 2010 11:50:48 +0800 |
parents | 7020ed3c3e37 |
children | 97bf0ff7a038 |
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 |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
29 /*! \brief Convert mb_img_fmt_t to VGImageFormat */ |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
30 static VGImageFormat |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
31 _mb_ifmt_2_vgifmt(mb_img_fmt_t fmt) { |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
32 VGImageFormat vgifmt; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
33 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
34 switch(fmt) { |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
35 case MB_IFMT_ARGB32: |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
36 vgifmt = VG_sARGB_8888; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
37 break; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
38 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
39 case MB_IFMT_RGB24: |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
40 vgifmt = -1; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
41 break; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
42 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
43 case MB_IFMT_A8: |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
44 vgifmt = VG_A_8; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
45 break; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
46 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
47 case MB_IFMT_A1: |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
48 vgifmt = -1; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
49 break; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
50 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
51 case MB_IFMT_RGB16_565: |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
52 vgifmt = VG_sRGB_565; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
53 break; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
54 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
55 default: |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
56 return -1; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
57 } |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
58 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
59 return vgifmt; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
60 } |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
61 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
62 /*! \brief create image object for OpenVG */ |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
63 static _ge_openvg_img_t * |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
64 _alloc_vgimage(mb_img_fmt_t fmt, int w, int h) { |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
65 VGImage vg_img; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
66 VGImageFormat vgifmt; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
67 _ge_openvg_img_t *ge_img; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
68 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
69 vgifmt = _mb_ifmt_2_vgifmt(fmt); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
70 if(vgifmt == -1) |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
71 return NULL; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
72 vg_img = vgCreateImage(vgifmt, w, h, |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
73 VG_IMAGE_QUALITY_NONANTIALIASED); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
74 if(vg_img == VG_INVALID_HANDLE) |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
75 return NULL; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
76 ge_img = O_ALLOC(_ge_openvg_img_t); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
77 if(ge_img == NULL) { |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
78 vgDestroyImage(vg_img); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
79 return NULL; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
80 } |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
81 ge_img->ref = 1; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
82 ge_img->img = vg_img; |
619
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
83 ge_img->activated_for = NULL; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
84 ge_img->deactivate_func = NULL; |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
85 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
86 return ge_img; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
87 } |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
88 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
89 /*! \brief Free image object for OpenVG */ |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
90 static void |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
91 _free_vgimage(_ge_openvg_img_t *ge_img) { |
619
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
92 if(--ge_img->ref > 0) { |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
93 if(ge_img->activated_for) { |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
94 ge_img->deactivate_func(ge_img->activated_for); |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
95 ge_img->activated_for = NULL; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
96 } |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
97 return; |
619
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
98 } |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
99 |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
100 vgDestroyImage(ge_img->img); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
101 free(ge_img); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
102 } |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
103 |
619
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
104 static void |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
105 _ge_vg_img_deactivate_for_pattern(void *obj) { |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
106 mbe_pattern_t *ptn = (mbe_pattern_t *)obj; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
107 VGPaint vg_paint; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
108 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
109 vg_paint = ptn->paint; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
110 vgPaintPattern(vg_paint, VG_INVALID_HANDLE); |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
111 } |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
112 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
113 /*! \brief Activate a VGImage for a pattern paint. |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
114 * |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
115 * \sa _ge_openvg_img |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
116 */ |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
117 void |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
118 _ge_vg_img_activate_for_pattern(mbe_pattern_t *ptn) { |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
119 _ge_openvg_img_t *ge_img; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
120 VGPaint vg_paint; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
121 VGImage vg_img; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
122 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
123 ge_img = ptn->asso_img; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
124 if(ge_img == NULL) |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
125 return; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
126 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
127 if(ge_img->activated_for == (void *)ptn) |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
128 return; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
129 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
130 if(ge_img->activated_for) |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
131 ge_img->deactivate_func(ge_img->activated_for); |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
132 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
133 ge_img->activated_for = ptn; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
134 ge_img->deactivate_func = _ge_vg_img_deactivate_for_pattern; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
135 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
136 vg_img = ge_img->img; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
137 vg_paint = ptn->paint; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
138 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
139 vgPaintPattern(vg_paint, vg_img); |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
140 } |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
141 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
142 /*! \brief Deactivate a VGImage for a VGSurface. |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
143 * |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
144 * A VGImage can not deatached from VGSurface. But, it is not clear |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
145 * in the document of EGL. We assume that a VGImage can be used as |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
146 * pattern of a paint, once associated surface is not current |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
147 * rendering context. |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
148 */ |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
149 static void |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
150 _ge_vg_img_deactivate_for_surface(void *obj) { |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
151 } |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
152 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
153 /*! \brief Activate a VGImage for a surface |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
154 * |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
155 * \sa _ge_openvg_img |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
156 */ |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
157 void |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
158 _ge_vg_img_activate_for_surface(mbe_surface_t *surf) { |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
159 _ge_openvg_img_t *ge_img; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
160 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
161 ge_img = surf->asso_img; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
162 if(ge_img == NULL) |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
163 return; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
164 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
165 if(ge_img->activated_for == (void *)surf) |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
166 return; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
167 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
168 if(ge_img->activated_for) |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
169 ge_img->deactivate_func(ge_img->activated_for); |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
170 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
171 ge_img->activated_for = surf; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
172 ge_img->deactivate_func = _ge_vg_img_deactivate_for_surface; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
173 } |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
174 |
610
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
175 /* |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
176 * 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
|
177 */ |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
178 mbe_pattern_t * |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
179 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
|
180 mbe_pattern_t *pattern; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
181 _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
|
182 VGfloat *mtx; |
610
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
183 VGPaint paint; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
184 |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
185 /* Support only from image surface */ |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
186 if(surface->asso_img == NULL) |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
187 return NULL; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
188 |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
189 paint = vgCreatePaint(); |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
190 if(paint == VG_INVALID_HANDLE) |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
191 return NULL; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
192 |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
193 ge_img = surface->asso_img; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
194 pattern = O_ALLOC(mbe_pattern_t); |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
195 pattern->asso_img = ge_img; |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
196 ge_img->ref++; /* increase reference count */ |
610
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
197 pattern->paint = paint; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
198 |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
199 mtx = pattern->mtx; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
200 MK_ID(mtx); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
201 |
610
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
202 return pattern; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
203 } |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
204 |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
205 void |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
206 _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
|
207 VGfloat affine; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
208 |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
209 vgSeti(VG_MATRIX_MODE, mode); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
210 vgLoadMatrix(mtx1); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
211 if(mtx2) |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
212 vgMultMatrix(mtx2); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
213 } |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
214 |
606
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
215 static mbe_pattern_t * |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
216 _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
|
217 int grad_type, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
218 grad_stop_t *stops, int stop_cnt) { |
604
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
219 VGPaint paint; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
220 mbe_pattern_t *pattern; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
221 static VGfloat *ov_stops = 0; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
222 static int max_stop_cnt = 0; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
223 VGfloat *cur_ov_stop; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
224 grad_stop_t *cur_stop; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
225 int i; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
226 |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
227 /* Make sure there is enough space */ |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
228 if(max_stop_cnt < stop_cnt) { |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
229 max_stop_cnt = (stop_cnt + 0xf) & ~0xf; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
230 cur_ov_stop = (VGfloat *)realloc(stops, |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
231 max_stop_cnt * sizeof(VGfloat) * 5); |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
232 if(cur_ov_stop == NULL) { |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
233 max_stop_cnt = 0; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
234 return NULL; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
235 } |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
236 ov_stops = cur_ov_stop; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
237 } |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
238 cur_ov_stop = ov_stops; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
239 |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
240 cur_stop = stops; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
241 for(i = 0; i < stop_cnt; i++) { |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
242 *cur_ov_stop++ = cur_stop->offset; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
243 *cur_ov_stop++ = cur_stop->r; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
244 *cur_ov_stop++ = cur_stop->g; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
245 *cur_ov_stop++ = cur_stop->b; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
246 *cur_ov_stop++ = cur_stop->a; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
247 } |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
248 |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
249 paint = vgCreatePaint(); |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
250 if(paint == VG_INVALID_HANDLE) |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
251 return NULL; |
606
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
252 vgSetParameteri(paint, VG_PAINT_TYPE, grad_type); |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
253 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
|
254 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
|
255 |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
256 pattern = O_ALLOC(mbe_pattern_t); |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
257 if(pattern == NULL) { |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
258 vgPaintDestroy(paint); |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
259 return NULL; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
260 } |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
261 |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
262 pattern->paint = paint; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
263 pattern->asso_img = NULL; |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
264 |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
265 MK_ID(pattern->mtx); |
604
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
266 |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
267 return pattern; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
268 } |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
269 |
606
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
270 /* |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
271 * \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
|
272 * point. It means radius0 is not working. |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
273 */ |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
274 mbe_pattern_t * |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
275 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
|
276 co_aix radius0, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
277 co_aix cx1, co_aix cy1, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
278 co_aix radius1, grad_stop_t *stops, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
279 int stop_cnt) { |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
280 mbe_pattern_t *pattern; |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
281 VGfloat gradient[] = {cx0, cy0, cx1, cy1, radius1}; |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
282 |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
283 pattern = _mbe_pattern_create_gradient(gradient, 5, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
284 VG_PAINT_TYPE_RADIAL_GRADIENT, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
285 stops, stop_cnt); |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
286 return pattern; |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
287 } |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
288 |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
289 mbe_pattern_t * |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
290 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
|
291 co_aix x1, co_aix y1, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
292 grad_stop_t *stops, int stop_cnt) { |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
293 mbe_pattern_t *pattern; |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
294 VGfloat gradient[] = {x0, y0, x1, y1}; |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
295 |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
296 pattern = _mbe_pattern_create_gradient(gradient, 4, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
297 VG_PAINT_TYPE_LINEAR_GRADIENT, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
298 stops, stop_cnt); |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
299 return pattern; |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
300 } |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
301 |
607
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
302 mbe_pattern_t * |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
303 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
|
304 VGPaint paint; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
305 mbe_pattern_t *pattern; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
306 _ge_openvg_img_t *ge_img; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
307 VGImage vg_img; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
308 VGImageFormat fmt = VG_sARGB_8888; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
309 |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
310 /* \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
|
311 * image. |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
312 */ |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
313 if(img->fmt != MB_IFMT_ARGB32) |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
314 return NULL; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
315 |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
316 /* Allocate objects */ |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
317 ge_img = _alloc_vgimage(MB_IFMT_ARGB32, img->w, img->h); |
607
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
318 pattern = O_ALLOC(mbe_pattern_t); |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
319 paint = vgCreatePaint(); |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
320 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
|
321 goto err; |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
322 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
323 /* Create and copy pixels into VGImage */ |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
324 vg_img = ge_img->img; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
325 vgImageSubData(vg_img, img->content, img->stride, fmt, |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
326 0, 0, img->w, img->h); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
327 |
607
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
328 pattern->paint = paint; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
329 pattern->asso_img = ge_img; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
330 |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
331 return pattern; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
332 |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
333 err: |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
334 if(ge_img) _free_vgimage(ge_img); |
607
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
335 if(pattern) free(pattern); |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
336 if(paint != VG_INVALID_HANDLE) vgDestroyPaint(paint); |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
337 vgDestroyImage(vg_img); |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
338 return NULL; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
339 } |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
340 |
600
20b396c09c23
Integrate pattern source with paint model of canvas
Thinker K.F. Li <thinker@branda.to>
parents:
598
diff
changeset
|
341 void |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
342 mbe_pattern_destroy(mbe_pattern_t *ptn) { |
619
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
343 if(ptn->asso_img) |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
344 _free_vgimage(ptn->asso_img); |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
345 vgDestroyPaint(ptn->paint); |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
346 free(ptn); |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
347 } |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
348 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
349 void |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
350 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
|
351 co_aix rev[6]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
352 |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
353 compute_reverse(mtx, rev); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
354 ptn->mtx[0] = rev[0]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
355 ptn->mtx[1] = rev[3]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
356 ptn->mtx[2] = 0; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
357 ptn->mtx[3] = rev[1]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
358 ptn->mtx[4] = rev[4]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
359 ptn->mtx[5] = 0; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
360 ptn->mtx[6] = rev[2]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
361 ptn->mtx[7] = rev[5]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
362 ptn->mtx[8] = 1; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
363 } |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
364 |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
365 void |
600
20b396c09c23
Integrate pattern source with paint model of canvas
Thinker K.F. Li <thinker@branda.to>
parents:
598
diff
changeset
|
366 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
|
367 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
|
368 VGPaint paint; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
369 VGuint color; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
370 |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
371 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
|
372 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
|
373 else { |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
374 paint = vgCreatePaint(); |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
375 ASSERT(paint != VG_INVALID_HANDLE); |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
376 canvas->paint = paint; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
377 canvas->src = NULL; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
378 } |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
379 |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
380 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
|
381 vgSetColor(paint, color); |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
382 canvas->paint_installed = 0; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
383 } |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
384 |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
385 void |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
386 mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas) { |
595 | 387 static VGint *scissors = NULL; |
388 static int n_scissors = 0; | |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
389 VGint *coord; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
390 area_t *area; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
391 int i; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
392 |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
393 _MK_CURRENT_CTX(canvas); |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
394 |
595 | 395 if(n_areas > n_scissors) { |
396 if(scissors) free(scissors); | |
604
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
397 n_scissors = (n_areas + 0xf) & ~0xf; |
595 | 398 scissors = (VGint *)malloc(sizeof(VGint) * n_scissors * 4); |
399 ASSERT(scissors != NULL); | |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
400 } |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
401 |
595 | 402 coord = scissors; |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
403 for(i = 0; i < n_areas; i++) { |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
404 area = areas[i]; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
405 *coord++ = area->x; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
406 *coord++ = area->y; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
407 *coord++ = area->w; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
408 *coord++ = area->h; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
409 } |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
410 |
616
7d70a811829b
mbe_fill_preserve() and mbe_reset_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
614
diff
changeset
|
411 vgSeti(VG_SCISSORING, VG_TRUE); |
595 | 412 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
|
413 } |
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
|
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 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
|
416 _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
|
417 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
|
418 EGLDisplay display; |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
419 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
|
420 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
|
421 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
|
422 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
|
423 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
|
424 |
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 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
|
426 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
|
427 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
|
428 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
|
429 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
|
430 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
|
431 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
|
432 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
|
433 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
|
434 attrib_list[i++] = 8; |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
435 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
|
436 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
|
437 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
|
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 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
|
440 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
|
441 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
|
442 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
|
443 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
|
444 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
|
445 attrib_list[i++] = 8; |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
446 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
|
447 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
|
448 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
|
449 |
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 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
|
451 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
|
452 attrib_list[i++] = 8; |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
453 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
|
454 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
|
455 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
|
456 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
457 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
|
458 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
|
459 attrib_list[i++] = 1; |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
460 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
|
461 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
|
462 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
|
463 |
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 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
|
465 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
|
466 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
|
467 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
|
468 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
|
469 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
|
470 attrib_list[i++] = 5; |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
471 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
|
472 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
|
473 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
|
474 |
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 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
|
476 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
|
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 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
|
480 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
|
481 #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
|
482 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
|
483 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
|
484 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
|
485 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
|
486 #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
|
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 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
|
489 |
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 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
|
491 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
|
492 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
|
493 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
|
494 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
495 *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
|
496 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
497 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
|
498 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
499 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
500 #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
|
501 #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
|
502 #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
|
503 |
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 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
|
505 _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
|
506 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
|
507 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
|
508 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
|
509 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
|
510 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
|
511 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
512 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
|
513 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
|
514 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
|
515 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
|
516 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
|
517 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
518 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
|
519 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
|
520 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
|
521 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
|
522 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
523 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
|
524 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
|
525 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
|
526 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
527 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
|
528 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
|
529 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
|
530 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
531 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
|
532 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
|
533 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
|
534 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
535 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
|
536 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
|
537 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
|
538 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
539 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
540 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
|
541 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
542 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
543 /*! \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
|
544 * |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
545 * 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
|
546 */ |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
547 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
|
548 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
|
549 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
|
550 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
|
551 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
|
552 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
|
553 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
|
554 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
|
555 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
|
556 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
|
557 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
558 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
|
559 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
|
560 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
|
561 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
562 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
|
563 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
|
564 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
|
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
|
566 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
|
567 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
|
568 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
|
569 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
570 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
|
571 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
|
572 |
605
a8fa4c550fe5
use O_ALLOC() to make code clear
Thinker K.F. Li <thinker@branda.to>
parents:
604
diff
changeset
|
573 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
|
574 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
|
575 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
|
576 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
|
577 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
578 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
579 surface->surface = egl_surface; |
619
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
580 surface->asso_img = NULL; |
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
|
581 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
582 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
|
583 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
584 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
585 #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
|
586 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
587 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
|
588 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
|
589 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
|
590 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
|
591 EGLConfig config; |
592
de9d210e9c38
Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents:
591
diff
changeset
|
592 EGLint attrib_list[5]; |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
593 _ge_openvg_img_t *ge_img; |
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
|
594 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
|
595 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
|
596 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
597 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
598 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
|
599 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
|
600 return NULL; |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
601 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
602 ge_img = _alloc_vgimage(fmt, w, h); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
603 if(ge_img == NULL) |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
604 return NULL; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
605 |
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
|
606 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
|
607 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
|
608 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
|
609 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
|
610 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
|
611 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
|
612 /* 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
|
613 * 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
|
614 */ |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
615 surface = eglCreatePbufferFromClientBuffer(display, EGL_OPENVG_IMAGE, |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
616 (EGLClientBuffer)ge_img->img, |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
617 config, attrib_list); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
618 if(surface == EGL_NO_SURFACE) { |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
619 _free_vgimage(ge_img); |
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
|
620 return NULL; |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
621 } |
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
|
622 |
605
a8fa4c550fe5
use O_ALLOC() to make code clear
Thinker K.F. Li <thinker@branda.to>
parents:
604
diff
changeset
|
623 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
|
624 if(mbe_surface == NULL) { |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
625 _free_vgimage(ge_img); |
591
71df2896877c
build graph_engine_openvg.c in makefile
Thinker K.F. Li <thinker@branda.to>
parents:
590
diff
changeset
|
626 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
|
627 return NULL; |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
628 } |
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
|
629 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
|
630 mbe_surface->asso_mbe = NULL; |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
631 mbe_surface->asso_img = ge_img; |
592
de9d210e9c38
Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents:
591
diff
changeset
|
632 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
|
633 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
|
634 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
635 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
|
636 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
637 |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
638 void |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
639 mbe_surface_destroy(mbe_surface_t *surface) { |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
640 EGLDisplay display; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
641 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
642 display = _VG_DISPLAY(); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
643 eglDestroySurface(display, surface->surface); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
644 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
645 if(surface->asso_mbe) |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
646 surface->asso_mbe->tgt = NULL; |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
647 |
619
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
648 if(surface->asso_img) |
618
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
649 _free_vgimage(surface->asso_img); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
650 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
651 free(surface); |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
652 } |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
653 |
622
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
654 void |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
655 mbe_copy_source(mbe_t *src_canvas, mbe_t *dst_canvas) { |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
656 VGImage vg_img; |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
657 |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
658 ASSERT(src_canvas->tgt->asso_img != NULL); |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
659 |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
660 _MK_CURRENT_CTX(dst_canvas); |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
661 |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
662 vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
663 vgLoadIdentity(); |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
664 |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
665 vg_img = src_canvas->tgt->asso_img; |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
666 vgDrawImage(vg_img); |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
667 } |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
668 |
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
|
669 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
|
670 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
|
671 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
|
672 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
|
673 EGLContext ctx, shared; |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
674 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
|
675 EGLint attrib_list[2] = {EGL_NONE}; |
613
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
676 static VGfloat clear_color[4] = {0, 0, 0, 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
|
677 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
|
678 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
679 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
|
680 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
|
681 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
|
682 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
|
683 |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
684 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
|
685 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
|
686 if(path == VG_INVALID_HANDLE) { |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
687 eglDestroyContext(display, ctx); |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
688 return NULL; |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
689 } |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
690 |
605
a8fa4c550fe5
use O_ALLOC() to make code clear
Thinker K.F. Li <thinker@branda.to>
parents:
604
diff
changeset
|
691 canvas = O_ALLOC(mbe_t); |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
692 if(canvas == NULL) { |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
693 eglDestroyContext(display, ctx); |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
694 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
|
695 return NULL; |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
696 } |
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
|
697 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
698 canvas->src = NULL; |
595 | 699 canvas->paint = VG_INVALID_HANDLE; |
597
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
700 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
|
701 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
|
702 canvas->ctx = ctx; |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
703 canvas->path = path; |
613
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
704 |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
705 /* Set clear color for the context */ |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
706 _MK_CURRENT_CTX(canvas); |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
707 vgSetfv(VG_CLEAR_COLOR, 4, clear_color); |
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
|
708 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
709 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
|
710 } |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
711 |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
712 void |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
713 mbe_destroy(mbe_t *canvas) { |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
714 EGLDisplay display; |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
715 |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
716 display = _VG_DISPLAY(); |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
717 |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
718 vgDestroyPath(canvas->path); |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
719 eglDestroyContext(display, canvas->ctx); |
591
71df2896877c
build graph_engine_openvg.c in makefile
Thinker K.F. Li <thinker@branda.to>
parents:
590
diff
changeset
|
720 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
|
721 free(canvas); |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
722 } |
593 | 723 |
608
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
724 void |
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
725 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
|
726 EGLDisplay display; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
727 VGHandle mask; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
728 EGLint w, h; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
729 EGLBoolean r; |
608
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
730 |
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
731 _MK_CURRENT_CTX(canvas); |
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
732 |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
733 display = _VG_DISPLAY(); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
734 |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
735 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
|
736 ASSERT(r == EGL_TRUE); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
737 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
|
738 ASSERT(r == EGL_TRUE); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
739 |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
740 /* 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
|
741 vgSeti(VG_MASKING, VG_TRUE); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
742 mask = vgCreateMaskLayer(w, h); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
743 ASSERT(mask != VG_INVALID_HANDLE); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
744 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
|
745 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
|
746 vgDestroyMaskLayer(mask); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
747 |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
748 mbe_paint(canvas); |
608
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
749 |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
750 vgSeti(VG_MASKING, VG_FALSE); |
608
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
751 } |
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
752 |
595 | 753 void |
754 mbe_paint(mbe_t *canvas) { | |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
755 EGLDisplay display; |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
756 EGLint w, h; |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
757 EGLBoolean r; |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
758 VGPath path; |
595 | 759 |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
760 _MK_CURRENT_CTX(canvas); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
761 _MK_CURRENT_PAINT(canvas); |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
762 if(canvas->src) |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
763 _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
|
764 VG_MATRIX_FILL_PAINT_TO_USER); |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
765 |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
766 display = _VG_DISPLAY(); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
767 |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
768 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
|
769 ASSERT(r == EGL_TRUE); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
770 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
|
771 ASSERT(r == EGL_TRUE); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
772 |
614
9c5705da2495
Fix the bug of foregting make current context before seting transform
Thinker K.F. Li <thinker@branda.to>
parents:
613
diff
changeset
|
773 /* |
9c5705da2495
Fix the bug of foregting make current context before seting transform
Thinker K.F. Li <thinker@branda.to>
parents:
613
diff
changeset
|
774 * Disable scissoring and identity transform matrix. |
9c5705da2495
Fix the bug of foregting make current context before seting transform
Thinker K.F. Li <thinker@branda.to>
parents:
613
diff
changeset
|
775 * |
9c5705da2495
Fix the bug of foregting make current context before seting transform
Thinker K.F. Li <thinker@branda.to>
parents:
613
diff
changeset
|
776 * Transform matrix from path to surface is assigned by |
9c5705da2495
Fix the bug of foregting make current context before seting transform
Thinker K.F. Li <thinker@branda.to>
parents:
613
diff
changeset
|
777 * mbe_transform(). Here, we temporary set it to identity, and |
9c5705da2495
Fix the bug of foregting make current context before seting transform
Thinker K.F. Li <thinker@branda.to>
parents:
613
diff
changeset
|
778 * restore it after paint. |
9c5705da2495
Fix the bug of foregting make current context before seting transform
Thinker K.F. Li <thinker@branda.to>
parents:
613
diff
changeset
|
779 */ |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
780 vgSeti(VG_SCISSORING, VG_FALSE); |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
781 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
|
782 vgLoadIdentity(); |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
783 |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
784 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
|
785 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
|
786 vguRect(path, 0, 0, w, h); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
787 vgDrawPath(path, VG_FILL_PATH); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
788 vgDestroyPath(path); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
789 |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
790 /* 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
|
791 vgLoadMatrix(canvas->mtx); |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
792 vgSeti(VG_SCISSORING, VG_TRUE); |
595 | 793 } |
794 | |
597
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
795 void |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
796 mbe_clear(mbe_t *canvas) { |
613
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
797 EGLDisplay display; |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
798 EGLint w, h; |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
799 EGLBoolean r; |
597
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
800 |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
801 _MK_CURRENT_CTX(canvas); |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
802 |
613
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
803 display = _VG_DISPLAY(); |
597
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
804 |
613
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
805 r = eglQuerySurface(display, canvas->tgt, EGL_WIDTH, &w); |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
806 ASSERT(r == EGL_TRUE); |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
807 r = eglQuerySurface(display, canvas->tgt, EGL_HEIGHT, &h); |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
808 ASSERT(r == EGL_TRUE); |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
809 |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
810 /* Clear regions to the color specified by mbe_create() */ |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
811 vgClear(0, 0, w, h); |
597
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
812 } |