Mercurial > MadButterfly
changeset 469:4dc0be6c044a Android_Skia
Add copy and clear graphic engine functions.
To replace set/get options, copy and clear is more meanful,
functional, and independently. set/get options are too graphic engine
dependently.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 12 Nov 2009 21:30:35 +0800 |
parents | ae784a86ba82 |
children | e54cd19cec28 |
files | include/mb_graph_engine_cairo.h include/mb_graph_engine_skia.h src/graph_engine_cairo.c src/graph_engine_skia.cpp src/redraw_man.c src/shape_stext.c |
diffstat | 6 files changed, 41 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/include/mb_graph_engine_cairo.h Thu Nov 12 21:26:10 2009 +0800 +++ b/include/mb_graph_engine_cairo.h Thu Nov 12 21:30:35 2009 +0800 @@ -13,7 +13,6 @@ #define MBE_OPERATOR_SOURCE CAIRO_OPERATOR_SOURCE #define MBE_STATUS_SUCCESS CAIRO_STATUS_SUCCESS -#define mbe_ft_font_face_create_for_pattern cairo_ft_font_face_create_for_pattern #define mbe_image_surface_create_from_png cairo_image_surface_create_from_png #define mbe_pattern_add_color_stop_rgba cairo_pattern_add_color_stop_rgba #define mbe_pattern_create_for_surface cairo_pattern_create_for_surface @@ -43,14 +42,11 @@ #define mbe_set_line_width cairo_set_line_width #define mbe_get_font_face cairo_get_font_face #define mbe_fill_preserve cairo_fill_preserve -#define mbe_set_operator cairo_set_operator -#define mbe_get_operator cairo_get_operator #define mbe_set_source cairo_set_source #define mbe_reset_clip cairo_reset_clip #define mbe_get_target cairo_get_target #define mbe_close_path cairo_close_path #define mbe_text_path cairo_text_path -#define mbe_show_text cairo_show_text #define mbe_rectangle cairo_rectangle #define mbe_in_stroke cairo_in_stroke #define mbe_new_path cairo_new_path @@ -70,7 +66,6 @@ typedef cairo_text_extents_t mbe_text_extents_t; typedef cairo_scaled_font_t mbe_scaled_font_t; typedef cairo_font_face_t mbe_font_face_t; -typedef cairo_operator_t mbe_operator_t; typedef cairo_surface_t mbe_surface_t; typedef cairo_pattern_t mbe_pattern_t; typedef cairo_status_t mbe_status_t; @@ -84,6 +79,24 @@ extern void mbe_free_font_face(mbe_font_face_t *face); +static void mbe_clear(mbe_t *canvas) { + cairo_operator_t old_op; + + old_op = cairo_get_operator(canvas); + cairo_set_operator(canvas, MBE_OPERATOR_CLEAR); + cairo_paint(canvas); + cairo_set_operator(canvas, old_op); +} + +static void mbe_copy_source(mbe_t *canvas) { + cairo_operator_t saved_op; + + saved_op = cairo_get_operator(canvas); + cairo_set_operator(canvas, MBE_OPERATOR_SOURCE); + cairo_paint(canvas); + cairo_set_operator(canvas, saved_op); +} + static mbe_scaled_font_t * mbe_scaled_font_create(mbe_font_face_t *face, mbe_matrix_t *fnt_mtx, mbe_matrix_t *ctm) {
--- a/include/mb_graph_engine_skia.h Thu Nov 12 21:26:10 2009 +0800 +++ b/include/mb_graph_engine_skia.h Thu Nov 12 21:30:35 2009 +0800 @@ -11,7 +11,6 @@ #define MBE_OPERATOR_SOURCE CAIRO_OPERATOR_SOURCE #define MBE_STATUS_SUCCESS CAIRO_STATUS_SUCCESS -#define mbe_ft_font_face_create_for_pattern #define mbe_image_surface_create_from_png #define mbe_pattern_add_color_stop_rgba #define mbe_pattern_create_for_surface @@ -23,7 +22,6 @@ #define mbe_scaled_font_reference #define mbe_pattern_create_radial #define mbe_pattern_create_linear -#define mbe_xlib_surface_create #define mbe_scaled_font_destroy #define mbe_font_face_reference #define mbe_set_source_surface @@ -42,14 +40,11 @@ #define mbe_set_line_width #define mbe_get_font_face #define mbe_fill_preserve -#define mbe_set_operator -#define mbe_get_operator #define mbe_set_source #define mbe_reset_clip #define mbe_get_target #define mbe_close_path #define mbe_text_path -#define mbe_show_text #define mbe_rectangle #define mbe_in_stroke #define mbe_new_path @@ -69,7 +64,6 @@ typedef cairo_text_extents_t mbe_text_extents_t; typedef cairo_scaled_font_t mbe_scaled_font_t; typedef cairo_font_face_t mbe_font_face_t; -typedef cairo_operator_t mbe_operator_t; typedef cairo_surface_t mbe_surface_t; typedef cairo_pattern_t mbe_pattern_t; typedef cairo_status_t mbe_status_t; @@ -81,6 +75,24 @@ int slant, int weight); extern void mbe_free_font_face(mbe_font_face_t *face); +static void mbe_clear(mbe_t *canvas) { + cairo_operator_t old_op; + + old_op = mbe_get_operator(canvas); + mbe_set_operator(canvas, MBE_OPERATOR_CLEAR); + mbe_paint(canvas); + mbe_set_operator(canvas, old_op); +} + +static void mbe_copy_source(mbe_t *canvas) { + mbe_operator_t saved_op; + + saved_op = mbe_get_operator(canvas); + mbe_set_operator(canvas, MBE_OPERATOR_SOURCE); + mbe_paint(canvas); + mbe_set_operator(canvas, saved_op); +} + static mbe_surface_t * mbe_image_surface_create_for_data(unsigned char *data, mb_img_fmt_t fmt,
--- a/src/graph_engine_cairo.c Thu Nov 12 21:26:10 2009 +0800 +++ b/src/graph_engine_cairo.c Thu Nov 12 21:30:35 2009 +0800 @@ -95,7 +95,7 @@ FcPattern *ptn; ptn = query_font_pattern(family, slant, weight); - cface = mbe_ft_font_face_create_for_pattern(ptn); + cface = cairo_ft_font_face_create_for_pattern(ptn); FcPatternDestroy(ptn); return cface;
--- a/src/graph_engine_skia.cpp Thu Nov 12 21:26:10 2009 +0800 +++ b/src/graph_engine_skia.cpp Thu Nov 12 21:30:35 2009 +0800 @@ -1,5 +1,7 @@ +extern "C" { #include "mb_graph_engine_skia.h" #include "mb_shapes.h" +}; #ifndef ASSERT #define ASSERT(x)
--- a/src/redraw_man.c Thu Nov 12 21:26:10 2009 +0800 +++ b/src/redraw_man.c Thu Nov 12 21:30:35 2009 +0800 @@ -1865,12 +1865,7 @@ #ifndef UNITTEST static void clear_canvas(canvas_t *canvas) { - mbe_operator_t old_op; - - old_op = mbe_get_operator(canvas); - mbe_set_operator(canvas, MBE_OPERATOR_CLEAR); - mbe_paint(canvas); - mbe_set_operator(canvas, old_op); + mbe_clear(canvas); } static void make_clip(mbe_t *cr, int n_dirty_areas, @@ -1892,15 +1887,10 @@ static void copy_cr_2_backend(redraw_man_t *rdman, int n_dirty_areas, area_t **dirty_areas) { - mbe_operator_t saved_op; - if(n_dirty_areas) make_clip(rdman->backend, n_dirty_areas, dirty_areas); - saved_op = mbe_get_operator(rdman->backend); - mbe_set_operator(rdman->backend, MBE_OPERATOR_SOURCE); - mbe_paint(rdman->backend); - mbe_set_operator(rdman->backend, saved_op); + mbe_copy_source(rdman->backend); } #else /* UNITTEST */ static void make_clip(mbe_t *cr, int n_dirty_areas,
--- a/src/shape_stext.c Thu Nov 12 21:26:10 2009 +0800 +++ b/src/shape_stext.c Thu Nov 12 21:30:35 2009 +0800 @@ -58,8 +58,6 @@ move_xys[move_cnt][0] = x; \ move_xys[move_cnt++][1] = y; \ } while(0) -#undef mbe_show_text -#define mbe_show_text(cr, txt) #undef mbe_scaled_font_destroy #define mbe_scaled_font_destroy(scaled) #undef mbe_text_path