From b699523d6799b3c3d7ab35508d9947eb1ffca8b4 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Wed, 9 Apr 2003 06:52:14 +0000 Subject: [PATCH] allow for a callback rtoo to provid e adest buffer when needed SVN revision: 6840 --- legacy/evas/src/lib/Evas_Engine_Buffer.h | 4 ++ .../evas/src/lib/engines/buffer/evas_engine.c | 40 +++++++++++------ .../evas/src/lib/engines/buffer/evas_engine.h | 10 ++++- .../evas/src/lib/engines/buffer/evas_outbuf.c | 43 ++++++++++++++++--- 4 files changed, 76 insertions(+), 21 deletions(-) diff --git a/legacy/evas/src/lib/Evas_Engine_Buffer.h b/legacy/evas/src/lib/Evas_Engine_Buffer.h index 0b319ea6b0..baf8440ede 100644 --- a/legacy/evas/src/lib/Evas_Engine_Buffer.h +++ b/legacy/evas/src/lib/Evas_Engine_Buffer.h @@ -25,6 +25,10 @@ struct _Evas_Engine_Info_Buffer int color_key_r; int color_key_g; int color_key_b; + struct { + void * (*new_update_region) (int x, int y, int w, int h, int *row_bytes); + void (*free_update_region) (int x, int y, int w, int h, void *data); + } func; } info; }; #endif diff --git a/legacy/evas/src/lib/engines/buffer/evas_engine.c b/legacy/evas/src/lib/engines/buffer/evas_engine.c index 62689e9288..1749a45a81 100644 --- a/legacy/evas/src/lib/engines/buffer/evas_engine.c +++ b/legacy/evas/src/lib/engines/buffer/evas_engine.c @@ -17,7 +17,9 @@ static void *evas_engine_buffer_output_setup(int w, int alpha_threshold, int color_key_r, int color_key_g, - int color_key_b + int color_key_b, + void * (*new_update_region) (int x, int y, int w, int h, int *row_bytes), + void (*free_update_region) (int x, int y, int w, int h, void *data) ); static void evas_engine_buffer_output_free(void *data); static void evas_engine_buffer_output_resize(void *data, int w, int h); @@ -207,7 +209,9 @@ evas_engine_buffer_setup(Evas *e, void *in) info->info.alpha_threshold, info->info.color_key_r, info->info.color_key_g, - info->info.color_key_b); + info->info.color_key_b, + info->info.func.new_update_region, + info->info.func.free_update_region); e->engine.data.output = re; if (!e->engine.data.output) return; e->engine.data.context = e->engine.func->context_new(e->engine.data.output); @@ -223,7 +227,9 @@ evas_engine_buffer_output_setup(int w, int alpha_threshold, int color_key_r, int color_key_g, - int color_key_b + int color_key_b, + void * (*new_update_region) (int x, int y, int w, int h, int *row_bytes), + void (*free_update_region) (int x, int y, int w, int h, void *data) ) { Render_Engine *re; @@ -246,7 +252,6 @@ evas_engine_buffer_output_setup(int w, evas_buffer_outbuf_buf_init(); - /* get any stored performance metrics from device (xserver) */ { Outbuf_Depth dep; DATA32 color_key; @@ -271,7 +276,9 @@ evas_engine_buffer_output_setup(int w, dest_buffer_row_bytes, use_color_key, color_key, - alpha_threshold); + alpha_threshold, + new_update_region, + free_update_region); } re->tb = evas_common_tilebuf_new(w, h); /* in preliminary tests 16x16 gave highest framerates */ @@ -298,20 +305,23 @@ evas_engine_buffer_output_resize(void *data, int w, int h) re = (Render_Engine *)data; { - int depth; - void *dest; - int dest_row_bytes; - int alpha_level; - DATA32 color_key; - char use_color_key; - + int depth; + void *dest; + int dest_row_bytes; + int alpha_level; + DATA32 color_key; + char use_color_key; + void * (*new_update_region) (int x, int y, int w, int h, int *row_bytes); + void (*free_update_region) (int x, int y, int w, int h, void *data); + depth = re->ob->depth; dest = re->ob->dest; dest_row_bytes = re->ob->dest_row_bytes; alpha_level = re->ob->alpha_level; color_key = re->ob->color_key; use_color_key = re->ob->use_color_key; - + new_update_region = re->ob->func.new_update_region; + free_update_region = re->ob->func.free_update_region; evas_buffer_outbuf_buf_free(re->ob); re->ob = evas_buffer_outbuf_buf_setup_fb(w, h, @@ -320,7 +330,9 @@ evas_engine_buffer_output_resize(void *data, int w, int h) dest_row_bytes, use_color_key, color_key, - alpha_level); + alpha_level, + new_update_region, + free_update_region); } evas_common_tilebuf_free(re->tb); re->tb = evas_common_tilebuf_new(w, h); diff --git a/legacy/evas/src/lib/engines/buffer/evas_engine.h b/legacy/evas/src/lib/engines/buffer/evas_engine.h index 5d7abe3094..13dd0b8e96 100644 --- a/legacy/evas/src/lib/engines/buffer/evas_engine.h +++ b/legacy/evas/src/lib/engines/buffer/evas_engine.h @@ -26,6 +26,11 @@ struct _Outbuf int alpha_level; DATA32 color_key; char use_color_key : 1; + + struct { + void * (*new_update_region) (int x, int y, int w, int h, int *row_bytes); + void (*free_update_region) (int x, int y, int w, int h, void *data); + } func; }; /****/ @@ -33,7 +38,10 @@ struct _Outbuf void evas_buffer_outbuf_buf_init (void); void evas_buffer_outbuf_buf_free (Outbuf *buf); -Outbuf *evas_buffer_outbuf_buf_setup_fb (int w, int h, Outbuf_Depth depth, void *dest, int dest_row_bytes, int use_color_key, DATA32 color_key, int alpha_level); +Outbuf *evas_buffer_outbuf_buf_setup_fb (int w, int h, Outbuf_Depth depth, void *dest, int dest_row_bytes, int use_color_key, DATA32 color_key, int alpha_level, + void * (*new_update_region) (int x, int y, int w, int h, int *row_bytes), + void (*free_update_region) (int x, int y, int w, int h, void *data)); + RGBA_Image *evas_buffer_outbuf_buf_new_region_for_update (Outbuf *buf, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch); void evas_buffer_outbuf_buf_free_region_for_update (Outbuf *buf, RGBA_Image *update); diff --git a/legacy/evas/src/lib/engines/buffer/evas_outbuf.c b/legacy/evas/src/lib/engines/buffer/evas_outbuf.c index 86cbd4b654..37a843fbae 100644 --- a/legacy/evas/src/lib/engines/buffer/evas_outbuf.c +++ b/legacy/evas/src/lib/engines/buffer/evas_outbuf.c @@ -15,7 +15,10 @@ evas_buffer_outbuf_buf_free(Outbuf *buf) } Outbuf * -evas_buffer_outbuf_buf_setup_fb(int w, int h, Outbuf_Depth depth, void *dest, int dest_row_bytes, int use_color_key, DATA32 color_key, int alpha_level) +evas_buffer_outbuf_buf_setup_fb(int w, int h, Outbuf_Depth depth, void *dest, int dest_row_bytes, int use_color_key, DATA32 color_key, int alpha_level, + void * (*new_update_region) (int x, int y, int w, int h, int *row_bytes), + void (*free_update_region) (int x, int y, int w, int h, void *data) + ) { Outbuf *buf; @@ -32,7 +35,9 @@ evas_buffer_outbuf_buf_setup_fb(int w, int h, Outbuf_Depth depth, void *dest, in buf->alpha_level = alpha_level; buf->color_key = color_key; buf->use_color_key = use_color_key; - + + buf->func.new_update_region = new_update_region; + buf->func.free_update_region = free_update_region; return buf; } @@ -68,17 +73,26 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int { DATA8 thresh; int xx, yy; + int row_bytes; + DATA8 *dest; DATA32 colorkey; DATA32 *src; DATA8 *dst; colorkey = buf->color_key; thresh = buf->alpha_level; + row_bytes = buf->dest_row_bytes; + dest = (DATA8 *)(buf->dest) + (y * row_bytes) + (x * 3); + if (buf->func.new_update_region) + { + dest = buf->func.new_update_region(x, y, w, h, &row_bytes); + } + if (!dest) break; if (buf->use_color_key) { for (yy = 0; yy < h; yy++) { - dst = (DATA8 *)(buf->dest) + ((y + yy) * buf->dest_row_bytes) + (x * 3); + dst = dest + (yy * row_bytes); src = update->image->data + (yy * update->image->w); for (xx = 0; xx < w; xx++) { @@ -102,7 +116,7 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int { for (yy = 0; yy < h; yy++) { - dst = (DATA8 *)(buf->dest) + ((y + yy) * buf->dest_row_bytes) + (x * 3); + dst = dest + (yy * row_bytes); src = update->image->data + (yy * update->image->w); for (xx = 0; xx < w; xx++) { @@ -113,6 +127,10 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int } } } + if (buf->func.free_update_region) + { + buf->func.free_update_region(x, y, w, h, dest); + } } break; case OUTBUF_DEPTH_BGR_24BPP_888_888: @@ -120,17 +138,26 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int { DATA8 thresh; int xx, yy; + int row_bytes; + DATA8 *dest; DATA32 colorkey; DATA32 *src; DATA8 *dst; colorkey = buf->color_key; thresh = buf->alpha_level; + row_bytes = buf->dest_row_bytes; + dest = (DATA8 *)(buf->dest) + (y * row_bytes) + (x * 3); + if (buf->func.new_update_region) + { + dest = buf->func.new_update_region(x, y, w, h, &row_bytes); + } + if (!dest) break; if (buf->use_color_key) { for (yy = 0; yy < h; yy++) { - dst = (DATA8 *)(buf->dest) + ((y + yy) * buf->dest_row_bytes) + (x * 3); + dst = dest + (yy * row_bytes); src = update->image->data + (yy * update->image->w); for (xx = 0; xx < w; xx++) { @@ -154,7 +181,7 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int { for (yy = 0; yy < h; yy++) { - dst = (DATA8 *)(buf->dest) + ((y + yy) * buf->dest_row_bytes) + (x * 3); + dst = dest + (yy * row_bytes); src = update->image->data + (yy * update->image->w); for (xx = 0; xx < w; xx++) { @@ -165,6 +192,10 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int } } } + if (buf->func.free_update_region) + { + buf->func.free_update_region(x, y, w, h, dest); + } } break; case OUTBUF_DEPTH_RGB_32BPP_888_8888: