summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/software_gdi/evas_gdi_main.c
blob: 98f1a79ab23dcfa4355a343bf5a39ccb0f6a28bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "evas_common_private.h"
#include "evas_engine.h"


int
evas_software_gdi_init (HWND         window,
                        unsigned int borderless,
                        unsigned int fullscreen EINA_UNUSED,
                        unsigned int region,
                        Outbuf *buf)
{
   if (!window)
     {
        ERR("[Engine] [GDI] Window is NULL");
        return 0;
     }

   buf->priv.gdi.window = window;
   buf->priv.gdi.dc = GetDC(window);
   buf->priv.gdi.borderless = borderless;
   buf->priv.gdi.region = region;
   if (!buf->priv.gdi.dc)
     {
        ERR("[Engine] [GDI] Can not get DC");
        return 0;
     }

   if (GetDeviceCaps(buf->priv.gdi.dc, BITSPIXEL) != 32)
     {
        ERR("[Engine] [GDI] no compatible depth");
        ReleaseDC(window, buf->priv.gdi.dc);
        return 0;
     }

   /* FIXME: support fullscreen */

   buf->priv.gdi.bitmap_info = (BITMAPINFO_GDI *)malloc(sizeof(BITMAPINFO_GDI));
   if (!buf->priv.gdi.bitmap_info)
     {
        ERR("[Engine] [GDI] Can not allocate bitmap info");
        ReleaseDC(window, buf->priv.gdi.dc);
        return 0;
     }

   buf->priv.gdi.bitmap_info->bih.biSize = sizeof(BITMAPINFOHEADER);
   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 = 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 = 32;
   buf->priv.gdi.bitmap_info->bih.biCompression = BI_BITFIELDS;
   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;
}

void
evas_software_gdi_shutdown(Outbuf *buf)
{
   if (!buf)
     return;

   free(buf->priv.gdi.bitmap_info);
   ReleaseDC(buf->priv.gdi.window, buf->priv.gdi.dc);
   if (buf->priv.gdi.regions)
     DeleteObject(buf->priv.gdi.regions);
}

void
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 = 4 * buf->width * buf->height;
}