Mercurial > MadButterfly
annotate src/graph_engine_openvg.c @ 598:aba62eb9362d openvg
define color source for VG
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 01 Jul 2010 16:16:46 +0800 |
parents | 3300992b29ff |
children | 20b396c09c23 |
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" |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 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
|
4 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
|
5 |
589
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
6 #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
|
7 #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
|
8 #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
|
9 |
598
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
10 #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
|
11 (((int)(0xf * g) & 0xf) << 16) | \ |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
12 (((int)(0xf * b) & 0xf) << 16) | \ |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
13 ((int)(0xf * a) & 0xf)) |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
14 |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
15 void mbe_set_source_rgba(mbe_t *canvas, co_comp_t r, co_comp_t g, |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
16 co_comp_t b, co_comp_t a) { |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
17 VGPaint paint; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
18 VGuint color; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
19 |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
20 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
|
21 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
|
22 else { |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
23 paint = vgCreatePaint(); |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
24 ASSERT(paint != VG_INVALID_HANDLE); |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
25 canvas->paint = paint; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
26 canvas->src = NULL; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
27 } |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
28 |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
29 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
|
30 vgSetColor(paint, color); |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
31 canvas->paint_installed = 0; |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
32 } |
aba62eb9362d
define color source for VG
Thinker K.F. Li <thinker@branda.to>
parents:
597
diff
changeset
|
33 |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
34 void |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
35 mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas) { |
595 | 36 static VGint *scissors = NULL; |
37 static int n_scissors = 0; | |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
38 VGint *coord; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
39 area_t *area; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
40 int i; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
41 |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
42 _MK_CURRENT_CTX(canvas); |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
43 |
595 | 44 if(n_areas > n_scissors) { |
45 if(scissors) free(scissors); | |
46 n_scissors = (n_areas + 0xf) & 0xf; | |
47 scissors = (VGint *)malloc(sizeof(VGint) * n_scissors * 4); | |
48 ASSERT(scissors != NULL); | |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
49 } |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
50 |
595 | 51 coord = scissors; |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
52 for(i = 0; i < n_areas; i++) { |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
53 area = areas[i]; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
54 *coord++ = area->x; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
55 *coord++ = area->y; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
56 *coord++ = area->w; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
57 *coord++ = area->h; |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
58 } |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
59 |
595 | 60 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
|
61 } |
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
|
62 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
63 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
|
64 _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
|
65 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
|
66 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
|
67 EGLint attrib_list[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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 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
|
98 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
99 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
|
100 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
|
101 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
|
102 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
|
103 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
113 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
|
114 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
|
115 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
116 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
117 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
|
118 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
|
119 #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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 #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
|
125 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
126 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
|
127 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
128 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
|
129 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
|
130 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
|
131 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
|
132 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
133 *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
|
134 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
135 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
|
136 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
137 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
138 #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
|
139 #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
|
140 #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
|
141 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
142 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
|
143 _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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
150 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
|
151 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
|
152 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
|
153 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
|
154 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
|
155 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
156 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
|
157 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
|
158 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
|
159 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
|
160 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
161 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
|
162 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
|
163 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
|
164 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
165 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
|
166 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
|
167 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
|
168 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
169 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
|
170 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
|
171 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
|
172 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
173 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
|
174 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
|
175 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
|
176 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
177 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
178 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
|
179 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
180 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
181 /*! \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
|
182 * |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
183 * 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
|
184 */ |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
185 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
|
186 mbe_vg_win_surface_create(Display *display, Drawable drawable, |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
187 Visual *visual, int width, int height) { |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
188 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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 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
|
195 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
200 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
|
201 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
|
202 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
|
203 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
204 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
|
205 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
|
206 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
|
207 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
208 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
|
209 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
|
210 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
211 surface = (mbe_surface_t *)malloc(sizeof(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
|
212 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
|
213 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
|
214 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
|
215 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
216 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
217 surface->surface = egl_surface; |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
218 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
219 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
|
220 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
221 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
222 #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
|
223 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
224 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
|
225 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
|
226 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
|
227 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
|
228 EGLConfig config; |
592
de9d210e9c38
Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents:
591
diff
changeset
|
229 EGLint attrib_list[5]; |
589
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
230 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
|
231 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
|
232 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
233 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
234 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
|
235 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
|
236 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
|
237 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
238 display = _VG_DISPLAY(); |
592
de9d210e9c38
Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents:
591
diff
changeset
|
239 attrib_list[0] = EGL_WIDTH; |
de9d210e9c38
Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents:
591
diff
changeset
|
240 attrib_list[1] = w; |
de9d210e9c38
Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents:
591
diff
changeset
|
241 attrib_list[2] = EGL_HEIGHT; |
de9d210e9c38
Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents:
591
diff
changeset
|
242 attrib_list[3] = h; |
de9d210e9c38
Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents:
591
diff
changeset
|
243 attrib_list[4] = EGL_NONE; |
589
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
244 /* 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
|
245 * We need use some other surface to replace this one. |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
246 */ |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
247 surface = eglCreatePbufferSurface(display, config, attrib_list); |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
248 if(surface == EGL_NO_SURFACE) |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
249 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
|
250 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
251 mbe_surface = (mbe_surface_t *)malloc(sizeof(mbe_surface_t)); |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
252 if(mbe_surface == NULL) { |
591
71df2896877c
build graph_engine_openvg.c in makefile
Thinker K.F. Li <thinker@branda.to>
parents:
590
diff
changeset
|
253 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
|
254 return NULL; |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
255 } |
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
|
256 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
|
257 mbe_surface->asso_mbe = NULL; |
592
de9d210e9c38
Specify width and height while create an image surface
Thinker K.F. Li <thinker@branda.to>
parents:
591
diff
changeset
|
258 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
|
259 mbe_surface->h = h; |
589
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
260 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
261 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
|
262 } |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
263 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
264 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
|
265 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
|
266 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
|
267 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
|
268 EGLContext ctx, shared; |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
269 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
|
270 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
|
271 mbe_t *canvas; |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
272 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
273 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
|
274 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
|
275 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
|
276 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
|
277 |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
278 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
|
279 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
|
280 if(path == VG_INVALID_HANDLE) { |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
281 eglDestroyContext(display, ctx); |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
282 return NULL; |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
283 } |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
284 |
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
|
285 canvas = (mbe_t *)malloc(sizeof(mbe_t)); |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
286 if(canvas == NULL) { |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
287 eglDestroyContext(display, ctx); |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
288 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
|
289 return NULL; |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
290 } |
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
|
291 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
292 canvas->src = NULL; |
595 | 293 canvas->paint = VG_INVALID_HANDLE; |
597
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
294 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
|
295 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
|
296 canvas->ctx = ctx; |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
297 canvas->path = path; |
589
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
298 |
d733e198bb25
Move functions from mb_graph_engine_openvg.h to the C file
Thinker K.F. Li <thinker@branda.to>
parents:
588
diff
changeset
|
299 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
|
300 } |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
301 |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
302 void |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
303 mbe_destroy(mbe_t *canvas) { |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
304 EGLDisplay display; |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
305 |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
306 display = _VG_DISPLAY(); |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
307 |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
308 vgDestroyPath(canvas->path); |
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
309 eglDestroyContext(display, canvas->ctx); |
591
71df2896877c
build graph_engine_openvg.c in makefile
Thinker K.F. Li <thinker@branda.to>
parents:
590
diff
changeset
|
310 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
|
311 free(canvas); |
590
b714f0c9992e
include a VGPath in VG canvas
Thinker K.F. Li <thinker@branda.to>
parents:
589
diff
changeset
|
312 } |
593 | 313 |
595 | 314 void |
315 mbe_paint(mbe_t *canvas) { | |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
316 EGLDisplay display; |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
317 EGLint w, h; |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
318 EGLBoolean r; |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
319 VGPath path; |
595 | 320 |
596
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
321 _MK_CURRENT_CTX(canvas); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
322 _MK_CURRENT_PAINT(canvas); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
323 |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
324 display = _VG_DISPLAY(); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
325 |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
326 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
|
327 ASSERT(r == EGL_TRUE); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
328 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
|
329 ASSERT(r == EGL_TRUE); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
330 |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
331 vgSeti(VG_SCISSORING, VG_FALSE); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
332 |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
333 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
|
334 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
|
335 vguRect(path, 0, 0, w, h); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
336 vgDrawPath(path, VG_FILL_PATH); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
337 vgDestroyPath(path); |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
338 |
aaab76730beb
Define mbe_paint() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
595
diff
changeset
|
339 vgSeti(VG_SCISSORING, VG_TRUE); |
595 | 340 } |
341 | |
597
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
342 void |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
343 mbe_clear(mbe_t *canvas) { |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
344 VGPaint paint; |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
345 |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
346 _MK_CURRENT_CTX(canvas); |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
347 |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
348 paint = vgCreatePaint(); |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
349 ASSERT(paint != VG_INVALID_HANDLE); |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
350 vgSetColor(paint, 0); |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
351 |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
352 vgSetPaint(paint, VG_FILL_PATH); |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
353 vgSeti(VG_BLEND_MODE, VG_BLEND_SRC); |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
354 vgDrawPath(canvas->path, VG_FILL_PATH); |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
355 vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER); |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
356 |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
357 vgDestroyPaint(paint); |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
358 |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
359 canvas->paint_installed = 0; |
3300992b29ff
Define mbe_clear() for VG
Thinker K.F. Li <thinker@branda.to>
parents:
596
diff
changeset
|
360 } |