Enlightenment CVS committal Author : doursse Project : e17 Module : libs/evas
Dir : e17/libs/evas/src/modules/engines/software_ddraw Modified Files: Evas_Engine_Software_DDraw.h evas_ddraw_main.cpp evas_engine.c evas_engine.h Log Message: dos to unix file format =================================================================== RCS file: /cvs/e/e17/libs/evas/src/modules/engines/software_ddraw/Evas_Engine_Software_DDraw.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- Evas_Engine_Software_DDraw.h 25 Jun 2008 06:40:10 -0000 1.4 +++ Evas_Engine_Software_DDraw.h 28 Jun 2008 07:06:34 -0000 1.5 @@ -1,26 +1,26 @@ -#ifndef __EVAS_ENGINE_SOFTWARE_DDRAW_H__ -#define __EVAS_ENGINE_SOFTWARE_DDRAW_H__ - - -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#undef WIN32_LEAN_AND_MEAN - - -typedef struct _Evas_Engine_Info_Software_DDraw Evas_Engine_Info_Software_DDraw; - -struct _Evas_Engine_Info_Software_DDraw -{ - /* 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 { - HWND window; - int depth; - int rotation; - } info; -}; - - -#endif /* __EVAS_ENGINE_SOFTWARE_DDRAW_H__ */ +#ifndef __EVAS_ENGINE_SOFTWARE_DDRAW_H__ +#define __EVAS_ENGINE_SOFTWARE_DDRAW_H__ + + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#undef WIN32_LEAN_AND_MEAN + + +typedef struct _Evas_Engine_Info_Software_DDraw Evas_Engine_Info_Software_DDraw; + +struct _Evas_Engine_Info_Software_DDraw +{ + /* 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 { + HWND window; + int depth; + int rotation; + } info; +}; + + +#endif /* __EVAS_ENGINE_SOFTWARE_DDRAW_H__ */ =================================================================== RCS file: /cvs/e/e17/libs/evas/src/modules/engines/software_ddraw/evas_ddraw_main.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- evas_ddraw_main.cpp 25 Jun 2008 06:40:10 -0000 1.2 +++ evas_ddraw_main.cpp 28 Jun 2008 07:06:34 -0000 1.3 @@ -1,195 +1,195 @@ -#include "evas_common.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 -evas_software_ddraw_masks_get(Outbuf *buf) -{ - DDPIXELFORMAT pixel_format; - - ZeroMemory(&pixel_format, sizeof(pixel_format)); - pixel_format.dwSize = sizeof(pixel_format); - - if (FAILED(buf->priv.dd.surface_primary->GetPixelFormat(&pixel_format))) - return 0; - - buf->priv.mask.r = pixel_format.dwRBitMask; - buf->priv.mask.g = pixel_format.dwGBitMask; - buf->priv.mask.b = pixel_format.dwBBitMask; - - return 1; -} - -void * -evas_software_ddraw_lock(Outbuf *buf, - int *ddraw_width, - int *ddraw_height, - int *ddraw_pitch, - int *ddraw_depth) -{ - DDSURFACEDESC surface_desc; - - ZeroMemory(&surface_desc, sizeof(surface_desc)); - surface_desc.dwSize = sizeof(surface_desc); - - if (FAILED(buf->priv.dd.surface_back->Lock(NULL, - &surface_desc, - DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, - NULL))) - return NULL; - - *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; -} - -void -evas_software_ddraw_unlock_and_flip(Outbuf *buf) -{ - RECT dst_rect; - RECT src_rect; - POINT p; - - if (FAILED(buf->priv.dd.surface_back->Unlock(NULL))) - return; - - /* we figure out where on the primary surface our window lives */ - p.x = 0; - p.y = 0; - ClientToScreen(buf->priv.dd.window, &p); - GetClientRect(buf->priv.dd.window, &dst_rect); - OffsetRect(&dst_rect, p.x, p.y); - SetRect(&src_rect, 0, 0, buf->width, buf->height); - - /* nothing to do if the function fails, so we don't check the result */ - buf->priv.dd.surface_primary->Blt(&dst_rect, - buf->priv.dd.surface_back, - &src_rect, - DDBLT_WAIT, NULL); -} - -void -evas_software_ddraw_surface_resize(Outbuf *buf) -{ - DDSURFACEDESC surface_desc; - - buf->priv.dd.surface_back->Release(); - memset (&surface_desc, 0, sizeof (surface_desc)); - surface_desc.dwSize = sizeof (surface_desc); - /* FIXME: that code does not compile. Must know why */ -#if 0 - surface_desc.dwFlags = DDSD_HEIGHT | DDSD_WIDTH; - surface_desc.dwWidth = width; - surface_desc.dwHeight = height; - buf->priv.dd.surface_back->SetSurfaceDesc(&surface_desc, NULL); -#else - surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; - surface_desc.dwWidth = buf->width; - surface_desc.dwHeight = buf->height; - buf->priv.dd.object->CreateSurface(&surface_desc, - &buf->priv.dd.surface_back, - NULL); -#endif -} +#include "evas_common.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 +evas_software_ddraw_masks_get(Outbuf *buf) +{ + DDPIXELFORMAT pixel_format; + + ZeroMemory(&pixel_format, sizeof(pixel_format)); + pixel_format.dwSize = sizeof(pixel_format); + + if (FAILED(buf->priv.dd.surface_primary->GetPixelFormat(&pixel_format))) + return 0; + + buf->priv.mask.r = pixel_format.dwRBitMask; + buf->priv.mask.g = pixel_format.dwGBitMask; + buf->priv.mask.b = pixel_format.dwBBitMask; + + return 1; +} + +void * +evas_software_ddraw_lock(Outbuf *buf, + int *ddraw_width, + int *ddraw_height, + int *ddraw_pitch, + int *ddraw_depth) +{ + DDSURFACEDESC surface_desc; + + ZeroMemory(&surface_desc, sizeof(surface_desc)); + surface_desc.dwSize = sizeof(surface_desc); + + if (FAILED(buf->priv.dd.surface_back->Lock(NULL, + &surface_desc, + DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, + NULL))) + return NULL; + + *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; +} + +void +evas_software_ddraw_unlock_and_flip(Outbuf *buf) +{ + RECT dst_rect; + RECT src_rect; + POINT p; + + if (FAILED(buf->priv.dd.surface_back->Unlock(NULL))) + return; + + /* we figure out where on the primary surface our window lives */ + p.x = 0; + p.y = 0; + ClientToScreen(buf->priv.dd.window, &p); + GetClientRect(buf->priv.dd.window, &dst_rect); + OffsetRect(&dst_rect, p.x, p.y); + SetRect(&src_rect, 0, 0, buf->width, buf->height); + + /* nothing to do if the function fails, so we don't check the result */ + buf->priv.dd.surface_primary->Blt(&dst_rect, + buf->priv.dd.surface_back, + &src_rect, + DDBLT_WAIT, NULL); +} + +void +evas_software_ddraw_surface_resize(Outbuf *buf) +{ + DDSURFACEDESC surface_desc; + + buf->priv.dd.surface_back->Release(); + memset (&surface_desc, 0, sizeof (surface_desc)); + surface_desc.dwSize = sizeof (surface_desc); + /* FIXME: that code does not compile. Must know why */ +#if 0 + surface_desc.dwFlags = DDSD_HEIGHT | DDSD_WIDTH; + surface_desc.dwWidth = width; + surface_desc.dwHeight = height; + buf->priv.dd.surface_back->SetSurfaceDesc(&surface_desc, NULL); +#else + surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; + surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + surface_desc.dwWidth = buf->width; + surface_desc.dwHeight = buf->height; + buf->priv.dd.object->CreateSurface(&surface_desc, + &buf->priv.dd.surface_back, + NULL); +#endif +} =================================================================== RCS file: /cvs/e/e17/libs/evas/src/modules/engines/software_ddraw/evas_engine.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- evas_engine.c 25 Jun 2008 06:40:10 -0000 1.4 +++ evas_engine.c 28 Jun 2008 07:06:34 -0000 1.5 @@ -1,346 +1,346 @@ -#include "evas_common.h" -#include "evas_private.h" -#include "evas_engine.h" -#include "Evas_Engine_Software_DDraw.h" - -/* function tables - filled in later (func and parent func) */ -static Evas_Func func, pfunc; - -/* engine struct data */ -typedef struct _Render_Engine Render_Engine; - -struct _Render_Engine -{ - Tilebuf *tb; - Outbuf *ob; - Tilebuf_Rect *rects; - Evas_Object_List *cur_rect; - int end : 1; -}; - - -static void * -_output_setup(int width, - int height, - int rot, - HWND window, - int depth) -{ - Render_Engine *re; - - re = calloc(1, sizeof(Render_Engine)); - if (!re) - return NULL; - - /* 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(); - - evas_software_ddraw_outbuf_init(); - - re->ob = evas_software_ddraw_outbuf_setup(width, height, rot, - OUTBUF_DEPTH_INHERIT, - window, depth); - if (!re->ob) - { - free(re); - 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); - if (!re->tb) - { - evas_software_ddraw_outbuf_free(re->ob); - free(re); - return NULL; - } - /* in preliminary tests 16x16 gave highest framerates */ - evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); - - return re; -} - - -/* engine api this module provides */ - -static void * -eng_info(Evas *e) -{ - Evas_Engine_Info_Software_DDraw *info; - - info = calloc(1, sizeof(Evas_Engine_Info_Software_DDraw)); - if (!info) return NULL; - info->magic.magic = rand(); - return info; - e = NULL; -} - -static void -eng_info_free(Evas *e, void *info) -{ - Evas_Engine_Info_Software_DDraw *in; - - in = (Evas_Engine_Info_Software_DDraw *)info; - free(in); -} - -static void -eng_setup(Evas *e, void *in) -{ - Render_Engine *re; - Evas_Engine_Info_Software_DDraw *info; - - info = (Evas_Engine_Info_Software_DDraw *)in; - if (!e->engine.data.output) - e->engine.data.output = _output_setup(e->output.w, - e->output.h, - info->info.rotation, - info->info.window, - info->info.depth); - else - { - int ponebuf = 0; - - 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 -eng_output_free(void *data) -{ - Render_Engine *re; - - if (!data) return; - - re = (Render_Engine *)data; - evas_software_ddraw_outbuf_free(re->ob); - evas_common_tilebuf_free(re->tb); - if (re->rects) evas_common_tilebuf_free_render_rects(re->rects); - free(re); - - evas_common_font_shutdown(); - evas_common_image_shutdown(); -} - -static void -eng_output_resize(void *data, int width, int height) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_software_ddraw_outbuf_reconfigure(re->ob, - width, - height, - evas_software_ddraw_outbuf_rot_get(re->ob), - OUTBUF_DEPTH_INHERIT); - evas_common_tilebuf_free(re->tb); - re->tb = evas_common_tilebuf_new(width, height); - if (re->tb) - evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); -} - -static void -eng_output_tile_size_set(void *data, int w, int h) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_tilebuf_set_tile_size(re->tb, w, h); -} - -static void -eng_output_redraws_rect_add(void *data, int x, int y, int w, int h) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_tilebuf_add_redraw(re->tb, x, y, w, h); -} - -static void -eng_output_redraws_rect_del(void *data, int x, int y, int w, int h) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_tilebuf_del_redraw(re->tb, x, y, w, h); -} - -static void -eng_output_redraws_clear(void *data) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_tilebuf_clear(re->tb); -} - -static void * -eng_output_redraws_next_update_get(void *data, - int *x, - int *y, - int *w, - int *h, - int *cx, - int *cy, - int *cw, - int *ch) -{ - Render_Engine *re; - RGBA_Image *surface; - Tilebuf_Rect *rect; - int ux; - int uy; - int uw; - int uh; - - re = (Render_Engine *)data; - if (re->end) - { - re->end = 0; - return NULL; - } - if (!re->rects) - { - re->rects = evas_common_tilebuf_get_render_rects(re->tb); - 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; - } - - surface = evas_software_ddraw_outbuf_new_region_for_update(re->ob, - ux, - uy, - uw, - uh, - cx, - cy, - cw, - ch); - - *x = ux; - *y = uy; - *w = uw; - *h = uh; - - return surface; -} - -static void -eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_pipe_begin(surface); - evas_common_pipe_flush(surface); - evas_software_ddraw_outbuf_push_updated_region(re->ob, surface, x, y, w, h); - evas_software_ddraw_outbuf_free_region_for_update(re->ob, surface); - evas_common_cpu_end_opt(); -} - -static void -eng_output_flush(void *data) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_software_ddraw_outbuf_flush(re->ob); -} - -static void -eng_output_idle_flush(void *data) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_software_ddraw_outbuf_idle_flush(re->ob); -} - - -/* module advertising code */ -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, - "software_ddraw", - "none" -}; +#include "evas_common.h" +#include "evas_private.h" +#include "evas_engine.h" +#include "Evas_Engine_Software_DDraw.h" + +/* function tables - filled in later (func and parent func) */ +static Evas_Func func, pfunc; + +/* engine struct data */ +typedef struct _Render_Engine Render_Engine; + +struct _Render_Engine +{ + Tilebuf *tb; + Outbuf *ob; + Tilebuf_Rect *rects; + Evas_Object_List *cur_rect; + int end : 1; +}; + + +static void * +_output_setup(int width, + int height, + int rot, + HWND window, + int depth) +{ + Render_Engine *re; + + re = calloc(1, sizeof(Render_Engine)); + if (!re) + return NULL; + + /* 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(); + + evas_software_ddraw_outbuf_init(); + + re->ob = evas_software_ddraw_outbuf_setup(width, height, rot, + OUTBUF_DEPTH_INHERIT, + window, depth); + if (!re->ob) + { + free(re); + 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); + if (!re->tb) + { + evas_software_ddraw_outbuf_free(re->ob); + free(re); + return NULL; + } + /* in preliminary tests 16x16 gave highest framerates */ + evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); + + return re; +} + + +/* engine api this module provides */ + +static void * +eng_info(Evas *e) +{ + Evas_Engine_Info_Software_DDraw *info; + + info = calloc(1, sizeof(Evas_Engine_Info_Software_DDraw)); + if (!info) return NULL; + info->magic.magic = rand(); + return info; + e = NULL; +} + +static void +eng_info_free(Evas *e, void *info) +{ + Evas_Engine_Info_Software_DDraw *in; + + in = (Evas_Engine_Info_Software_DDraw *)info; + free(in); +} + +static void +eng_setup(Evas *e, void *in) +{ + Render_Engine *re; + Evas_Engine_Info_Software_DDraw *info; + + info = (Evas_Engine_Info_Software_DDraw *)in; + if (!e->engine.data.output) + e->engine.data.output = _output_setup(e->output.w, + e->output.h, + info->info.rotation, + info->info.window, + info->info.depth); + else + { + int ponebuf = 0; + + 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 +eng_output_free(void *data) +{ + Render_Engine *re; + + if (!data) return; + + re = (Render_Engine *)data; + evas_software_ddraw_outbuf_free(re->ob); + evas_common_tilebuf_free(re->tb); + if (re->rects) evas_common_tilebuf_free_render_rects(re->rects); + free(re); + + evas_common_font_shutdown(); + evas_common_image_shutdown(); +} + +static void +eng_output_resize(void *data, int width, int height) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_software_ddraw_outbuf_reconfigure(re->ob, + width, + height, + evas_software_ddraw_outbuf_rot_get(re->ob), + OUTBUF_DEPTH_INHERIT); + evas_common_tilebuf_free(re->tb); + re->tb = evas_common_tilebuf_new(width, height); + if (re->tb) + evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); +} + +static void +eng_output_tile_size_set(void *data, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_tilebuf_set_tile_size(re->tb, w, h); +} + +static void +eng_output_redraws_rect_add(void *data, int x, int y, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_tilebuf_add_redraw(re->tb, x, y, w, h); +} + +static void +eng_output_redraws_rect_del(void *data, int x, int y, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_tilebuf_del_redraw(re->tb, x, y, w, h); +} + +static void +eng_output_redraws_clear(void *data) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_tilebuf_clear(re->tb); +} + +static void * +eng_output_redraws_next_update_get(void *data, + int *x, + int *y, + int *w, + int *h, + int *cx, + int *cy, + int *cw, + int *ch) +{ + Render_Engine *re; + RGBA_Image *surface; + Tilebuf_Rect *rect; + int ux; + int uy; + int uw; + int uh; + + re = (Render_Engine *)data; + if (re->end) + { + re->end = 0; + return NULL; + } + if (!re->rects) + { + re->rects = evas_common_tilebuf_get_render_rects(re->tb); + 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; + } + + surface = evas_software_ddraw_outbuf_new_region_for_update(re->ob, + ux, + uy, + uw, + uh, + cx, + cy, + cw, + ch); + + *x = ux; + *y = uy; + *w = uw; + *h = uh; + + return surface; +} + +static void +eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_pipe_begin(surface); + evas_common_pipe_flush(surface); + evas_software_ddraw_outbuf_push_updated_region(re->ob, surface, x, y, w, h); + evas_software_ddraw_outbuf_free_region_for_update(re->ob, surface); + evas_common_cpu_end_opt(); +} + +static void +eng_output_flush(void *data) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_software_ddraw_outbuf_flush(re->ob); +} + +static void +eng_output_idle_flush(void *data) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_software_ddraw_outbuf_idle_flush(re->ob); +} + + +/* module advertising code */ +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, + "software_ddraw", + "none" +}; =================================================================== RCS file: /cvs/e/e17/libs/evas/src/modules/engines/software_ddraw/evas_engine.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- evas_engine.h 25 Jun 2008 06:40:10 -0000 1.6 +++ evas_engine.h 28 Jun 2008 07:06:34 -0000 1.7 @@ -1,192 +1,192 @@ -#ifndef __EVAS_ENGINE_H__ -#define __EVAS_ENGINE_H__ - - -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#undef WIN32_LEAN_AND_MEAN -#include <ddraw.h> - -typedef struct _Outbuf Outbuf; -typedef struct _Outbuf_Region Outbuf_Region; -typedef struct _DD_Output_Buffer DD_Output_Buffer; - -enum _Outbuf_Depth -{ - OUTBUF_DEPTH_NONE, - OUTBUF_DEPTH_INHERIT, - OUTBUF_DEPTH_RGB_16BPP_565_565_DITHERED, - OUTBUF_DEPTH_RGB_16BPP_555_555_DITHERED, - OUTBUF_DEPTH_RGB_16BPP_444_444_DITHERED, - OUTBUF_DEPTH_RGB_16BPP_565_444_DITHERED, - OUTBUF_DEPTH_RGB_32BPP_888_8888, - OUTBUF_DEPTH_LAST -}; - -typedef enum _Outbuf_Depth Outbuf_Depth; - -struct _Outbuf -{ - Outbuf_Depth depth; - int width; - int height; - int rot; - int onebuf; - - struct { - Convert_Pal *pal; - struct { - HWND window; - LPDIRECTDRAW object; - LPDIRECTDRAWSURFACE surface_primary; - LPDIRECTDRAWSURFACE surface_back; - LPDIRECTDRAWCLIPPER clipper; - int depth; - unsigned char swap : 1; - unsigned char bit_swap : 1; - } dd; - struct { - DATA32 r, g, b; - } 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 */ - 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; -}; - -struct _Outbuf_Region -{ - DD_Output_Buffer *ddob; - int x; - int y; - int width; - int height; -}; - -struct _DD_Output_Buffer -{ - void *data; - int width; - int height; - int depth; - int pitch; -/* int w, h, bpl; */ - int psize; -}; - - -/* evas_outbuf.c */ - -void evas_software_ddraw_outbuf_init(void); - -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); - -void evas_software_ddraw_outbuf_reconfigure(Outbuf *buf, - int width, - int height, - int rotation, - Outbuf_Depth depth); - -RGBA_Image *evas_software_ddraw_outbuf_new_region_for_update(Outbuf *buf, - int x, - int y, - int w, - int h, - int *cx, - int *cy, - int *cw, - int *ch); - -void evas_software_ddraw_outbuf_push_updated_region(Outbuf *buf, - RGBA_Image *update, - int x, - int y, - int w, - int h); - -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); - -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, - 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 -extern "C" { -#endif - -int evas_software_ddraw_init (HWND window, - int depth, - Outbuf *buf); - -void evas_software_ddraw_shutdown(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 -} -#endif - - -#endif /* __EVAS_ENGINE_H__ */ +#ifndef __EVAS_ENGINE_H__ +#define __EVAS_ENGINE_H__ + + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#undef WIN32_LEAN_AND_MEAN +#include <ddraw.h> + +typedef struct _Outbuf Outbuf; +typedef struct _Outbuf_Region Outbuf_Region; +typedef struct _DD_Output_Buffer DD_Output_Buffer; + +enum _Outbuf_Depth +{ + OUTBUF_DEPTH_NONE, + OUTBUF_DEPTH_INHERIT, + OUTBUF_DEPTH_RGB_16BPP_565_565_DITHERED, + OUTBUF_DEPTH_RGB_16BPP_555_555_DITHERED, + OUTBUF_DEPTH_RGB_16BPP_444_444_DITHERED, + OUTBUF_DEPTH_RGB_16BPP_565_444_DITHERED, + OUTBUF_DEPTH_RGB_32BPP_888_8888, + OUTBUF_DEPTH_LAST +}; + +typedef enum _Outbuf_Depth Outbuf_Depth; + +struct _Outbuf +{ + Outbuf_Depth depth; + int width; + int height; + int rot; + int onebuf; + + struct { + Convert_Pal *pal; + struct { + HWND window; + LPDIRECTDRAW object; + LPDIRECTDRAWSURFACE surface_primary; + LPDIRECTDRAWSURFACE surface_back; + LPDIRECTDRAWCLIPPER clipper; + int depth; + unsigned char swap : 1; + unsigned char bit_swap : 1; + } dd; + struct { + DATA32 r, g, b; + } 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 */ + 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; +}; + +struct _Outbuf_Region +{ + DD_Output_Buffer *ddob; + int x; + int y; + int width; + int height; +}; + +struct _DD_Output_Buffer +{ + void *data; + int width; + int height; + int depth; + int pitch; +/* int w, h, bpl; */ + int psize; +}; + + +/* evas_outbuf.c */ + +void evas_software_ddraw_outbuf_init(void); + +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); + +void evas_software_ddraw_outbuf_reconfigure(Outbuf *buf, + int width, + int height, + int rotation, + Outbuf_Depth depth); + +RGBA_Image *evas_software_ddraw_outbuf_new_region_for_update(Outbuf *buf, + int x, + int y, + int w, + int h, + int *cx, + int *cy, + int *cw, + int *ch); + +void evas_software_ddraw_outbuf_push_updated_region(Outbuf *buf, + RGBA_Image *update, + int x, + int y, + int w, + int h); + +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); + +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, + 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 +extern "C" { +#endif + +int evas_software_ddraw_init (HWND window, + int depth, + Outbuf *buf); + +void evas_software_ddraw_shutdown(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 +} +#endif + + +#endif /* __EVAS_ENGINE_H__ */ ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs