diff options
author | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
commit | 07274513e984f0b5544586c74508ccd16e7dcafa (patch) | |
tree | b32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/evas/src/modules/engines/software_ddraw/evas_ddraw_main.cpp | |
parent | Added Irrlicht 1.8, but without all the Windows binaries. (diff) | |
download | SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2 SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz |
Remove EFL, since it's been released now.
Diffstat (limited to 'libraries/evas/src/modules/engines/software_ddraw/evas_ddraw_main.cpp')
-rw-r--r-- | libraries/evas/src/modules/engines/software_ddraw/evas_ddraw_main.cpp | 248 |
1 files changed, 0 insertions, 248 deletions
diff --git a/libraries/evas/src/modules/engines/software_ddraw/evas_ddraw_main.cpp b/libraries/evas/src/modules/engines/software_ddraw/evas_ddraw_main.cpp deleted file mode 100644 index 2c467c8..0000000 --- a/libraries/evas/src/modules/engines/software_ddraw/evas_ddraw_main.cpp +++ /dev/null | |||
@@ -1,248 +0,0 @@ | |||
1 | #include "evas_common.h" | ||
2 | #include "evas_engine.h" | ||
3 | |||
4 | int | ||
5 | evas_software_ddraw_init (HWND window, | ||
6 | int depth, | ||
7 | int fullscreen, | ||
8 | Outbuf *buf) | ||
9 | { | ||
10 | DDSURFACEDESC surface_desc; | ||
11 | DDPIXELFORMAT pixel_format; | ||
12 | HRESULT res; | ||
13 | int width; | ||
14 | int height; | ||
15 | |||
16 | if (!buf) | ||
17 | return 0; | ||
18 | |||
19 | buf->priv.dd.window = window; | ||
20 | |||
21 | res = DirectDrawCreate(NULL, &buf->priv.dd.object, NULL); | ||
22 | if (FAILED(res)) | ||
23 | return 0; | ||
24 | |||
25 | if (buf->priv.dd.fullscreen) | ||
26 | { | ||
27 | DDSCAPS caps; | ||
28 | |||
29 | res = buf->priv.dd.object->SetCooperativeLevel(window, | ||
30 | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); | ||
31 | if (FAILED(res)) | ||
32 | goto release_object; | ||
33 | |||
34 | width = GetSystemMetrics(SM_CXSCREEN); | ||
35 | height = GetSystemMetrics(SM_CYSCREEN); | ||
36 | |||
37 | ZeroMemory(&pixel_format, sizeof(pixel_format)); | ||
38 | pixel_format.dwSize = sizeof(pixel_format); | ||
39 | buf->priv.dd.surface_primary->GetPixelFormat(&pixel_format); | ||
40 | |||
41 | if (pixel_format.dwRGBBitCount != (DWORD)depth) | ||
42 | goto release_object; | ||
43 | |||
44 | buf->priv.dd.depth = depth; | ||
45 | |||
46 | res = buf->priv.dd.object->SetDisplayMode(width, height, depth); | ||
47 | if (FAILED(res)) | ||
48 | goto release_object; | ||
49 | |||
50 | memset(&surface_desc, 0, sizeof(surface_desc)); | ||
51 | surface_desc.dwSize = sizeof(surface_desc); | ||
52 | surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; | ||
53 | surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; | ||
54 | surface_desc.dwBackBufferCount = 1; | ||
55 | |||
56 | res = buf->priv.dd.object->CreateSurface(&surface_desc, | ||
57 | &buf->priv.dd.surface_primary, NULL); | ||
58 | if (FAILED(res)) | ||
59 | goto release_object; | ||
60 | |||
61 | caps.dwCaps = DDSCAPS_BACKBUFFER; | ||
62 | res = buf->priv.dd.surface_primary->GetAttachedSurface(&caps, | ||
63 | &buf->priv.dd.surface_back); | ||
64 | if (FAILED(res)) | ||
65 | goto release_surface_primary; | ||
66 | } | ||
67 | else | ||
68 | { | ||
69 | RECT rect; | ||
70 | |||
71 | if (!GetClientRect(window, &rect)) | ||
72 | goto release_object; | ||
73 | |||
74 | width = rect.right - rect.left; | ||
75 | height = rect.bottom - rect.top; | ||
76 | |||
77 | res = buf->priv.dd.object->SetCooperativeLevel(window, DDSCL_NORMAL); | ||
78 | if (FAILED(res)) | ||
79 | goto release_object; | ||
80 | |||
81 | res = buf->priv.dd.object->CreateClipper(0, &buf->priv.dd.clipper, NULL); | ||
82 | if (FAILED(res)) | ||
83 | goto release_object; | ||
84 | |||
85 | res = buf->priv.dd.clipper->SetHWnd(0, window); | ||
86 | if (FAILED(res)) | ||
87 | goto release_clipper; | ||
88 | |||
89 | memset(&surface_desc, 0, sizeof(surface_desc)); | ||
90 | surface_desc.dwSize = sizeof(surface_desc); | ||
91 | surface_desc.dwFlags = DDSD_CAPS; | ||
92 | surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | ||
93 | |||
94 | res = buf->priv.dd.object->CreateSurface(&surface_desc, &buf->priv.dd.surface_primary, NULL); | ||
95 | if (FAILED(res)) | ||
96 | goto release_clipper; | ||
97 | |||
98 | res = buf->priv.dd.surface_primary->SetClipper(buf->priv.dd.clipper); | ||
99 | if (FAILED(res)) | ||
100 | goto release_surface_primary; | ||
101 | |||
102 | memset (&surface_desc, 0, sizeof(surface_desc)); | ||
103 | surface_desc.dwSize = sizeof(surface_desc); | ||
104 | surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; | ||
105 | surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; | ||
106 | surface_desc.dwWidth = width; | ||
107 | surface_desc.dwHeight = height; | ||
108 | |||
109 | res = buf->priv.dd.object->CreateSurface(&surface_desc, &buf->priv.dd.surface_back, NULL); | ||
110 | if (FAILED(res)) | ||
111 | goto release_surface_primary; | ||
112 | |||
113 | ZeroMemory(&pixel_format, sizeof(pixel_format)); | ||
114 | pixel_format.dwSize = sizeof(pixel_format); | ||
115 | buf->priv.dd.surface_primary->GetPixelFormat(&pixel_format); | ||
116 | |||
117 | if (pixel_format.dwRGBBitCount != (DWORD)depth) | ||
118 | goto release_surface_back; | ||
119 | |||
120 | buf->priv.dd.depth = depth; | ||
121 | } | ||
122 | |||
123 | return 1; | ||
124 | |||
125 | release_surface_back: | ||
126 | buf->priv.dd.surface_back->Release(); | ||
127 | release_surface_primary: | ||
128 | buf->priv.dd.surface_primary->Release(); | ||
129 | release_clipper: | ||
130 | if (!buf->priv.dd.fullscreen) | ||
131 | buf->priv.dd.clipper->Release(); | ||
132 | release_object: | ||
133 | buf->priv.dd.object->Release(); | ||
134 | |||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | void | ||
139 | evas_software_ddraw_shutdown(Outbuf *buf) | ||
140 | { | ||
141 | if (!buf) | ||
142 | return; | ||
143 | |||
144 | if (buf->priv.dd.fullscreen) | ||
145 | if (buf->priv.dd.surface_back) | ||
146 | buf->priv.dd.surface_back->Release(); | ||
147 | if (buf->priv.dd.surface_primary) | ||
148 | buf->priv.dd.surface_primary->Release(); | ||
149 | if (!buf->priv.dd.fullscreen) | ||
150 | if (buf->priv.dd.clipper) | ||
151 | buf->priv.dd.clipper->Release(); | ||
152 | if (buf->priv.dd.object) | ||
153 | buf->priv.dd.object->Release(); | ||
154 | } | ||
155 | |||
156 | int | ||
157 | evas_software_ddraw_masks_get(Outbuf *buf) | ||
158 | { | ||
159 | DDPIXELFORMAT pixel_format; | ||
160 | |||
161 | ZeroMemory(&pixel_format, sizeof(pixel_format)); | ||
162 | pixel_format.dwSize = sizeof(pixel_format); | ||
163 | |||
164 | if (FAILED(buf->priv.dd.surface_primary->GetPixelFormat(&pixel_format))) | ||
165 | return 0; | ||
166 | |||
167 | buf->priv.mask.r = pixel_format.dwRBitMask; | ||
168 | buf->priv.mask.g = pixel_format.dwGBitMask; | ||
169 | buf->priv.mask.b = pixel_format.dwBBitMask; | ||
170 | |||
171 | return 1; | ||
172 | } | ||
173 | |||
174 | void * | ||
175 | evas_software_ddraw_lock(Outbuf *buf, | ||
176 | int *ddraw_width, | ||
177 | int *ddraw_height, | ||
178 | int *ddraw_pitch, | ||
179 | int *ddraw_depth) | ||
180 | { | ||
181 | DDSURFACEDESC surface_desc; | ||
182 | |||
183 | ZeroMemory(&surface_desc, sizeof(surface_desc)); | ||
184 | surface_desc.dwSize = sizeof(surface_desc); | ||
185 | |||
186 | if (FAILED(buf->priv.dd.surface_back->Lock(NULL, | ||
187 | &surface_desc, | ||
188 | DDLOCK_WAIT | DDLOCK_WRITEONLY | DDLOCK_SURFACEMEMORYPTR | DDLOCK_NOSYSLOCK, | ||
189 | NULL))) | ||
190 | return NULL; | ||
191 | |||
192 | *ddraw_width = surface_desc.dwWidth; | ||
193 | *ddraw_height = surface_desc.dwHeight; | ||
194 | *ddraw_pitch = surface_desc.lPitch; | ||
195 | *ddraw_depth = surface_desc.ddpfPixelFormat.dwRGBBitCount >> 3; | ||
196 | |||
197 | return surface_desc.lpSurface; | ||
198 | } | ||
199 | |||
200 | void | ||
201 | evas_software_ddraw_unlock_and_flip(Outbuf *buf) | ||
202 | { | ||
203 | RECT dst_rect; | ||
204 | RECT src_rect; | ||
205 | POINT p; | ||
206 | |||
207 | if (FAILED(buf->priv.dd.surface_back->Unlock(NULL))) | ||
208 | return; | ||
209 | |||
210 | /* we figure out where on the primary surface our window lives */ | ||
211 | p.x = 0; | ||
212 | p.y = 0; | ||
213 | ClientToScreen(buf->priv.dd.window, &p); | ||
214 | GetClientRect(buf->priv.dd.window, &dst_rect); | ||
215 | OffsetRect(&dst_rect, p.x, p.y); | ||
216 | SetRect(&src_rect, 0, 0, buf->width, buf->height); | ||
217 | |||
218 | /* nothing to do if the function fails, so we don't check the result */ | ||
219 | buf->priv.dd.surface_primary->Blt(&dst_rect, | ||
220 | buf->priv.dd.surface_back, | ||
221 | &src_rect, | ||
222 | DDBLT_WAIT, NULL); | ||
223 | } | ||
224 | |||
225 | void | ||
226 | evas_software_ddraw_surface_resize(Outbuf *buf) | ||
227 | { | ||
228 | DDSURFACEDESC surface_desc; | ||
229 | |||
230 | buf->priv.dd.surface_back->Release(); | ||
231 | memset (&surface_desc, 0, sizeof (surface_desc)); | ||
232 | surface_desc.dwSize = sizeof (surface_desc); | ||
233 | /* FIXME: that code does not compile. Must know why */ | ||
234 | #if 0 | ||
235 | surface_desc.dwFlags = DDSD_HEIGHT | DDSD_WIDTH; | ||
236 | surface_desc.dwWidth = width; | ||
237 | surface_desc.dwHeight = height; | ||
238 | buf->priv.dd.surface_back->SetSurfaceDesc(&surface_desc, NULL); | ||
239 | #else | ||
240 | surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; | ||
241 | surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; | ||
242 | surface_desc.dwWidth = buf->width; | ||
243 | surface_desc.dwHeight = buf->height; | ||
244 | buf->priv.dd.object->CreateSurface(&surface_desc, | ||
245 | &buf->priv.dd.surface_back, | ||
246 | NULL); | ||
247 | #endif | ||
248 | } | ||