Evas: remove depth usage in GDI and DirectDraw engines

Test Plan: compilation and elementary_test

Reviewers: raster

Reviewed By: raster

Subscribers: cedric, raster

Differential Revision: https://phab.enlightenment.org/D5792
This commit is contained in:
Vincent Torri 2018-02-07 22:10:24 +09:00 committed by Carsten Haitzler (Rasterman)
parent 000d43b29e
commit d54f0f66cf
13 changed files with 74 additions and 378 deletions

View File

@ -1334,7 +1334,6 @@ _ecore_evas_engine_software_gdi_init(Ecore_Evas *ee)
{
/* FIXME: REDRAW_DEBUG missing for now */
einfo->info.window = ((Ecore_Win32_Window *)ee->prop.window)->window;
einfo->info.depth = ecore_win32_screen_depth_get();
einfo->info.rotation = 0;
einfo->info.borderless = 0;
einfo->info.fullscreen = 0;
@ -1377,7 +1376,6 @@ _ecore_evas_engine_software_ddraw_init(Ecore_Evas *ee)
{
/* FIXME: REDRAW_DEBUG missing for now */
einfo->info.window = ((Ecore_Win32_Window *)ee->prop.window)->window;
einfo->info.depth = ecore_win32_screen_depth_get();
einfo->info.rotation = 0;
if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
{

View File

@ -17,7 +17,6 @@ struct _Evas_Engine_Info_Software_DDraw
struct {
HWND window;
int depth;
int rotation;
unsigned int fullscreen : 1;
} info;

View File

@ -5,8 +5,7 @@
DD_Output_Buffer *
evas_software_ddraw_output_buffer_new(int depth,
int width,
evas_software_ddraw_output_buffer_new(int width,
int height,
void *data)
{
@ -16,10 +15,9 @@ evas_software_ddraw_output_buffer_new(int depth,
if (!ddob) return NULL;
ddob->data = data;
ddob->depth = depth;
ddob->width = width;
ddob->height = height;
ddob->pitch = width * depth / 8;
ddob->pitch = width * 4;
ddob->psize = ddob->pitch * height;
if (!ddob->data)
@ -48,7 +46,6 @@ evas_software_ddraw_output_buffer_paste(DD_Output_Buffer *ddob,
int ddraw_width,
int ddraw_height,
int ddraw_pitch,
int ddraw_depth,
int x,
int y)
{
@ -69,9 +66,9 @@ evas_software_ddraw_output_buffer_paste(DD_Output_Buffer *ddob,
height = ((y + ddob->height) > ddraw_height)
? ddraw_height - y
: ddob->height;
pitch = width * ddob->depth / 8;
pitch = width * 4;
dd_data = (DATA8 *)ddraw_data + y * ddraw_pitch + x * ddraw_depth;
dd_data = (DATA8 *)ddraw_data + y * ddraw_pitch + x * 32;
evas_data = (unsigned char *)ddob->data;
for (j = 0; j < height; j++, evas_data += ddob->pitch, dd_data += ddraw_pitch)
memcpy(dd_data, evas_data, pitch);
@ -84,9 +81,3 @@ evas_software_ddraw_output_buffer_data(DD_Output_Buffer *ddob,
if (bytes_per_line_ret) *bytes_per_line_ret = ddob->pitch;
return ddob->data;
}
int
evas_software_ddraw_output_buffer_depth(DD_Output_Buffer *ddob)
{
return ddob->depth;
}

View File

@ -3,7 +3,6 @@
int
evas_software_ddraw_init (HWND window,
int depth,
int fullscreen,
Outbuf *buf)
{
@ -38,12 +37,10 @@ evas_software_ddraw_init (HWND window,
pixel_format.dwSize = sizeof(pixel_format);
buf->priv.dd.surface_primary->GetPixelFormat(&pixel_format);
if (pixel_format.dwRGBBitCount != (DWORD)depth)
if (pixel_format.dwRGBBitCount != 32)
goto release_object;
buf->priv.dd.depth = depth;
res = buf->priv.dd.object->SetDisplayMode(width, height, depth);
res = buf->priv.dd.object->SetDisplayMode(width, height, 32);
if (FAILED(res))
goto release_object;
@ -54,7 +51,8 @@ evas_software_ddraw_init (HWND window,
surface_desc.dwBackBufferCount = 1;
res = buf->priv.dd.object->CreateSurface(&surface_desc,
&buf->priv.dd.surface_primary, NULL);
&buf->priv.dd.surface_primary,
NULL);
if (FAILED(res))
goto release_object;
@ -116,10 +114,8 @@ evas_software_ddraw_init (HWND window,
pixel_format.dwSize = sizeof(pixel_format);
buf->priv.dd.surface_primary->GetPixelFormat(&pixel_format);
if (pixel_format.dwRGBBitCount != (DWORD)depth)
if (pixel_format.dwRGBBitCount != 32)
goto release_surface_back;
buf->priv.dd.depth = depth;
}
return 1;
@ -177,8 +173,7 @@ void *
evas_software_ddraw_lock(Outbuf *buf,
int *ddraw_width,
int *ddraw_height,
int *ddraw_pitch,
int *ddraw_depth)
int *ddraw_pitch)
{
DDSURFACEDESC surface_desc;
@ -194,7 +189,6 @@ evas_software_ddraw_lock(Outbuf *buf,
*ddraw_width = surface_desc.dwWidth;
*ddraw_height = surface_desc.dwHeight;
*ddraw_pitch = surface_desc.lPitch;
*ddraw_depth = surface_desc.ddpfPixelFormat.dwRGBBitCount >> 3;
return surface_desc.lpSurface;
}

View File

@ -34,9 +34,7 @@ eng_output_setup(void *engine, void *in, unsigned int w, unsigned int h)
ob = evas_software_ddraw_outbuf_setup(w, h,
info->info.rotation,
OUTBUF_DEPTH_INHERIT,
info->info.window,
info->info.depth,
info->info.fullscreen);
if (!ob) goto on_error;

View File

@ -5,6 +5,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include <ddraw.h>
#include "../software_generic/Evas_Engine_Software_Generic.h"
@ -14,7 +15,6 @@ typedef struct _DD_Output_Buffer DD_Output_Buffer;
struct _Outbuf
{
Outbuf_Depth depth;
int width;
int height;
int rot;
@ -28,7 +28,6 @@ struct _Outbuf
LPDIRECTDRAWSURFACE surface_primary;
LPDIRECTDRAWSURFACE surface_back;
LPDIRECTDRAWCLIPPER clipper;
int depth;
unsigned char fullscreen : 1;
unsigned char swap : 1;
unsigned char bit_swap : 1;
@ -67,7 +66,6 @@ struct _DD_Output_Buffer
void *data;
int width;
int height;
int depth;
int pitch;
int psize;
};
@ -108,9 +106,7 @@ void evas_software_ddraw_outbuf_free(Outbuf *buf);
Outbuf *evas_software_ddraw_outbuf_setup(int width,
int height,
int rotation,
Outbuf_Depth depth,
HWND window,
int w_depth,
int fullscreen);
void evas_software_ddraw_outbuf_reconfigure(Outbuf *buf,
@ -144,14 +140,11 @@ 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);
int evas_software_ddraw_outbuf_rot_get(Outbuf *buf);
/* evas_ddraw_buffer.c */
DD_Output_Buffer *evas_software_ddraw_output_buffer_new(int depth,
int width,
DD_Output_Buffer *evas_software_ddraw_output_buffer_new(int width,
int height,
void *data);
@ -162,15 +155,12 @@ void evas_software_ddraw_output_buffer_paste(DD_Output_Buffer *ddob,
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
@ -178,7 +168,6 @@ extern "C" {
#endif
int evas_software_ddraw_init (HWND window,
int depth,
int fullscreen,
Outbuf *buf);
@ -189,8 +178,7 @@ 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);
int *ddraw_pitch);
void evas_software_ddraw_unlock_and_flip(Outbuf *buf);

View File

@ -1,88 +1,6 @@
#include "evas_common_private.h"
#include "evas_engine.h"
static Eina_List *ddpool = NULL;
static int ddsize = 0;
#define ddmemlimit 10 * 1024 * 1024
#define ddcountlimit 32
static DD_Output_Buffer *
_find_ddob(int depth, int w, int h, void *data)
{
Eina_List *l;
Eina_List *ddl;
DD_Output_Buffer *ddob = NULL;
DD_Output_Buffer *ddob2;
int sz;
int lbytes;
int bpp;
bpp = depth / 8;
if (bpp == 3) bpp = 4;
lbytes = (((w * bpp) + 3) / 4) * 4;
sz = lbytes * h;
EINA_LIST_FOREACH(ddpool, l, ddob2)
{
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 = eina_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 = eina_list_prepend(ddpool, ddob);
ddsize += ddob->psize * ddob->depth / 8;
while ((ddsize > (ddmemlimit)) ||
(eina_list_count(ddpool) > ddcountlimit))
{
Eina_List *xl;
xl = eina_list_last(ddpool);
if (!xl)
{
ddsize = 0;
break;
}
ddob = xl->data;
ddpool = eina_list_remove_list(ddpool, xl);
evas_software_ddraw_output_buffer_free(ddob);
}
}
static void
_clear_ddob(int sync EINA_UNUSED)
{
while (ddpool)
{
DD_Output_Buffer *ddob;
ddob = ddpool->data;
ddpool = eina_list_remove_list(ddpool, ddpool);
evas_software_ddraw_output_buffer_free(ddob);
}
ddsize = 0;
}
void
evas_software_ddraw_outbuf_init(void)
{
@ -102,9 +20,7 @@ Outbuf *
evas_software_ddraw_outbuf_setup(int width,
int height,
int rotation,
Outbuf_Depth depth,
HWND window,
int w_depth,
int fullscreen)
{
Outbuf *buf;
@ -115,10 +31,9 @@ evas_software_ddraw_outbuf_setup(int width,
buf->width = width;
buf->height = height;
buf->depth = depth;
buf->rot = rotation;
if (!evas_software_ddraw_init(window, w_depth, fullscreen, buf))
if (!evas_software_ddraw_init(window, fullscreen, buf))
{
free(buf);
return NULL;
@ -128,7 +43,7 @@ evas_software_ddraw_outbuf_setup(int width,
Gfx_Func_Convert conv_func;
DD_Output_Buffer *ddob;
ddob = evas_software_ddraw_output_buffer_new(w_depth, 1, 1, NULL);
ddob = evas_software_ddraw_output_buffer_new(1, 1, NULL);
conv_func = NULL;
if (ddob)
@ -139,7 +54,7 @@ evas_software_ddraw_outbuf_setup(int width,
conv_func = evas_common_convert_func_get(0,
width,
height,
evas_software_ddraw_output_buffer_depth (ddob),
32,
buf->priv.mask.r,
buf->priv.mask.g,
buf->priv.mask.b,
@ -149,7 +64,7 @@ evas_software_ddraw_outbuf_setup(int width,
conv_func = evas_common_convert_func_get(0,
height,
width,
evas_software_ddraw_output_buffer_depth (ddob),
32,
buf->priv.mask.r,
buf->priv.mask.g,
buf->priv.mask.b,
@ -163,11 +78,10 @@ evas_software_ddraw_outbuf_setup(int width,
{
ERR("DDraw engine Error"
" {"
" At depth %i:"
" At depth 32:"
" RGB format mask: %08x, %08x, %08x"
" Not supported by and compiled in converters!"
" }",
buf->priv.dd.depth,
buf->priv.mask.r,
buf->priv.mask.g,
buf->priv.mask.b);
@ -183,10 +97,10 @@ evas_software_ddraw_outbuf_reconfigure(Outbuf *buf,
int width,
int height,
int rotation,
Outbuf_Depth depth)
Outbuf_Depth depth EINA_UNUSED)
{
if ((width == buf->width) && (height == buf->height) &&
(rotation == buf->rot) && (depth == buf->depth))
(rotation == buf->rot))
return;
buf->width = width;
buf->height = height;
@ -225,13 +139,7 @@ evas_software_ddraw_outbuf_new_region_for_update(Outbuf *buf,
(buf->priv.mask.g == 0x00ff00) &&
(buf->priv.mask.b == 0x0000ff))
{
obr->ddob = _find_ddob(buf->priv.dd.depth, w, h, NULL);
/* obr->ddob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp, */
/* buf->priv.dd.vis, */
/* buf->priv.dd.depth, */
/* w, h, */
/* use_shm, */
/* NULL); */
obr->ddob = evas_software_ddraw_output_buffer_new(w, h, NULL);
im = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
w, h,
(DATA32 *) evas_software_ddraw_output_buffer_data(obr->ddob, &bpl),
@ -245,25 +153,9 @@ evas_software_ddraw_outbuf_new_region_for_update(Outbuf *buf,
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
im->extended_info = obr;
if ((buf->rot == 0) || (buf->rot == 180))
obr->ddob = _find_ddob(buf->priv.dd.depth, w, h, NULL);
/*
obr->ddob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp,
buf->priv.dd.vis,
buf->priv.dd.depth,
w, h,
use_shm,
NULL);
*/
obr->ddob = evas_software_ddraw_output_buffer_new(w, h, NULL);
else if ((buf->rot == 90) || (buf->rot == 270))
obr->ddob = _find_ddob(buf->priv.dd.depth, h, w, NULL);
/*
obr->ddob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp,
buf->priv.dd.vis,
buf->priv.dd.depth,
h, w,
use_shm,
NULL);
*/
obr->ddob = evas_software_ddraw_output_buffer_new(h, w, NULL);
}
buf->priv.pending_writes = eina_list_append(buf->priv.pending_writes, im);
@ -289,7 +181,7 @@ evas_software_ddraw_outbuf_push_updated_region(Outbuf *buf,
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),
32,
buf->priv.mask.r,
buf->priv.mask.g,
buf->priv.mask.b,
@ -297,7 +189,7 @@ evas_software_ddraw_outbuf_push_updated_region(Outbuf *buf,
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),
32,
buf->priv.mask.r,
buf->priv.mask.g,
buf->priv.mask.b,
@ -340,7 +232,7 @@ evas_software_ddraw_outbuf_push_updated_region(Outbuf *buf,
if (data != src_data)
conv_func(src_data, data,
0,
bpl / ((evas_software_ddraw_output_buffer_depth(obr->ddob) / 8)) - obr->width,
bpl / 4 - obr->width,
obr->width,
obr->height,
x,
@ -358,7 +250,6 @@ evas_software_ddraw_outbuf_flush(Outbuf *buf, Tilebuf_Rect *surface_damage EINA_
int ddraw_width;
int ddraw_height;
int ddraw_pitch;
int ddraw_depth;
if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return;
@ -366,8 +257,7 @@ evas_software_ddraw_outbuf_flush(Outbuf *buf, Tilebuf_Rect *surface_damage EINA_
if (!(ddraw_data = evas_software_ddraw_lock(buf,
&ddraw_width,
&ddraw_height,
&ddraw_pitch,
&ddraw_depth)))
&ddraw_pitch)))
goto free_images;
/* copy safely the images that need to be drawn onto the back surface */
@ -382,7 +272,6 @@ evas_software_ddraw_outbuf_flush(Outbuf *buf, Tilebuf_Rect *surface_damage EINA_
ddraw_width,
ddraw_height,
ddraw_pitch,
ddraw_depth,
obr->x,
obr->y);
}
@ -399,10 +288,8 @@ evas_software_ddraw_outbuf_flush(Outbuf *buf, Tilebuf_Rect *surface_damage EINA_
buf->priv.prev_pending_writes);
obr = im->extended_info;
evas_cache_image_drop(&im->cache_entry);
if (obr->ddob) _unfind_ddob(obr->ddob);
/*
if (obr->ddob) evas_software_x11_x_output_buffer_free(obr->ddob);
*/
if (obr->ddob)
evas_software_ddraw_output_buffer_free(obr->ddob);
free(obr);
}
buf->priv.prev_pending_writes = buf->priv.pending_writes;
@ -425,10 +312,10 @@ evas_software_ddraw_outbuf_idle_flush(Outbuf *buf)
buf->priv.prev_pending_writes);
obr = im->extended_info;
evas_cache_image_drop((Image_Entry *)im);
if (obr->ddob) _unfind_ddob(obr->ddob);
if (obr->ddob)
evas_software_ddraw_output_buffer_free(obr->ddob);
free(obr);
}
_clear_ddob(0);
}
int
@ -443,12 +330,6 @@ evas_software_ddraw_outbuf_height_get(Outbuf *buf)
return buf->height;
}
Outbuf_Depth
evas_software_ddraw_outbuf_depth_get(Outbuf *buf)
{
return buf->depth;
}
int
evas_software_ddraw_outbuf_rot_get(Outbuf *buf)
{

View File

@ -17,7 +17,6 @@ struct _Evas_Engine_Info_Software_Gdi
struct {
HWND window;
int depth;
int rotation;
unsigned int borderless : 1;
unsigned int fullscreen : 1;

View File

@ -16,6 +16,14 @@ struct _Render_Engine
};
/* engine api this module provides */
static void
eng_output_info_setup(void *info)
{
Evas_Engine_Info_Software_Gdi *einfo = info;
einfo->render_mode = EVAS_RENDER_MODE_BLOCKING;
}
static void *
eng_output_setup(void *engine, void *in, unsigned int w, unsigned int h)
{
@ -35,9 +43,7 @@ eng_output_setup(void *engine, void *in, unsigned int w, unsigned int h)
ob = evas_software_gdi_outbuf_setup(w, h,
info->info.rotation,
OUTBUF_DEPTH_INHERIT,
info->info.window,
info->info.depth,
info->info.borderless,
info->info.fullscreen,
info->info.region,
@ -81,9 +87,7 @@ eng_output_update(void *engine EINA_UNUSED, void *data, void *in, unsigned int w
ob = evas_software_gdi_outbuf_setup(w,
h,
info->info.rotation,
OUTBUF_DEPTH_INHERIT,
info->info.window,
info->info.depth,
info->info.borderless,
info->info.fullscreen,
info->info.region,
@ -134,6 +138,7 @@ module_open(Evas_Module *em)
func = pfunc;
/* now to override methods */
#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
ORD(output_info_setup);
ORD(output_setup);
ORD(output_update);
ORD(canvas_alpha_get);

View File

@ -47,7 +47,6 @@ struct BITMAPINFO_GDI
struct _Outbuf
{
Outbuf_Depth depth;
int width;
int height;
int rot;
@ -60,7 +59,6 @@ struct _Outbuf
HWND window;
HDC dc;
HRGN regions;
int depth;
unsigned char borderless : 1;
unsigned char fullscreen : 1;
unsigned char region : 1;
@ -101,7 +99,6 @@ struct _Gdi_Output_Buffer
int width;
int height;
void *data;
int depth;
int pitch;
int psize;
};
@ -109,7 +106,6 @@ struct _Gdi_Output_Buffer
/* evas_gdi_main.c */
int evas_software_gdi_init (HWND window,
int depth,
unsigned int borderless,
unsigned int fullscreen,
unsigned int region,
@ -123,7 +119,6 @@ void evas_software_gdi_bitmap_resize(Outbuf *buf);
Gdi_Output_Buffer *evas_software_gdi_output_buffer_new(HDC dc,
BITMAPINFO_GDI *bitmap_info,
int depth,
int width,
int height,
void *data);
@ -137,8 +132,6 @@ void evas_software_gdi_output_buffer_paste(Gdi_Output_Buffer *gdiob,
DATA8 *evas_software_gdi_output_buffer_data(Gdi_Output_Buffer *gdiob,
int *pitch);
int evas_software_gdi_output_buffer_depth(Gdi_Output_Buffer *gdiob);
/* evas_outbuf.c */
void evas_software_gdi_outbuf_init(void);
@ -148,9 +141,7 @@ void evas_software_gdi_outbuf_free(Outbuf *buf);
Outbuf *evas_software_gdi_outbuf_setup(int width,
int height,
int rotation,
Outbuf_Depth depth,
HWND window,
int w_depth,
unsigned int borderless,
unsigned int fullscreen,
unsigned int region,
@ -188,8 +179,6 @@ int evas_software_gdi_outbuf_width_get(Outbuf *buf);
int evas_software_gdi_outbuf_height_get(Outbuf *buf);
Outbuf_Depth evas_software_gdi_outbuf_depth_get(Outbuf *buf);
int evas_software_gdi_outbuf_rot_get(Outbuf *buf);

View File

@ -6,7 +6,6 @@
Gdi_Output_Buffer *
evas_software_gdi_output_buffer_new(HDC dc,
BITMAPINFO_GDI *bitmap_info,
int depth,
int width,
int height,
void *data)
@ -20,7 +19,7 @@ evas_software_gdi_output_buffer_new(HDC dc,
{
bitmap_info->bih.biWidth = width;
bitmap_info->bih.biHeight = -height;
bitmap_info->bih.biSizeImage = (depth >> 3) * width * height;
bitmap_info->bih.biSizeImage = 4 * width * height;
gdiob->bitmap = CreateDIBSection(dc,
(const BITMAPINFO *)bitmap_info,
DIB_RGB_COLORS,
@ -39,9 +38,7 @@ evas_software_gdi_output_buffer_new(HDC dc,
gdiob->data = data;
gdiob->width = width;
gdiob->height = height;
gdiob->depth = depth;
gdiob->pitch = width * (depth >> 3);
/* gdiob->psize = gdiob->pitch * height; */
gdiob->pitch = width * 4;
return gdiob;
}
@ -83,9 +80,3 @@ evas_software_gdi_output_buffer_data(Gdi_Output_Buffer *gdiob,
if (pitch) *pitch = gdiob->pitch;
return gdiob->data;
}
int
evas_software_gdi_output_buffer_depth(Gdi_Output_Buffer *gdiob)
{
return gdiob->depth;
}

View File

@ -4,7 +4,6 @@
int
evas_software_gdi_init (HWND window,
int depth,
unsigned int borderless,
unsigned int fullscreen EINA_UNUSED,
unsigned int region,
@ -26,14 +25,12 @@ evas_software_gdi_init (HWND window,
return 0;
}
/* FIXME: check depth */
if (depth != GetDeviceCaps(buf->priv.gdi.dc, BITSPIXEL))
if (GetDeviceCaps(buf->priv.gdi.dc, BITSPIXEL) != 32)
{
ERR("[Engine] [GDI] no compatible depth");
ReleaseDC(window, buf->priv.gdi.dc);
return 0;
}
buf->priv.gdi.depth = depth;
/* FIXME: support fullscreen */
@ -49,32 +46,16 @@ evas_software_gdi_init (HWND window,
buf->priv.gdi.bitmap_info->bih.biWidth = buf->width;
buf->priv.gdi.bitmap_info->bih.biHeight = -buf->height;
buf->priv.gdi.bitmap_info->bih.biPlanes = 1;
buf->priv.gdi.bitmap_info->bih.biSizeImage = (buf->priv.gdi.depth >> 3) * buf->width * buf->height;
buf->priv.gdi.bitmap_info->bih.biSizeImage = 4 * buf->width * buf->height;
buf->priv.gdi.bitmap_info->bih.biXPelsPerMeter = 0;
buf->priv.gdi.bitmap_info->bih.biYPelsPerMeter = 0;
buf->priv.gdi.bitmap_info->bih.biClrUsed = 0;
buf->priv.gdi.bitmap_info->bih.biClrImportant = 0;
buf->priv.gdi.bitmap_info->bih.biBitCount = buf->priv.gdi.depth;
buf->priv.gdi.bitmap_info->bih.biBitCount = 32;
buf->priv.gdi.bitmap_info->bih.biCompression = BI_BITFIELDS;
switch (depth)
{
case 16:
buf->priv.gdi.bitmap_info->masks[0] = 0x0000f800;
buf->priv.gdi.bitmap_info->masks[1] = 0x000007e0;
buf->priv.gdi.bitmap_info->masks[2] = 0x0000001f;
break;
case 32:
buf->priv.gdi.bitmap_info->masks[0] = 0x00ff0000;
buf->priv.gdi.bitmap_info->masks[1] = 0x0000ff00;
buf->priv.gdi.bitmap_info->masks[2] = 0x000000ff;
break;
default:
ERR("[Engine] [GDI] wrong depth");
free(buf->priv.gdi.bitmap_info);
ReleaseDC(window, buf->priv.gdi.dc);
return 0;
}
buf->priv.gdi.bitmap_info->masks[0] = 0x00ff0000;
buf->priv.gdi.bitmap_info->masks[1] = 0x0000ff00;
buf->priv.gdi.bitmap_info->masks[2] = 0x000000ff;
return 1;
}
@ -96,5 +77,5 @@ evas_software_gdi_bitmap_resize(Outbuf *buf)
{
buf->priv.gdi.bitmap_info->bih.biWidth = buf->width;
buf->priv.gdi.bitmap_info->bih.biHeight = -buf->height;
buf->priv.gdi.bitmap_info->bih.biSizeImage = (buf->priv.gdi.depth >> 3) * buf->width * buf->height;
buf->priv.gdi.bitmap_info->bih.biSizeImage = 4 * buf->width * buf->height;
}

View File

@ -1,89 +1,6 @@
#include "evas_common_private.h"
#include "evas_engine.h"
static Eina_List *gdipool = NULL;
static int gdisize = 0;
static int gdimemlimit = 10 * 1024 * 1024;
static int gdicountlimit = 32;
static Gdi_Output_Buffer *
_find_gdiob(HDC dc, BITMAPINFO_GDI *bitmap_info, int depth, int w, int h, void *data)
{
Eina_List *l = NULL;
Eina_List *gdil = NULL;
Gdi_Output_Buffer *gdiob = NULL;
Gdi_Output_Buffer *gdiob2;
int sz;
int lbytes;
int bpp;
bpp = depth >> 3;
if (bpp == 3) bpp = 4;
lbytes = (((w * bpp) + 3) / 4) * 4;
sz = lbytes * h;
EINA_LIST_FOREACH(gdipool, l, gdiob2)
{
if ((gdiob2->dc != dc) ||
(gdiob2->bitmap_info != bitmap_info) ||
(gdiob2->depth != depth))
continue;
if (gdiob2->psize == sz)
{
gdiob = gdiob2;
gdil = l;
goto have_gdiob;
}
}
if (!gdiob)
return evas_software_gdi_output_buffer_new(dc, bitmap_info, depth, w, h, data);
have_gdiob:
gdipool = eina_list_remove_list(gdipool, gdil);
gdiob->width = w;
gdiob->height = h;
gdiob->pitch = lbytes;
gdisize -= gdiob->psize * (gdiob->depth >> 3);
return gdiob;
}
static void
_unfind_gdiob(Gdi_Output_Buffer *gdiob)
{
gdipool = eina_list_prepend(gdipool, gdiob);
gdisize += gdiob->psize * (gdiob->depth >> 3);
while ((gdisize > (gdimemlimit)) ||
((int)eina_list_count(gdipool) > gdicountlimit))
{
Eina_List *xl;
xl = eina_list_last(gdipool);
if (!xl)
{
gdisize = 0;
break;
}
gdiob = xl->data;
gdipool = eina_list_remove_list(gdipool, xl);
evas_software_gdi_output_buffer_free(gdiob);
}
}
static void
_clear_gdiob()
{
while (gdipool)
{
Gdi_Output_Buffer *gdiob;
gdiob = gdipool->data;
gdipool = eina_list_remove_list(gdipool, gdipool);
evas_software_gdi_output_buffer_free(gdiob);
}
gdisize = 0;
}
void
evas_software_gdi_outbuf_init(void)
{
@ -104,7 +21,8 @@ evas_software_gdi_outbuf_free(Outbuf *buf)
buf->priv.pending_writes = eina_list_remove_list(buf->priv.pending_writes, buf->priv.pending_writes);
obr = im->extended_info;
evas_cache_image_drop(&im->cache_entry);
if (obr->gdiob) _unfind_gdiob(obr->gdiob);
if (obr->gdiob)
evas_software_gdi_output_buffer_free(obr->gdiob);
/* if (obr->mxob) _unfind_xob(obr->mxob, 0); */
free(obr);
}
@ -119,9 +37,7 @@ Outbuf *
evas_software_gdi_outbuf_setup(int width,
int height,
int rotation,
Outbuf_Depth depth,
HWND window,
int w_depth,
unsigned int borderless,
unsigned int fullscreen,
unsigned int region,
@ -136,13 +52,12 @@ evas_software_gdi_outbuf_setup(int width,
buf->width = width;
buf->height = height;
buf->depth = depth;
buf->rot = rotation;
buf->priv.mask_dither = mask_dither;
buf->priv.destination_alpha = destination_alpha;
if (!evas_software_gdi_init(window, w_depth, borderless, fullscreen, region, buf))
if (!evas_software_gdi_init(window, borderless, fullscreen, region, buf))
{
free(buf);
return NULL;
@ -152,7 +67,7 @@ evas_software_gdi_outbuf_setup(int width,
Gfx_Func_Convert conv_func;
Gdi_Output_Buffer *gdiob;
gdiob = evas_software_gdi_output_buffer_new(buf->priv.gdi.dc, buf->priv.gdi.bitmap_info, w_depth, 1, 1, NULL);
gdiob = evas_software_gdi_output_buffer_new(buf->priv.gdi.dc, buf->priv.gdi.bitmap_info, 1, 1, NULL);
conv_func = NULL;
if (gdiob)
@ -161,7 +76,7 @@ evas_software_gdi_outbuf_setup(int width,
conv_func = evas_common_convert_func_get(0,
width,
height,
evas_software_gdi_output_buffer_depth (gdiob),
32,
buf->priv.gdi.bitmap_info->masks[0],
buf->priv.gdi.bitmap_info->masks[1],
buf->priv.gdi.bitmap_info->masks[2],
@ -171,7 +86,7 @@ evas_software_gdi_outbuf_setup(int width,
conv_func = evas_common_convert_func_get(0,
height,
width,
evas_software_gdi_output_buffer_depth (gdiob),
32,
buf->priv.gdi.bitmap_info->masks[0],
buf->priv.gdi.bitmap_info->masks[1],
buf->priv.gdi.bitmap_info->masks[2],
@ -184,11 +99,10 @@ evas_software_gdi_outbuf_setup(int width,
{
ERR(".[ soft_gdi engine Error ]."
" {"
" At depth %i:"
" At depth 32:"
" RGB format mask: %08lx, %08lx, %08lx"
" Not supported by and compiled in converters!"
" }",
buf->priv.gdi.depth,
buf->priv.gdi.bitmap_info->masks[0],
buf->priv.gdi.bitmap_info->masks[1],
buf->priv.gdi.bitmap_info->masks[2]);
@ -204,10 +118,10 @@ evas_software_gdi_outbuf_reconfigure(Outbuf *buf,
int width,
int height,
int rotation,
Outbuf_Depth depth)
Outbuf_Depth depth EINA_UNUSED)
{
if ((width == buf->width) && (height == buf->height) &&
(rotation == buf->rot) && (depth == buf->depth))
(rotation == buf->rot))
return;
buf->width = width;
buf->height = height;
@ -249,15 +163,9 @@ evas_software_gdi_outbuf_new_region_for_update(Outbuf *buf,
(buf->priv.gdi.bitmap_info->masks[1] == 0x00ff00) &&
(buf->priv.gdi.bitmap_info->masks[2] == 0x0000ff))
{
obr->gdiob = _find_gdiob(buf->priv.gdi.dc,
buf->priv.gdi.bitmap_info,
buf->priv.gdi.depth,
w, h, NULL);
/* obr->gdiob = evas_software_gdi_output_buffer_new(buf->priv.gdi.dc, */
/* buf->priv.gdi.bitmap_info, */
/* buf->priv.gdi.depth, */
/* w, h, */
/* NULL); */
obr->gdiob = evas_software_gdi_output_buffer_new(buf->priv.gdi.dc,
buf->priv.gdi.bitmap_info,
w, h, NULL);
im = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
w, h,
(DATA32 *)evas_software_gdi_output_buffer_data(obr->gdiob, &bpl),
@ -276,31 +184,13 @@ evas_software_gdi_outbuf_new_region_for_update(Outbuf *buf,
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
im->extended_info = obr;
if ((buf->rot == 0) || (buf->rot == 180))
obr->gdiob = _find_gdiob(buf->priv.gdi.dc,
buf->priv.gdi.bitmap_info,
buf->priv.gdi.depth,
w, h, NULL);
/*
obr->gdiob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp,
buf->priv.dd.vis,
buf->priv.dd.depth,
w, h,
use_shm,
NULL);
*/
obr->gdiob = evas_software_gdi_output_buffer_new(buf->priv.gdi.dc,
buf->priv.gdi.bitmap_info,
w, h, NULL);
else if ((buf->rot == 90) || (buf->rot == 270))
obr->gdiob = _find_gdiob(buf->priv.gdi.dc,
buf->priv.gdi.bitmap_info,
buf->priv.gdi.depth,
h, w, NULL);
/*
obr->gdiob = evas_software_x11_x_output_buffer_new(buf->priv.dd.disp,
buf->priv.dd.vis,
buf->priv.dd.depth,
h, w,
use_shm,
NULL);
*/
obr->gdiob = evas_software_gdi_output_buffer_new(buf->priv.gdi.dc,
buf->priv.gdi.bitmap_info,
h, w, NULL);
/* if (buf->priv.gdi.mask) */
/* obr->mgdiob = _find_gdiob(buf->priv.gdi.dc, */
/* buf->priv.gdi.bitmap_info, */
@ -336,16 +226,14 @@ evas_software_gdi_outbuf_push_updated_region(Outbuf *buf,
obr = update->extended_info;
if ((buf->rot == 0) || (buf->rot == 180))
conv_func = evas_common_convert_func_get(0, w, h,
evas_software_gdi_output_buffer_depth(obr->gdiob),
conv_func = evas_common_convert_func_get(0, w, h, 32,
buf->priv.gdi.bitmap_info->masks[0],
buf->priv.gdi.bitmap_info->masks[1],
buf->priv.gdi.bitmap_info->masks[2],
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_gdi_output_buffer_depth(obr->gdiob),
conv_func = evas_common_convert_func_get(0, h, w, 32,
buf->priv.gdi.bitmap_info->masks[0],
buf->priv.gdi.bitmap_info->masks[1],
buf->priv.gdi.bitmap_info->masks[2],
@ -389,7 +277,7 @@ evas_software_gdi_outbuf_push_updated_region(Outbuf *buf,
if (data != src_data)
conv_func(src_data, data,
0,
bpl / (evas_software_gdi_output_buffer_depth(obr->gdiob) >> 3) - obr->width,
bpl / 4 - obr->width,
obr->width,
obr->height,
x,
@ -580,9 +468,9 @@ evas_software_gdi_outbuf_flush(Outbuf *buf, Tilebuf_Rect *surface_damage EINA_UN
buf->priv.prev_pending_writes);
obr = im->extended_info;
evas_cache_image_drop(&im->cache_entry);
if (obr->gdiob) _unfind_gdiob(obr->gdiob);
if (obr->gdiob)
evas_software_gdi_output_buffer_free(obr->gdiob);
/* if (obr->mgdiob) _unfind_gdiob(obr->mgdiob); */
/* if (obr->gdiob) evas_software_x11_x_output_buffer_free(obr->gdiob); */
free(obr);
}
buf->priv.prev_pending_writes = buf->priv.pending_writes;
@ -605,11 +493,11 @@ evas_software_gdi_outbuf_idle_flush(Outbuf *buf)
buf->priv.prev_pending_writes);
obr = im->extended_info;
evas_cache_image_drop((Image_Entry *)im);
if (obr->gdiob) _unfind_gdiob(obr->gdiob);
if (obr->gdiob)
evas_software_gdi_output_buffer_free(obr->gdiob);
/* if (obr->mxob) _unfind_xob(obr->mxob, 0); */
free(obr);
}
_clear_gdiob();
}
int
@ -624,12 +512,6 @@ evas_software_gdi_outbuf_height_get(Outbuf *buf)
return buf->height;
}
Outbuf_Depth
evas_software_gdi_outbuf_depth_get(Outbuf *buf)
{
return buf->depth;
}
int
evas_software_gdi_outbuf_rot_get(Outbuf *buf)
{