Mercurial > MadButterfly
comparison src/X_supp.c @ 448:16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
mb_graph_engine is a layer to separate MadButterfly from Cairo.
It is only a set of macro mapping to cairo implementation, now.
But, it provides a oppotunities to replace cairo with other engines;
likes skia.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 04 Aug 2009 23:35:41 +0800 |
parents | 892f4efe2e48 |
children | a417fd980228 |
comparison
equal
deleted
inserted
replaced
447:38aae921243f | 448:16116d84bc5e |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <stdlib.h> | 2 #include <stdlib.h> |
3 #include <string.h> | 3 #include <string.h> |
4 #include <X11/Xlib.h> | 4 #include <X11/Xlib.h> |
5 #include <X11/Xutil.h> | 5 #include <X11/Xutil.h> |
6 #include <cairo.h> | 6 #include "mb_graph_engine.h" |
7 #include <cairo-xlib.h> | 7 #include <cairo-xlib.h> |
8 #include "mb_redraw_man.h" | 8 #include "mb_redraw_man.h" |
9 #include "mb_timer.h" | 9 #include "mb_timer.h" |
10 #include "mb_X_supp.h" | 10 #include "mb_X_supp.h" |
11 | 11 |
29 | 29 |
30 struct _X_MB_runtime { | 30 struct _X_MB_runtime { |
31 Display *display; | 31 Display *display; |
32 Window win; | 32 Window win; |
33 Visual *visual; | 33 Visual *visual; |
34 cairo_surface_t *surface, *backend_surface; | 34 mbe_surface_t *surface, *backend_surface; |
35 cairo_t *cr, *backend_cr; | 35 mbe_t *cr, *backend_cr; |
36 redraw_man_t *rdman; | 36 redraw_man_t *rdman; |
37 mb_tman_t *tman; | 37 mb_tman_t *tman; |
38 mb_img_ldr_t *img_ldr; | 38 mb_img_ldr_t *img_ldr; |
39 int w, h; | 39 int w, h; |
40 | 40 |
439 xmb_rt->h = h; | 439 xmb_rt->h = h; |
440 X_init_connection(display_name, w, h, &xmb_rt->display, | 440 X_init_connection(display_name, w, h, &xmb_rt->display, |
441 &xmb_rt->visual, &xmb_rt->win); | 441 &xmb_rt->visual, &xmb_rt->win); |
442 | 442 |
443 xmb_rt->surface = | 443 xmb_rt->surface = |
444 cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); | 444 mbe_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); |
445 | 445 |
446 xmb_rt->backend_surface = | 446 xmb_rt->backend_surface = |
447 cairo_xlib_surface_create(xmb_rt->display, | 447 mbe_xlib_surface_create(xmb_rt->display, |
448 xmb_rt->win, | 448 xmb_rt->win, |
449 xmb_rt->visual, | 449 xmb_rt->visual, |
450 w, h); | 450 w, h); |
451 | 451 |
452 xmb_rt->cr = cairo_create(xmb_rt->surface); | 452 xmb_rt->cr = mbe_create(xmb_rt->surface); |
453 xmb_rt->backend_cr = cairo_create(xmb_rt->backend_surface); | 453 xmb_rt->backend_cr = mbe_create(xmb_rt->backend_surface); |
454 | 454 |
455 cairo_set_source_surface(xmb_rt->backend_cr, xmb_rt->surface, 0, 0); | 455 mbe_set_source_surface(xmb_rt->backend_cr, xmb_rt->surface, 0, 0); |
456 | 456 |
457 xmb_rt->rdman = (redraw_man_t *)malloc(sizeof(redraw_man_t)); | 457 xmb_rt->rdman = (redraw_man_t *)malloc(sizeof(redraw_man_t)); |
458 redraw_man_init(xmb_rt->rdman, xmb_rt->cr, xmb_rt->backend_cr); | 458 redraw_man_init(xmb_rt->rdman, xmb_rt->cr, xmb_rt->backend_cr); |
459 // FIXME: This is a wired loopback reference. This is inly required when we need | 459 // FIXME: This is a wired loopback reference. This is inly required when we need |
460 // to get the xmb_rt->tman for the animation. We should relocate the tman | 460 // to get the xmb_rt->tman for the animation. We should relocate the tman |
489 | 489 |
490 if(xmb_rt->img_ldr) | 490 if(xmb_rt->img_ldr) |
491 MB_IMG_LDR_FREE(xmb_rt->img_ldr); | 491 MB_IMG_LDR_FREE(xmb_rt->img_ldr); |
492 | 492 |
493 if(xmb_rt->cr) | 493 if(xmb_rt->cr) |
494 cairo_destroy(xmb_rt->cr); | 494 mbe_destroy(xmb_rt->cr); |
495 if(xmb_rt->backend_cr) | 495 if(xmb_rt->backend_cr) |
496 cairo_destroy(xmb_rt->backend_cr); | 496 mbe_destroy(xmb_rt->backend_cr); |
497 | 497 |
498 if(xmb_rt->surface) | 498 if(xmb_rt->surface) |
499 cairo_surface_destroy(xmb_rt->surface); | 499 mbe_surface_destroy(xmb_rt->surface); |
500 if(xmb_rt->backend_surface) | 500 if(xmb_rt->backend_surface) |
501 cairo_surface_destroy(xmb_rt->backend_surface); | 501 mbe_surface_destroy(xmb_rt->backend_surface); |
502 | 502 |
503 if(xmb_rt->display) | 503 if(xmb_rt->display) |
504 XCloseDisplay(xmb_rt->display); | 504 XCloseDisplay(xmb_rt->display); |
505 | 505 |
506 X_kb_destroy(&xmb_rt->kbinfo); | 506 X_kb_destroy(&xmb_rt->kbinfo); |