Mercurial > MadButterfly
annotate include/mb_graph_engine_openvg.h @ 588:e9923024f65e openvg
Implement mbe_scissoring() for OpenVG
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 30 Jun 2010 17:45:30 +0800 |
parents | b42d69ab8857 |
children | d733e198bb25 |
rev | line source |
---|---|
578
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1 #ifndef __MB_GE_OPENVG_H_ |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 #define __MB_GE_OPENVG_H_ |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 #include <stdio.h> |
582
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
5 #include <stdlib.h> |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
6 #include <EGL/egl.h> |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
7 #include <VG/openvg.h> |
578
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 #include "mb_basic_types.h" |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 #include "mb_img_ldr.h" |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
10 |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
11 /*! \defgroup mb_ge_cairo MadButterfly Graphic Engine with Cairo |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
12 * @{ |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
13 */ |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 #define MBE_OPERATOR_CLEAR OPENVG_OPERATOR_CLEAR |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
15 #define MBE_OPERATOR_SOURCE OPENVG_OPERATOR_SOURCE |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
16 #define MBE_STATUS_SUCCESS OPENVG_STATUS_SUCCESS |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
17 |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
18 #define mbe_image_surface_create_from_png(fn) ((mbe_surface_t *)NULL) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
19 #define mbe_image_surface_create_for_data(data, fmt, w, h, stride) \ |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
20 ((mbe_surface_t *)NULL) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
21 #define mbe_pattern_create_for_surface(canvas) ((mbe_pattern_t *)NULL) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
22 #define mbe_scaled_font_text_extents(scaled, utf8, extents) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
23 #define mbe_image_surface_get_stride(surface) (20) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
24 #define mbe_image_surface_get_format(surface) ((mb_img_fmt_t)0) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
25 #define mbe_image_surface_get_height(surface) (1) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
26 #define mbe_image_surface_get_width(surface) (1) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
27 #define mbe_image_surface_get_data(surface) ((unsigned char *)NULL) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
28 #define mbe_scaled_font_reference(scaled) ((mbe_scaled_font_t *)NULL) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
29 #define mbe_pattern_create_radial(cx0, cy0, radius0, \ |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
30 cx1, cy1, radius1, stops, stop_cnt) \ |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
31 ((mbe_pattern_t *)NULL) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
32 #define mbe_pattern_create_linear(x0, y0, x1, y1, stops, stop_cnt) \ |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
33 ((mbe_pattern_t *)NULL) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
34 #define mbe_scaled_font_destroy(scaled) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
35 #define mbe_font_face_reference(face) ((mbe_font_face_t *)NULL) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
36 #define mbe_scaled_font_create(face, fnt_mtx, ctm) ((mbe_scaled_font_t *)NULL) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
37 #define mbe_pattern_set_matrix(ptn, mtx) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
38 #define mbe_font_face_destroy(face) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
39 #define mbe_paint_with_alpha(canvas, alpha) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 #define mbe_set_source_rgba(canvas, r, g, b, a) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
41 #define mbe_set_scaled_font(canvas, scaled) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
42 #define mbe_pattern_destroy(pattern) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
43 #define mbe_get_scaled_font(canvas) ((mbe_scaled_font_t *)NULL) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
44 #define mbe_query_font_face(family, slant, weight) ((mbe_font_face_t *)NULL) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
45 #define mbe_free_font_face(face) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
46 #define mbe_set_line_width(canvas, w) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
47 #define mbe_set_source_rgb(canvas, r, g, b) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
48 #define mbe_get_font_face(canvas) ((mbe_font_face_t *)NULL) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
49 #define mbe_fill_preserve(canvas) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
50 #define mbe_copy_source(src_canvas, dst_canvas) |
582
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
51 #define mbe_set_source(canvas, pattern) \ |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
52 do { (canvas)->src = (pattern); } while(0) |
586
b42d69ab8857
Replace mbe_clip() with mbe_scissoring()
Thinker K.F. Li <thinker@branda.to>
parents:
585
diff
changeset
|
53 #define mbe_reset_scissoring(canvas) |
582
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
54 #define mbe_get_target(canvas) ((mbe_surface_t *)(canvas)->tgt) |
578
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
55 #define mbe_close_path(canvas) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
56 #define mbe_text_path(canvas, utf8) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
57 #define mbe_rectangle(canvas, x, y, w, h) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
58 #define mbe_in_stroke(canvas, x, y) (0) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
59 #define mbe_new_path(canvas) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
60 #define mbe_curve_to(canvas, x1, y1, x2, y2, x3, y3) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
61 #define mbe_restore(canvas) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
62 #define mbe_move_to(canvas, x, y) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
63 #define mbe_line_to(canvas, x, y) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
64 #define mbe_in_fill(canvas, x, y) (0) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
65 #define mbe_destroy(canvas) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
66 #define mbe_stroke(canvas) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
67 #define mbe_clear(canvas) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
68 #define mbe_paint(canvas) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
69 #define mbe_save(canvas) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
70 #define mbe_fill(canvas) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
71 #define mbe_arc(canvas, x, y, radius, angle_start, angle_stop) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
72 |
580
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
73 typedef struct _mbe_text_extents_t mbe_text_extents_t; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
74 typedef int mbe_scaled_font_t; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
75 typedef int mbe_font_face_t; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
76 typedef struct _ge_openvg_surface mbe_surface_t; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
77 typedef struct _ge_openvg_pattern mbe_pattern_t; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
78 typedef struct _ge_openvg_mbe mbe_t; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
79 |
578
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
80 struct _mbe_text_extents_t { |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
81 co_aix x_bearing; |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
82 co_aix y_bearing; |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
83 co_aix width; |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
84 co_aix height; |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
85 co_aix x_advance; |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
86 co_aix y_advance; |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
87 }; |
580
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
88 |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
89 struct _ge_openvg_mbe { |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
90 mbe_pattern_t *src; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
91 mbe_surface_t *tgt; |
582
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
92 EGLContext ctx; |
580
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
93 }; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
94 |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
95 struct _ge_openvg_surface { |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
96 void *surface; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
97 mbe_t *asso_mbe; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
98 }; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
99 |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
100 struct _ge_openvg_pattern { |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
101 void *pattern; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
102 void *asso_img; |
7bfeccdc91cb
Encapsulate information of OpenVG objects in structures.
Thinker K.F. Li <thinker@branda.to>
parents:
578
diff
changeset
|
103 }; |
578
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
104 |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
105 #define MB_MATRIX_2_OPENVG(vgmtx, mtx) do { \ |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
106 (vgmtx)[0] = (mtx)[0]; \ |
583
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
107 (vgmtx)[1] = (mtx)[1]; \ |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
108 (vgmtx)[2] = (mtx)[2]; \ |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
109 (vgmtx)[3] = (mtx)[3]; \ |
578
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
110 (vgmtx)[4] = (mtx)[4]; \ |
583
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
111 (vgmtx)[5] = (mtx)[5]; \ |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
112 (vgmtx)[6] = 0; \ |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
113 (vgmtx)[7] = 0; \ |
578
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
114 (vgmtx)[8] = 1; \ |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
115 } while(0) |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
116 |
582
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
117 extern EGLNativeDisplayType _ge_openvg_disp_id; |
584
543a2a8523fb
Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents:
583
diff
changeset
|
118 extern mbe_t *_ge_openvg_current_canvas; |
582
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
119 |
588
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
586
diff
changeset
|
120 extern void mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas); |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
586
diff
changeset
|
121 |
e9923024f65e
Implement mbe_scissoring() for OpenVG
Thinker K.F. Li <thinker@branda.to>
parents:
586
diff
changeset
|
122 |
584
543a2a8523fb
Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents:
583
diff
changeset
|
123 #define _VG_DISPLAY() eglGetDisplay(_ge_openvg_disp_id) |
543a2a8523fb
Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents:
583
diff
changeset
|
124 |
543a2a8523fb
Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents:
583
diff
changeset
|
125 /* \brief Make the context of a canvas to be current context. |
543a2a8523fb
Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents:
583
diff
changeset
|
126 */ |
543a2a8523fb
Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents:
583
diff
changeset
|
127 #define _MK_CURRENT_CTX(canvas) do { \ |
543a2a8523fb
Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents:
583
diff
changeset
|
128 if(_ge_openvg_current_canvas != (canvas)) { \ |
543a2a8523fb
Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents:
583
diff
changeset
|
129 _ge_openvg_current_canvas = canvas; \ |
543a2a8523fb
Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents:
583
diff
changeset
|
130 eglMakeCurrent(_VG_DISPLAY(), (canvas)->tgt, \ |
543a2a8523fb
Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents:
583
diff
changeset
|
131 (canvas)->tgt, (canvas)->ctx); \ |
543a2a8523fb
Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents:
583
diff
changeset
|
132 } \ |
543a2a8523fb
Make surce current VG context
Thinker K.F. Li <thinker@branda.to>
parents:
583
diff
changeset
|
133 } while(0) |
583
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
134 |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
135 static void |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
136 mbe_transform(mbe_t *canvas, co_aix *mtx) { |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
137 VGfloat vg_mtx[9]; |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
138 |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
139 _MK_CURRENT_CTX(canvas); |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
140 MB_MATRIX_2_OPENVG(vg_mtx, mtx); |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
141 vgLoadMatrix(vg_mtx); |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
142 } |
ca57132020e4
Set transform matrix for VG contexts
Thinker K.F. Li <thinker@branda.to>
parents:
582
diff
changeset
|
143 |
582
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
144 static int |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
145 _openvg_find_confg(mb_img_fmt_t fmt, int w, int h, |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
146 EGLConfig *config) { |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
147 EGLDisplay display; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
148 EGLint attrib_list[16]; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
149 EGLConfig configs[1]; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
150 EGLint nconfigs; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
151 int i = 0; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
152 EGLBoolean r; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
153 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
154 switch(fmt) { |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
155 case MB_IFMT_ARGB32: |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
156 attrib_list[i++] = EGL_RED_SIZE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
157 attrib_list[i++] = 8; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
158 attrib_list[i++] = EGL_GREEN_SIZE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
159 attrib_list[i++] = 8; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
160 attrib_list[i++] = EGL_BLUE_SIZE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
161 attrib_list[i++] = 8; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
162 attrib_list[i++] = EGL_ALPHA_SIZE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
163 attrib_list[i++] = 8; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
164 break; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
165 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
166 case MB_IFMT_RGB24: |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
167 attrib_list[i++] = EGL_RED_SIZE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
168 attrib_list[i++] = 8; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
169 attrib_list[i++] = EGL_GREEN_SIZE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
170 attrib_list[i++] = 8; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
171 attrib_list[i++] = EGL_BLUE_SIZE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
172 attrib_list[i++] = 8; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
173 break; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
174 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
175 case MB_IFMT_A8: |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
176 attrib_list[i++] = EGL_ALPHA_SIZE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
177 attrib_list[i++] = 8; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
178 break; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
179 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
180 case MB_IFMT_A1: |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
181 attrib_list[i++] = EGL_ALPHA_SIZE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
182 attrib_list[i++] = 1; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
183 break; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
184 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
185 case MB_IFMT_RGB16_565: |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
186 attrib_list[i++] = EGL_RED_SIZE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
187 attrib_list[i++] = 5; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
188 attrib_list[i++] = EGL_GREEN_SIZE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
189 attrib_list[i++] = 6; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
190 attrib_list[i++] = EGL_BLUE_SIZE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
191 attrib_list[i++] = 5; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
192 break; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
193 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
194 default: |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
195 return -1; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
196 } |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
197 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
198 attrib_list[i++] = EGL_SURFACE_TYPE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
199 attrib_list[i++] = EGL_PBUFFER_BIT; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
200 #if 0 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
201 attrib_list[i++] = EGL_MAX_PBUFFER_WIDTH; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
202 attrib_list[i++] = w; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
203 attrib_list[i++] = EGL_MAX_PBUFFER_HEIGHT; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
204 attrib_list[i++] = h; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
205 #endif |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
206 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
207 attrib_list[i++] = EGL_NONE; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
208 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
209 display = _VG_DISPLAY(); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
210 r = eglChooseConfig(display, attrib_list, configs, 1, &nconfigs); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
211 if(!r) |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
212 return -1; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
213 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
214 *config = configs[0]; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
215 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
216 return 0; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
217 } |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
218 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
219 #define EGL_GLX 1 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
220 #ifdef EGL_GLX |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
221 #include <X11/Xlib.h> |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
222 #include <X11/Xutil.h> |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
223 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
224 static int |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
225 _get_img_fmt_from_xvisual(Display *display, Visual *visual) { |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
226 VisualID visual_id; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
227 XVisualInfo temp; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
228 XVisualInfo *infos; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
229 int n; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
230 int fmt = -1; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
231 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
232 visual_id = XVisualIDFromVisual(visual); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
233 temp.visualid = visual_id; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
234 infos = XGetVisualInfo(display, VisualIDMask, &temp, &n); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
235 if(n != 1) |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
236 return -1; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
237 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
238 switch(infos->depth) { |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
239 case 32: |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
240 fmt = MB_IFMT_ARGB32; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
241 break; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
242 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
243 case 24: |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
244 fmt = MB_IFMT_RGB24; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
245 break; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
246 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
247 case 16: |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
248 fmt = MB_IFMT_RGB16_565; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
249 break; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
250 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
251 case 8: |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
252 fmt = MB_IFMT_A8; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
253 break; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
254 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
255 case 1: |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
256 fmt = MB_IFMT_A1; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
257 break; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
258 } |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
259 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
260 return fmt; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
261 } |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
262 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
263 /*! \brief Create an EGL window surface for X11. |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
264 * |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
265 * This function is compiled only for GLX enabled. |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
266 */ |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
267 static mbe_surface_t * |
585
6af1aa74e57c
Rename to mbe_vg_win_surface_create() and matching EGL display
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
268 mbe_vg_win_surface_create(Display *display, Drawable drawable, |
6af1aa74e57c
Rename to mbe_vg_win_surface_create() and matching EGL display
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
269 Visual *visual, int width, int height) { |
582
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
270 EGLDisplay egl_disp; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
271 EGLSurface egl_surface; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
272 mbe_surface_t *surface; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
273 EGLConfig config; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
274 EGLint attrib_list[2] = {EGL_NONE}; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
275 int fmt; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
276 int r; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
277 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
278 fmt = _get_img_fmt_from_xvisual(display, visual); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
279 if(fmt == -1) |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
280 return NULL; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
281 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
282 r = _openvg_find_confg(fmt, width, height, &config); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
283 if(r != 0) |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
284 return NULL; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
285 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
286 egl_disp = eglGetDisplay(display); |
585
6af1aa74e57c
Rename to mbe_vg_win_surface_create() and matching EGL display
Thinker K.F. Li <thinker@branda.to>
parents:
584
diff
changeset
|
287 if(egl_disp == EGL_NO_DISPLAY || egl_disp != _VG_DISPLAY()) |
582
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
288 return NULL; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
289 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
290 egl_surface = eglCreateWindowSurface(egl_disp, config, drawable, |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
291 attrib_list); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
292 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
293 surface = (mbe_surface_t *)malloc(sizeof(mbe_surface_t)); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
294 if(surface == NULL) { |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
295 eglDestroySurface(egl_disp, egl_surface); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
296 return NULL; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
297 } |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
298 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
299 surface->surface = egl_surface; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
300 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
301 return surface; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
302 } |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
303 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
304 #endif |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
305 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
306 static mbe_surface_t * |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
307 mbe_image_surface_create(mb_img_fmt_t fmt, int w, int h) { |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
308 EGLSurface surface; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
309 EGLDisplay display; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
310 EGLConfig config; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
311 EGLint attrib_list[2] = {EGL_NONE}; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
312 mbe_surface_t *mbe_surface; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
313 int r; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
314 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
315 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
316 r = _openvg_find_confg(fmt, w, h, &config); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
317 if(r != 0) |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
318 return NULL; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
319 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
320 display = _VG_DISPLAY(); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
321 /* Some implementation does not support pbuffer. |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
322 * We need use some other surface to replace this one. |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
323 */ |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
324 surface = eglCreatePbufferSurface(display, config, attrib_list); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
325 if(surface == EGL_NO_SURFACE) |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
326 return NULL; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
327 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
328 mbe_surface = (mbe_surface_t *)malloc(sizeof(mbe_surface_t)); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
329 if(mbe_surface == NULL) |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
330 return NULL; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
331 mbe_surface->surface = surface; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
332 mbe_surface->asso_mbe = NULL; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
333 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
334 return mbe_surface; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
335 } |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
336 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
337 static void |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
338 mbe_surface_destroy(mbe_surface_t *surface) { |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
339 EGLDisplay display; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
340 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
341 display = _VG_DISPLAY(); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
342 eglDestroySurface(display, surface->surface); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
343 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
344 if(surface->asso_mbe) |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
345 surface->asso_mbe->tgt = NULL; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
346 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
347 free(surface); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
348 } |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
349 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
350 static mbe_t * |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
351 mbe_create(mbe_surface_t *surface) { |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
352 EGLDisplay display; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
353 EGLConfig config; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
354 EGLContext ctx, shared; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
355 EGLint attrib_list[2] = {EGL_NONE}; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
356 mbe_t *canvas; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
357 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
358 display = _VG_DISPLAY(); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
359 ctx = eglCreateContext(display, config, shared, attrib_list); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
360 if(ctx == EGL_NO_CONTEXT) |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
361 return NULL; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
362 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
363 canvas = (mbe_t *)malloc(sizeof(mbe_t)); |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
364 if(canvas == NULL) |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
365 return NULL; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
366 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
367 canvas->src = NULL; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
368 canvas->tgt = surface; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
369 canvas->ctx = ctx; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
370 |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
371 return canvas; |
dd546c4da180
deal with EGL surface, context for OpenVG GE
Thinker K.F. Li <thinker@branda.to>
parents:
580
diff
changeset
|
372 } |
578
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
373 |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
374 /* @} */ |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
375 |
fd5f5d9e00d2
A dummy graphic engine for OpenVG.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
376 #endif /* __MB_GE_OPENVG_H_ */ |