Remove DirectFB, will add a new one based on SDL code.

Remove DirectFB, will create a new one based on SDL.


SVN revision: 34559
This commit is contained in:
Gustavo Sverzut Barbieri 2008-05-13 19:32:00 +00:00
parent ad70ab93f4
commit 782e77d9ae
7 changed files with 0 additions and 1289 deletions

View File

@ -1,6 +0,0 @@
.deps
.libs
Makefile
Makefile.in
*.lo
*.la

View File

@ -1,22 +0,0 @@
#ifndef _EVAS_ENGINE_DIRECTFB_H
#define _EVAS_ENGINE_DIRECTFB_H
#include <directfb/directfb.h>
typedef struct _Evas_Engine_Info_DirectFB Evas_Engine_Info_DirectFB;
struct _Evas_Engine_Info_DirectFB
{
/* PRIVATE - don't mess with this baby or evas will poke its tongue out */
/* at you and make nasty noises */
Evas_Engine_Info magic;
struct {
IDirectFB *dfb;
IDirectFBSurface *surface;
DFBSurfaceDrawingFlags flags;
} info;
};
#endif

View File

@ -1,37 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = \
-I. \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/lib/include \
@FREETYPE_CFLAGS@ \
@DIRECTFB_CFLAGS@
if BUILD_ENGINE_DIRECTFB
pkgdir = $(libdir)/evas/modules/engines/directfb/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = \
evas_engine_dfb.c \
evas_engine_dfb_image_objects.c \
evas_engine_dfb_image_objects.h \
evas_engine_dfb.h
module_la_LIBADD = @DIRECTFB_LIBS@ $(top_builddir)/src/lib/libevas.la
module_la_LDFLAGS = -module -avoid-version
module_la_LIBTOOLFLAGS = --tag=disable-static
module_la_DEPENDENCIES = $(top_builddir)/config.h
include_HEADERS = Evas_Engine_DirectFB.h
endif
EXTRA_DIST = \
evas_engine_dfb.c \
evas_engine_dfb_image_objects.c \
evas_engine_dfb_image_objects.h \
evas_engine_dfb.h \
Evas_Engine_DirectFB.h

View File

@ -1,316 +0,0 @@
#include "evas_engine_dfb.h"
#include <math.h>
#include <string.h>
static Evas_Func func, pfunc;
static void *
eng_info(Evas *e)
{
Evas_Engine_Info_DirectFB *info;
info = calloc(1, sizeof(Evas_Engine_Info_DirectFB));
if (!info)
return NULL;
info->magic.magic = rand();
return info;
e = NULL;
}
static void
eng_info_free(Evas *e, void *info)
{
Evas_Engine_Info_DirectFB *in;
in = (Evas_Engine_Info_DirectFB *)info;
free(in);
}
static void *eng_output_setup(int w, int h, IDirectFB *dfb, IDirectFBSurface *surf, DFBSurfaceDrawingFlags flags);
static void
eng_setup(Evas *e, void *in)
{
Evas_Engine_Info_DirectFB *info;
info = (Evas_Engine_Info_DirectFB *) in;
if (!e->engine.data.output)
e->engine.data.output =
eng_output_setup(e->output.w,
e->output.h,
info->info.dfb,
info->info.surface,
info->info.flags);
if (!e->engine.data.output)
return;
if (!e->engine.data.context)
e->engine.data.context =
e->engine.func->context_new(e->engine.data.output);
}
static void *
eng_output_setup(int w, int h, IDirectFB *dfb, IDirectFBSurface *surf, DFBSurfaceDrawingFlags flags)
{
Render_Engine *re;
DFBSurfaceDescription dsc;
DFBResult res;
RGBA_Image *im;
re = calloc(1, sizeof(Render_Engine));
/* if we haven't initialized - init (automatic abort if already done) */
evas_common_cpu_init();
evas_common_blend_init();
evas_common_image_init();
evas_common_convert_init();
evas_common_scale_init();
evas_common_rectangle_init();
evas_common_gradient_init();
evas_common_polygon_init();
evas_common_line_init();
evas_common_font_init();
evas_common_draw_init();
evas_common_tilebuf_init();
re->tb = evas_common_tilebuf_new(w, h);
/* in preliminary tests 16x16 gave highest framerates */
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
re->dfb = dfb;
re->surface = surf;
memset(&dsc, 0, sizeof(DFBSurfaceDescription));
dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
dsc.width = (w > 0) ? w : 1;
dsc.height = (h > 0) ? h : 1;
dsc.pixelformat = DSPF_ARGB;
res = dfb->CreateSurface(dfb, &dsc, &re->backbuf);
if (res != DFB_OK)
{
printf("DFB engine: cannot create backbuf: %s\n",
DirectFBErrorString(res));
exit(-1);
}
re->backbuf->SetDrawingFlags(re->backbuf, flags);
/* We create a "fake" RGBA_Image which points the to DFB surface. Each access
* to that surface is wrapped in Lock / Unlock calls whenever the data is
* manipulated directly. */
im = (RGBA_Image*) evas_cache_image_empty(evas_common_image_cache_get());
evas_cache_image_size_set(&im->cache_entry, w, h);
re->rgba_image = im;
return re;
}
static void
eng_output_free(void *data)
{
Render_Engine *re;
re = (Render_Engine *) data;
evas_common_tilebuf_free(re->tb);
if (re->rects)
evas_common_tilebuf_free_render_rects(re->rects);
re->backbuf->Release(re->backbuf);
evas_cache_image_drop(&re->rgba_image->cache_entry);
free(re);
evas_common_font_shutdown();
evas_common_image_shutdown();
}
static void
eng_output_resize(void *data, int w, int h)
{
Render_Engine *re;
IDirectFBSurface *new_surf;
DFBSurfaceDescription dsc;
re = (Render_Engine *) data;
if (w == re->tb->outbuf_w && h == re->tb->outbuf_h) return;
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);
memset(&dsc, 0, sizeof(DFBSurfaceDescription));
dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
dsc.width = (w > 0) ? w : 1;
dsc.height = (h > 0) ? h : 1;
dsc.pixelformat = DSPF_ARGB;
if (re->dfb->CreateSurface(re->dfb, &dsc, &new_surf) == DFB_OK)
{
new_surf->StretchBlit(new_surf, re->backbuf, NULL, NULL);
re->backbuf->Release(re->backbuf);
re->backbuf = new_surf;
re->rgba_image = (RGBA_Image*) evas_cache_image_size_set(&re->rgba_image->cache_entry, w, h);
}
}
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;
Tilebuf_Rect *rect;
int ux, uy, uw, uh, pitch;
void *pixels;
DFBRegion region;
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);
re->cur_rect = (Evas_Object_List *) 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;
}
*cx = *x = ux;
*cy = *y = uy;
*cw = *w = uw;
*ch = *h = uh;
region.x1 = ux;
region.y1 = uy;
region.x2 = ux + uw - 1;
region.y2 = uy + uh - 1;
re->backbuf->SetClip(re->backbuf, &region);
re->backbuf->Clear(re->backbuf, 0, 0, 0, 0);
re->backbuf->SetClip(re->backbuf, NULL);
re->backbuf->Lock(re->backbuf, DSLF_WRITE, &pixels, &pitch);
re->rgba_image->image.data = pixels;
return re->rgba_image;
}
static void
eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
{
Render_Engine *re;
DFBRectangle rect = {x, y, w, h};
DFBRegion region = {x, y, x + w, y + h};
re = (Render_Engine *) data;
re->backbuf->Unlock(re->backbuf);
/* XXX TODO: store rect + x,y and use BatchBlit() */
re->surface->Blit(re->surface, re->backbuf, &rect, x, y);
re->surface->Flip(re->surface, &region, DSFLIP_NONE);
evas_common_cpu_end_opt();
re->rgba_image->image.data = NULL;
}
static void
eng_output_flush(void *data)
{
Render_Engine *re;
re = (Render_Engine *) data;
}
static void
eng_output_idle_flush(void *data)
{
Render_Engine *re;
re = (Render_Engine *) data;
}
EAPI int
module_open(Evas_Module *em)
{
if (!em) return 0;
/* get whatever engine module we inherit from */
if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
/* store it for later use */
func = pfunc;
/* now to override methods */
#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
ORD(info);
ORD(info_free);
ORD(setup);
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;
}
EAPI void
module_close(void)
{
}
EAPI Evas_Module_Api evas_modapi =
{
EVAS_MODULE_API_VERSION,
EVAS_MODULE_TYPE_ENGINE,
"directfb",
"none"
};

View File

@ -1,22 +0,0 @@
#ifndef EVAS_ENGINE_DFB_H
#define EVAS_ENGINE_DFB_H
#include "evas_common.h"
#include "evas_private.h"
#include "Evas_Engine_DirectFB.h"
#include "evas_engine_dfb_image_objects.h"
typedef struct _Render_Engine Render_Engine;
struct _Render_Engine
{
Tilebuf *tb;
Tilebuf_Rect *rects;
Evas_Object_List *cur_rect;
IDirectFB *dfb;
IDirectFBSurface *surface;
IDirectFBSurface *backbuf; /* do we need an outbuf beyond this? */
RGBA_Image *rgba_image;
int end:1;
};
#endif

View File

@ -1,821 +0,0 @@
#include "evas_engine_dfb.h"
#include <math.h>
#include <string.h>
static Evas_Hash * images = NULL;
static Evas_List * cache = NULL;
static int cache_size = 0;
static int cache_usage = 0;
static RGBA_Image *_dfb_image_create(Render_Engine *, int w, int h);
static void _dfb_image_free(RGBA_Image *im);
static void _dfb_image_unref(RGBA_Image *im);
static void _dfb_image_dirty(RGBA_Image *im);
static void _dfb_image_set_cache(int size);
static int _dfb_image_get_cache();
static void _dfb_image_flush_cache();
static void _dfb_image_cache(RGBA_Image *im);
static void _dfb_image_uncache(RGBA_Image *im);
static void _dfb_image_store(RGBA_Image *im);
static void _dfb_image_unstore(RGBA_Image *im);
static void _dfb_image_ref(RGBA_Image *im);
static void _dfb_image_unref(RGBA_Image *im);
static RGBA_Image *_dfb_image_find(const char *filename, const char *key, DATA64 timestamp);
/*
* Image objects
*/
void *
evas_engine_directfb_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
{
Render_Engine *re;
DFBSurfaceDescription dsc;
DFBImageDescription img_desc;
IDirectFBImageProvider *provider;
IDirectFBSurface *image;
RGBA_Image *im = NULL;
DATA64 mod_time;
re = (Render_Engine *) data;
*error = 0;
if (!file) return NULL;
// mod_time = evas_file_modified_time(file);
im = _dfb_image_find(file, key, mod_time);
if (im)
{
_dfb_image_ref(im);
return im;
}
/* Image is not in cache or not already used -> create it */
provider = NULL;
re->dfb->CreateImageProvider(re->dfb, file, &provider);
if (!provider) return NULL;
provider->GetSurfaceDescription(provider, &dsc);
provider->GetImageDescription(provider, &img_desc);
dsc.flags |= DSDESC_PIXELFORMAT;
dsc.pixelformat = DSPF_ARGB;
re->dfb->CreateSurface(re->dfb, &dsc, &image);
if (!image)
{
provider->Release(provider);
return NULL;
}
provider->RenderTo(provider, image, NULL);
provider->Release(provider);
im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
dsc.width, dsc.height,
(void*) image,
img_desc.caps & DICAPS_ALPHACHANNEL,
EVAS_COLORSPACE_ARGB8888);
im->cache_entry.file = strdup(file);
im->cache_entry.key = strdup(key);
_dfb_image_ref(im);
return im;
}
void *
evas_engine_directfb_image_new_from_data(void *data, int w, int h,
DATA32 * image_data, int alpha, int cspace)
{
/* FIXME document this peculiarity */
return evas_engine_directfb_image_new_from_copied_data(data, w, h, image_data, alpha, cspace);
}
void *
evas_engine_directfb_image_new_from_copied_data(void *data, int w, int h,
DATA32 * image_data, int alpha, int cspace)
{
/* FIXME use alpha and cspace here or not? */
Render_Engine *re;
RGBA_Image *im = NULL;
IDirectFBSurface *surf;
void *p;
int pitch;
re = (Render_Engine *) data;
im = _dfb_image_create(re, w, h);
if (im)
{
surf = (IDirectFBSurface *) im->image.data;
if (surf->Lock(surf, DSLF_WRITE, &p, &pitch) == DFB_OK)
{
memcpy(p, image_data, w * h * sizeof(DATA32));
surf->Unlock(surf);
}
}
/* FIXME */
free(image_data);
return im;
}
void
evas_engine_directfb_image_free(void *data, void *image)
{
Render_Engine *re;
re = (Render_Engine *) data;
_dfb_image_unref(image);
}
void
evas_engine_directfb_image_size_get(void *data, void *image, int *w, int *h)
{
Render_Engine *re;
RGBA_Image *im;
re = (Render_Engine *) data;
im = image;
if (w)
*w = im->cache_entry.w;
if (h)
*h = im->cache_entry.h;
}
void *
evas_engine_directfb_image_size_set(void *data, void *image, int w, int h)
{
Render_Engine *re;
IDirectFBSurface *old_surf;
IDirectFBSurface *new_surf;
DFBRectangle outrect;
RGBA_Image *im, *im_old;
re = (Render_Engine *) data;
im_old = image;
im = _dfb_image_create(re, w, h);
old_surf = (IDirectFBSurface *) im_old->image.data;
if (im)
{
outrect.x = 0;
outrect.y = 0;
outrect.w = w;
outrect.h = h;
new_surf = (IDirectFBSurface *) im->image.data;
new_surf->StretchBlit(new_surf, old_surf, NULL, &outrect);
}
evas_common_cpu_end_opt;
_dfb_image_unref(im_old);
return im;
}
void *
evas_engine_directfb_image_dirty_region(void *data, void *image, int x, int y,
int w, int h)
{
_dfb_image_dirty(image);
return image;
x = 0;
y = 0;
w = 0;
h = 0;
}
void *
evas_engine_directfb_image_data_get(void *data, void *image, int to_write,
DATA32 ** image_data)
{
Render_Engine *re;
RGBA_Image *im;
IDirectFBSurface *surf;
void *p;
int pitch;
DATA32 *buf = NULL;
int size;
re = (Render_Engine *) data;
im = image;
surf = (IDirectFBSurface *) im->image.data;
size = im->cache_entry.w * im->cache_entry.h * sizeof(DATA32);
surf->Lock(surf, DSLF_READ, &p, &pitch);
if ((buf = malloc(size)))
buf = memcpy(buf, p, size);
*image_data = buf;
surf->Unlock(surf);
return im;
}
void *
evas_engine_directfb_image_data_put(void *data, void *image,
DATA32 * image_data)
{
Render_Engine *re;
RGBA_Image *im;
re = (Render_Engine *)data;
im = image;
if (image_data != im->image.data)
{
int w, h;
w = im->cache_entry.w;
h = im->cache_entry.h;
_dfb_image_unref(im);
/* FIXME alpha and cspace (0, 0) is not used here yet */
return evas_engine_directfb_image_new_from_data(data, w, h, image_data, 0, 0);
}
_dfb_image_dirty(im);
return im;
}
void *
evas_engine_directfb_image_alpha_set(void *data, void *image, int has_alpha)
{
RGBA_Image *im;
im = image;
if (has_alpha)
im->flags |= RGBA_IMAGE_HAS_ALPHA;
else
im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
return im;
}
int
evas_engine_directfb_image_alpha_get(void *data, void *image)
{
Render_Engine *re;
RGBA_Image *im;
re = (Render_Engine *) data;
im = image;
if (im->flags & RGBA_IMAGE_HAS_ALPHA)
return 1;
return 0;
}
void *
evas_engine_directfb_image_border_set(void *data, void *image, int l, int r, int t, int b)
{
return image;
}
void
evas_engine_directfb_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b)
{
Render_Engine *re;
RGBA_Image *im;
re = (Render_Engine *) data;
im = image;
}
void
evas_engine_directfb_image_draw(void *data, void *context, void *surface,
void *image, int src_region_x, int src_region_y,
int src_region_w, int src_region_h,
int dst_region_x, int dst_region_y,
int dst_region_w, int dst_region_h, int smooth)
{
int src_w, src_h, dst_w, dst_h;
int dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h;
double horiz_stretch, vert_stretch;
Render_Engine *re = (Render_Engine *) data;
DFBRectangle inrect;
DFBRectangle outrect;
RGBA_Image *im = (RGBA_Image *) image;
RGBA_Draw_Context *dc = (RGBA_Draw_Context *) context;
IDirectFBSurface *img = (IDirectFBSurface *) im->image.data;
src_w = im->cache_entry.w;
src_h = im->cache_entry.h;
dst_w = re->tb->outbuf_w;
dst_h = re->tb->outbuf_h;
if (!
(RECTS_INTERSECT
(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst_w,
dst_h)))
return;
if (!
(RECTS_INTERSECT
(src_region_x, src_region_y, src_region_w, src_region_h, 0, 0, src_w,
src_h)))
return;
if (dc->clip.use)
{
dst_clip_x = dc->clip.x;
dst_clip_y = dc->clip.y;
dst_clip_w = dc->clip.w;
dst_clip_h = dc->clip.h;
if (dst_clip_x < 0)
{
dst_clip_w += dst_clip_x;
dst_clip_x = 0;
}
if (dst_clip_y < 0)
{
dst_clip_h += dst_clip_y;
dst_clip_y = 0;
}
if ((dst_clip_x + dst_clip_w) > dst_w)
dst_clip_w = dst_w - dst_clip_x;
if ((dst_clip_y + dst_clip_h) > dst_h)
dst_clip_h = dst_h - dst_clip_y;
}
else
{
dst_clip_x = 0;
dst_clip_y = 0;
dst_clip_w = dst_w;
dst_clip_h = dst_h;
}
if (dst_clip_x < dst_region_x)
{
dst_clip_w += dst_clip_x - dst_region_x;
dst_clip_x = dst_region_x;
}
if ((dst_clip_x + dst_clip_w) > (dst_region_x + dst_region_w))
dst_clip_w = dst_region_x + dst_region_w - dst_clip_x;
if (dst_clip_y < dst_region_y)
{
dst_clip_h += dst_clip_y - dst_region_y;
dst_clip_y = dst_region_y;
}
if ((dst_clip_y + dst_clip_h) > (dst_region_y + dst_region_h))
dst_clip_h = dst_region_y + dst_region_h - dst_clip_y;
if ((src_region_w <= 0) || (src_region_h <= 0) ||
(dst_region_w <= 0) || (dst_region_h <= 0) ||
(dst_clip_w <= 0) || (dst_clip_h <= 0))
return;
/* sanitise x */
if (src_region_x < 0)
{
dst_region_x -= (src_region_x * dst_region_w) / src_region_w;
dst_region_w += (src_region_x * dst_region_w) / src_region_w;
src_region_w += src_region_x;
src_region_x = 0;
}
if (src_region_x >= src_w)
return;
if ((src_region_x + src_region_w) > src_w)
{
dst_region_w = (dst_region_w * (src_w - src_region_x)) / (src_region_w);
src_region_w = src_w - src_region_x;
}
if (dst_region_w <= 0)
return;
if (src_region_w <= 0)
return;
if (dst_clip_x < 0)
{
dst_clip_w += dst_clip_x;
dst_clip_x = 0;
}
if (dst_clip_w <= 0)
return;
if (dst_clip_x >= dst_w)
return;
if (dst_clip_x < dst_region_x)
{
dst_clip_w += (dst_clip_x - dst_region_x);
dst_clip_x = dst_region_x;
}
if ((dst_clip_x + dst_clip_w) > dst_w)
{
dst_clip_w = dst_w - dst_clip_x;
}
if (dst_clip_w <= 0)
return;
/* sanitise y */
if (src_region_y < 0)
{
dst_region_y -= (src_region_y * dst_region_h) / src_region_h;
dst_region_h += (src_region_y * dst_region_h) / src_region_h;
src_region_h += src_region_y;
src_region_y = 0;
}
if (src_region_y >= src_h)
return;
if ((src_region_y + src_region_h) > src_h)
{
dst_region_h = (dst_region_h * (src_h - src_region_y)) / (src_region_h);
src_region_h = src_h - src_region_y;
}
if (dst_region_h <= 0)
return;
if (src_region_h <= 0)
return;
if (dst_clip_y < 0)
{
dst_clip_h += dst_clip_y;
dst_clip_y = 0;
}
if (dst_clip_h <= 0)
return;
if (dst_clip_y >= dst_h)
return;
if (dst_clip_y < dst_region_y)
{
dst_clip_h += (dst_clip_y - dst_region_y);
dst_clip_y = dst_region_y;
}
if ((dst_clip_y + dst_clip_h) > dst_h)
{
dst_clip_h = dst_h - dst_clip_y;
}
if (dst_clip_h <= 0)
return;
/* Figure out scale ratios */
horiz_stretch = (double)dst_region_w / (double)src_region_w;
vert_stretch = (double)dst_region_h / (double)src_region_h;
inrect.x = src_region_x + floor((dst_clip_x - dst_region_x) / horiz_stretch);
inrect.y = src_region_y + floor((dst_clip_y - dst_region_y) / vert_stretch);
inrect.w = floor(src_region_w * dst_clip_w / dst_region_w);
inrect.h = floor(src_region_h * dst_clip_h / dst_region_h);
outrect.x = dst_clip_x;
outrect.y = dst_clip_y;
outrect.w = dst_clip_w;
outrect.h = dst_clip_h;
{
int r, g, b, a;
int mulr, mulg, mulb, mula;
int flags;
if (im->flags & RGBA_IMAGE_HAS_ALPHA)
flags = DSBLIT_BLEND_COLORALPHA | DSBLIT_BLEND_ALPHACHANNEL;
else
flags = DSBLIT_NOFX;
evas_engine_directfb_context_color_get(data, context, &r, &g, &b, &a);
if (evas_engine_directfb_context_multiplier_get
(data, context, &mulr, &mulg, &mulb, &mula))
{
re->backbuf->SetColor(re->backbuf, mulr, mulg, mulb, mula);
flags |= DSBLIT_COLORIZE;
}
else
{
re->backbuf->SetColor(re->backbuf, r, g, b, a);
}
re->backbuf->SetSrcBlendFunction(re->backbuf, DSBF_SRCALPHA);
img->SetSrcBlendFunction(img, DSBF_INVSRCALPHA);
re->backbuf->SetBlittingFlags(re->backbuf, flags);
re->backbuf->StretchBlit(re->backbuf, img, &inrect, &outrect);
}
evas_common_cpu_end_opt();
}
void
evas_engine_directfb_image_cache_flush(void *data)
{
Render_Engine *re;
int tmp_size;
re = (Render_Engine *) data;
tmp_size = cache_size;
cache_size = 0;
_dfb_image_set_cache(0);
_dfb_image_set_cache(tmp_size);
}
void
evas_engine_directfb_image_cache_set(void *data, int bytes)
{
_dfb_image_set_cache(bytes);
}
int
evas_engine_directfb_image_cache_get(void *data)
{
return _dfb_image_get_cache();
}
char *
evas_engine_directfb_image_comment_get(void *data, void *image, char *key)
{
Render_Engine *re;
RGBA_Image *im;
re = (Render_Engine *) data;
im = image;
return im->info.comment;
}
char *
evas_engine_directfb_image_format_get(void *data, void *image)
{
Render_Engine *re;
RGBA_Image *im;
re = (Render_Engine *) data;
im = image;
// if (im->info.format == 1) return "png";
return NULL;
}
void
evas_engine_directfb_image_colorspace_set(void *data, void *image, int cspace)
{
/* FIXME impliment image_colorspace_set */
}
int
evas_engine_directfb_image_colorspace_get(void *data, void *image)
{
/* FIXME impliment image_colorspace_get */
return 0;
}
void
evas_engine_directfb_image_native_set(void *data, void *image, void *native)
{
/* FIXME impliment image_native_set */
}
void *
evas_engine_directfb_image_native_get(void *data, void *image)
{
/* FIXME impliment image_native_get */
return NULL;
}
/*
* Private routines. These are slightly modified versions of the ones in
* engines/common/evas_image_main.c
*/
static void
_dfb_image_surface_free(RGBA_Image *im)
{
IDirectFBSurface *surf;
if ( (im->image.data) && (!im->image.no_free) )
{
surf = (IDirectFBSurface *)im->image.data;
surf->Release(surf);
im->image.data = NULL;
}
}
static RGBA_Image *
_dfb_image_create(Render_Engine *re, int w, int h)
{
RGBA_Image *im;
DFBSurfaceDescription dsc;
IDirectFBSurface *surf;
dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
dsc.width = w;
dsc.height = h;
dsc.pixelformat = DSPF_ARGB;
if (re->dfb->CreateSurface(re->dfb, &dsc, &surf) != DFB_OK)
return NULL;
return (RGBA_Image*) evas_cache_image_data(evas_common_image_cache_get(),
w, h,
(void*) surf,
1, EVAS_COLORSPACE_ARGB8888);
}
static void
_dfb_image_free(RGBA_Image *im)
{
if (im->image.data) _dfb_image_surface_free(im);
free(im);
}
static void
_dfb_image_ref(RGBA_Image *im)
{
im->cache_entry.references++;
if (im->cache_entry.references == 1) /* we were in cache - take us out */
{
_dfb_image_uncache(im);
_dfb_image_store(im);
}
}
static void
_dfb_image_unref(RGBA_Image *im)
{
im->cache_entry.references--;
if (im->cache_entry.references <= 0) /* we were are now in cache - put us in */
{
_dfb_image_unstore(im);
if ((cache_size > 0) &&
(!(im->flags & RGBA_IMAGE_IS_DIRTY)))
{
_dfb_image_cache(im);
_dfb_image_flush_cache();
}
else
{
_dfb_image_free(im);
}
}
}
static void
_dfb_image_set_cache(int size)
{
cache_size = size;
_dfb_image_flush_cache();
}
static int
_dfb_image_get_cache(void)
{
return cache_size;
}
static void
_dfb_image_cache(RGBA_Image *im)
{
int ram;
if (im->flags & RGBA_IMAGE_INDEXED) return;
im->flags |= RGBA_IMAGE_INDEXED;
cache = evas_list_prepend(cache, im);
ram = evas_common_image_ram_usage(im);
cache_usage += ram;
_dfb_image_flush_cache();
}
static void
_dfb_image_uncache(RGBA_Image *im)
{
int ram;
if (!(im->flags & RGBA_IMAGE_INDEXED)) return;
im->flags &= ~RGBA_IMAGE_INDEXED;
cache = evas_list_remove(cache, im);
ram = evas_common_image_ram_usage(im);
cache_usage -= ram;
}
static void
_dfb_image_flush_cache(void)
{
Evas_List *l, *l_next;
if (!cache) return;
if (cache_usage < cache_size) return;
for (l = evas_list_last(cache); l;)
{
RGBA_Image *im;
l_next = l->prev;
im = (RGBA_Image *)l;
_dfb_image_uncache(im);
_dfb_image_free(im);
if (cache_usage <= cache_size) return;
l = l_next;
}
}
static void
_dfb_image_dirty(RGBA_Image *im)
{
_dfb_image_unstore(im);
im->flags |= RGBA_IMAGE_IS_DIRTY;
}
static void
_dfb_image_store(RGBA_Image *im)
{
char *key;
int l1, l2, l3;
char buf[256];
if (im->flags & RGBA_IMAGE_IS_DIRTY) return;
if (im->flags & RGBA_IMAGE_INDEXED) return;
if ((!im->cache_entry.file) && (!im->cache_entry.key)) return;
l1 = 0;
if (im->cache_entry.file) l1 = strlen(im->cache_entry.file);
l2 = 0;
if (im->cache_entry.key) l2 = strlen(im->cache_entry.key);
// snprintf(buf, sizeof(buf), "%llx", im->timestamp);
// l3 = strlen(buf);
buf[0] = 0;
l3 = 0;
key = malloc(l1 + 3 + l2 + 3 + l3 +1);
if (!key) return;
key[0] = 0;
if (im->cache_entry.file) strcpy(key, im->cache_entry.file);
strcat(key, "/:/");
if (im->cache_entry.key) strcat(key, im->cache_entry.key);
strcat(key, "/:/");
strcat(key, buf);
images = evas_hash_add(images, key, im);
free(key);
im->flags |= RGBA_IMAGE_INDEXED;
}
static void
_dfb_image_unstore(RGBA_Image *im)
{
char *key;
int l1, l2, l3;
char buf[256];
if (!(im->flags & RGBA_IMAGE_INDEXED)) return;
if ((!im->cache_entry.file) && (!im->cache_entry.key)) return;
l1 = 0;
if (im->cache_entry.file) l1 = strlen(im->cache_entry.file);
l2 = 0;
if (im->cache_entry.key) l2 = strlen(im->cache_entry.key);
// snprintf(buf, sizeof(buf), "%llx", im->timestamp);
// l3 = strlen(buf);
buf[0] = 0;
l3 = 0;
key = malloc(l1 + 3 + l2 + 3 + l3 +1);
if (!key) return;
key[0] = 0;
if (im->cache_entry.file) strcpy(key, im->cache_entry.file);
strcat(key, "/:/");
if (im->cache_entry.key) strcat(key, im->cache_entry.key);
strcat(key, "/:/");
strcat(key, buf);
images = evas_hash_del(images, key, im);
free(key);
im->flags &= ~RGBA_IMAGE_INDEXED;
}
static RGBA_Image *
_dfb_image_find(const char *filename, const char *key, DATA64 timestamp)
{
Evas_List *l;
RGBA_Image *im;
char *str;
int l1, l2, l3;
char buf[256];
if ((!filename) && (!key)) return NULL;
l1 = 0;
if (filename) l1 = strlen(filename);
l2 = 0;
if (key) l2 = strlen(key);
// sprintf(buf, "%llx", timestamp);
// l3 = strlen(buf);
buf[0] = 0;
l3 = 0;
str = malloc(l1 + 3 + l2 + 3 + l3 +1);
if (!str) return NULL;
str[0] = 0;
if (filename) strcpy(str, filename);
strcat(str, "/:/");
if (key) strcat(str, key);
strcat(str, "/:/");
strcat(str, buf);
im = evas_hash_find(images, str);
free(str);
if (im) return im;
for (l = cache; l; l = l->next)
{
int ok;
im = (RGBA_Image *)l;
ok = 0;
if ((filename) && (im->cache_entry.file) &&
(!strcmp(filename, im->cache_entry.file)))
ok++;
if ((!filename) && (!im->cache_entry.file))
ok++;
if ((key) && (im->cache_entry.key) &&
(!strcmp(key, im->cache_entry.key)))
ok++;
if ((!key) && (!im->cache_entry.key))
ok++;
// if (im->timestamp == timestamp)
// ok++;
if (ok >= 2) return im;
}
return NULL;
}

