Mercurial > MadButterfly
annotate include/mb_graph_engine_cairo.h @ 639:dc32c1c140ae
First compilable image loader binding for Javascript
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 26 Jul 2010 20:13:58 +0800 |
parents | 058945dff7bd |
children | 34710e86b4a2 |
rev | line source |
---|---|
465
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1 #ifndef __MB_GE_CAIRO_H_ |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 #define __MB_GE_CAIRO_H_ |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 #include <stdio.h> |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
5 #include <cairo.h> |
635
058945dff7bd
Mark-out cairo-directfb.h temporary.
Thinker K.F. Li <thinker@branda.to>
parents:
633
diff
changeset
|
6 /* This include file should be remove from here, since it will only be |
058945dff7bd
Mark-out cairo-directfb.h temporary.
Thinker K.F. Li <thinker@branda.to>
parents:
633
diff
changeset
|
7 * used by directfb runtime module. Other modules would not use it. |
058945dff7bd
Mark-out cairo-directfb.h temporary.
Thinker K.F. Li <thinker@branda.to>
parents:
633
diff
changeset
|
8 * FourDollars, please, confirms it. |
058945dff7bd
Mark-out cairo-directfb.h temporary.
Thinker K.F. Li <thinker@branda.to>
parents:
633
diff
changeset
|
9 * |
058945dff7bd
Mark-out cairo-directfb.h temporary.
Thinker K.F. Li <thinker@branda.to>
parents:
633
diff
changeset
|
10 * #include <cairo-directfb.h> |
058945dff7bd
Mark-out cairo-directfb.h temporary.
Thinker K.F. Li <thinker@branda.to>
parents:
633
diff
changeset
|
11 */ |
480
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
12 #include "mb_basic_types.h" |
465
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
13 #include "mb_img_ldr.h" |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
15 /*! \defgroup mb_ge_cairo MadButterfly Graphic Engine with Cairo |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
16 * @{ |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
17 */ |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
18 #define MBE_OPERATOR_CLEAR CAIRO_OPERATOR_CLEAR |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
19 #define MBE_OPERATOR_SOURCE CAIRO_OPERATOR_SOURCE |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
20 #define MBE_STATUS_SUCCESS CAIRO_STATUS_SUCCESS |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
21 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
22 #define mbe_image_surface_create_from_png cairo_image_surface_create_from_png |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
23 #define mbe_pattern_create_for_surface cairo_pattern_create_for_surface |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
24 #define mbe_scaled_font_text_extents cairo_scaled_font_text_extents |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
25 #define mbe_image_surface_get_stride cairo_image_surface_get_stride |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
26 #define mbe_image_surface_get_height cairo_image_surface_get_height |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
27 #define mbe_image_surface_get_width cairo_image_surface_get_width |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
28 #define mbe_image_surface_get_data cairo_image_surface_get_data |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
29 #define mbe_scaled_font_reference cairo_scaled_font_reference |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
30 #define mbe_xlib_surface_create cairo_xlib_surface_create |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
31 #define mbe_scaled_font_destroy cairo_scaled_font_destroy |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
32 #define mbe_font_face_reference cairo_font_face_reference |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
33 #define mbe_font_face_destroy cairo_font_face_destroy |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
34 #define mbe_paint_with_alpha cairo_paint_with_alpha |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
35 #define mbe_surface_destroy cairo_surface_destroy |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
36 #define mbe_set_source_rgba cairo_set_source_rgba |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
37 #define mbe_set_scaled_font cairo_set_scaled_font |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
38 #define mbe_pattern_destroy cairo_pattern_destroy |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
39 #define mbe_get_scaled_font cairo_get_scaled_font |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 #define mbe_set_source_rgb cairo_set_source_rgb |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
41 #define mbe_set_line_width cairo_set_line_width |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
42 #define mbe_get_font_face cairo_get_font_face |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
43 #define mbe_fill_preserve cairo_fill_preserve |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
44 #define mbe_set_source cairo_set_source |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
45 #define mbe_reset_clip cairo_reset_clip |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
46 #define mbe_get_target cairo_get_target |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
47 #define mbe_close_path cairo_close_path |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
48 #define mbe_text_path cairo_text_path |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
49 #define mbe_rectangle cairo_rectangle |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
50 #define mbe_in_stroke cairo_in_stroke |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
51 #define mbe_new_path cairo_new_path |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
52 #define mbe_curve_to cairo_curve_to |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
53 #define mbe_restore cairo_restore |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
54 #define mbe_move_to cairo_move_to |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
55 #define mbe_line_to cairo_line_to |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
56 #define mbe_in_fill cairo_in_fill |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
57 #define mbe_destroy cairo_destroy |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
58 #define mbe_stroke cairo_stroke |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
59 #define mbe_create cairo_create |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
60 #define mbe_paint cairo_paint |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
61 #define mbe_save cairo_save |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
62 #define mbe_fill cairo_fill |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
63 #define mbe_clip cairo_clip |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
64 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
65 typedef cairo_text_extents_t mbe_text_extents_t; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
66 typedef cairo_scaled_font_t mbe_scaled_font_t; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
67 typedef cairo_font_face_t mbe_font_face_t; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
68 typedef cairo_surface_t mbe_surface_t; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
69 typedef cairo_pattern_t mbe_pattern_t; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
70 typedef cairo_t mbe_t; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
71 |
473
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
72 #define MB_MATRIX_2_CAIRO(cmtx, mtx) { \ |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
73 (cmtx).xx = (mtx)[0]; \ |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
74 (cmtx).xy = (mtx)[1]; \ |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
75 (cmtx).x0 = (mtx)[2]; \ |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
76 (cmtx).yx = (mtx)[3]; \ |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
77 (cmtx).yy = (mtx)[4]; \ |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
78 (cmtx).y0 = (mtx)[5]; \ |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
79 } |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
80 |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
81 |
465
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
82 extern mbe_font_face_t * mbe_query_font_face(const char *family, |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
83 int slant, int weight); |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
84 extern void mbe_free_font_face(mbe_font_face_t *face); |
480
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
85 extern mbe_pattern_t *mbe_pattern_create_radial(co_aix cx0, co_aix cy0, |
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
86 co_aix radius0, |
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
87 co_aix cx1, co_aix cy1, |
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
88 co_aix radius1, |
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
89 grad_stop_t *stops, |
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
90 int stop_cnt); |
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
91 extern mbe_pattern_t *mbe_pattern_create_linear(co_aix x0, co_aix y0, |
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
92 co_aix x1, co_aix y1, |
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
93 grad_stop_t *stops, |
e813ac222f48
Merge add colors into constructor of gradient pattern.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
94 int stop_cnt); |
465
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
95 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
96 |
473
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
97 static void mbe_pattern_set_matrix(mbe_pattern_t *ptn, |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
98 const co_aix matrix[6]) { |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
99 cairo_matrix_t cmtx; |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
100 |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
101 MB_MATRIX_2_CAIRO(cmtx, matrix); |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
102 cairo_pattern_set_matrix(ptn, &cmtx); |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
103 } |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
104 |
469
4dc0be6c044a
Add copy and clear graphic engine functions.
Thinker K.F. Li <thinker@branda.to>
parents:
465
diff
changeset
|
105 static void mbe_clear(mbe_t *canvas) { |
4dc0be6c044a
Add copy and clear graphic engine functions.
Thinker K.F. Li <thinker@branda.to>
parents:
465
diff
changeset
|
106 cairo_operator_t old_op; |
633
6f71f1b8e4e7
Let compilation on SMP8655 succeeded.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
512
diff
changeset
|
107 |
469
4dc0be6c044a
Add copy and clear graphic engine functions.
Thinker K.F. Li <thinker@branda.to>
parents:
465
diff
changeset
|
108 old_op = cairo_get_operator(canvas); |
481
273307d061b7
imported patch typo_cairo.diff
Thinker K.F. Li <thinker@branda.to>
parents:
480
diff
changeset
|
109 cairo_set_operator(canvas, CAIRO_OPERATOR_CLEAR); |
469
4dc0be6c044a
Add copy and clear graphic engine functions.
Thinker K.F. Li <thinker@branda.to>
parents:
465
diff
changeset
|
110 cairo_paint(canvas); |
4dc0be6c044a
Add copy and clear graphic engine functions.
Thinker K.F. Li <thinker@branda.to>
parents:
465
diff
changeset
|
111 cairo_set_operator(canvas, old_op); |
4dc0be6c044a
Add copy and clear graphic engine functions.
Thinker K.F. Li <thinker@branda.to>
parents:
465
diff
changeset
|
112 } |
4dc0be6c044a
Add copy and clear graphic engine functions.
Thinker K.F. Li <thinker@branda.to>
parents:
465
diff
changeset
|
113 |
512
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
481
diff
changeset
|
114 static void mbe_copy_source(mbe_t *src, mbe_t *dst) { |
469
4dc0be6c044a
Add copy and clear graphic engine functions.
Thinker K.F. Li <thinker@branda.to>
parents:
465
diff
changeset
|
115 cairo_operator_t saved_op; |
512
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
481
diff
changeset
|
116 cairo_surface_t *surf; |
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
481
diff
changeset
|
117 cairo_pattern_t *ptn; |
633
6f71f1b8e4e7
Let compilation on SMP8655 succeeded.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
512
diff
changeset
|
118 |
512
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
481
diff
changeset
|
119 surf = cairo_get_target(src); |
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
481
diff
changeset
|
120 ptn = cairo_pattern_create_for_surface(surf); |
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
481
diff
changeset
|
121 cairo_set_source(src, ptn); |
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
481
diff
changeset
|
122 cairo_pattern_destroy(ptn); |
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
481
diff
changeset
|
123 saved_op = cairo_get_operator(dst); |
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
481
diff
changeset
|
124 cairo_set_operator(dst, CAIRO_OPERATOR_SOURCE); |
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
481
diff
changeset
|
125 cairo_paint(dst); |
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
481
diff
changeset
|
126 cairo_set_operator(dst, saved_op); |
469
4dc0be6c044a
Add copy and clear graphic engine functions.
Thinker K.F. Li <thinker@branda.to>
parents:
465
diff
changeset
|
127 } |
4dc0be6c044a
Add copy and clear graphic engine functions.
Thinker K.F. Li <thinker@branda.to>
parents:
465
diff
changeset
|
128 |
465
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
129 static mbe_scaled_font_t * |
473
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
130 mbe_scaled_font_create(mbe_font_face_t *face, co_aix fnt_mtx[6], |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
131 co_aix ctm[6]) { |
465
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
132 cairo_font_options_t *options; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
133 mbe_scaled_font_t *scaled; |
473
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
134 cairo_matrix_t cfnt_mtx, cctm; |
465
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
135 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
136 options = cairo_font_options_create(); |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
137 if(options == NULL) |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
138 return NULL; |
633
6f71f1b8e4e7
Let compilation on SMP8655 succeeded.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
512
diff
changeset
|
139 |
473
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
140 MB_MATRIX_2_CAIRO(cfnt_mtx, fnt_mtx); |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
141 MB_MATRIX_2_CAIRO(cctm, ctm); |
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
471
diff
changeset
|
142 scaled = cairo_scaled_font_create(face, &cfnt_mtx, &cctm, options); |
465
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
143 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
144 cairo_font_options_destroy(options); |
633
6f71f1b8e4e7
Let compilation on SMP8655 succeeded.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
512
diff
changeset
|
145 |
465
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
146 return scaled; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
147 } |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
148 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
149 static mbe_surface_t * |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
150 mbe_image_surface_create_for_data(unsigned char *data, |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
151 mb_img_fmt_t fmt, |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
152 int width, int height, |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
153 int stride) { |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
154 cairo_format_t _fmt; |
633
6f71f1b8e4e7
Let compilation on SMP8655 succeeded.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
512
diff
changeset
|
155 |
465
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
156 switch(fmt) { |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
157 case MB_IFMT_ARGB32: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
158 _fmt = CAIRO_FORMAT_ARGB32; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
159 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
160 case MB_IFMT_RGB24: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
161 _fmt = CAIRO_FORMAT_RGB24; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
162 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
163 case MB_IFMT_A8: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
164 _fmt = CAIRO_FORMAT_A8; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
165 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
166 case MB_IFMT_A1: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
167 _fmt = CAIRO_FORMAT_A1; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
168 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
169 default: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
170 return NULL; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
171 } |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
172 return cairo_image_surface_create_for_data(data, _fmt, |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
173 width, height, stride); |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
174 } |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
175 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
176 static mb_img_fmt_t |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
177 mbe_image_surface_get_format(mbe_surface_t *surface) { |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
178 cairo_format_t _fmt; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
179 mb_img_fmt_t fmt; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
180 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
181 _fmt = cairo_image_surface_get_format(surface); |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
182 switch(_fmt) { |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
183 case CAIRO_FORMAT_ARGB32: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
184 fmt = MB_IFMT_ARGB32; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
185 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
186 case CAIRO_FORMAT_RGB24: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
187 fmt = MB_IFMT_RGB24; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
188 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
189 case CAIRO_FORMAT_A8: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
190 fmt = MB_IFMT_A8; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
191 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
192 case CAIRO_FORMAT_A1: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
193 fmt = MB_IFMT_A1; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
194 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
195 default: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
196 fmt = MB_IFMT_DUMMY; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
197 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
198 } |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
199 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
200 return fmt; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
201 } |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
202 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
203 static mbe_surface_t * |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
204 mbe_image_surface_create(mb_img_fmt_t fmt, int width, int height) { |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
205 cairo_format_t _fmt; |
633
6f71f1b8e4e7
Let compilation on SMP8655 succeeded.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
512
diff
changeset
|
206 |
465
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
207 switch(fmt) { |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
208 case MB_IFMT_ARGB32: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
209 _fmt = CAIRO_FORMAT_ARGB32; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
210 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
211 case MB_IFMT_RGB24: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
212 _fmt = CAIRO_FORMAT_RGB24; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
213 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
214 case MB_IFMT_A8: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
215 _fmt = CAIRO_FORMAT_A8; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
216 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
217 case MB_IFMT_A1: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
218 _fmt = CAIRO_FORMAT_A1; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
219 break; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
220 default: |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
221 return NULL; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
222 } |
633
6f71f1b8e4e7
Let compilation on SMP8655 succeeded.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
512
diff
changeset
|
223 |
465
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
224 return cairo_image_surface_create(_fmt, width, height); |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
225 } |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
226 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
227 static void |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
228 mbe_transform(mbe_t *mbe, const co_aix matrix[6]) { |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
229 cairo_matrix_t cmtx; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
230 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
231 cmtx.xx = matrix[0]; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
232 cmtx.xy = matrix[1]; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
233 cmtx.x0 = matrix[2]; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
234 cmtx.yx = matrix[3]; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
235 cmtx.yy = matrix[4]; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
236 cmtx.y0 = matrix[5]; |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
237 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
238 cairo_transform(mbe, &cmtx); |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
239 } |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
240 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
241 static void |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
242 mbe_arc(mbe_t *mbe, co_aix x, co_aix y, co_aix radius, |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
243 co_aix angle_start, co_aix angle_stop) { |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
244 if(angle_start <= angle_stop) |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
245 cairo_arc(mbe, x, y, radius, angle_start, angle_stop); |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
246 else |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
247 cairo_arc_negative(mbe, x, y, radius, angle_start, angle_stop); |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
248 } |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
249 /* @} */ |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
250 |
d8181696b689
Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
251 #endif /* __MB_GE_CAIRO_H_ */ |