annotate include/mb_graph_engine.h @ 463:aa2b388fba4e

Remove functions unused from definition of graphic engine.
author Thinker K.F. Li <thinker@branda.to>
date Sun, 08 Nov 2009 00:37:29 +0800
parents bb4f651090bf
children d8181696b689
rev   line source
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 #ifndef __MBE_H_
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2 #define __MBE_H_
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3
450
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
4 #include <stdio.h>
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 #include <cairo.h>
451
5c9e2a8a4bd8 Remove all "cairo" wording.
Thinker K.F. Li <thinker@branda.to>
parents: 450
diff changeset
6 #include <cairo-xlib.h>
450
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
7 #include "mb_img_ldr.h"
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
8
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
9 /*! \defgroup mb_graph_engine MadButterfly Graphic Engine
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
10 * @{
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
11 */
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
12 #define MBE_OPERATOR_CLEAR CAIRO_OPERATOR_CLEAR
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
13 #define MBE_OPERATOR_SOURCE CAIRO_OPERATOR_SOURCE
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
14 #define MBE_STATUS_SUCCESS CAIRO_STATUS_SUCCESS
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
15
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16 #define mbe_ft_font_face_create_for_pattern cairo_ft_font_face_create_for_pattern
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17 #define mbe_image_surface_create_from_png cairo_image_surface_create_from_png
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18 #define mbe_pattern_add_color_stop_rgba cairo_pattern_add_color_stop_rgba
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19 #define mbe_pattern_create_for_surface cairo_pattern_create_for_surface
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20 #define mbe_scaled_font_text_extents cairo_scaled_font_text_extents
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21 #define mbe_image_surface_get_stride cairo_image_surface_get_stride
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22 #define mbe_image_surface_get_height cairo_image_surface_get_height
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 #define mbe_image_surface_get_width cairo_image_surface_get_width
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
24 #define mbe_image_surface_get_data cairo_image_surface_get_data
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
25 #define mbe_scaled_font_reference cairo_scaled_font_reference
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26 #define mbe_pattern_create_radial cairo_pattern_create_radial
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27 #define mbe_pattern_create_linear cairo_pattern_create_linear
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
28 #define mbe_xlib_surface_create cairo_xlib_surface_create
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
29 #define mbe_scaled_font_destroy cairo_scaled_font_destroy
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
30 #define mbe_font_options_create cairo_font_options_create
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
31 #define mbe_font_face_reference cairo_font_face_reference
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
32 #define mbe_set_source_surface cairo_set_source_surface
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
33 #define mbe_scaled_font_status cairo_scaled_font_status
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
34 #define mbe_scaled_font_create cairo_scaled_font_create
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
35 #define mbe_pattern_set_matrix cairo_pattern_set_matrix
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
36 #define mbe_font_face_destroy cairo_font_face_destroy
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
37 #define mbe_paint_with_alpha cairo_paint_with_alpha
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
38 #define mbe_font_face_status cairo_font_face_status
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
39 #define mbe_surface_destroy cairo_surface_destroy
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
40 #define mbe_set_source_rgba cairo_set_source_rgba
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
41 #define mbe_set_scaled_font cairo_set_scaled_font
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
42 #define mbe_pattern_destroy cairo_pattern_destroy
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
43 #define mbe_get_scaled_font cairo_get_scaled_font
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
44 #define mbe_set_source_rgb cairo_set_source_rgb
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
45 #define mbe_set_line_width cairo_set_line_width
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
46 #define mbe_get_font_face cairo_get_font_face
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
47 #define mbe_fill_preserve cairo_fill_preserve
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
48 #define mbe_set_operator cairo_set_operator
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
49 #define mbe_get_operator cairo_get_operator
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
50 #define mbe_set_source cairo_set_source
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
51 #define mbe_reset_clip cairo_reset_clip
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52 #define mbe_get_target cairo_get_target
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
53 #define mbe_close_path cairo_close_path
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
54 #define mbe_text_path cairo_text_path
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
55 #define mbe_show_text cairo_show_text
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
56 #define mbe_rectangle cairo_rectangle
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57 #define mbe_in_stroke cairo_in_stroke
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58 #define mbe_new_path cairo_new_path
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
59 #define mbe_curve_to cairo_curve_to
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
60 #define mbe_restore cairo_restore
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
61 #define mbe_move_to cairo_move_to
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
62 #define mbe_line_to cairo_line_to
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
63 #define mbe_in_fill cairo_in_fill
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
64 #define mbe_destroy cairo_destroy
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
65 #define mbe_stroke cairo_stroke
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
66 #define mbe_create cairo_create
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
67 #define mbe_paint cairo_paint
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
68 #define mbe_save cairo_save
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
69 #define mbe_fill cairo_fill
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
70 #define mbe_clip cairo_clip
450
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
71
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
72 typedef cairo_text_extents_t mbe_text_extents_t;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
73 typedef cairo_font_options_t mbe_font_options_t;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
74 typedef cairo_scaled_font_t mbe_scaled_font_t;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
75 typedef cairo_font_face_t mbe_font_face_t;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
76 typedef cairo_operator_t mbe_operator_t;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
77 typedef cairo_surface_t mbe_surface_t;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
78 typedef cairo_pattern_t mbe_pattern_t;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
79 typedef cairo_status_t mbe_status_t;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
80 typedef cairo_matrix_t mbe_matrix_t;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
81 typedef cairo_t mbe_t;
458
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
82 typedef float co_aix;
450
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
83
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
84 static mbe_surface_t *
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
85 mbe_image_surface_create_for_data(unsigned char *data,
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
86 mb_img_fmt_t fmt,
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
87 int width, int height,
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
88 int stride) {
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
89 cairo_format_t _fmt;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
90
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
91 switch(fmt) {
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
92 case MB_IFMT_ARGB32:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
93 _fmt = CAIRO_FORMAT_ARGB32;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
94 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
95 case MB_IFMT_RGB24:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
96 _fmt = CAIRO_FORMAT_RGB24;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
97 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
98 case MB_IFMT_A8:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
99 _fmt = CAIRO_FORMAT_A8;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
100 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
101 case MB_IFMT_A1:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
102 _fmt = CAIRO_FORMAT_A1;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
103 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
104 default:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
105 return NULL;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
106 }
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
107 return cairo_image_surface_create_for_data(data, _fmt,
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
108 width, height, stride);
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
109 }
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
110
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
111 static mb_img_fmt_t
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
112 mbe_image_surface_get_format(mbe_surface_t *surface) {
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
113 cairo_format_t _fmt;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
114 mb_img_fmt_t fmt;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
115
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
116 _fmt = cairo_image_surface_get_format(surface);
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
117 switch(_fmt) {
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
118 case CAIRO_FORMAT_ARGB32:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
119 fmt = MB_IFMT_ARGB32;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
120 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
121 case CAIRO_FORMAT_RGB24:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
122 fmt = MB_IFMT_RGB24;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
123 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
124 case CAIRO_FORMAT_A8:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
125 fmt = MB_IFMT_A8;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
126 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
127 case CAIRO_FORMAT_A1:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
128 fmt = MB_IFMT_A1;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
129 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
130 default:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
131 fmt = MB_IFMT_DUMMY;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
132 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
133 }
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
134
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
135 return fmt;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
136 }
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
137
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
138 static mbe_surface_t *
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
139 mbe_image_surface_create(mb_img_fmt_t fmt, int width, int height) {
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
140 cairo_format_t _fmt;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
141
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
142 switch(fmt) {
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
143 case MB_IFMT_ARGB32:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
144 _fmt = CAIRO_FORMAT_ARGB32;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
145 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
146 case MB_IFMT_RGB24:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
147 _fmt = CAIRO_FORMAT_RGB24;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
148 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
149 case MB_IFMT_A8:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
150 _fmt = CAIRO_FORMAT_A8;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
151 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
152 case MB_IFMT_A1:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
153 _fmt = CAIRO_FORMAT_A1;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
154 break;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
155 default:
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
156 return NULL;
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
157 }
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
158
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
159 return cairo_image_surface_create(_fmt, width, height);
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
160 }
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
161
458
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
162 static void
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
163 mbe_transform(mbe_t *mbe, const co_aix matrix[6]) {
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
164 cairo_matrix_t cmtx;
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
165
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
166 cmtx.xx = matrix[0];
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
167 cmtx.xy = matrix[1];
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
168 cmtx.x0 = matrix[2];
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
169 cmtx.yx = matrix[3];
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
170 cmtx.yy = matrix[4];
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
171 cmtx.y0 = matrix[5];
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
172
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
173 cairo_transform(mbe, &cmtx);
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
174 }
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
175
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
176 static void
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
177 mbe_arc(mbe_t *mbe, co_aix x, co_aix y, co_aix radius,
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
178 co_aix angle_start, co_aix angle_stop) {
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
179 if(angle_start <= angle_stop)
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
180 cairo_arc(mbe, x, y, radius, angle_start, angle_stop);
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
181 else
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
182 cairo_arc_negative(mbe, x, y, radius, angle_start, angle_stop);
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
183 }
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 451
diff changeset
184
450
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 449
diff changeset
185 /* @} */
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
186
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
187 #endif /* __MBE_H_ */