Fix directfb engine with new Evas cache API.

NOTE: This engine should be rewritten and use the new engine cache api.


SVN revision: 34360
This commit is contained in:
Cedric BAIL 2008-04-24 14:37:14 +00:00
parent 39289b21d5
commit 3938160157
2 changed files with 58 additions and 92 deletions

View File

@ -99,11 +99,8 @@ eng_output_setup(int w, int h, IDirectFB *dfb, IDirectFBSurface *surf, DFBSurfac
/* We create a "fake" RGBA_Image which points the to DFB surface. Each access /* 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 * to that surface is wrapped in Lock / Unlock calls whenever the data is
* manipulated directly. */ * manipulated directly. */
im = evas_cache_image_empty(evas_common_image_cache_get()); im = (RGBA_Image*) evas_cache_image_empty(evas_common_image_cache_get());
im->image->w = w; evas_cache_image_size_set(&im->cache_entry, w, h);
im->image->h = h;
im->image->no_free = 1;
im->image->data = NULL;
re->rgba_image = im; re->rgba_image = im;
return re; return re;
@ -119,7 +116,7 @@ eng_output_free(void *data)
if (re->rects) if (re->rects)
evas_common_tilebuf_free_render_rects(re->rects); evas_common_tilebuf_free_render_rects(re->rects);
re->backbuf->Release(re->backbuf); re->backbuf->Release(re->backbuf);
evas_cache_image_drop(re->rgba_image); evas_cache_image_drop(&re->rgba_image->cache_entry);
free(re); free(re);
evas_common_font_shutdown(); evas_common_font_shutdown();
@ -151,9 +148,7 @@ eng_output_resize(void *data, int w, int h)
new_surf->StretchBlit(new_surf, re->backbuf, NULL, NULL); new_surf->StretchBlit(new_surf, re->backbuf, NULL, NULL);
re->backbuf->Release(re->backbuf); re->backbuf->Release(re->backbuf);
re->backbuf = new_surf; re->backbuf = new_surf;
re->rgba_image->image->w = w; re->rgba_image = (RGBA_Image*) evas_cache_image_size_set(&re->rgba_image->cache_entry, w, h);
re->rgba_image->image->h = h;
re->rgba_image->image->data = NULL;
} }
} }
@ -240,7 +235,7 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i
re->backbuf->SetClip(re->backbuf, NULL); re->backbuf->SetClip(re->backbuf, NULL);
re->backbuf->Lock(re->backbuf, DSLF_WRITE, &pixels, &pitch); re->backbuf->Lock(re->backbuf, DSLF_WRITE, &pixels, &pitch);
re->rgba_image->image->data = pixels; re->rgba_image->image.data = pixels;
return re->rgba_image; return re->rgba_image;
} }
@ -258,7 +253,7 @@ eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int
re->surface->Flip(re->surface, &region, DSFLIP_NONE); re->surface->Flip(re->surface, &region, DSFLIP_NONE);
evas_common_cpu_end_opt(); evas_common_cpu_end_opt();
re->rgba_image->image->data = NULL; re->rgba_image->image.data = NULL;
} }
static void static void

View File

