evas: move buffer engine to use more generic infrastructure.

This commit is contained in:
Cedric BAIL 2014-06-18 11:11:49 +02:00
parent c7ddcb14ac
commit bef09531c1
3 changed files with 155 additions and 277 deletions

View File

@ -21,12 +21,7 @@ typedef struct _Render_Engine Render_Engine;
struct _Render_Engine
{
Tilebuf *tb;
Outbuf *ob;
Tilebuf_Rect *rects;
Eina_Inlist *cur_rect;
Eina_Inarray previous_rects;
int end : 1;
Render_Engine_Software_Generic generic;
};
/* prototypes we will use here */
@ -36,15 +31,6 @@ static void *eng_info(Evas *eo_e EINA_UNUSED);
static void eng_info_free(Evas *eo_e EINA_UNUSED, void *info);
static int eng_setup(Evas *eo_e, void *info);
static void eng_output_free(void *data);
static void eng_output_resize(void *data, int w, int h);
static void eng_output_tile_size_set(void *data, int w, int h);
static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
static void eng_output_redraws_clear(void *data);
static void *eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch);
static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h, Evas_Render_Mode render_mode);
static void eng_output_flush(void *data, Evas_Render_Mode render_mode);
static void eng_output_idle_flush(void *data);
/* internal engine routines */
static void *
@ -64,7 +50,10 @@ _output_setup(int w,
void *switch_data
)
{
Outbuf *ob;
Render_Engine *re;
Outbuf_Depth dep;
DATA32 color_key = 0;
re = calloc(1, sizeof(Render_Engine));
if (!re)
@ -85,42 +74,53 @@ _output_setup(int w,
evas_buffer_outbuf_buf_init();
{
Outbuf_Depth dep;
DATA32 color_key = 0;
dep = OUTBUF_DEPTH_BGR_24BPP_888_888;
if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_ARGB32)
dep = OUTBUF_DEPTH_ARGB_32BPP_8888_8888;
else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_RGB32)
dep = OUTBUF_DEPTH_RGB_32BPP_888_8888;
else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_BGRA32)
dep = OUTBUF_DEPTH_BGRA_32BPP_8888_8888;
else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_RGB24)
dep = OUTBUF_DEPTH_RGB_24BPP_888_888;
else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_BGR24)
dep = OUTBUF_DEPTH_BGR_24BPP_888_888;
R_VAL(&color_key) = color_key_r;
G_VAL(&color_key) = color_key_g;
B_VAL(&color_key) = color_key_b;
A_VAL(&color_key) = 0;
ob = evas_buffer_outbuf_buf_setup_fb(w,
h,
dep,
dest_buffer,
dest_buffer_row_bytes,
use_color_key,
color_key,
alpha_threshold,
new_update_region,
free_update_region,
switch_buffer,
switch_data);
if (!ob) goto on_error;
dep = OUTBUF_DEPTH_BGR_24BPP_888_888;
if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_ARGB32)
dep = OUTBUF_DEPTH_ARGB_32BPP_8888_8888;
else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_RGB32)
dep = OUTBUF_DEPTH_RGB_32BPP_888_8888;
else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_BGRA32)
dep = OUTBUF_DEPTH_BGRA_32BPP_8888_8888;
else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_RGB24)
dep = OUTBUF_DEPTH_RGB_24BPP_888_888;
else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_BGR24)
dep = OUTBUF_DEPTH_BGR_24BPP_888_888;
R_VAL(&color_key) = color_key_r;
G_VAL(&color_key) = color_key_g;
B_VAL(&color_key) = color_key_b;
A_VAL(&color_key) = 0;
re->ob = evas_buffer_outbuf_buf_setup_fb(w,
h,
dep,
dest_buffer,
dest_buffer_row_bytes,
use_color_key,
color_key,
alpha_threshold,
new_update_region,
free_update_region,
switch_buffer,
switch_data);
}
re->tb = evas_common_tilebuf_new(w, h);
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
eina_inarray_step_set(&re->previous_rects, sizeof (Eina_Inarray), sizeof (Eina_Rectangle), 8);
if (!evas_render_engine_software_generic_init(&re->generic, ob,
evas_buffer_outbuf_buf_swap_mode_get,
evas_buffer_outbuf_buf_rot_get,
evas_buffer_outbuf_reconfigure,
evas_buffer_outbuf_buf_new_region_for_update,
evas_buffer_outbuf_buf_push_updated_region,
evas_buffer_outbuf_buf_free_region_for_update,
NULL,
evas_buffer_outbuf_buf_switch_buffer,
evas_buffer_outbuf_buf_free,
w, h))
goto on_error;
return re;
on_error:
if (ob) evas_buffer_outbuf_buf_free(ob);
free(re);
return NULL;
}
/* engine api this module provides */
@ -180,209 +180,21 @@ eng_output_free(void *data)
Render_Engine *re;
re = (Render_Engine *)data;
evas_buffer_outbuf_buf_free(re->ob);
evas_common_tilebuf_free(re->tb);
if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
evas_render_engine_software_generic_clean(&re->generic);
free(re);
evas_common_font_shutdown();
evas_common_image_shutdown();
}
static void
eng_output_resize(void *data, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
{
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);
void * (*switch_buffer) (void *switch_data, void *dest);
void *switch_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;
switch_buffer = re->ob->func.switch_buffer;
switch_data = re->ob->switch_data;
evas_buffer_outbuf_buf_free(re->ob);
re->ob = evas_buffer_outbuf_buf_setup_fb(w,
h,
depth,
dest,
dest_row_bytes,
use_color_key,
color_key,
alpha_level,
new_update_region,
free_update_region,
switch_buffer,
switch_data);
}
evas_common_tilebuf_free(re->tb);
re->tb = evas_common_tilebuf_new(w, h);
if (re->tb)
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
}
static void
eng_output_tile_size_set(void *data, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_set_tile_size(re->tb, w, h);
}
static void
eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
}
static void
eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
}
static void
eng_output_redraws_clear(void *data)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_clear(re->tb);
}
static void *
eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
{
Render_Engine *re;
RGBA_Image *surface;
Tilebuf_Rect *rect;
int ux, uy, uw, uh;
re = (Render_Engine *)data;
if (re->end)
{
re->end = 0;
return NULL;
}
if (!re->rects)
{
re->rects = evas_common_tilebuf_get_render_rects(re->tb);
/* handle double buffering */
if (re->ob->func.switch_buffer)
{
Eina_Rectangle *pushing;
if (re->ob->first_frame && !re->previous_rects.len)
{
evas_common_tilebuf_add_redraw(re->tb, 0, 0, re->ob->w, re->ob->h);
re->ob->first_frame = 0;
}
/* push previous frame */
EINA_INARRAY_FOREACH(&re->previous_rects, pushing)
evas_common_tilebuf_add_redraw(re->tb, pushing->x, pushing->y, pushing->w, pushing->h);
eina_inarray_flush(&re->previous_rects);
/* save current list of damage */
EINA_INLIST_FOREACH(re->rects, rect)
{
Eina_Rectangle local;
EINA_RECTANGLE_SET(&local, rect->x, rect->y, rect->w, rect->h);
eina_inarray_push(&re->previous_rects, &local);
}
/* and regenerate the damage list by tacking into account the damage over two frames */
evas_common_tilebuf_free_render_rects(re->rects);
re->rects = evas_common_tilebuf_get_render_rects(re->tb);
}
re->cur_rect = EINA_INLIST_GET(re->rects);
}
if (!re->cur_rect) return NULL;
rect = (Tilebuf_Rect *)re->cur_rect;
ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
re->cur_rect = re->cur_rect->next;
if (!re->cur_rect)
{
evas_common_tilebuf_free_render_rects(re->rects);
re->rects = NULL;
re->end = 1;
}
if ((ux + uw) > re->ob->w) uw = re->ob->w - ux;
if ((uy + uh) > re->ob->h) uh = re->ob->h - uy;
if ((uw <= 0) || (uh <= 0)) return NULL;
surface = evas_buffer_outbuf_buf_new_region_for_update(re->ob,
ux, uy, uw, uh,
cx, cy, cw, ch);
*x = ux; *y = uy; *w = uw; *h = uh;
return surface;
}
static void
eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h, Evas_Render_Mode render_mode)
{
Render_Engine *re;
if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return;
re = (Render_Engine *)data;
#ifdef BUILD_PIPE_RENDER
evas_common_pipe_map_begin(surface);
#endif
evas_buffer_outbuf_buf_push_updated_region(re->ob, surface, x, y, w, h);
evas_buffer_outbuf_buf_free_region_for_update(re->ob, surface);
evas_common_cpu_end_opt();
}
static void
eng_output_flush(void *data, Evas_Render_Mode render_mode)
{
Render_Engine *re = (Render_Engine *)data;
if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return;
evas_buffer_outbuf_buf_switch_buffer(re->ob);
}
static void
eng_output_idle_flush(void *data EINA_UNUSED)
{
}
static Eina_Bool
eng_canvas_alpha_get(void *data, void *context EINA_UNUSED)
{
Render_Engine *re;
re = (Render_Engine *)data;
if (re->ob->priv.back_buf)
return re->ob->priv.back_buf->cache_entry.flags.alpha;
if (re->generic.ob->priv.back_buf)
return re->generic.ob->priv.back_buf->cache_entry.flags.alpha;
return EINA_TRUE;
}
@ -411,15 +223,6 @@ module_open(Evas_Module *em)
ORD(setup);
ORD(canvas_alpha_get);
ORD(output_free);
ORD(output_resize);
ORD(output_tile_size_set);
ORD(output_redraws_rect_add);
ORD(output_redraws_rect_del);
ORD(output_redraws_clear);
ORD(output_redraws_next_update_get);
ORD(output_redraws_next_update_push);
ORD(output_flush);
ORD(output_idle_flush);
/* now advertise out own api */
em->functions = (void *)(&func);
return 1;