View File

@ -1,65 +0,0 @@
#ifndef EVAS_ENGINE_DFB_IMAGE_OBJECTS_H
#define EVAS_ENGINE_DFB_IMAGE_OBJECTS_H
void *evas_engine_directfb_image_load(void *data, const char *file,
const char *key, int *error, Evas_Image_Load_Opts *lo);
void *evas_engine_directfb_image_new_from_data(void *data, int w,
int h,
DATA32 *image_data,
int alpha, int cspace);
void *evas_engine_directfb_image_new_from_copied_data(void *data,
int w,
int h,
DATA32 *image_data,
int alpha, int cspace);
void evas_engine_directfb_image_free(void *data, void *image);
void evas_engine_directfb_image_size_get(void *data, void *image,
int *w, int *h);
void *evas_engine_directfb_image_size_set(void *data, void *image,
int w, int h);
void *evas_engine_directfb_image_dirty_region(void *data,
void *image, int x,
int y, int w,
int h);
void *evas_engine_directfb_image_data_get(void *data, void *image,
int to_write,
DATA32 ** image_data);
void *evas_engine_directfb_image_data_put(void *data, void *image,
DATA32 * image_data);
void *evas_engine_directfb_image_alpha_set(void *data,
void *image,
int has_alpha);
int evas_engine_directfb_image_alpha_get(void *data,
void *image);
void *evas_engine_directfb_image_border_set(void *data,
void *image,
int l, int r, int t, int b);
void evas_engine_directfb_image_border_get(void *data,
void *image,
int *l, int *r, int *t, int *b);
void evas_engine_directfb_image_draw(void *data, void *context,
void *surface, void *image,
int src_x, int src_y,
int src_w, int src_h,
int dst_x, int dst_y,
int dst_w, int dst_h,
int smooth);
char *evas_engine_directfb_image_comment_get(void *data,
void *image,
char *key);
char *evas_engine_directfb_image_format_get(void *data,
void *image);
void evas_engine_directfb_image_colorspace_set(void *data,
void *image,
int cspace);
int evas_engine_directfb_image_colorspace_get(void *data,
void *image);
void evas_engine_directfb_image_native_set(void *data,
void *image,
void *native);
void *evas_engine_directfb_image_native_get(void *data,
void *image);
void evas_engine_directfb_image_cache_flush(void *data);
void evas_engine_directfb_image_cache_set(void *data, int bytes);
int evas_engine_directfb_image_cache_get(void *data);
#endif