Mercurial > MadButterfly
comparison src/X_main.c @ 24:e598bc809c0f
No more flash when animation.
1. Add a buffer surface.
2. Draw on the surface
3. Copy content of buffer surface to XLib surface.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 03 Aug 2008 02:08:31 +0800 |
parents | 56f592f56ff7 |
children | d50f33040de6 |
comparison
equal
deleted
inserted
replaced
23:56f592f56ff7 | 24:e598bc809c0f |
---|---|
11 #include "paint.h" | 11 #include "paint.h" |
12 | 12 |
13 Display *display; | 13 Display *display; |
14 | 14 |
15 void draw_path(cairo_t *cr, int w, int h) { | 15 void draw_path(cairo_t *cr, int w, int h) { |
16 cairo_t *tmpcr; | |
17 cairo_surface_t *tmpsuf; | |
16 redraw_man_t rdman; | 18 redraw_man_t rdman; |
17 shape_t *path1, *path2, *path3; | 19 shape_t *path1, *path2, *path3; |
18 coord_t *coord1, *coord2; | 20 coord_t *coord1, *coord2; |
19 paint_t *fill1, *fill2, *fill3; | 21 paint_t *fill1, *fill2, *fill3; |
20 paint_t *stroke; | 22 paint_t *stroke; |
21 grad_stop_t fill3_stops[3]; | 23 grad_stop_t fill3_stops[3]; |
22 int i; | 24 int i; |
23 | 25 |
24 redraw_man_init(&rdman, cr); | 26 tmpsuf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); |
27 tmpcr = cairo_create(tmpsuf); | |
28 cairo_set_source_surface(cr, tmpsuf, 0, 0); | |
29 redraw_man_init(&rdman, tmpcr, cr); | |
25 coord1 = rdman_coord_new(&rdman, rdman.root_coord); | 30 coord1 = rdman_coord_new(&rdman, rdman.root_coord); |
26 coord2 = rdman_coord_new(&rdman, rdman.root_coord); | 31 coord2 = rdman_coord_new(&rdman, rdman.root_coord); |
27 | 32 |
28 fill1 = paint_color_new(&rdman, 1, 1, 0, 0.5); | 33 fill1 = paint_color_new(&rdman, 1, 1, 0, 0.5); |
29 fill2 = paint_color_new(&rdman, 0, 1, 1, 0.5); | 34 fill2 = paint_color_new(&rdman, 0, 1, 1, 0.5); |
92 fill1->free(fill1); | 97 fill1->free(fill1); |
93 fill2->free(fill2); | 98 fill2->free(fill2); |
94 redraw_man_destroy(&rdman); | 99 redraw_man_destroy(&rdman); |
95 sh_path_free(path1); | 100 sh_path_free(path1); |
96 sh_path_free(path2); | 101 sh_path_free(path2); |
102 cairo_destroy(tmpcr); | |
103 cairo_surface_destroy(tmpsuf); | |
97 } | 104 } |
98 | 105 |
99 void drawing(cairo_surface_t *surface, int w, int h) { | 106 void drawing(cairo_surface_t *surface, int w, int h) { |
100 cairo_t *cr; | 107 cairo_t *cr; |
101 | 108 |