View File

@ -1,6 +1,9 @@
#ifndef EVAS_ENGINE_H
#define EVAS_ENGINE_H
#include "evas_common_private.h"
#include "../software_generic/Evas_Engine_Software_Generic.h"
/* this thing is for eina_log */
extern int _evas_engine_buffer_log_dom ;
@ -29,21 +32,6 @@ extern int _evas_engine_buffer_log_dom ;
#endif
#define CRI(...) EINA_LOG_DOM_CRIT(_evas_engine_buffer_log_dom, __VA_ARGS__)
typedef struct _Outbuf Outbuf;
typedef enum _Outbuf_Depth Outbuf_Depth;
enum _Outbuf_Depth
{
OUTBUF_DEPTH_NONE,
OUTBUF_DEPTH_ARGB_32BPP_8888_8888,
OUTBUF_DEPTH_BGRA_32BPP_8888_8888,
OUTBUF_DEPTH_RGB_32BPP_888_8888,
OUTBUF_DEPTH_BGR_32BPP_888_8888,
OUTBUF_DEPTH_RGB_24BPP_888_888,
OUTBUF_DEPTH_BGR_24BPP_888_888,
OUTBUF_DEPTH_LAST
};
struct _Outbuf
{
@ -75,6 +63,18 @@ struct _Outbuf
void evas_buffer_outbuf_buf_init (void);
void evas_buffer_outbuf_buf_free (Outbuf *buf);
void evas_buffer_outbuf_buf_update_fb (Outbuf *buf,
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),
void * (*switch_buffer) (void *data, void *dest_buffer),
void *switch_data);
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),
@ -82,10 +82,12 @@ Outbuf *evas_buffer_outbuf_buf_setup_fb (int w, int h, Outbuf
void *switch_data);
void evas_buffer_outbuf_reconfigure (Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth);
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);
void evas_buffer_outbuf_buf_push_updated_region (Outbuf *buf, RGBA_Image *update, int x, int y, int w, int h);
void evas_buffer_outbuf_buf_switch_buffer (Outbuf *buf);
Render_Engine_Swap_Mode evas_buffer_outbuf_buf_swap_mode_get(Outbuf *buf);
int evas_buffer_outbuf_buf_rot_get (Outbuf *buf);
#endif

