From c3ca8b12476c355d0beba1708b7990770c45a4a7 Mon Sep 17 00:00:00 2001 From: caro Date: Wed, 19 Nov 2008 07:52:05 +0000 Subject: [PATCH] create the bitmap only once. Increased speed :) git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@37711 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- .../software_16_wince/evas_wince_gdi_buffer.c | 40 ++++++++++------------ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/modules/engines/software_16_wince/evas_wince_gdi_buffer.c b/src/modules/engines/software_16_wince/evas_wince_gdi_buffer.c index beafd6c..5f0a0bb 100644 --- a/src/modules/engines/software_16_wince/evas_wince_gdi_buffer.c +++ b/src/modules/engines/software_16_wince/evas_wince_gdi_buffer.c @@ -13,9 +13,10 @@ struct BITMAPINFO_16bpp struct Evas_Engine_WinCE_GDI_Priv { - BITMAPINFO_16bpp *bitmap_info; HWND window; HDC dc; + BITMAPINFO_16bpp *bitmap_info; + HBITMAP bitmap; int width; int height; }; @@ -94,21 +95,28 @@ evas_software_wince_gdi_output_buffer_new(void *priv, int width, int height) { + Evas_Engine_WinCE_GDI_Priv *priv2; FB_Output_Buffer *fbob; void *buffer; fbob = calloc(1, sizeof(FB_Output_Buffer)); if (!fbob) return NULL; - buffer = malloc (width * height * 2); /* we are sure to have 16bpp */ - if (!buffer) + fbob->priv = priv; + + priv2 = (Evas_Engine_WinCE_GDI_Priv *)fbob->priv; + priv2->bitmap = CreateDIBSection(priv2->dc, + (const BITMAPINFO *)priv2->bitmap_info, + DIB_RGB_COLORS, + (void **)(&buffer), + NULL, + 0); + if (!priv2->bitmap) { free(fbob); return NULL; } - fbob->priv = priv; - fbob->im = (Soft16_Image *) evas_cache_image_data(evas_common_soft16_image_cache_get(), width, height, (DATA32 *)buffer, 0, EVAS_COLORSPACE_RGB565_A5P); if (fbob->im) fbob->im->stride = width; @@ -119,7 +127,10 @@ evas_software_wince_gdi_output_buffer_new(void *priv, void evas_software_wince_gdi_output_buffer_free(FB_Output_Buffer *fbob) { - free(fbob->im->pixels); + Evas_Engine_WinCE_GDI_Priv *priv; + + priv = (Evas_Engine_WinCE_GDI_Priv *)fbob->priv; + DeleteObject(priv->bitmap); free(fbob); } @@ -134,20 +145,9 @@ evas_software_wince_gdi_output_buffer_paste(FB_Output_Buffer *fbob) (fbob->im->cache_entry.h == priv->height)) { HDC dc; - HDC dc2; - HBITMAP bitmap; - void *bits; - - dc2 = GetDC(priv->window); - bitmap = CreateDIBSection(priv->dc, - (const BITMAPINFO *)priv->bitmap_info, - DIB_RGB_COLORS, - (void **)(&bits), - NULL, - 0); + dc = CreateCompatibleDC(priv->dc); - SelectObject(dc, bitmap); - memcpy(bits, fbob->im->pixels, priv->width * priv->height * 2); + SelectObject(dc, priv->bitmap); BitBlt(priv->dc, 0, 0, priv->width, priv->height, @@ -155,8 +155,6 @@ evas_software_wince_gdi_output_buffer_paste(FB_Output_Buffer *fbob) 0, 0, SRCCOPY); DeleteDC(dc); - DeleteObject(bitmap); - ReleaseDC(priv->window, dc2); } } -- 2.7.4