aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/modules/engines/software_16_wince/evas_wince_gdi_buffer.c
blob: f32db4a21daaf56c4cbcb6d818bdcd666cd44153 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include "evas_common.h"
#include "evas_engine.h"


typedef struct BITMAPINFO_16bpp BITMAPINFO_16bpp;
typedef struct Evas_Engine_WinCE_GDI_Priv Evas_Engine_WinCE_GDI_Priv;

struct BITMAPINFO_16bpp
{
   BITMAPINFOHEADER bih;
   DWORD            masks[3];
};

struct Evas_Engine_WinCE_GDI_Priv
{
   HWND              window;
   HDC               dc;
   BITMAPINFO_16bpp *bitmap_info;
   HBITMAP           bitmap;
   int               width;
   int               height;
};

void *
evas_software_wince_gdi_init(HWND window,
                             int  width,
                             int  height,
                             int  fullscreen)
{
   Evas_Engine_WinCE_GDI_Priv *priv;

   priv = (Evas_Engine_WinCE_GDI_Priv *)malloc(sizeof(Evas_Engine_WinCE_GDI_Priv));
   if (!priv)
     return NULL;

   priv->window = window;
   priv->dc = GetDC(window);
   if (!priv->dc)
     {
        ERR("Can not get DC");
        free(priv);
        return NULL;
     }

   if (fullscreen)
     {
        priv->width = GetSystemMetrics(SM_CXSCREEN);
        priv->height = GetSystemMetrics(SM_CYSCREEN);
     }
   else
     {
        priv->width = width;
        priv->height = height;
     }

   priv->bitmap_info = (BITMAPINFO_16bpp *)malloc(sizeof(BITMAPINFO_16bpp));
   if (!priv->bitmap_info)
     {
        ERR("Can not allocate bitmap info");
        ReleaseDC(window, priv->dc);
        free(priv);
        return NULL;
     }

   priv->bitmap_info->bih.biSize = sizeof(BITMAPINFOHEADER);
   priv->bitmap_info->bih.biWidth = priv->width;
   priv->bitmap_info->bih.biHeight = -priv->height;
   priv->bitmap_info->bih.biPlanes = 1;
   priv->bitmap_info->bih.biSizeImage = 2 * priv->width * priv->height;
   priv->bitmap_info->bih.biXPelsPerMeter = 0;
   priv->bitmap_info->bih.biYPelsPerMeter = 0;
   priv->bitmap_info->bih.biClrUsed = 0;
   priv->bitmap_info->bih.biClrImportant = 0;
   priv->bitmap_info->bih.biBitCount = 16;
   priv->bitmap_info->bih.biCompression = BI_BITFIELDS;
   priv->bitmap_info->masks[0] = 0x0000f800;
   priv->bitmap_info->masks[1] = 0x000007e0;
   priv->bitmap_info->masks[2] = 0x0000001f;

   return priv;
}

void
evas_software_wince_gdi_shutdown(void *priv)
{
   free(((Evas_Engine_WinCE_GDI_Priv *)priv)->bitmap_info);
   ReleaseDC(((Evas_Engine_WinCE_GDI_Priv *)priv)->window, ((Evas_Engine_WinCE_GDI_Priv *)priv)->dc);
   free(priv);
}


FB_Output_Buffer *
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;

   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->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;

   return fbob;
}

void
evas_software_wince_gdi_output_buffer_free(FB_Output_Buffer *fbob)
{
   Evas_Engine_WinCE_GDI_Priv *priv;

   priv = (Evas_Engine_WinCE_GDI_Priv *)fbob->priv;
   DeleteObject(priv->bitmap);
   free(fbob);
}

void
evas_software_wince_gdi_output_buffer_paste(FB_Output_Buffer *fbob)
{
   Evas_Engine_WinCE_GDI_Priv *priv;

   priv = (Evas_Engine_WinCE_GDI_Priv *)fbob->priv;

   if ((fbob->im->cache_entry.w == priv->width) &&
       (fbob->im->cache_entry.h == priv->height))
     {
        HDC dc;

        dc = CreateCompatibleDC(priv->dc);
        SelectObject(dc, priv->bitmap);
        BitBlt(priv->dc,
               0, 0,
               priv->width, priv->height,
               dc,
               0, 0,
               SRCCOPY);
        DeleteDC(dc);

     }
}

void
evas_software_wince_gdi_surface_resize(FB_Output_Buffer *fbob)
{
}