diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/evas/src/modules/engines/software_16_wince/evas_wince_gdi_buffer.c | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/libraries/evas/src/modules/engines/software_16_wince/evas_wince_gdi_buffer.c b/libraries/evas/src/modules/engines/software_16_wince/evas_wince_gdi_buffer.c new file mode 100644 index 0000000..f32db4a --- /dev/null +++ b/libraries/evas/src/modules/engines/software_16_wince/evas_wince_gdi_buffer.c | |||
@@ -0,0 +1,165 @@ | |||
1 | #include "evas_common.h" | ||
2 | #include "evas_engine.h" | ||
3 | |||
4 | |||
5 | typedef struct BITMAPINFO_16bpp BITMAPINFO_16bpp; | ||
6 | typedef struct Evas_Engine_WinCE_GDI_Priv Evas_Engine_WinCE_GDI_Priv; | ||
7 | |||
8 | struct BITMAPINFO_16bpp | ||
9 | { | ||
10 | BITMAPINFOHEADER bih; | ||
11 | DWORD masks[3]; | ||
12 | }; | ||
13 | |||
14 | struct Evas_Engine_WinCE_GDI_Priv | ||
15 | { | ||
16 | HWND window; | ||
17 | HDC dc; | ||
18 | BITMAPINFO_16bpp *bitmap_info; | ||
19 | HBITMAP bitmap; | ||
20 | int width; | ||
21 | int height; | ||
22 | }; | ||
23 | |||
24 | void * | ||
25 | evas_software_wince_gdi_init(HWND window, | ||
26 | int width, | ||
27 | int height, | ||
28 | int fullscreen) | ||
29 | { | ||
30 | Evas_Engine_WinCE_GDI_Priv *priv; | ||
31 | |||
32 | priv = (Evas_Engine_WinCE_GDI_Priv *)malloc(sizeof(Evas_Engine_WinCE_GDI_Priv)); | ||
33 | if (!priv) | ||
34 | return NULL; | ||
35 | |||
36 | priv->window = window; | ||
37 | priv->dc = GetDC(window); | ||
38 | if (!priv->dc) | ||
39 | { | ||
40 | ERR("Can not get DC"); | ||
41 | free(priv); | ||
42 | return NULL; | ||
43 | } | ||
44 | |||
45 | if (fullscreen) | ||
46 | { | ||
47 | priv->width = GetSystemMetrics(SM_CXSCREEN); | ||
48 | priv->height = GetSystemMetrics(SM_CYSCREEN); | ||
49 | } | ||
50 | else | ||
51 | { | ||
52 | priv->width = width; | ||
53 | priv->height = height; | ||
54 | } | ||
55 | |||
56 | priv->bitmap_info = (BITMAPINFO_16bpp *)malloc(sizeof(BITMAPINFO_16bpp)); | ||
57 | if (!priv->bitmap_info) | ||
58 | { | ||
59 | ERR("Can not allocate bitmap info"); | ||
60 | ReleaseDC(window, priv->dc); | ||
61 | free(priv); | ||
62 | return NULL; | ||
63 | } | ||
64 | |||
65 | priv->bitmap_info->bih.biSize = sizeof(BITMAPINFOHEADER); | ||
66 | priv->bitmap_info->bih.biWidth = priv->width; | ||
67 | priv->bitmap_info->bih.biHeight = -priv->height; | ||
68 | priv->bitmap_info->bih.biPlanes = 1; | ||
69 | priv->bitmap_info->bih.biSizeImage = 2 * priv->width * priv->height; | ||
70 | priv->bitmap_info->bih.biXPelsPerMeter = 0; | ||
71 | priv->bitmap_info->bih.biYPelsPerMeter = 0; | ||
72 | priv->bitmap_info->bih.biClrUsed = 0; | ||
73 | priv->bitmap_info->bih.biClrImportant = 0; | ||
74 | priv->bitmap_info->bih.biBitCount = 16; | ||
75 | priv->bitmap_info->bih.biCompression = BI_BITFIELDS; | ||
76 | priv->bitmap_info->masks[0] = 0x0000f800; | ||
77 | priv->bitmap_info->masks[1] = 0x000007e0; | ||
78 | priv->bitmap_info->masks[2] = 0x0000001f; | ||
79 | |||
80 | return priv; | ||
81 | } | ||
82 | |||
83 | void | ||
84 | evas_software_wince_gdi_shutdown(void *priv) | ||
85 | { | ||
86 | free(((Evas_Engine_WinCE_GDI_Priv *)priv)->bitmap_info); | ||
87 | ReleaseDC(((Evas_Engine_WinCE_GDI_Priv *)priv)->window, ((Evas_Engine_WinCE_GDI_Priv *)priv)->dc); | ||
88 | free(priv); | ||
89 | } | ||
90 | |||
91 | |||
92 | FB_Output_Buffer * | ||
93 | evas_software_wince_gdi_output_buffer_new(void *priv, | ||
94 | int width, | ||
95 | int height) | ||
96 | { | ||
97 | Evas_Engine_WinCE_GDI_Priv *priv2; | ||
98 | FB_Output_Buffer *fbob; | ||
99 | void *buffer; | ||
100 | |||
101 | fbob = calloc(1, sizeof(FB_Output_Buffer)); | ||
102 | if (!fbob) return NULL; | ||
103 | |||
104 | fbob->priv = priv; | ||
105 | |||
106 | priv2 = (Evas_Engine_WinCE_GDI_Priv *)fbob->priv; | ||
107 | |||
108 | priv2->bitmap = CreateDIBSection(priv2->dc, | ||
109 | (const BITMAPINFO *)priv2->bitmap_info, | ||
110 | DIB_RGB_COLORS, | ||
111 | (void **)(&buffer), | ||
112 | NULL, | ||
113 | 0); | ||
114 | if (!priv2->bitmap) | ||
115 | { | ||
116 | free(fbob); | ||
117 | return NULL; | ||
118 | } | ||
119 | |||
120 | fbob->im = (Soft16_Image *) evas_cache_image_data(evas_common_soft16_image_cache_get(), width, height, (DATA32 *)buffer, 0, EVAS_COLORSPACE_RGB565_A5P); | ||
121 | if (fbob->im) | ||
122 | fbob->im->stride = width; | ||
123 | |||
124 | return fbob; | ||
125 | } | ||
126 | |||
127 | void | ||
128 | evas_software_wince_gdi_output_buffer_free(FB_Output_Buffer *fbob) | ||
129 | { | ||
130 | Evas_Engine_WinCE_GDI_Priv *priv; | ||
131 | |||
132 | priv = (Evas_Engine_WinCE_GDI_Priv *)fbob->priv; | ||
133 | DeleteObject(priv->bitmap); | ||
134 | free(fbob); | ||
135 | } | ||
136 | |||
137 | void | ||
138 | evas_software_wince_gdi_output_buffer_paste(FB_Output_Buffer *fbob) | ||
139 | { | ||
140 | Evas_Engine_WinCE_GDI_Priv *priv; | ||
141 | |||
142 | priv = (Evas_Engine_WinCE_GDI_Priv *)fbob->priv; | ||
143 | |||
144 | if ((fbob->im->cache_entry.w == priv->width) && | ||
145 | (fbob->im->cache_entry.h == priv->height)) | ||
146 | { | ||
147 | HDC dc; | ||
148 | |||
149 | dc = CreateCompatibleDC(priv->dc); | ||
150 | SelectObject(dc, priv->bitmap); | ||
151 | BitBlt(priv->dc, | ||
152 | 0, 0, | ||
153 | priv->width, priv->height, | ||
154 | dc, | ||
155 | 0, 0, | ||
156 | SRCCOPY); | ||
157 | DeleteDC(dc); | ||
158 | |||
159 | } | ||
160 | } | ||
161 | |||
162 | void | ||
163 | evas_software_wince_gdi_surface_resize(FB_Output_Buffer *fbob) | ||
164 | { | ||
165 | } | ||