Mercurial > MadButterfly
annotate src/graph_engine_openvg.c @ 1077:e224f496e6b8 openvg
Add missed functions for openvg
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 01 Dec 2010 23:00:36 +0800 |
parents | bd18951b51d5 |
children | 394d7d4c0673 |
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 |
1077
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
11 #ifndef ERR |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
12 #include <stdio.h> |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
13 #include <stdlib.h> |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
14 #define ERR(msg) do { fprintf(stderr, __FILE__ ":%d: %s", __LINE__, msg); abort(); } while(0) |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
15 #endif |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
16 #ifndef NOT_IMPLEMENT |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
17 #define NOT_IMPLEMENT(func) \ |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
18 ERR(func " is not impmemented\n") |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
19 #endif |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
20 |
598
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
21 #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
|
22 (((int)(0xf * g) & 0xf) << 16) | \ |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
23 (((int)(0xf * b) & 0xf) << 16) | \ |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
24 ((int)(0xf * a) & 0xf)) |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
25 |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
26 #define MK_ID(mtx) \ |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
27 do { \ |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
28 (mtx)[0] = 1; \ |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
29 (mtx)[1] = 0; \ |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
30 (mtx)[2] = 0; \ |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
31 (mtx)[3] = 0; \ |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
32 (mtx)[4] = 1; \ |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
33 (mtx)[5] = 0; \ |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
34 (mtx)[6] = 0; \ |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
35 (mtx)[7] = 0; \ |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
36 (mtx)[8] = 1; \ |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
37 } while(0) |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
38 |
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
|
39 /*! \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
|
40 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
|
41 _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
|
42 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
|
43 |
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 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
|
45 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
|
46 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
|
47 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
|
48 |
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 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
|
50 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
|
51 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
|
52 |
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 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
|
54 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
|
55 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
|
56 |
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 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
|
58 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
|
59 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
|
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 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
|
62 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
|
63 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
|
64 |
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 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
|
66 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
|
67 } |
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 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
|
70 } |
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 |
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 /*! \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
|
73 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
|
74 _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
|
75 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
|
76 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
|
77 _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
|
78 |
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 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 } |
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 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
|
92 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
|
93 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
|
94 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
|
95 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
96 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
|
97 } |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
98 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
99 /*! \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
|
100 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
|
101 _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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 } |
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
|
107 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
|
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 |
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
|
110 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
|
111 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
|
112 } |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
113 |
619
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
114 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
|
115 _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
|
116 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
|
117 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
|
118 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
119 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
|
120 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
|
121 } |
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 /*! \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
|
124 * |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
125 * \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
|
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 void |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
128 _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
|
129 _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
|
130 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
|
131 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
|
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 = 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
|
134 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
|
135 return; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
136 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
137 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
|
138 return; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
139 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
140 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
|
141 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
|
142 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
143 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
|
144 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
|
145 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
146 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
|
147 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
|
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 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
|
150 } |
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 /*! \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
|
153 * |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
154 * 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
|
155 * 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
|
156 * 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
|
157 * 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
|
158 */ |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
159 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
|
160 _ge_vg_img_deactivate_for_surface(void *obj) { |
1077
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
161 NOT_IMPLEMENT("_ge_vg_img_deactivate_for_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
|
162 } |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
163 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
164 /*! \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
|
165 * |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
166 * \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
|
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 void |
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_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
|
170 _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
|
171 |
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 = 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
|
173 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
|
174 return; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
175 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
176 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
|
177 return; |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
178 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
179 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
|
180 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
|
181 |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
182 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
|
183 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
|
184 } |
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
185 |
610
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
186 /* |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
187 * 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
|
188 */ |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
189 mbe_pattern_t * |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
190 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
|
191 mbe_pattern_t *pattern; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
192 _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
|
193 VGfloat *mtx; |
610
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
194 VGPaint paint; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
195 |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
196 /* Support only from image surface */ |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
197 if(surface->asso_img == NULL) |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
198 return NULL; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
199 |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
200 paint = vgCreatePaint(); |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
201 if(paint == VG_INVALID_HANDLE) |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
202 return NULL; |
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 ge_img = surface->asso_img; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
205 pattern = O_ALLOC(mbe_pattern_t); |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
206 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
|
207 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
|
208 pattern->paint = paint; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
209 |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
210 mtx = pattern->mtx; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
211 MK_ID(mtx); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
212 |
610
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
213 return pattern; |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
214 } |
e78bff7d23d3
create pattern from surface for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
608
diff
changeset
|
215 |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
216 void |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
217 _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
|
218 VGfloat affine; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
219 |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
220 vgSeti(VG_MATRIX_MODE, mode); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
221 vgLoadMatrix(mtx1); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
222 if(mtx2) |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
223 vgMultMatrix(mtx2); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
224 } |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
225 |
606
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
226 static mbe_pattern_t * |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
227 _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
|
228 int grad_type, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
229 grad_stop_t *stops, int stop_cnt) { |
604
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
230 VGPaint paint; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
231 mbe_pattern_t *pattern; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
232 static VGfloat *ov_stops = 0; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
233 static int max_stop_cnt = 0; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
234 VGfloat *cur_ov_stop; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
235 grad_stop_t *cur_stop; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
236 int i; |
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 /* Make sure there is enough space */ |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
239 if(max_stop_cnt < stop_cnt) { |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
240 max_stop_cnt = (stop_cnt + 0xf) & ~0xf; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
241 cur_ov_stop = (VGfloat *)realloc(stops, |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
242 max_stop_cnt * sizeof(VGfloat) * 5); |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
243 if(cur_ov_stop == NULL) { |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
244 max_stop_cnt = 0; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
245 return NULL; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
246 } |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
247 ov_stops = cur_ov_stop; |
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 cur_ov_stop = ov_stops; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
250 |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
251 cur_stop = stops; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
252 for(i = 0; i < stop_cnt; i++) { |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
253 *cur_ov_stop++ = cur_stop->offset; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
254 *cur_ov_stop++ = cur_stop->r; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
255 *cur_ov_stop++ = cur_stop->g; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
256 *cur_ov_stop++ = cur_stop->b; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
257 *cur_ov_stop++ = cur_stop->a; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
258 } |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
259 |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
260 paint = vgCreatePaint(); |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
261 if(paint == VG_INVALID_HANDLE) |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
262 return NULL; |
606
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
263 vgSetParameteri(paint, VG_PAINT_TYPE, grad_type); |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
264 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
|
265 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
|
266 |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
267 pattern = O_ALLOC(mbe_pattern_t); |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
268 if(pattern == NULL) { |
627
97bf0ff7a038
linked with libEGL and libOpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
622
diff
changeset
|
269 vgDestroyPaint(paint); |
604
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
270 return NULL; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
271 } |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
272 |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
273 pattern->paint = paint; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
274 pattern->asso_img = NULL; |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
275 |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
276 MK_ID(pattern->mtx); |
604
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
277 |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
278 return pattern; |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
279 } |
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
280 |
606
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
281 /* |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
282 * \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
|
283 * point. It means radius0 is not working. |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
284 */ |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
285 mbe_pattern_t * |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
286 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
|
287 co_aix radius0, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
288 co_aix cx1, co_aix cy1, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
289 co_aix radius1, grad_stop_t *stops, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
290 int stop_cnt) { |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
291 mbe_pattern_t *pattern; |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
292 VGfloat gradient[] = {cx0, cy0, cx1, cy1, radius1}; |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
293 |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
294 pattern = _mbe_pattern_create_gradient(gradient, 5, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
295 VG_PAINT_TYPE_RADIAL_GRADIENT, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
296 stops, stop_cnt); |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
297 return pattern; |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
298 } |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
299 |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
300 mbe_pattern_t * |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
301 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
|
302 co_aix x1, co_aix y1, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
303 grad_stop_t *stops, int stop_cnt) { |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
304 mbe_pattern_t *pattern; |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
305 VGfloat gradient[] = {x0, y0, x1, y1}; |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
306 |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
307 pattern = _mbe_pattern_create_gradient(gradient, 4, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
308 VG_PAINT_TYPE_LINEAR_GRADIENT, |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
309 stops, stop_cnt); |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
310 return pattern; |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
311 } |
e21eb54c7d9c
Implement radial gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
605
diff
changeset
|
312 |
607
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
313 mbe_pattern_t * |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
314 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
|
315 VGPaint paint; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
316 mbe_pattern_t *pattern; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
317 _ge_openvg_img_t *ge_img; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
318 VGImage vg_img; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
319 VGImageFormat fmt = VG_sARGB_8888; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
320 |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
321 /* \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
|
322 * image. |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
323 */ |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
324 if(img->fmt != MB_IFMT_ARGB32) |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
325 return NULL; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
326 |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
327 /* 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
|
328 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
|
329 pattern = O_ALLOC(mbe_pattern_t); |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
330 paint = vgCreatePaint(); |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
331 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
|
332 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
|
333 |
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 /* 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
|
335 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
|
336 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
|
337 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
|
338 |
607
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
339 pattern->paint = paint; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
340 pattern->asso_img = ge_img; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
341 |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
342 return pattern; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
343 |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
344 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
|
345 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
|
346 if(pattern) free(pattern); |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
347 if(paint != VG_INVALID_HANDLE) vgDestroyPaint(paint); |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
348 vgDestroyImage(vg_img); |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
349 return NULL; |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
350 } |
51dc49fd34a8
Create pattern from an image
Thinker K.F. Li <thinker@branda.to>
parents:
606
diff
changeset
|
351 |
600
20b396c09c23
Integrate pattern source with paint model of canvas
Thinker K.F. Li <thinker@branda.to>
parents:
598
diff
changeset
|
352 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
|
353 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
|
354 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
|
355 _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
|
356 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
|
357 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
|
358 } |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
359 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
360 void |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
361 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
|
362 co_aix rev[6]; |
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 compute_reverse(mtx, rev); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
365 ptn->mtx[0] = rev[0]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
366 ptn->mtx[1] = rev[3]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
367 ptn->mtx[2] = 0; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
368 ptn->mtx[3] = rev[1]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
369 ptn->mtx[4] = rev[4]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
370 ptn->mtx[5] = 0; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
371 ptn->mtx[6] = rev[2]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
372 ptn->mtx[7] = rev[5]; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
373 ptn->mtx[8] = 1; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
374 } |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
375 |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
376 void |
600
20b396c09c23
Integrate pattern source with paint model of canvas
Thinker K.F. Li <thinker@branda.to>
parents:
598
diff
changeset
|
377 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
|
378 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
|
379 VGPaint paint; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
380 VGuint color; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
381 |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
382 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
|
383 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
|
384 else { |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
385 paint = vgCreatePaint(); |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
386 ASSERT(paint != VG_INVALID_HANDLE); |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
387 canvas->paint = paint; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
388 canvas->src = NULL; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
389 } |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
390 |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
391 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
|
392 vgSetColor(paint, color); |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
393 canvas->paint_installed = 0; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
394 } |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
395 |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
396 void |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
397 mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas) { |
595 | 398 static VGint *scissors = NULL; |
399 static int n_scissors = 0; | |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
400 VGint *coord; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
401 area_t *area; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
402 int i; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
403 |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
404 _MK_CURRENT_CTX(canvas); |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
405 |
595 | 406 if(n_areas > n_scissors) { |
407 if(scissors) free(scissors); | |
604
38514a7c6b26
Linear gradient for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
600
diff
changeset
|
408 n_scissors = (n_areas + 0xf) & ~0xf; |
595 | 409 scissors = (VGint *)malloc(sizeof(VGint) * n_scissors * 4); |
410 ASSERT(scissors != NULL); | |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
411 } |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
412 |
595 | 413 coord = scissors; |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
414 for(i = 0; i < n_areas; i++) { |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
415 area = areas[i]; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
416 *coord++ = area->x; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
417 *coord++ = area->y; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
418 *coord++ = area->w; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
419 *coord++ = area->h; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
420 } |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
421 |
616
7d70a811829b
mbe_fill_preserve() and mbe_reset_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
614
diff
changeset
|
422 vgSeti(VG_SCISSORING, VG_TRUE); |
595 | 423 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
|
424 } |
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
|
425 |
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 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
|
427 _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
|
428 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
|
429 EGLDisplay display; |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
430 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
|
431 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
|
432 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
|
433 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
|
434 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
|
435 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
436 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
|
437 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
|
438 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
|
439 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
|
440 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
|
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_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
|
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_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
|
445 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
|
446 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
|
447 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
448 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
|
449 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
|
450 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
|
451 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
|
452 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
|
453 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
|
454 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
|
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_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
|
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++] = 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
|
460 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
|
461 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
462 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
|
463 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
|
464 attrib_list[i++] = 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
|
465 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
|
466 |
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 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
|
468 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
|
469 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
|
470 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
|
471 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
|
472 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
|
473 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
|
474 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
|
475 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
476 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
|
477 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
|
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 |
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_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
|
481 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
|
482 #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
|
483 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
|
484 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
|
485 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
|
486 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
|
487 #endif |
630
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
488 |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
489 attrib_list[i++] = EGL_RENDERABLE_TYPE; |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
490 attrib_list[i++] = EGL_OPENVG_BIT; |
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
|
491 |
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 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
|
493 |
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 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
|
495 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
|
496 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
|
497 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
|
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 *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
|
500 |
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 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
|
502 } |
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 #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
|
505 #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
|
506 #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
|
507 |
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 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
|
509 _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
|
510 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
|
511 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
|
512 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
|
513 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
|
514 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
|
515 |
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 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
|
517 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
|
518 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
|
519 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
|
520 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
|
521 |
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 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
|
523 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
|
524 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
|
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 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
|
528 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
|
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 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
|
532 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
|
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 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
|
536 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
|
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 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
|
540 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
|
541 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
|
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 |
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 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
|
545 } |
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 /*! \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
|
548 * |
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 * 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
|
550 */ |
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 mbe_surface_t * |
1077
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
552 mbe_win_surface_create(Display *display, Drawable drawable, |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
553 Visual *visual, int width, int height) { |
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
|
554 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
|
555 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
|
556 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
|
557 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
|
558 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
|
559 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
|
560 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
|
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 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
|
563 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
|
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 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
|
567 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
|
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_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
|
571 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
|
572 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
|
573 |
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 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
|
575 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
|
576 |
605
a8fa4c550fe5
use O_ALLOC() to make code clear
Thinker K.F. Li <thinker@branda.to>
parents:
604
diff
changeset
|
577 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
|
578 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
|
579 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
|
580 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
|
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 |
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 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
|
584 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
|
585 |
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 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
|
587 } |
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 |
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 #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
|
590 |
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 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
|
592 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
|
593 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
|
594 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
|
595 EGLConfig config; |
592
de9d210e9c38
Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents:
591
diff
changeset
|
596 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
|
597 _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
|
598 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
|
599 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
|
600 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
601 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
602 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
|
603 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
|
604 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
|
605 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
606 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
|
607 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
|
608 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
|
609 |
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
|
610 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
|
611 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
|
612 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
|
613 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
|
614 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
|
615 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
|
616 /* 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
|
617 * 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
|
618 */ |
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
|
619 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
|
620 (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
|
621 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
|
622 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
|
623 _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
|
624 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
|
625 } |
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
|
626 |
605
a8fa4c550fe5
use O_ALLOC() to make code clear
Thinker K.F. Li <thinker@branda.to>
parents:
604
diff
changeset
|
627 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
|
628 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
|
629 _free_vgimage(ge_img); |
591
71df2896877c
build graph_engine_openvg.c in makefile
Thinker K.F. Li <thinker@branda.to>
parents:
590
diff
changeset
|
630 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
|
631 return NULL; |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
632 } |
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
|
633 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
|
634 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
|
635 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
|
636 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
|
637 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
|
638 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
639 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
|
640 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
641 |
1077
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
642 mbe_surface_t * |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
643 mbe_image_surface_create_for_data(unsigned char *data, |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
644 mb_img_fmt_t fmt, |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
645 int width, int height, |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
646 int stride) { |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
647 NOT_IMPLEMENT("mbe_image_surface_create_for_data"); |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
648 return NULL; |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
649 } |
e224f496e6b8
Add missed functions for openvg
Thinker K.F. Li <thinker@codemud.net>
parents:
630
diff
changeset
|
650 |
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
|
651 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
|
652 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
|
653 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
|
654 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
655 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
|
656 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
|
657 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
658 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
|
659 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
|
660 |
619
7020ed3c3e37
Actiavte a VGImage before using a pattern paint or image surface.
Thinker K.F. Li <thinker@branda.to>
parents:
618
diff
changeset
|
661 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
|
662 _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
|
663 |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
664 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
|
665 } |
35a67a837a53
Use reference count to trace life of _ge_openvg_img_t objects
Thinker K.F. Li <thinker@branda.to>
parents:
616
diff
changeset
|
666 |
622
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
667 void |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
668 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
|
669 VGImage vg_img; |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
670 |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
671 ASSERT(src_canvas->tgt->asso_img != NULL); |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
672 |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
673 _MK_CURRENT_CTX(dst_canvas); |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
674 |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
675 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
|
676 vgLoadIdentity(); |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
677 |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
678 vg_img = src_canvas->tgt->asso_img; |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
679 vgDrawImage(vg_img); |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
680 } |
39bd74da7f92
mbe_copy_source() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
619
diff
changeset
|
681 |
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
|
682 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
|
683 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
|
684 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
|
685 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
|
686 EGLContext ctx, shared; |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
687 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
|
688 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
|
689 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
|
690 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
|
691 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
692 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
|
693 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
|
694 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
|
695 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
|
696 |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
697 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
|
698 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
|
699 if(path == VG_INVALID_HANDLE) { |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
700 eglDestroyContext(display, ctx); |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
701 return NULL; |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
702 } |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
703 |
605
a8fa4c550fe5
use O_ALLOC() to make code clear
Thinker K.F. Li <thinker@branda.to>
parents:
604
diff
changeset
|
704 canvas = O_ALLOC(mbe_t); |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
705 if(canvas == NULL) { |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
706 eglDestroyContext(display, ctx); |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
707 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
|
708 return NULL; |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
709 } |
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
|
710 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
711 canvas->src = NULL; |
595 | 712 canvas->paint = VG_INVALID_HANDLE; |
597
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
713 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
|
714 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
|
715 canvas->ctx = ctx; |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
716 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
|
717 |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
718 /* 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
|
719 _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
|
720 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
|
721 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
722 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
|
723 } |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
724 |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
725 void |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
726 mbe_destroy(mbe_t *canvas) { |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
727 EGLDisplay display; |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
728 |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
729 display = _VG_DISPLAY(); |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
730 |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
731 vgDestroyPath(canvas->path); |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
732 eglDestroyContext(display, canvas->ctx); |
591
71df2896877c
build graph_engine_openvg.c in makefile
Thinker K.F. Li <thinker@branda.to>
parents:
590
diff
changeset
|
733 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
|
734 free(canvas); |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
735 } |
593 | 736 |
608
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
737 void |
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
738 mbe_paint_with_alpha(mbe_t *canvas, co_comp_t alpha) { |
629
608f58b9b84d
Use color transform and make compatible with OpenVG 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
627
diff
changeset
|
739 VGfloat color_trans[8] = {1, 1, 1, alpha, 0, 0, 0, 0}; |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
740 EGLDisplay display; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
741 EGLint w, h; |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
742 EGLBoolean r; |
608
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
743 |
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
744 _MK_CURRENT_CTX(canvas); |
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
745 |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
746 display = _VG_DISPLAY(); |
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 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
|
749 ASSERT(r == EGL_TRUE); |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
750 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
|
751 ASSERT(r == EGL_TRUE); |
629
608f58b9b84d
Use color transform and make compatible with OpenVG 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
627
diff
changeset
|
752 |
608f58b9b84d
Use color transform and make compatible with OpenVG 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
627
diff
changeset
|
753 /* Setup color transform for alpha */ |
608f58b9b84d
Use color transform and make compatible with OpenVG 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
627
diff
changeset
|
754 #ifdef OPENVG_1_1 |
608f58b9b84d
Use color transform and make compatible with OpenVG 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
627
diff
changeset
|
755 vgSetfv(VG_COLOR_TRANSFORM_VALUES, 8, color_trans); |
608f58b9b84d
Use color transform and make compatible with OpenVG 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
627
diff
changeset
|
756 vgSeti(VG_COLOR_TRANSFORM, VG_TRUE); |
608f58b9b84d
Use color transform and make compatible with OpenVG 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
627
diff
changeset
|
757 #endif |
608f58b9b84d
Use color transform and make compatible with OpenVG 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
627
diff
changeset
|
758 |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
759 mbe_paint(canvas); |
608
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
760 |
629
608f58b9b84d
Use color transform and make compatible with OpenVG 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
627
diff
changeset
|
761 #ifdef OPENVG_1_1 |
608f58b9b84d
Use color transform and make compatible with OpenVG 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
627
diff
changeset
|
762 vgSeti(VG_COLOR_TRANSFORM, VG_FALSE); |
608f58b9b84d
Use color transform and make compatible with OpenVG 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
627
diff
changeset
|
763 #endif |
608
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
764 } |
6c74bc371e37
paint with alpha for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
607
diff
changeset
|
765 |
595 | 766 void |
767 mbe_paint(mbe_t *canvas) { | |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
768 EGLDisplay display; |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
769 EGLint w, h; |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
770 EGLBoolean r; |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
771 VGPath path; |
595 | 772 |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
773 _MK_CURRENT_CTX(canvas); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
774 _MK_CURRENT_PAINT(canvas); |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
775 if(canvas->src) |
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
776 _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
|
777 VG_MATRIX_FILL_PAINT_TO_USER); |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
778 |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
779 display = _VG_DISPLAY(); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
780 |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
781 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
|
782 ASSERT(r == EGL_TRUE); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
783 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
|
784 ASSERT(r == EGL_TRUE); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
785 |
614
9c5705da2495
Fix the bug of foregting make current context before seting transform
Thinker K.F. Li <thinker@branda.to>
parents:
613
diff
changeset
|
786 /* |
9c5705da2495
Fix the bug of foregting make current context before seting transform
Thinker K.F. Li <thinker@branda.to>
parents:
613
diff
changeset
|
787 * 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
|
788 * |
9c5705da2495
Fix the bug of foregting make current context before seting transform
Thinker K.F. Li <thinker@branda.to>
parents:
613
diff
changeset
|
789 * 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
|
790 * 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
|
791 * 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
|
792 */ |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
793 vgSeti(VG_SCISSORING, VG_FALSE); |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
794 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
|
795 vgLoadIdentity(); |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
796 |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
797 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
|
798 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
|
799 vguRect(path, 0, 0, w, h); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
800 vgDrawPath(path, VG_FILL_PATH); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
801 vgDestroyPath(path); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
802 |
612
b1d1b6c5af90
Implements setting pattern matrix for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
610
diff
changeset
|
803 /* 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
|
804 vgLoadMatrix(canvas->mtx); |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
805 vgSeti(VG_SCISSORING, VG_TRUE); |
595 | 806 } |
807 | |
597
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
808 void |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
809 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
|
810 EGLDisplay display; |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
811 EGLint w, h; |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
812 EGLBoolean r; |
597
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
813 |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
814 _MK_CURRENT_CTX(canvas); |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
815 |
613
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
816 display = _VG_DISPLAY(); |
597
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
817 |
613
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
818 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
|
819 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
|
820 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
|
821 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
|
822 |
6a0be737a3f3
mbe_clear() use vgClear() to clear regions for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
612
diff
changeset
|
823 /* 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
|
824 vgClear(0, 0, w, h); |
597
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
825 } |
630
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
826 |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
827 void mbe_init() { |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
828 static EGLContext init_ctx; |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
829 static EGLSurface init_surf; |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
830 EGLDisplay display; |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
831 EGLConfig config; |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
832 EGLint nconfigs; |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
833 EGLint attrib_list[] = { |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
834 EGL_RED_SIZE, 1, |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
835 EGL_GREEN_SIZE, 1, |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
836 EGL_BLUE_SIZE, 1, |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
837 EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT, |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
838 EGL_NONE}; |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
839 EGLint surf_attribs[] = { |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
840 EGL_WIDTH, 1, |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
841 EGL_HEIGHT, 1, |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
842 EGL_NONE}; |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
843 EGLBoolean r; |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
844 |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
845 display = _VG_DISPLAY(); |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
846 eglInitialize(display, NULL, NULL); |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
847 |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
848 r = eglChooseConfig(display, attrib_list, &config, 1, &nconfigs); |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
849 ASSERT(r); |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
850 |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
851 eglBindAPI(EGL_OPENVG_API); |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
852 |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
853 init_ctx = eglCreateContext(display, config, EGL_NO_CONTEXT, NULL); |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
854 ASSERT(init_ctx != EGL_NO_CONTEXT); |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
855 |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
856 init_surf = eglCreatePbufferSurface(display, config, surf_attribs); |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
857 ASSERT(init_surf != EGL_NO_SURFACE); |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
858 |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
859 eglMakeCurrent(display, init_surf, init_surf, init_ctx); |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
860 } |
bd18951b51d5
Add initial code for graphic engines
Thinker K.F. Li <thinker@branda.to>
parents:
629
diff
changeset
|
861 |