annotate src/graph_engine_openvg.c @ 1081:14c2bdcbbcca openvg

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