annotate include/mb_graph_engine_skia.h @ 465:d8181696b689 Android_Skia

Move functions into graphic engine layers. Cairo and Skia have their own header files and C/C++ files. Some functions are refactoried and move into graphic engine layer to make reset of MadButterfly independently from graphic engines.
author Thinker K.F. Li <thinker@branda.to>
date Thu, 12 Nov 2009 21:22:30 +0800
parents
children 4dc0be6c044a
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_SKIA_H_
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2 #define __MB_GE_SKIA_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 "mb_img_ldr.h"
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7 /*! \defgroup mb_ge_skia MadButterfly Graphic Engine with Skia
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8 * @{
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9 */
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10 #define MBE_OPERATOR_CLEAR CAIRO_OPERATOR_CLEAR
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11 #define MBE_OPERATOR_SOURCE CAIRO_OPERATOR_SOURCE
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12 #define MBE_STATUS_SUCCESS CAIRO_STATUS_SUCCESS
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
13
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
14 #define mbe_ft_font_face_create_for_pattern
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
15 #define mbe_image_surface_create_from_png
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16 #define mbe_pattern_add_color_stop_rgba
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17 #define mbe_pattern_create_for_surface
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18 #define mbe_scaled_font_text_extents
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19 #define mbe_image_surface_get_stride
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20 #define mbe_image_surface_get_height
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21 #define mbe_image_surface_get_width
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22 #define mbe_image_surface_get_data
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 #define mbe_scaled_font_reference
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
24 #define mbe_pattern_create_radial
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
25 #define mbe_pattern_create_linear
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26 #define mbe_xlib_surface_create
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27 #define mbe_scaled_font_destroy
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
28 #define mbe_font_face_reference
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
29 #define mbe_set_source_surface
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
30 #define mbe_scaled_font_status
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
31 #define mbe_scaled_font_create
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
32 #define mbe_pattern_set_matrix
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
33 #define mbe_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
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
35 #define mbe_font_face_status
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
36 #define mbe_surface_destroy
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
37 #define mbe_set_source_rgba
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
38 #define mbe_set_scaled_font
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
39 #define mbe_pattern_destroy
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
40 #define mbe_get_scaled_font
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
41 #define mbe_set_source_rgb
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
42 #define mbe_set_line_width
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
43 #define mbe_get_font_face
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
44 #define mbe_fill_preserve
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
45 #define mbe_set_operator
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
46 #define mbe_get_operator
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
47 #define mbe_set_source
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
48 #define mbe_reset_clip
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
49 #define mbe_get_target
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
50 #define mbe_close_path
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
51 #define mbe_text_path
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52 #define mbe_show_text
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
53 #define mbe_rectangle
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
54 #define mbe_in_stroke
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
55 #define mbe_new_path
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
56 #define mbe_curve_to
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57 #define mbe_restore
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58 #define mbe_move_to
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
59 #define mbe_line_to
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
60 #define mbe_in_fill
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
61 #define mbe_destroy
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
62 #define mbe_stroke
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
63 #define mbe_create
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
64 #define mbe_paint
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
65 #define mbe_save
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
66 #define mbe_fill
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
67 #define mbe_clip
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
68
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
69 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
70 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
71 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
72 typedef cairo_operator_t mbe_operator_t;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
73 typedef cairo_surface_t mbe_surface_t;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
74 typedef cairo_pattern_t mbe_pattern_t;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
75 typedef cairo_status_t mbe_status_t;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
76 typedef cairo_matrix_t mbe_matrix_t;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
77 typedef cairo_t mbe_t;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
78 typedef float co_aix;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
79
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
80 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
81 int slant, int weight);
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
82 extern void mbe_free_font_face(mbe_font_face_t *face);
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
83
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
84 static mbe_surface_t *
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
85 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
86 mb_img_fmt_t fmt,
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
87 int width, int height,
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
88 int stride) {
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
89 cairo_format_t _fmt;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
90
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
91 switch(fmt) {
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
92 case MB_IFMT_ARGB32:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
93 _fmt = CAIRO_FORMAT_ARGB32;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
94 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
95 case MB_IFMT_RGB24:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
96 _fmt = CAIRO_FORMAT_RGB24;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
97 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
98 case MB_IFMT_A8:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
99 _fmt = CAIRO_FORMAT_A8;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
100 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
101 case MB_IFMT_A1:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
102 _fmt = CAIRO_FORMAT_A1;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
103 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
104 default:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
105 return NULL;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
106 }
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
107 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
108 width, height, stride);
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
109 }
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
110
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
111 static mb_img_fmt_t
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
112 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
113 cairo_format_t _fmt;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
114 mb_img_fmt_t fmt;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
115
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
116 _fmt = cairo_image_surface_get_format(surface);
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
117 switch(_fmt) {
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
118 case CAIRO_FORMAT_ARGB32:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
119 fmt = MB_IFMT_ARGB32;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
120 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
121 case CAIRO_FORMAT_RGB24:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
122 fmt = MB_IFMT_RGB24;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
123 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
124 case CAIRO_FORMAT_A8:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
125 fmt = MB_IFMT_A8;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
126 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
127 case CAIRO_FORMAT_A1:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
128 fmt = MB_IFMT_A1;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
129 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
130 default:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
131 fmt = MB_IFMT_DUMMY;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
132 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
133 }
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
134
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
135 return fmt;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
136 }
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
137
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
138 static mbe_surface_t *
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
139 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
140 cairo_format_t _fmt;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
141
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
142 switch(fmt) {
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
143 case MB_IFMT_ARGB32:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
144 _fmt = CAIRO_FORMAT_ARGB32;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
145 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
146 case MB_IFMT_RGB24:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
147 _fmt = CAIRO_FORMAT_RGB24;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
148 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
149 case MB_IFMT_A8:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
150 _fmt = CAIRO_FORMAT_A8;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
151 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
152 case MB_IFMT_A1:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
153 _fmt = CAIRO_FORMAT_A1;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
154 break;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
155 default:
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
156 return NULL;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
157 }
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
158
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
159 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
160 }
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
161
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
162 static void
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
163 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
164 cairo_matrix_t cmtx;
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
165
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
166 cmtx.xx = matrix[0];
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
167 cmtx.xy = matrix[1];
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
168 cmtx.x0 = matrix[2];
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
169 cmtx.yx = matrix[3];
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
170 cmtx.yy = matrix[4];
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
171 cmtx.y0 = matrix[5];
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
172
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
173 cairo_transform(mbe, &cmtx);
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 void
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
177 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
178 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
179 if(angle_start <= angle_stop)
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
180 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
181 else
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
182 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
183 }
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
184 /* @} */
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
185
d8181696b689 Move functions into graphic engine layers.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
186 #endif /* __MB_GE_SKIA_H_ */