forked from enlightenment/efl
put directdraw initialisation in the engine. use the evas cache
SVN revision: 34903
This commit is contained in:
parent
288b801e42
commit
23488e9a60
|
@ -2,8 +2,10 @@
|
||||||
#define __EVAS_ENGINE_SOFTWARE_DDRAW_H__
|
#define __EVAS_ENGINE_SOFTWARE_DDRAW_H__
|
||||||
|
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <ddraw.h>
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
|
|
||||||
|
|
||||||
typedef struct _Evas_Engine_Info_Software_DDraw Evas_Engine_Info_Software_DDraw;
|
typedef struct _Evas_Engine_Info_Software_DDraw Evas_Engine_Info_Software_DDraw;
|
||||||
|
|
||||||
|
@ -15,9 +17,6 @@ struct _Evas_Engine_Info_Software_DDraw
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
HWND window;
|
HWND window;
|
||||||
LPDIRECTDRAW object;
|
|
||||||
LPDIRECTDRAWSURFACE surface_primary;
|
|
||||||
LPDIRECTDRAWSURFACE surface_back;
|
|
||||||
int depth;
|
int depth;
|
||||||
int rotation;
|
int rotation;
|
||||||
} info;
|
} info;
|
||||||
|
|
|
@ -1,29 +1,30 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "evas_common.h"
|
||||||
#include "evas_engine.h"
|
#include "evas_engine.h"
|
||||||
|
|
||||||
|
|
||||||
DDraw_Output_Buffer *
|
DD_Output_Buffer *
|
||||||
evas_software_ddraw_output_buffer_new(int depth,
|
evas_software_ddraw_output_buffer_new(int depth,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
DDraw_Output_Buffer *ddob;
|
DD_Output_Buffer *ddob;
|
||||||
|
|
||||||
ddob = calloc(1, sizeof(DDraw_Output_Buffer));
|
ddob = calloc(1, sizeof(DD_Output_Buffer));
|
||||||
if (!ddob) return NULL;
|
if (!ddob) return NULL;
|
||||||
|
|
||||||
ddob->image = data;
|
ddob->data = data;
|
||||||
ddob->depth = depth;
|
ddob->depth = depth;
|
||||||
ddob->width = width;
|
ddob->width = width;
|
||||||
ddob->height = height;
|
ddob->height = height;
|
||||||
ddob->pitch = width * depth / 8;
|
ddob->pitch = width * depth / 8;
|
||||||
|
|
||||||
if (!ddob->image)
|
if (!ddob->data)
|
||||||
{
|
{
|
||||||
ddob->image = malloc(ddob->pitch * height);
|
ddob->data = malloc(ddob->pitch * height);
|
||||||
if (!ddob->image)
|
if (!ddob->data)
|
||||||
{
|
{
|
||||||
free(ddob);
|
free(ddob);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -34,21 +35,21 @@ evas_software_ddraw_output_buffer_new(int depth,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
evas_software_ddraw_output_buffer_free(DDraw_Output_Buffer *ddob)
|
evas_software_ddraw_output_buffer_free(DD_Output_Buffer *ddob)
|
||||||
{
|
{
|
||||||
if (ddob->image) free(ddob->image);
|
if (ddob->data) free(ddob->data);
|
||||||
free(ddob);
|
free(ddob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
evas_software_ddraw_output_buffer_paste(DDraw_Output_Buffer *ddob,
|
evas_software_ddraw_output_buffer_paste(DD_Output_Buffer *ddob,
|
||||||
void *ddraw_data,
|
void *ddraw_data,
|
||||||
int ddraw_width,
|
int ddraw_width,
|
||||||
int ddraw_height,
|
int ddraw_height,
|
||||||
int ddraw_pitch,
|
int ddraw_pitch,
|
||||||
int ddraw_depth,
|
int ddraw_depth,
|
||||||
int x,
|
int x,
|
||||||
int y)
|
int y)
|
||||||
{
|
{
|
||||||
DATA8 *dd_data;
|
DATA8 *dd_data;
|
||||||
DATA8 *evas_data;
|
DATA8 *evas_data;
|
||||||
|
@ -70,21 +71,21 @@ evas_software_ddraw_output_buffer_paste(DDraw_Output_Buffer *ddob,
|
||||||
pitch = width * ddob->depth / 8;
|
pitch = width * ddob->depth / 8;
|
||||||
|
|
||||||
dd_data = (DATA8 *)ddraw_data + y * ddraw_pitch + x * ddraw_depth;
|
dd_data = (DATA8 *)ddraw_data + y * ddraw_pitch + x * ddraw_depth;
|
||||||
evas_data = (unsigned char *)ddob->image;
|
evas_data = (unsigned char *)ddob->data;
|
||||||
for (j = 0; j < height; j++, evas_data += ddob->pitch, dd_data += ddraw_pitch)
|
for (j = 0; j < height; j++, evas_data += ddob->pitch, dd_data += ddraw_pitch)
|
||||||
memcpy(dd_data, evas_data, pitch);
|
memcpy(dd_data, evas_data, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
DATA8 *
|
DATA8 *
|
||||||
evas_software_ddraw_output_buffer_data(DDraw_Output_Buffer *ddob,
|
evas_software_ddraw_output_buffer_data(DD_Output_Buffer *ddob,
|
||||||
int *bytes_per_line_ret)
|
int *bytes_per_line_ret)
|
||||||
{
|
{
|
||||||
if (bytes_per_line_ret) *bytes_per_line_ret = ddob->pitch;
|
if (bytes_per_line_ret) *bytes_per_line_ret = ddob->pitch;
|
||||||
return ddob->image;
|
return ddob->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
evas_software_ddraw_output_buffer_depth(DDraw_Output_Buffer *ddob)
|
evas_software_ddraw_output_buffer_depth(DD_Output_Buffer *ddob)
|
||||||
{
|
{
|
||||||
return ddob->depth;
|
return ddob->depth;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,104 @@
|
||||||
|
#include "evas_common.h"
|
||||||
#include "evas_engine.h"
|
#include "evas_engine.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
evas_software_ddraw_init (HWND window,
|
||||||
|
int depth,
|
||||||
|
Outbuf *buf)
|
||||||
|
{
|
||||||
|
DDSURFACEDESC surface_desc;
|
||||||
|
DDPIXELFORMAT pixel_format;
|
||||||
|
RECT rect;
|
||||||
|
LPDIRECTDRAW o;
|
||||||
|
HRESULT res;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
|
||||||
|
if (!buf)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!GetClientRect(window, &rect))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
width = rect.right - rect.left;
|
||||||
|
height = rect.bottom - rect.top;
|
||||||
|
|
||||||
|
buf->priv.dd.window = window;
|
||||||
|
|
||||||
|
res = DirectDrawCreate(NULL, &buf->priv.dd.object, NULL);
|
||||||
|
if (FAILED(res))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
res = buf->priv.dd.object->SetCooperativeLevel(window, DDSCL_NORMAL);
|
||||||
|
if (FAILED(res))
|
||||||
|
goto release_object;
|
||||||
|
|
||||||
|
res = buf->priv.dd.object->CreateClipper (0, &buf->priv.dd.clipper, NULL);
|
||||||
|
if (FAILED(res))
|
||||||
|
goto release_object;
|
||||||
|
|
||||||
|
res = buf->priv.dd.clipper->SetHWnd (0, window);
|
||||||
|
if (FAILED(res))
|
||||||
|
goto release_clipper;
|
||||||
|
|
||||||
|
memset(&surface_desc, 0, sizeof(surface_desc));
|
||||||
|
surface_desc.dwSize = sizeof(surface_desc);
|
||||||
|
surface_desc.dwFlags = DDSD_CAPS;
|
||||||
|
surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
||||||
|
|
||||||
|
res = buf->priv.dd.object->CreateSurface (&surface_desc, &buf->priv.dd.surface_primary, NULL);
|
||||||
|
if (FAILED(res))
|
||||||
|
goto release_clipper;
|
||||||
|
|
||||||
|
res = buf->priv.dd.surface_primary->SetClipper (buf->priv.dd.clipper);
|
||||||
|
if (FAILED(res))
|
||||||
|
goto release_surface_primary;
|
||||||
|
|
||||||
|
memset (&surface_desc, 0, sizeof(surface_desc));
|
||||||
|
surface_desc.dwSize = sizeof(surface_desc);
|
||||||
|
surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
||||||
|
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||||
|
surface_desc.dwWidth = width;
|
||||||
|
surface_desc.dwHeight = height;
|
||||||
|
|
||||||
|
res = buf->priv.dd.object->CreateSurface (&surface_desc, &buf->priv.dd.surface_back, NULL);
|
||||||
|
if (FAILED(res))
|
||||||
|
goto release_surface_primary;
|
||||||
|
|
||||||
|
ZeroMemory(&pixel_format, sizeof(pixel_format));
|
||||||
|
pixel_format.dwSize = sizeof(pixel_format);
|
||||||
|
buf->priv.dd.surface_primary->GetPixelFormat(&pixel_format);
|
||||||
|
|
||||||
|
if (pixel_format.dwRGBBitCount != depth)
|
||||||
|
goto release_surface_back;
|
||||||
|
|
||||||
|
buf->priv.dd.depth = depth;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
release_surface_back:
|
||||||
|
buf->priv.dd.surface_back->Release();
|
||||||
|
release_surface_primary:
|
||||||
|
buf->priv.dd.surface_primary->Release();
|
||||||
|
release_clipper:
|
||||||
|
buf->priv.dd.clipper->Release();
|
||||||
|
release_object:
|
||||||
|
buf->priv.dd.object->Release();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
evas_software_ddraw_shutdown(Outbuf *buf)
|
||||||
|
{
|
||||||
|
if (!buf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
buf->priv.dd.surface_back->Release();
|
||||||
|
buf->priv.dd.surface_primary->Release();
|
||||||
|
buf->priv.dd.clipper->Release();
|
||||||
|
buf->priv.dd.object->Release();
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
evas_software_ddraw_masks_get(Outbuf *buf)
|
evas_software_ddraw_masks_get(Outbuf *buf)
|
||||||
|
@ -20,7 +119,11 @@ evas_software_ddraw_masks_get(Outbuf *buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
evas_software_ddraw_lock(Outbuf *buf, int *ddraw_width, int *ddraw_height, int *ddraw_pitch, int *ddraw_depth)
|
evas_software_ddraw_lock(Outbuf *buf,
|
||||||
|
int *ddraw_width,
|
||||||
|
int *ddraw_height,
|
||||||
|
int *ddraw_pitch,
|
||||||
|
int *ddraw_depth)
|
||||||
{
|
{
|
||||||
DDSURFACEDESC surface_desc;
|
DDSURFACEDESC surface_desc;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
#include "evas_engine.h"
|
#include "evas_common.h"
|
||||||
#include "evas_private.h"
|
#include "evas_private.h"
|
||||||
|
#include "evas_engine.h"
|
||||||
#include "Evas_Engine_Software_DDraw.h"
|
#include "Evas_Engine_Software_DDraw.h"
|
||||||
|
|
||||||
|
/* function tables - filled in later (func and parent func) */
|
||||||
|
static Evas_Func func, pfunc;
|
||||||
|
|
||||||
/* engine struct data */
|
/* engine struct data */
|
||||||
typedef struct _Render_Engine Render_Engine;
|
typedef struct _Render_Engine Render_Engine;
|
||||||
|
|
||||||
|
@ -15,58 +19,18 @@ struct _Render_Engine
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* function tables - filled in later (func and parent func) */
|
|
||||||
static Evas_Func func, pfunc;
|
|
||||||
|
|
||||||
/* prototypes we will use here */
|
|
||||||
static void *_output_setup(int width,
|
|
||||||
int height,
|
|
||||||
int rotation,
|
|
||||||
HWND window,
|
|
||||||
LPDIRECTDRAW lpDD,
|
|
||||||
LPDIRECTDRAWSURFACE surface_primary,
|
|
||||||
LPDIRECTDRAWSURFACE surface_back,
|
|
||||||
int w_depth);
|
|
||||||
|
|
||||||
static void *eng_info(Evas *e);
|
|
||||||
static void eng_info_free(Evas *e,
|
|
||||||
void *info);
|
|
||||||
static void eng_setup(Evas *e,
|
|
||||||
void *info);
|
|
||||||
static void eng_output_free(void *data);
|
|
||||||
static void eng_output_resize(void *data,
|
|
||||||
int width,
|
|
||||||
int height);
|
|
||||||
static void eng_output_tile_size_set(void *data,
|
|
||||||
int width,
|
|
||||||
int height);
|
|
||||||
static void eng_output_redraws_rect_add(void *data,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int width,
|
|
||||||
int height);
|
|
||||||
static void eng_output_redraws_rect_del(void *data,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int width,
|
|
||||||
int height);
|
|
||||||
static void eng_output_redraws_clear(void *data);
|
|
||||||
|
|
||||||
/* internal engine routines */
|
|
||||||
static void *
|
static void *
|
||||||
_output_setup(int width,
|
_output_setup(int width,
|
||||||
int height,
|
int height,
|
||||||
int rotation,
|
int rot,
|
||||||
HWND window,
|
HWND window,
|
||||||
LPDIRECTDRAW object,
|
int depth)
|
||||||
LPDIRECTDRAWSURFACE surface_primary,
|
|
||||||
LPDIRECTDRAWSURFACE surface_back,
|
|
||||||
int w_depth)
|
|
||||||
{
|
{
|
||||||
Render_Engine *re;
|
Render_Engine *re;
|
||||||
|
|
||||||
re = (Render_Engine *)calloc(1, sizeof(Render_Engine));
|
re = calloc(1, sizeof(Render_Engine));
|
||||||
if (!re) return NULL;
|
if (!re)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
/* if we haven't initialized - init (automatic abort if already done) */
|
/* if we haven't initialized - init (automatic abort if already done) */
|
||||||
evas_common_cpu_init();
|
evas_common_cpu_init();
|
||||||
|
@ -85,14 +49,24 @@ _output_setup(int width,
|
||||||
|
|
||||||
evas_software_ddraw_outbuf_init();
|
evas_software_ddraw_outbuf_init();
|
||||||
|
|
||||||
/* get any stored performance metrics from device */
|
re->ob = evas_software_ddraw_outbuf_setup(width, height, rot,
|
||||||
re->ob = evas_software_ddraw_outbuf_setup_dd(width, height, rotation, OUTBUF_DEPTH_INHERIT, window, object, surface_primary, surface_back, w_depth);
|
OUTBUF_DEPTH_INHERIT,
|
||||||
|
window, depth);
|
||||||
if (!re->ob)
|
if (!re->ob)
|
||||||
{
|
{
|
||||||
free(re);
|
free(re);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* for updates return 1 big buffer, but only use portions of it, also cache
|
||||||
|
it and keepit around until an idle_flush */
|
||||||
|
/* disable for now - i am hunting down why some expedite tests are slower,
|
||||||
|
* as well as shaped stuff is broken and probable non-32bpp is broken as
|
||||||
|
* convert funcs dont do the right thing
|
||||||
|
*
|
||||||
|
re->ob->onebuf = 1;
|
||||||
|
*/
|
||||||
|
|
||||||
re->tb = evas_common_tilebuf_new(width, height);
|
re->tb = evas_common_tilebuf_new(width, height);
|
||||||
if (!re->tb)
|
if (!re->tb)
|
||||||
{
|
{
|
||||||
|
@ -100,21 +74,21 @@ _output_setup(int width,
|
||||||
free(re);
|
free(re);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: that comment :) */
|
|
||||||
/* in preliminary tests 16x16 gave highest framerates */
|
/* in preliminary tests 16x16 gave highest framerates */
|
||||||
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
|
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
|
||||||
|
|
||||||
return re;
|
return re;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* engine api this module provides */
|
/* engine api this module provides */
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
eng_info(Evas *e)
|
eng_info(Evas *e)
|
||||||
{
|
{
|
||||||
Evas_Engine_Info_Software_DDraw *info;
|
Evas_Engine_Info_Software_DDraw *info;
|
||||||
|
|
||||||
info = (Evas_Engine_Info_Software_DDraw *)calloc(1, sizeof(Evas_Engine_Info_Software_DDraw));
|
info = calloc(1, sizeof(Evas_Engine_Info_Software_DDraw));
|
||||||
if (!info) return NULL;
|
if (!info) return NULL;
|
||||||
info->magic.magic = rand();
|
info->magic.magic = rand();
|
||||||
return info;
|
return info;
|
||||||
|
@ -122,8 +96,7 @@ eng_info(Evas *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eng_info_free(Evas *e,
|
eng_info_free(Evas *e, void *info)
|
||||||
void *info)
|
|
||||||
{
|
{
|
||||||
Evas_Engine_Info_Software_DDraw *in;
|
Evas_Engine_Info_Software_DDraw *in;
|
||||||
|
|
||||||
|
@ -132,29 +105,38 @@ eng_info_free(Evas *e,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eng_setup(Evas *e,
|
eng_setup(Evas *e, void *in)
|
||||||
void *info)
|
|
||||||
{
|
{
|
||||||
Render_Engine *re;
|
Render_Engine *re;
|
||||||
Evas_Engine_Info_Software_DDraw *in;
|
Evas_Engine_Info_Software_DDraw *info;
|
||||||
|
|
||||||
in = (Evas_Engine_Info_Software_DDraw *)info;
|
info = (Evas_Engine_Info_Software_DDraw *)in;
|
||||||
if (!e->engine.data.output)
|
if (!e->engine.data.output)
|
||||||
e->engine.data.output =
|
e->engine.data.output = _output_setup(e->output.w,
|
||||||
_output_setup(e->output.w,
|
e->output.h,
|
||||||
e->output.h,
|
info->info.rotation,
|
||||||
in->info.rotation,
|
info->info.window,
|
||||||
in->info.window,
|
info->info.depth);
|
||||||
in->info.object,
|
else
|
||||||
in->info.surface_primary,
|
{
|
||||||
in->info.surface_back,
|
int ponebuf = 0;
|
||||||
in->info.depth);
|
|
||||||
if (!e->engine.data.output) return;
|
|
||||||
if (!e->engine.data.context)
|
|
||||||
e->engine.data.context =
|
|
||||||
e->engine.func->context_new(e->engine.data.output);
|
|
||||||
|
|
||||||
re = (Render_Engine *)e->engine.data.output;
|
re = e->engine.data.output;
|
||||||
|
ponebuf = re->ob->onebuf;
|
||||||
|
evas_software_ddraw_outbuf_free(re->ob);
|
||||||
|
re->ob = evas_software_ddraw_outbuf_setup(e->output.w,
|
||||||
|
e->output.h,
|
||||||
|
info->info.rotation,
|
||||||
|
OUTBUF_DEPTH_INHERIT,
|
||||||
|
info->info.window,
|
||||||
|
info->info.depth);
|
||||||
|
re->ob->onebuf = ponebuf;
|
||||||
|
}
|
||||||
|
if (!e->engine.data.output) return;
|
||||||
|
if (!e->engine.data.context)
|
||||||
|
e->engine.data.context = e->engine.func->context_new(e->engine.data.output);
|
||||||
|
|
||||||
|
re = e->engine.data.output;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -162,6 +144,8 @@ eng_output_free(void *data)
|
||||||
{
|
{
|
||||||
Render_Engine *re;
|
Render_Engine *re;
|
||||||
|
|
||||||
|
if (!data) return;
|
||||||
|
|
||||||
re = (Render_Engine *)data;
|
re = (Render_Engine *)data;
|
||||||
evas_software_ddraw_outbuf_free(re->ob);
|
evas_software_ddraw_outbuf_free(re->ob);
|
||||||
evas_common_tilebuf_free(re->tb);
|
evas_common_tilebuf_free(re->tb);
|
||||||
|
@ -173,9 +157,7 @@ eng_output_free(void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eng_output_resize(void *data,
|
eng_output_resize(void *data, int width, int height)
|
||||||
int width,
|
|
||||||
int height)
|
|
||||||
{
|
{
|
||||||
Render_Engine *re;
|
Render_Engine *re;
|
||||||
|
|
||||||
|
@ -183,8 +165,8 @@ eng_output_resize(void *data,
|
||||||
evas_software_ddraw_outbuf_reconfigure(re->ob,
|
evas_software_ddraw_outbuf_reconfigure(re->ob,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
evas_software_ddraw_outbuf_rot_get(re->ob),
|
evas_software_ddraw_outbuf_rot_get(re->ob),
|
||||||
OUTBUF_DEPTH_INHERIT);
|
OUTBUF_DEPTH_INHERIT);
|
||||||
evas_common_tilebuf_free(re->tb);
|
evas_common_tilebuf_free(re->tb);
|
||||||
re->tb = evas_common_tilebuf_new(width, height);
|
re->tb = evas_common_tilebuf_new(width, height);
|
||||||
if (re->tb)
|
if (re->tb)
|
||||||
|
@ -192,40 +174,30 @@ eng_output_resize(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eng_output_tile_size_set(void *data,
|
eng_output_tile_size_set(void *data, int w, int h)
|
||||||
int width,
|
|
||||||
int height)
|
|
||||||
{
|
{
|
||||||
Render_Engine *re;
|
Render_Engine *re;
|
||||||
|
|
||||||
re = (Render_Engine *)data;
|
re = (Render_Engine *)data;
|
||||||
evas_common_tilebuf_set_tile_size(re->tb, width, height);
|
evas_common_tilebuf_set_tile_size(re->tb, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eng_output_redraws_rect_add(void *data,
|
eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int width,
|
|
||||||
int height)
|
|
||||||
{
|
{
|
||||||
Render_Engine *re;
|
Render_Engine *re;
|
||||||
|
|
||||||
re = (Render_Engine *)data;
|
re = (Render_Engine *)data;
|
||||||
evas_common_tilebuf_add_redraw(re->tb, x, y, width, height);
|
evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eng_output_redraws_rect_del(void *data,
|
eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int width,
|
|
||||||
int height)
|
|
||||||
{
|
{
|
||||||
Render_Engine *re;
|
Render_Engine *re;
|
||||||
|
|
||||||
re = (Render_Engine *)data;
|
re = (Render_Engine *)data;
|
||||||
evas_common_tilebuf_del_redraw(re->tb, x, y, width, height);
|
evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -239,14 +211,14 @@ eng_output_redraws_clear(void *data)
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
eng_output_redraws_next_update_get(void *data,
|
eng_output_redraws_next_update_get(void *data,
|
||||||
int *x,
|
int *x,
|
||||||
int *y,
|
int *y,
|
||||||
int *w,
|
int *w,
|
||||||
int *h,
|
int *h,
|
||||||
int *cx,
|
int *cx,
|
||||||
int *cy,
|
int *cy,
|
||||||
int *cw,
|
int *cw,
|
||||||
int *ch)
|
int *ch)
|
||||||
{
|
{
|
||||||
Render_Engine *re;
|
Render_Engine *re;
|
||||||
RGBA_Image *surface;
|
RGBA_Image *surface;
|
||||||
|
@ -269,7 +241,10 @@ eng_output_redraws_next_update_get(void *data,
|
||||||
}
|
}
|
||||||
if (!re->cur_rect) return NULL;
|
if (!re->cur_rect) return NULL;
|
||||||
rect = (Tilebuf_Rect *)re->cur_rect;
|
rect = (Tilebuf_Rect *)re->cur_rect;
|
||||||
ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
|
ux = rect->x;
|
||||||
|
uy = rect->y;
|
||||||
|
uw = rect->w;
|
||||||
|
uh = rect->h;
|
||||||
re->cur_rect = re->cur_rect->next;
|
re->cur_rect = re->cur_rect->next;
|
||||||
if (!re->cur_rect)
|
if (!re->cur_rect)
|
||||||
{
|
{
|
||||||
|
@ -279,30 +254,33 @@ eng_output_redraws_next_update_get(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
surface = evas_software_ddraw_outbuf_new_region_for_update(re->ob,
|
surface = evas_software_ddraw_outbuf_new_region_for_update(re->ob,
|
||||||
ux, uy,
|
ux,
|
||||||
uw, uh,
|
uy,
|
||||||
cx, cy,
|
uw,
|
||||||
cw, ch);
|
uh,
|
||||||
*x = ux; *y = uy; *w = uw; *h = uh;
|
cx,
|
||||||
|
cy,
|
||||||
|
cw,
|
||||||
|
ch);
|
||||||
|
|
||||||
|
*x = ux;
|
||||||
|
*y = uy;
|
||||||
|
*w = uw;
|
||||||
|
*h = uh;
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eng_output_redraws_next_update_push(void *data,
|
eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
|
||||||
void *surface,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int w,
|
|
||||||
int h)
|
|
||||||
{
|
{
|
||||||
Render_Engine *re;
|
Render_Engine *re;
|
||||||
|
|
||||||
re = (Render_Engine *)data;
|
re = (Render_Engine *)data;
|
||||||
evas_common_pipe_begin((RGBA_Image *)surface);
|
evas_common_pipe_begin(surface);
|
||||||
evas_common_pipe_flush((RGBA_Image *)surface);
|
evas_common_pipe_flush(surface);
|
||||||
evas_software_ddraw_outbuf_push_updated_region(re->ob, (RGBA_Image *)surface, x, y, w, h);
|
evas_software_ddraw_outbuf_push_updated_region(re->ob, surface, x, y, w, h);
|
||||||
evas_software_ddraw_outbuf_free_region_for_update(re->ob, (RGBA_Image *)surface);
|
evas_software_ddraw_outbuf_free_region_for_update(re->ob, surface);
|
||||||
evas_common_cpu_end_opt();
|
evas_common_cpu_end_opt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,8 +299,10 @@ eng_output_idle_flush(void *data)
|
||||||
Render_Engine *re;
|
Render_Engine *re;
|
||||||
|
|
||||||
re = (Render_Engine *)data;
|
re = (Render_Engine *)data;
|
||||||
|
evas_software_ddraw_outbuf_idle_flush(re->ob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* module advertising code */
|
/* module advertising code */
|
||||||
EAPI int
|
EAPI int
|
||||||
module_open(Evas_Module *em)
|
module_open(Evas_Module *em)
|
||||||
|
@ -360,8 +340,7 @@ module_close(void)
|
||||||
EAPI Evas_Module_Api evas_modapi =
|
EAPI Evas_Module_Api evas_modapi =
|
||||||
{
|
{
|
||||||
EVAS_MODULE_API_VERSION,
|
EVAS_MODULE_API_VERSION,
|
||||||
EVAS_MODULE_TYPE_ENGINE,
|
EVAS_MODULE_TYPE_ENGINE,
|
||||||
"software_ddraw",
|
"software_ddraw",
|
||||||
"none"
|
"none"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
#define __EVAS_ENGINE_H__
|
#define __EVAS_ENGINE_H__
|
||||||
|
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
#include <ddraw.h>
|
#include <ddraw.h>
|
||||||
|
|
||||||
#include "evas_common.h"
|
|
||||||
|
|
||||||
typedef struct _Outbuf Outbuf;
|
typedef struct _Outbuf Outbuf;
|
||||||
typedef struct _DDraw_Output_Buffer DDraw_Output_Buffer;
|
typedef struct _Outbuf_Region Outbuf_Region;
|
||||||
|
typedef struct _DD_Output_Buffer DD_Output_Buffer;
|
||||||
|
|
||||||
enum _Outbuf_Depth
|
enum _Outbuf_Depth
|
||||||
{
|
{
|
||||||
|
@ -25,112 +25,164 @@ enum _Outbuf_Depth
|
||||||
|
|
||||||
typedef enum _Outbuf_Depth Outbuf_Depth;
|
typedef enum _Outbuf_Depth Outbuf_Depth;
|
||||||
|
|
||||||
|
|
||||||
struct _Outbuf
|
struct _Outbuf
|
||||||
{
|
{
|
||||||
int width;
|
Outbuf_Depth depth;
|
||||||
int height;
|
int width;
|
||||||
int rot;
|
int height;
|
||||||
Outbuf_Depth depth;
|
int rot;
|
||||||
|
int onebuf;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
Convert_Pal *pal;
|
||||||
struct {
|
struct {
|
||||||
HWND window;
|
HWND window;
|
||||||
LPDIRECTDRAW object;
|
LPDIRECTDRAW object;
|
||||||
LPDIRECTDRAWSURFACE surface_primary;
|
LPDIRECTDRAWSURFACE surface_primary;
|
||||||
LPDIRECTDRAWSURFACE surface_back;
|
LPDIRECTDRAWSURFACE surface_back;
|
||||||
int depth;
|
LPDIRECTDRAWCLIPPER clipper;
|
||||||
|
int depth;
|
||||||
|
unsigned char swap : 1;
|
||||||
|
unsigned char bit_swap : 1;
|
||||||
} dd;
|
} dd;
|
||||||
struct {
|
struct {
|
||||||
DATA32 r, g, b;
|
DATA32 r, g, b;
|
||||||
} mask;
|
} mask;
|
||||||
|
|
||||||
|
/* 1 big buffer for updates - flush on idle_flush */
|
||||||
|
RGBA_Image *onebuf;
|
||||||
|
Evas_List *onebuf_regions;
|
||||||
|
|
||||||
/* a list of pending regions to write to the target */
|
/* a list of pending regions to write to the target */
|
||||||
Evas_List *pending_writes;
|
Evas_List *pending_writes;
|
||||||
|
/* a list of previous frame pending regions to write to the target */
|
||||||
|
Evas_List *prev_pending_writes;
|
||||||
|
|
||||||
|
unsigned char mask_dither : 1;
|
||||||
|
unsigned char destination_alpha : 1;
|
||||||
|
unsigned char debug : 1;
|
||||||
|
unsigned char synced : 1;
|
||||||
} priv;
|
} priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _DDraw_Output_Buffer
|
struct _Outbuf_Region
|
||||||
{
|
{
|
||||||
void *image;
|
DD_Output_Buffer *ddob;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _DD_Output_Buffer
|
||||||
|
{
|
||||||
|
void *data;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int depth;
|
int depth;
|
||||||
int pitch;
|
int pitch;
|
||||||
|
/* int w, h, bpl; */
|
||||||
|
int psize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Outbuf functions */
|
/* evas_outbuf.c */
|
||||||
void evas_software_ddraw_outbuf_init(void);
|
|
||||||
void evas_software_ddraw_outbuf_free(Outbuf *buf);
|
void evas_software_ddraw_outbuf_init(void);
|
||||||
Outbuf *evas_software_ddraw_outbuf_setup_dd(int width,
|
|
||||||
int height,
|
void evas_software_ddraw_outbuf_free(Outbuf *buf);
|
||||||
int rotation,
|
|
||||||
Outbuf_Depth depth,
|
Outbuf *evas_software_ddraw_outbuf_setup(int width,
|
||||||
HWND window,
|
int height,
|
||||||
LPDIRECTDRAW object,
|
int rotation,
|
||||||
LPDIRECTDRAWSURFACE surface_primary,
|
Outbuf_Depth depth,
|
||||||
LPDIRECTDRAWSURFACE surface_back,
|
HWND window,
|
||||||
int w_depth);
|
int w_depth);
|
||||||
RGBA_Image *evas_software_ddraw_outbuf_new_region_for_update(Outbuf *buf,
|
|
||||||
int x,
|
void evas_software_ddraw_outbuf_reconfigure(Outbuf *buf,
|
||||||
int y,
|
int width,
|
||||||
int width,
|
int height,
|
||||||
int height,
|
int rotation,
|
||||||
int *cx,
|
Outbuf_Depth depth);
|
||||||
int *cy,
|
|
||||||
int *cw,
|
RGBA_Image *evas_software_ddraw_outbuf_new_region_for_update(Outbuf *buf,
|
||||||
int *ch);
|
int x,
|
||||||
void evas_software_ddraw_outbuf_free_region_for_update(Outbuf *buf,
|
int y,
|
||||||
RGBA_Image *update);
|
int w,
|
||||||
void evas_software_ddraw_outbuf_flush(Outbuf *buf);
|
int h,
|
||||||
void evas_software_ddraw_outbuf_push_updated_region(Outbuf *buf,
|
int *cx,
|
||||||
RGBA_Image *update,
|
int *cy,
|
||||||
int x,
|
int *cw,
|
||||||
int y,
|
int *ch);
|
||||||
int width,
|
|
||||||
int height);
|
void evas_software_ddraw_outbuf_push_updated_region(Outbuf *buf,
|
||||||
void evas_software_ddraw_outbuf_reconfigure(Outbuf *buf,
|
RGBA_Image *update,
|
||||||
int width,
|
int x,
|
||||||
int height,
|
int y,
|
||||||
int rotation,
|
int w,
|
||||||
Outbuf_Depth depth);
|
int h);
|
||||||
int evas_software_ddraw_outbuf_width_get(Outbuf *buf);
|
|
||||||
int evas_software_ddraw_outbuf_height_get(Outbuf *buf);
|
void evas_software_ddraw_outbuf_free_region_for_update(Outbuf *buf,
|
||||||
|
RGBA_Image *update);
|
||||||
|
|
||||||
|
void evas_software_ddraw_outbuf_flush(Outbuf *buf);
|
||||||
|
|
||||||
|
void evas_software_ddraw_outbuf_idle_flush(Outbuf *buf);
|
||||||
|
|
||||||
|
int evas_software_ddraw_outbuf_width_get(Outbuf *buf);
|
||||||
|
|
||||||
|
int evas_software_ddraw_outbuf_height_get(Outbuf *buf);
|
||||||
|
|
||||||
Outbuf_Depth evas_software_ddraw_outbuf_depth_get(Outbuf *buf);
|
Outbuf_Depth evas_software_ddraw_outbuf_depth_get(Outbuf *buf);
|
||||||
int evas_software_ddraw_outbuf_rot_get(Outbuf *buf);
|
|
||||||
|
|
||||||
/* Output Buffer functions */
|
int evas_software_ddraw_outbuf_rot_get(Outbuf *buf);
|
||||||
DDraw_Output_Buffer *evas_software_ddraw_output_buffer_new(int depth,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
void *data);
|
|
||||||
void evas_software_ddraw_output_buffer_free(DDraw_Output_Buffer *ddob);
|
|
||||||
void evas_software_ddraw_output_buffer_paste(DDraw_Output_Buffer *ddob,
|
|
||||||
void *ddraw_data,
|
|
||||||
int ddraw_width,
|
|
||||||
int ddraw_height,
|
|
||||||
int ddraw_pitch,
|
|
||||||
int ddraw_depth,
|
|
||||||
int x,
|
|
||||||
int y);
|
|
||||||
DATA8 *evas_software_ddraw_output_buffer_data(DDraw_Output_Buffer *ddob,
|
|
||||||
int *bytes_per_line_ret);
|
|
||||||
int evas_software_ddraw_output_buffer_depth(DDraw_Output_Buffer *ddob);
|
|
||||||
|
|
||||||
|
/* evas_ddraw_buffer.c */
|
||||||
|
|
||||||
|
DD_Output_Buffer *evas_software_ddraw_output_buffer_new(int depth,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
void evas_software_ddraw_output_buffer_free(DD_Output_Buffer *ddob);
|
||||||
|
|
||||||
|
void evas_software_ddraw_output_buffer_paste(DD_Output_Buffer *ddob,
|
||||||
|
void *ddraw_data,
|
||||||
|
int ddraw_width,
|
||||||
|
int ddraw_height,
|
||||||
|
int ddraw_pitch,
|
||||||
|
int ddraw_depth,
|
||||||
|
int x,
|
||||||
|
int y);
|
||||||
|
|
||||||
|
DATA8 *evas_software_ddraw_output_buffer_data(DD_Output_Buffer *ddob,
|
||||||
|
int *bytes_per_line_ret);
|
||||||
|
|
||||||
|
int evas_software_ddraw_output_buffer_depth(DD_Output_Buffer *ddob);
|
||||||
|
|
||||||
|
/* evas_ddraw_main.cpp */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int evas_software_ddraw_init (HWND window,
|
||||||
|
int depth,
|
||||||
|
Outbuf *buf);
|
||||||
|
|
||||||
int evas_software_ddraw_masks_get(Outbuf *buf);
|
void evas_software_ddraw_shutdown(Outbuf *buf);
|
||||||
void *evas_software_ddraw_lock(Outbuf *buf, int *ddraw_width, int *ddraw_height, int *ddraw_pitch, int *ddraw_depth);
|
|
||||||
void evas_software_ddraw_unlock_and_flip(Outbuf *buf);
|
|
||||||
void evas_software_ddraw_surface_resize(Outbuf *buf);
|
|
||||||
|
|
||||||
|
int evas_software_ddraw_masks_get(Outbuf *buf);
|
||||||
|
|
||||||
|
void *evas_software_ddraw_lock(Outbuf *buf,
|
||||||
|
int *ddraw_width,
|
||||||
|
int *ddraw_height,
|
||||||
|
int *ddraw_pitch,
|
||||||
|
int *ddraw_depth);
|
||||||
|
|
||||||
|
void evas_software_ddraw_unlock_and_flip(Outbuf *buf);
|
||||||
|
|
||||||
|
void evas_software_ddraw_surface_resize(Outbuf *buf);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,89 @@
|
||||||
|
#include "evas_common.h"
|
||||||
#include "evas_engine.h"
|
#include "evas_engine.h"
|
||||||
|
|
||||||
|
|
||||||
|
static Evas_List *ddpool = NULL;
|
||||||
|
static int ddsize = 0;
|
||||||
|
static int ddmemlimit = 10 * 1024 * 1024;
|
||||||
|
static int ddcountlimit = 32;
|
||||||
|
|
||||||
|
static DD_Output_Buffer *
|
||||||
|
_find_ddob(int depth, int w, int h, void *data)
|
||||||
|
{
|
||||||
|
Evas_List *l;
|
||||||
|
Evas_List *ddl;
|
||||||
|
DD_Output_Buffer *ddob = NULL;
|
||||||
|
int sz;
|
||||||
|
int lbytes;
|
||||||
|
int bpp;
|
||||||
|
|
||||||
|
bpp = depth / 8;
|
||||||
|
if (bpp == 3) bpp = 4;
|
||||||
|
lbytes = (((w * bpp) + 3) / 4) * 4;
|
||||||
|
sz = lbytes * h;
|
||||||
|
for (l = ddpool; l; l = l->next)
|
||||||
|
{
|
||||||
|
DD_Output_Buffer *ddob2;
|
||||||
|
|
||||||
|
ddob2 = l->data;
|
||||||
|
if (ddob2->depth != depth)
|
||||||
|
continue;
|
||||||
|
if (ddob2->psize == sz)
|
||||||
|
{
|
||||||
|
ddob = ddob2;
|
||||||
|
ddl = l;
|
||||||
|
goto have_ddob;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ddob)
|
||||||
|
return evas_software_ddraw_output_buffer_new(depth, w, h, data);
|
||||||
|
|
||||||
|
have_ddob:
|
||||||
|
ddpool = evas_list_remove_list(ddpool, ddl);
|
||||||
|
ddob->width = w;
|
||||||
|
ddob->height = h;
|
||||||
|
ddob->pitch = lbytes;
|
||||||
|
ddsize -= ddob->psize * (ddob->depth / 8);
|
||||||
|
|
||||||
|
return ddob;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_unfind_ddob(DD_Output_Buffer *ddob)
|
||||||
|
{
|
||||||
|
ddpool = evas_list_prepend(ddpool, ddob);
|
||||||
|
ddsize += ddob->psize * ddob->depth / 8;
|
||||||
|
while ((ddsize > (ddmemlimit)) ||
|
||||||
|
(evas_list_count(ddpool) > ddcountlimit))
|
||||||
|
{
|
||||||
|
Evas_List *xl;
|
||||||
|
|
||||||
|
xl = evas_list_last(ddpool);
|
||||||
|
if (!xl)
|
||||||
|
{
|
||||||
|
ddsize = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ddob = xl->data;
|
||||||
|
ddpool = evas_list_remove_list(ddpool, xl);
|
||||||
|
evas_software_ddraw_output_buffer_free(ddob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_clear_ddob(int sync)
|
||||||
|
{
|
||||||
|
while (ddpool)
|
||||||
|
{
|
||||||
|
DD_Output_Buffer *ddob;
|
||||||
|
|
||||||
|
ddob = ddpool->data;
|
||||||
|
ddpool = evas_list_remove_list(ddpool, ddpool);
|
||||||
|
evas_software_ddraw_output_buffer_free(ddob);
|
||||||
|
}
|
||||||
|
ddsize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
evas_software_ddraw_outbuf_init(void)
|
evas_software_ddraw_outbuf_init(void)
|
||||||
{
|
{
|
||||||
|
@ -9,19 +92,20 @@ evas_software_ddraw_outbuf_init(void)
|
||||||
void
|
void
|
||||||
evas_software_ddraw_outbuf_free(Outbuf *buf)
|
evas_software_ddraw_outbuf_free(Outbuf *buf)
|
||||||
{
|
{
|
||||||
|
if (!buf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
evas_software_ddraw_shutdown(buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
Outbuf *
|
Outbuf *
|
||||||
evas_software_ddraw_outbuf_setup_dd(int width,
|
evas_software_ddraw_outbuf_setup(int width,
|
||||||
int height,
|
int height,
|
||||||
int rotation,
|
int rotation,
|
||||||
Outbuf_Depth depth,
|
Outbuf_Depth depth,
|
||||||
HWND window,
|
HWND window,
|
||||||
LPDIRECTDRAW object,
|
int w_depth)
|
||||||
LPDIRECTDRAWSURFACE surface_primary,
|
|
||||||
LPDIRECTDRAWSURFACE surface_back,
|
|
||||||
int w_depth)
|
|
||||||
{
|
{
|
||||||
Outbuf *buf;
|
Outbuf *buf;
|
||||||
|
|
||||||
|
@ -34,15 +118,15 @@ evas_software_ddraw_outbuf_setup_dd(int width,
|
||||||
buf->depth = depth;
|
buf->depth = depth;
|
||||||
buf->rot = rotation;
|
buf->rot = rotation;
|
||||||
|
|
||||||
buf->priv.dd.window = window;
|
if (!evas_software_ddraw_init(window, w_depth, buf))
|
||||||
buf->priv.dd.object = object;
|
{
|
||||||
buf->priv.dd.surface_primary = surface_primary;
|
free(buf);
|
||||||
buf->priv.dd.surface_back = surface_back;
|
return NULL;
|
||||||
buf->priv.dd.depth = w_depth;
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Gfx_Func_Convert conv_func;
|
Gfx_Func_Convert conv_func;
|
||||||
DDraw_Output_Buffer *ddob;
|
DD_Output_Buffer *ddob;
|
||||||
|
|
||||||
ddob = evas_software_ddraw_output_buffer_new(w_depth, 1, 1, NULL);
|
ddob = evas_software_ddraw_output_buffer_new(w_depth, 1, 1, NULL);
|
||||||
|
|
||||||
|
@ -72,19 +156,21 @@ evas_software_ddraw_outbuf_setup_dd(int width,
|
||||||
PAL_MODE_NONE,
|
PAL_MODE_NONE,
|
||||||
rotation);
|
rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
evas_software_ddraw_output_buffer_free(ddob);
|
evas_software_ddraw_output_buffer_free(ddob);
|
||||||
|
|
||||||
if (!conv_func)
|
if (!conv_func)
|
||||||
{
|
{
|
||||||
printf(".[ Evas Error ].\n"
|
fprintf(stderr, ".[ Evas Error ].\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
" At depth %i:\n"
|
" At depth %i:\n"
|
||||||
" RGB format mask: %08x, %08x, %08x\n"
|
" RGB format mask: %08x, %08x, %08x\n"
|
||||||
" Not supported by and compiled in converters!\n"
|
" Not supported by and compiled in converters!\n"
|
||||||
" }\n",
|
" }\n",
|
||||||
buf->priv.dd.depth,
|
buf->priv.dd.depth,
|
||||||
buf->priv.mask.r,
|
buf->priv.mask.r,
|
||||||
buf->priv.mask.g,
|
buf->priv.mask.g,
|
||||||
buf->priv.mask.b);
|
buf->priv.mask.b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,70 +178,179 @@ evas_software_ddraw_outbuf_setup_dd(int width,
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
evas_software_ddraw_outbuf_reconfigure(Outbuf *buf,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
int rotation,
|
||||||
|
Outbuf_Depth depth)
|
||||||
|
{
|
||||||
|
if ((width == buf->width) && (height == buf->height) &&
|
||||||
|
(rotation == buf->rot) && (depth == buf->depth))
|
||||||
|
return;
|
||||||
|
buf->width = width;
|
||||||
|
buf->height = height;
|
||||||
|
buf->rot = rotation;
|
||||||
|
evas_software_ddraw_surface_resize(buf);
|
||||||
|
}
|
||||||
|
|
||||||
RGBA_Image *
|
RGBA_Image *
|
||||||
evas_software_ddraw_outbuf_new_region_for_update(Outbuf *buf,
|
evas_software_ddraw_outbuf_new_region_for_update(Outbuf *buf,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
int width,
|
int w,
|
||||||
int height,
|
int h,
|
||||||
int *cx,
|
int *cx,
|
||||||
int *cy,
|
int *cy,
|
||||||
int *cw,
|
int *cw,
|
||||||
int *ch)
|
int *ch)
|
||||||
{
|
{
|
||||||
RGBA_Image *im;
|
RGBA_Image *im;
|
||||||
DDraw_Output_Buffer *ddob = NULL;
|
Outbuf_Region *obr;
|
||||||
int bpl = 0;
|
int bpl = 0;
|
||||||
|
int alpha = 0;
|
||||||
|
|
||||||
|
obr = calloc(1, sizeof(Outbuf_Region));
|
||||||
|
obr->x = x;
|
||||||
|
obr->y = y;
|
||||||
|
obr->width = w;
|
||||||
|
obr->height = h;
|
||||||
*cx = 0;
|
*cx = 0;
|
||||||
*cy = 0;
|
*cy = 0;
|
||||||
*cw = width;
|
*cw = w;
|
||||||
*ch = height;
|
*ch = h;
|
||||||
|
|
||||||
if ((buf->rot == 0) &&
|
if ((buf->rot == 0) &&
|
||||||
(buf->priv.mask.r == 0xff0000) &&
|
(buf->priv.mask.r == 0xff0000) &&
|
||||||
(buf->priv.mask.g == 0x00ff00) &&
|
(buf->priv.mask.g == 0x00ff00) &&
|
||||||
(buf->priv.mask.b == 0x0000ff))
|
(buf->priv.mask.b == 0x0000ff))
|
||||||
{
|
{
|
||||||
im = (RGBA_Image*) evas_cache_image_empty(evas_common_image_cache_get());
|
obr->ddob = _find_ddob(buf->priv.dd.depth, w, h, NULL);
|
||||||
if (!im) return NULL;
|
/* obr->ddob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp, */
|
||||||
im = (RGBA_Image*) evas_cache_image_size_set(&im->cache_entry, width, height);
|
/* buf->priv.dd.vis, */
|
||||||
if (!im) return NULL;
|
/* buf->priv.dd.depth, */
|
||||||
im->image.no_free = 1;
|
/* w, h, */
|
||||||
ddob = evas_software_ddraw_output_buffer_new(buf->priv.dd.depth,
|
/* use_shm, */
|
||||||
width,
|
/* NULL); */
|
||||||
height,
|
im = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
|
||||||
NULL);
|
w, h,
|
||||||
im->extended_info = ddob;
|
(DATA32 *) evas_software_ddraw_output_buffer_data(obr->ddob, &bpl),
|
||||||
im->image.data = (DATA32 *)evas_software_ddraw_output_buffer_data(ddob, &bpl);
|
alpha, EVAS_COLORSPACE_ARGB8888);
|
||||||
|
im->extended_info = obr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
im = evas_cache_image_empty(evas_common_image_cache_get());
|
im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
|
||||||
if (!im) return NULL;
|
im->cache_entry.flags.alpha |= alpha ? 1 : 0;
|
||||||
evas_cache_image_surface_alloc(&im->cache_entry, width, height);
|
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
|
||||||
im->extended_info = ddob;
|
im->extended_info = obr;
|
||||||
if ((buf->rot == 0) || (buf->rot == 180))
|
if ((buf->rot == 0) || (buf->rot == 180))
|
||||||
ddob = evas_software_ddraw_output_buffer_new(buf->priv.dd.depth,
|
obr->ddob = _find_ddob(buf->priv.dd.depth, w, h, NULL);
|
||||||
width,
|
/*
|
||||||
height,
|
obr->ddob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp,
|
||||||
NULL);
|
buf->priv.dd.vis,
|
||||||
|
buf->priv.dd.depth,
|
||||||
|
w, h,
|
||||||
|
use_shm,
|
||||||
|
NULL);
|
||||||
|
*/
|
||||||
else if ((buf->rot == 90) || (buf->rot == 270))
|
else if ((buf->rot == 90) || (buf->rot == 270))
|
||||||
ddob = evas_software_ddraw_output_buffer_new(buf->priv.dd.depth,
|
obr->ddob = _find_ddob(buf->priv.dd.depth, h, w, NULL);
|
||||||
width,
|
/*
|
||||||
height,
|
obr->ddob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp,
|
||||||
NULL);
|
buf->priv.dd.vis,
|
||||||
im->extended_info = ddob;
|
buf->priv.dd.depth,
|
||||||
|
h, w,
|
||||||
|
use_shm,
|
||||||
|
NULL);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->priv.pending_writes = evas_list_append(buf->priv.pending_writes, im);
|
buf->priv.pending_writes = evas_list_append(buf->priv.pending_writes, im);
|
||||||
|
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
evas_software_ddraw_outbuf_push_updated_region(Outbuf *buf,
|
||||||
|
RGBA_Image *update,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int w,
|
||||||
|
int h)
|
||||||
|
{
|
||||||
|
Gfx_Func_Convert conv_func;
|
||||||
|
Outbuf_Region *obr;
|
||||||
|
DATA32 *src_data;
|
||||||
|
void *data;
|
||||||
|
int bpl = 0, yy;
|
||||||
|
|
||||||
|
conv_func = NULL;
|
||||||
|
obr = update->extended_info;
|
||||||
|
|
||||||
|
if ((buf->rot == 0) || (buf->rot == 180))
|
||||||
|
conv_func = evas_common_convert_func_get(0, w, h,
|
||||||
|
evas_software_ddraw_output_buffer_depth(obr->ddob),
|
||||||
|
buf->priv.mask.r,
|
||||||
|
buf->priv.mask.g,
|
||||||
|
buf->priv.mask.b,
|
||||||
|
PAL_MODE_NONE,
|
||||||
|
buf->rot);
|
||||||
|
else if ((buf->rot == 90) || (buf->rot == 270))
|
||||||
|
conv_func = evas_common_convert_func_get(0, h, w,
|
||||||
|
evas_software_ddraw_output_buffer_depth(obr->ddob),
|
||||||
|
buf->priv.mask.r,
|
||||||
|
buf->priv.mask.g,
|
||||||
|
buf->priv.mask.b,
|
||||||
|
PAL_MODE_NONE, buf->rot);
|
||||||
|
if (!conv_func) return;
|
||||||
|
|
||||||
|
data = evas_software_ddraw_output_buffer_data(obr->ddob, &bpl);
|
||||||
|
src_data = update->image.data;
|
||||||
|
if (buf->rot == 0)
|
||||||
|
{
|
||||||
|
obr->x = x;
|
||||||
|
obr->y = y;
|
||||||
|
}
|
||||||
|
else if (buf->rot == 90)
|
||||||
|
{
|
||||||
|
obr->x = y;
|
||||||
|
obr->y = buf->width - x - w;
|
||||||
|
}
|
||||||
|
else if (buf->rot == 180)
|
||||||
|
{
|
||||||
|
obr->x = buf->width - x - w;
|
||||||
|
obr->y = buf->height - y - h;
|
||||||
|
}
|
||||||
|
else if (buf->rot == 270)
|
||||||
|
{
|
||||||
|
obr->x = buf->height - y - h;
|
||||||
|
obr->y = x;
|
||||||
|
}
|
||||||
|
if ((buf->rot == 0) || (buf->rot == 180))
|
||||||
|
{
|
||||||
|
obr->width = w;
|
||||||
|
obr->height = h;
|
||||||
|
}
|
||||||
|
else if ((buf->rot == 90) || (buf->rot == 270))
|
||||||
|
{
|
||||||
|
obr->width = h;
|
||||||
|
obr->height = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data != src_data)
|
||||||
|
conv_func(src_data, data,
|
||||||
|
0,
|
||||||
|
bpl / ((evas_software_ddraw_output_buffer_depth(obr->ddob) / 8)) - obr->width,
|
||||||
|
obr->width,
|
||||||
|
obr->height,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
evas_software_ddraw_outbuf_free_region_for_update(Outbuf *buf,
|
evas_software_ddraw_outbuf_free_region_for_update(Outbuf *buf,
|
||||||
RGBA_Image *update)
|
RGBA_Image *update)
|
||||||
{
|
{
|
||||||
/* no need to do anything - they are cleaned up on flush */
|
/* no need to do anything - they are cleaned up on flush */
|
||||||
}
|
}
|
||||||
|
@ -181,136 +376,68 @@ evas_software_ddraw_outbuf_flush(Outbuf *buf)
|
||||||
/* copy safely the images that need to be drawn onto the back surface */
|
/* copy safely the images that need to be drawn onto the back surface */
|
||||||
for (l = buf->priv.pending_writes; l; l = l->next)
|
for (l = buf->priv.pending_writes; l; l = l->next)
|
||||||
{
|
{
|
||||||
RGBA_Image *im;
|
RGBA_Image *im;
|
||||||
DDraw_Output_Buffer *ddob;
|
Outbuf_Region *obr;
|
||||||
|
DD_Output_Buffer *ddob;
|
||||||
|
|
||||||
im = l->data;
|
im = l->data;
|
||||||
ddob = im->extended_info;
|
obr = im->extended_info;
|
||||||
/* paste now */
|
ddob = obr->ddob;
|
||||||
evas_software_ddraw_output_buffer_paste(ddob,
|
evas_software_ddraw_output_buffer_paste(ddob,
|
||||||
ddraw_data,
|
ddraw_data,
|
||||||
ddraw_width,
|
ddraw_width,
|
||||||
ddraw_height,
|
ddraw_height,
|
||||||
ddraw_pitch,
|
ddraw_pitch,
|
||||||
ddraw_depth,
|
ddraw_depth,
|
||||||
ddob->x,
|
obr->x,
|
||||||
ddob->y);
|
obr->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unlock the back surface and flip the surface */
|
/* unlock the back surface and flip the surface */
|
||||||
evas_software_ddraw_unlock_and_flip(buf);
|
evas_software_ddraw_unlock_and_flip(buf);
|
||||||
|
|
||||||
free_images:
|
free_images:
|
||||||
while (buf->priv.pending_writes)
|
while (buf->priv.prev_pending_writes)
|
||||||
{
|
{
|
||||||
RGBA_Image *im;
|
RGBA_Image *im;
|
||||||
DDraw_Output_Buffer *ddob;
|
Outbuf_Region *obr;
|
||||||
|
|
||||||
im = buf->priv.pending_writes->data;
|
im = buf->priv.prev_pending_writes->data;
|
||||||
buf->priv.pending_writes = evas_list_remove_list(buf->priv.pending_writes,
|
buf->priv.prev_pending_writes =
|
||||||
buf->priv.pending_writes);
|
evas_list_remove_list(buf->priv.prev_pending_writes,
|
||||||
ddob = im->extended_info;
|
buf->priv.prev_pending_writes);
|
||||||
evas_cache_image_drop(im);
|
obr = im->extended_info;
|
||||||
if (ddob) evas_software_ddraw_output_buffer_free(ddob);
|
evas_cache_image_drop((Image_Entry *)im);
|
||||||
|
if (obr->ddob) _unfind_ddob(obr->ddob);
|
||||||
|
/*
|
||||||
|
if (obr->ddob) evas_software_x11_x_output_buffer_free(obr->ddob);
|
||||||
|
*/
|
||||||
|
free(obr);
|
||||||
}
|
}
|
||||||
|
buf->priv.prev_pending_writes = buf->priv.pending_writes;
|
||||||
|
buf->priv.pending_writes = NULL;
|
||||||
|
|
||||||
evas_common_cpu_end_opt();
|
evas_common_cpu_end_opt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
evas_software_ddraw_outbuf_push_updated_region(Outbuf *buf,
|
evas_software_ddraw_outbuf_idle_flush(Outbuf *buf)
|
||||||
RGBA_Image *update,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int width,
|
|
||||||
int height)
|
|
||||||
{
|
{
|
||||||
Gfx_Func_Convert conv_func;
|
while (buf->priv.prev_pending_writes)
|
||||||
DDraw_Output_Buffer *ddob;
|
|
||||||
DATA32 *src_data;
|
|
||||||
void *data;
|
|
||||||
int bpl = 0;
|
|
||||||
|
|
||||||
conv_func = NULL;
|
|
||||||
ddob = update->extended_info;
|
|
||||||
|
|
||||||
if ((buf->rot == 0) || (buf->rot == 180))
|
|
||||||
conv_func = evas_common_convert_func_get(NULL,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
evas_software_ddraw_output_buffer_depth(ddob),
|
|
||||||
buf->priv.mask.r,
|
|
||||||
buf->priv.mask.g,
|
|
||||||
buf->priv.mask.b,
|
|
||||||
PAL_MODE_NONE,
|
|
||||||
buf->rot);
|
|
||||||
else if ((buf->rot == 90) || (buf->rot == 270))
|
|
||||||
conv_func = evas_common_convert_func_get(NULL,
|
|
||||||
height,
|
|
||||||
width,
|
|
||||||
evas_software_ddraw_output_buffer_depth(ddob),
|
|
||||||
buf->priv.mask.r,
|
|
||||||
buf->priv.mask.g,
|
|
||||||
buf->priv.mask.b,
|
|
||||||
PAL_MODE_NONE,
|
|
||||||
buf->rot);
|
|
||||||
|
|
||||||
if (!conv_func) return;
|
|
||||||
|
|
||||||
data = evas_software_ddraw_output_buffer_data(ddob, &bpl);
|
|
||||||
src_data = update->image->data;
|
|
||||||
if (buf->rot == 0)
|
|
||||||
{
|
{
|
||||||
ddob->x = x;
|
RGBA_Image *im;
|
||||||
ddob->y = y;
|
Outbuf_Region *obr;
|
||||||
}
|
|
||||||
else if (buf->rot == 90)
|
|
||||||
{
|
|
||||||
ddob->x = y;
|
|
||||||
ddob->y = buf->width - x - width;
|
|
||||||
}
|
|
||||||
else if (buf->rot == 180)
|
|
||||||
{
|
|
||||||
ddob->x = buf->width - x - width;
|
|
||||||
ddob->y = buf->height - y - height;
|
|
||||||
}
|
|
||||||
else if (buf->rot == 270)
|
|
||||||
{
|
|
||||||
ddob->x = buf->height - y - height;
|
|
||||||
ddob->y = x;
|
|
||||||
}
|
|
||||||
if ((buf->rot == 0) || (buf->rot == 180))
|
|
||||||
{
|
|
||||||
ddob->width = width;
|
|
||||||
ddob->height = height;
|
|
||||||
}
|
|
||||||
else if ((buf->rot == 90) || (buf->rot == 270))
|
|
||||||
{
|
|
||||||
ddob->width = height;
|
|
||||||
ddob->height = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data != src_data)
|
im = buf->priv.prev_pending_writes->data;
|
||||||
conv_func(src_data, data,
|
buf->priv.prev_pending_writes =
|
||||||
0,
|
evas_list_remove_list(buf->priv.prev_pending_writes,
|
||||||
bpl /
|
buf->priv.prev_pending_writes);
|
||||||
((evas_software_ddraw_output_buffer_depth(ddob))) - ddob->width,
|
obr = im->extended_info;
|
||||||
ddob->width, ddob->height, x, y, NULL);
|
evas_cache_image_drop((Image_Entry *)im);
|
||||||
}
|
if (obr->ddob) _unfind_ddob(obr->ddob);
|
||||||
|
free(obr);
|
||||||
void
|
}
|
||||||
evas_software_ddraw_outbuf_reconfigure(Outbuf *buf,
|
_clear_ddob(0);
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
int rotation,
|
|
||||||
Outbuf_Depth depth)
|
|
||||||
{
|
|
||||||
if ((width == buf->width) && (height == buf->height) &&
|
|
||||||
(rotation == buf->rot) && (depth == buf->depth))
|
|
||||||
return;
|
|
||||||
buf->width = width;
|
|
||||||
buf->height = height;
|
|
||||||
buf->rot = rotation;
|
|
||||||
evas_software_ddraw_surface_resize(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in New Issue