View File

@ -29,19 +29,13 @@ evas_buffer_outbuf_buf_free(Outbuf *buf)
free(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,
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),
void * (*switch_buffer) (void *data, void *dest_buffer),
void *switch_data
)
void
evas_buffer_outbuf_buf_update_fb(Outbuf *buf, 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),
void * (*switch_buffer) (void *data, void *dest_buffer),
void *switch_data)
{
Outbuf *buf;
buf = calloc(1, sizeof(Outbuf));
if (!buf) return NULL;
buf->w = w;
buf->h = h;
buf->depth = depth;
@ -92,6 +86,33 @@ evas_buffer_outbuf_buf_setup_fb(int w, int h, Outbuf_Depth depth, void *dest, in
buf->dest,
0, EVAS_COLORSPACE_ARGB8888);
}
}
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),
void * (*switch_buffer) (void *data, void *dest_buffer),
void *switch_data)
{
Outbuf *buf;
buf = calloc(1, sizeof(Outbuf));
if (!buf) return NULL;
evas_buffer_outbuf_buf_update_fb(buf,
w,
h,
depth,
dest,
dest_row_bytes,
use_color_key,
color_key,
alpha_level,
new_update_region,
free_update_region,
switch_buffer,
switch_data);
return buf;
}
@ -417,3 +438,55 @@ evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int
break;
}
}
void
evas_buffer_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot EINA_UNUSED, Outbuf_Depth 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);
void * (*switch_buffer) (void *switch_data, void *dest);
void *switch_data;
if (depth == OUTBUF_DEPTH_INHERIT) depth = ob->depth;
dest = ob->dest;
dest_row_bytes = ob->dest_row_bytes;
alpha_level = ob->alpha_level;
color_key = ob->color_key;
use_color_key = ob->use_color_key;
new_update_region = ob->func.new_update_region;
free_update_region = ob->func.free_update_region;
switch_buffer = ob->func.switch_buffer;
switch_data = ob->switch_data;
evas_buffer_outbuf_buf_update_fb(ob,
w,
h,
depth,
dest,
dest_row_bytes,
use_color_key,
color_key,
alpha_level,
new_update_region,
free_update_region,
switch_buffer,
switch_data);
}
Render_Engine_Swap_Mode
evas_buffer_outbuf_buf_swap_mode_get(Outbuf *ob)
{
if (ob->func.switch_buffer) return MODE_DOUBLE;
return MODE_FULL;
}
int
evas_buffer_outbuf_buf_rot_get(Outbuf *buf EINA_UNUSED)
{
return 0;
}