@ -69,26 +69,14 @@ evas_engine_directfb_image_load(void *data, const char *file, const char *key, i
provider->RenderTo(provider, image, NULL); provider->RenderTo(provider, image, NULL);
provider->Release(provider); provider->Release(provider);
im = evas_common_image_new(); im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
im->image = evas_common_image_surface_new(im); dsc.width, dsc.height,
if (!im->image) (void*) image,
{ img_desc.caps & DICAPS_ALPHACHANNEL,
image->Release(image); EVAS_COLORSPACE_ARGB8888);
_dfb_image_free(im);
return NULL;
}
im->image->w = dsc.width;
im->image->h = dsc.height;
im->image->data = (void *)image;
im->image->no_free = 0;
if (img_desc.caps & DICAPS_ALPHACHANNEL)
im->flags |= RGBA_IMAGE_HAS_ALPHA;
// im->timestamp = mod_time; im->cache_entry.file = strdup(file);
if (file) im->cache_entry.key = strdup(key);
im->info.file = strdup(file);
if (key)
im->info.key = strdup(key);
_dfb_image_ref(im); _dfb_image_ref(im);
return im; return im;
@ -119,7 +107,7 @@ evas_engine_directfb_image_new_from_copied_data(void *data, int w, int h,
if (im) if (im)
{ {
surf = (IDirectFBSurface *) im->image->data; surf = (IDirectFBSurface *) im->image.data;
if (surf->Lock(surf, DSLF_WRITE, &p, &pitch) == DFB_OK) if (surf->Lock(surf, DSLF_WRITE, &p, &pitch) == DFB_OK)
{ {
memcpy(p, image_data, w * h * sizeof(DATA32)); memcpy(p, image_data, w * h * sizeof(DATA32));
@ -149,9 +137,9 @@ evas_engine_directfb_image_size_get(void *data, void *image, int *w, int *h)
re = (Render_Engine *) data; re = (Render_Engine *) data;
im = image; im = image;
if (w) if (w)
*w = im->image->w; *w = im->cache_entry.w;
if (h) if (h)
*h = im->image->h; *h = im->cache_entry.h;
} }
void * void *
@ -165,15 +153,15 @@ evas_engine_directfb_image_size_set(void *data, void *image, int w, int h)
re = (Render_Engine *) data; re = (Render_Engine *) data;
im_old = image; im_old = image;
im = _dfb_image_create(re, w,h); im = _dfb_image_create(re, w, h);
old_surf = (IDirectFBSurface *) im_old->image->data; old_surf = (IDirectFBSurface *) im_old->image.data;
if (im) if (im)
{ {
outrect.x = 0; outrect.x = 0;
outrect.y = 0; outrect.y = 0;
outrect.w = w; outrect.w = w;
outrect.h = h; outrect.h = h;
new_surf = (IDirectFBSurface *) im->image->data; new_surf = (IDirectFBSurface *) im->image.data;
new_surf->StretchBlit(new_surf, old_surf, NULL, &outrect); new_surf->StretchBlit(new_surf, old_surf, NULL, &outrect);
} }
evas_common_cpu_end_opt; evas_common_cpu_end_opt;
@ -208,8 +196,8 @@ evas_engine_directfb_image_data_get(void *data, void *image, int to_write,
re = (Render_Engine *) data; re = (Render_Engine *) data;
im = image; im = image;
surf = (IDirectFBSurface *) im->image->data; surf = (IDirectFBSurface *) im->image.data;
size = im->image->w * im->image->h * sizeof(DATA32); size = im->cache_entry.w * im->cache_entry.h * sizeof(DATA32);
surf->Lock(surf, DSLF_READ, &p, &pitch); surf->Lock(surf, DSLF_READ, &p, &pitch);
if ((buf = malloc(size))) if ((buf = malloc(size)))
@ -229,12 +217,12 @@ evas_engine_directfb_image_data_put(void *data, void *image,
re = (Render_Engine *)data; re = (Render_Engine *)data;
im = image; im = image;
if (image_data != im->image->data) if (image_data != im->image.data)
{ {
int w, h; int w, h;
w = im->image->w; w = im->cache_entry.w;
h = im->image->h; h = im->cache_entry.h;
_dfb_image_unref(im); _dfb_image_unref(im);
/* FIXME alpha and cspace (0, 0) is not used here yet */ /* 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); return evas_engine_directfb_image_new_from_data(data, w, h, image_data, 0, 0);
@ -302,10 +290,10 @@ evas_engine_directfb_image_draw(void *data, void *context, void *surface,
DFBRectangle outrect; DFBRectangle outrect;
RGBA_Image *im = (RGBA_Image *) image; RGBA_Image *im = (RGBA_Image *) image;
RGBA_Draw_Context *dc = (RGBA_Draw_Context *) context; RGBA_Draw_Context *dc = (RGBA_Draw_Context *) context;
IDirectFBSurface *img = (IDirectFBSurface *) im->image->data; IDirectFBSurface *img = (IDirectFBSurface *) im->image.data;
src_w = im->image->w; src_w = im->cache_entry.w;
src_h = im->image->h; src_h = im->cache_entry.h;
dst_w = re->tb->outbuf_w; dst_w = re->tb->outbuf_w;
dst_h = re->tb->outbuf_h; dst_h = re->tb->outbuf_h;
@ -573,16 +561,15 @@ evas_engine_directfb_image_native_get(void *data, void *image)
*/ */
static void static void
_dfb_image_surface_free(RGBA_Surface *is) _dfb_image_surface_free(RGBA_Image *im)
{ {
IDirectFBSurface *surf; IDirectFBSurface *surf;
if ( (is->data) && (!is->no_free) ) if ( (im->image.data) && (!im->image.no_free) )
{ {
surf = (IDirectFBSurface *)is->data; surf = (IDirectFBSurface *)im->image.data;
surf->Release(surf); surf->Release(surf);
is->data = NULL; im->image.data = NULL;
} }
free(is);
} }
@ -593,49 +580,33 @@ _dfb_image_create(Render_Engine *re, int w, int h)
DFBSurfaceDescription dsc; DFBSurfaceDescription dsc;
IDirectFBSurface *surf; IDirectFBSurface *surf;
im = evas_common_image_new();
if (!im) return NULL;
im->image = evas_common_image_surface_new(im);
if (!im->image)
{
_dfb_image_free(im);
return NULL;
}
im->image->w = w;
im->image->h = h;
dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT; dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
dsc.width = w; dsc.width = w;
dsc.height = h; dsc.height = h;
dsc.pixelformat = DSPF_ARGB; dsc.pixelformat = DSPF_ARGB;
if (re->dfb->CreateSurface(re->dfb, &dsc, &surf) != DFB_OK) if (re->dfb->CreateSurface(re->dfb, &dsc, &surf) != DFB_OK)
{ return NULL;
_dfb_image_free(im);
return NULL; return (RGBA_Image*) evas_cache_image_data(evas_common_image_cache_get(),
} w, h,
im->image->data = (void*) surf; (void*) surf,
im->flags = RGBA_IMAGE_IS_DIRTY; 1, EVAS_COLORSPACE_ARGB8888);
im->references = 1;
return im;
} }
static void static void
_dfb_image_free(RGBA_Image *im) _dfb_image_free(RGBA_Image *im)
{ {
if (im->image) _dfb_image_surface_free(im->image); if (im->image.data) _dfb_image_surface_free(im);
if (im->info.file) free(im->info.file);
if (im->info.key) free(im->info.key);
if (im->info.comment) free(im->info.comment);
free(im); free(im);
} }
static void static void
_dfb_image_ref(RGBA_Image *im) _dfb_image_ref(RGBA_Image *im)
{ {
im->references++; im->cache_entry.references++;
if (im->references == 1) /* we were in cache - take us out */ if (im->cache_entry.references == 1) /* we were in cache - take us out */
{ {
_dfb_image_uncache(im); _dfb_image_uncache(im);
_dfb_image_store(im); _dfb_image_store(im);
@ -645,8 +616,8 @@ _dfb_image_ref(RGBA_Image *im)
static void static void
_dfb_image_unref(RGBA_Image *im) _dfb_image_unref(RGBA_Image *im)
{ {
im->references--; im->cache_entry.references--;
if (im->references <= 0) /* we were are now in cache - put us in */ if (im->cache_entry.references <= 0) /* we were are now in cache - put us in */
{ {
_dfb_image_unstore(im); _dfb_image_unstore(im);
if ((cache_size > 0) && if ((cache_size > 0) &&
@ -741,11 +712,11 @@ _dfb_image_store(RGBA_Image *im)
if (im->flags & RGBA_IMAGE_IS_DIRTY) return; if (im->flags & RGBA_IMAGE_IS_DIRTY) return;
if (im->flags & RGBA_IMAGE_INDEXED) return; if (im->flags & RGBA_IMAGE_INDEXED) return;
if ((!im->info.file) && (!im->info.key)) return; if ((!im->cache_entry.file) && (!im->cache_entry.key)) return;
l1 = 0; l1 = 0;
if (im->info.file) l1 = strlen(im->info.file); if (im->cache_entry.file) l1 = strlen(im->cache_entry.file);
l2 = 0; l2 = 0;
if (im->info.key) l2 = strlen(im->info.key); if (im->cache_entry.key) l2 = strlen(im->cache_entry.key);
// snprintf(buf, sizeof(buf), "%llx", im->timestamp); // snprintf(buf, sizeof(buf), "%llx", im->timestamp);
// l3 = strlen(buf); // l3 = strlen(buf);
buf[0] = 0; buf[0] = 0;
@ -753,9 +724,9 @@ _dfb_image_store(RGBA_Image *im)
key = malloc(l1 + 3 + l2 + 3 + l3 +1); key = malloc(l1 + 3 + l2 + 3 + l3 +1);
if (!key) return; if (!key) return;
key[0] = 0; key[0] = 0;
if (im->info.file) strcpy(key, im->info.file); if (im->cache_entry.file) strcpy(key, im->cache_entry.file);
strcat(key, "/:/"); strcat(key, "/:/");
if (im->info.key) strcat(key, im->info.key); if (im->cache_entry.key) strcat(key, im->cache_entry.key);
strcat(key, "/:/"); strcat(key, "/:/");
strcat(key, buf); strcat(key, buf);
images = evas_hash_add(images, key, im); images = evas_hash_add(images, key, im);
@ -771,11 +742,11 @@ _dfb_image_unstore(RGBA_Image *im)
char buf[256]; char buf[256];
if (!(im->flags & RGBA_IMAGE_INDEXED)) return; if (!(im->flags & RGBA_IMAGE_INDEXED)) return;
if ((!im->info.file) && (!im->info.key)) return; if ((!im->cache_entry.file) && (!im->cache_entry.key)) return;
l1 = 0; l1 = 0;
if (im->info.file) l1 = strlen(im->info.file); if (im->cache_entry.file) l1 = strlen(im->cache_entry.file);
l2 = 0; l2 = 0;
if (im->info.key) l2 = strlen(im->info.key); if (im->cache_entry.key) l2 = strlen(im->cache_entry.key);
// snprintf(buf, sizeof(buf), "%llx", im->timestamp); // snprintf(buf, sizeof(buf), "%llx", im->timestamp);
// l3 = strlen(buf); // l3 = strlen(buf);
buf[0] = 0; buf[0] = 0;
@ -783,9 +754,9 @@ _dfb_image_unstore(RGBA_Image *im)
key = malloc(l1 + 3 + l2 + 3 + l3 +1); key = malloc(l1 + 3 + l2 + 3 + l3 +1);
if (!key) return; if (!key) return;
key[0] = 0; key[0] = 0;
if (im->info.file) strcpy(key, im->info.file); if (im->cache_entry.file) strcpy(key, im->cache_entry.file);
strcat(key, "/:/"); strcat(key, "/:/");
if (im->info.key) strcat(key, im->info.key); if (im->cache_entry.key) strcat(key, im->cache_entry.key);
strcat(key, "/:/"); strcat(key, "/:/");
strcat(key, buf); strcat(key, buf);
images = evas_hash_del(images, key, im); images = evas_hash_del(images, key, im);
@ -830,15 +801,15 @@ _dfb_image_find(const char *filename, const char *key, DATA64 timestamp)
im = (RGBA_Image *)l; im = (RGBA_Image *)l;
ok = 0; ok = 0;
if ((filename) && (im->info.file) && if ((filename) && (im->cache_entry.file) &&
(!strcmp(filename, im->info.file))) (!strcmp(filename, im->cache_entry.file)))
ok++; ok++;
if ((!filename) && (!im->info.file)) if ((!filename) && (!im->cache_entry.file))
ok++; ok++;
if ((key) && (im->info.key) && if ((key) && (im->cache_entry.key) &&
(!strcmp(key, im->info.key))) (!strcmp(key, im->cache_entry.key)))
ok++; ok++;
if ((!key) && (!im->info.key)) if ((!key) && (!im->cache_entry.key))
ok++; ok++;
// if (im->timestamp == timestamp) // if (im->timestamp == timestamp)
// ok++; // ok++;