2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
1954
|
26 |
// copy from awt.h
|
|
27 |
#ifndef _WIN32_WINNT
|
|
28 |
#define _WIN32_WINNT 0x0600
|
|
29 |
#endif
|
|
30 |
|
|
31 |
// copy from awt.h
|
|
32 |
#ifndef _WIN32_IE
|
|
33 |
#define _WIN32_IE 0x0600
|
|
34 |
#endif
|
|
35 |
|
2
|
36 |
#include "splashscreen_impl.h"
|
|
37 |
#include <windowsx.h>
|
|
38 |
#include <windows.h>
|
|
39 |
#include <winuser.h>
|
|
40 |
|
|
41 |
#ifndef WS_EX_LAYERED
|
|
42 |
#define WS_EX_LAYERED 0x80000
|
|
43 |
#endif
|
|
44 |
|
|
45 |
#ifndef ULW_ALPHA
|
|
46 |
#define ULW_ALPHA 0x00000002
|
|
47 |
#endif
|
|
48 |
|
|
49 |
#ifndef AC_SRC_OVER
|
|
50 |
#define AC_SRC_OVER 0x00
|
|
51 |
#endif
|
|
52 |
|
|
53 |
#ifndef AC_SRC_ALPHA
|
|
54 |
#define AC_SRC_ALPHA 0x01
|
|
55 |
#endif
|
|
56 |
|
|
57 |
#define WM_SPLASHUPDATE WM_USER+1
|
|
58 |
#define WM_SPLASHRECONFIGURE WM_USER+2
|
|
59 |
|
|
60 |
/* Could use npt but decided to cut down on linked code size */
|
|
61 |
char* SplashConvertStringAlloc(const char* in, int *size) {
|
|
62 |
int len, outChars, rc;
|
|
63 |
WCHAR* buf;
|
|
64 |
if (!in) {
|
|
65 |
return NULL;
|
|
66 |
}
|
|
67 |
len = strlen(in);
|
|
68 |
outChars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, in, len,
|
|
69 |
NULL, 0);
|
|
70 |
buf = malloc(outChars*sizeof(WCHAR));
|
|
71 |
rc = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, in, len,
|
|
72 |
buf, outChars);
|
|
73 |
if (rc==0) {
|
|
74 |
free(buf);
|
|
75 |
return NULL;
|
|
76 |
} else {
|
|
77 |
if (size) {
|
|
78 |
*size = rc;
|
|
79 |
}
|
|
80 |
return (char*)buf;
|
|
81 |
}
|
|
82 |
}
|
|
83 |
|
|
84 |
unsigned
|
|
85 |
SplashTime(void)
|
|
86 |
{
|
|
87 |
return GetTickCount();
|
|
88 |
}
|
|
89 |
|
|
90 |
void
|
|
91 |
SplashInitFrameShape(Splash * splash, int imageIndex)
|
|
92 |
{
|
|
93 |
RGNDATA *pRgnData;
|
|
94 |
RGNDATAHEADER *pRgnHdr;
|
|
95 |
ImageRect maskRect;
|
|
96 |
|
|
97 |
if (!splash->maskRequired)
|
|
98 |
return;
|
|
99 |
|
|
100 |
/* reserving memory for the worst case */
|
|
101 |
pRgnData = (RGNDATA *) malloc(sizeof(RGNDATAHEADER) +
|
|
102 |
sizeof(RECT) * (splash->width / 2 + 1) * splash->height);
|
|
103 |
pRgnHdr = (RGNDATAHEADER *) pRgnData;
|
|
104 |
initRect(&maskRect, 0, 0, splash->width, splash->height, 1,
|
|
105 |
splash->width * splash->imageFormat.depthBytes,
|
|
106 |
splash->frames[imageIndex].bitmapBits, &splash->imageFormat);
|
|
107 |
|
|
108 |
pRgnHdr->dwSize = sizeof(RGNDATAHEADER);
|
|
109 |
pRgnHdr->iType = RDH_RECTANGLES;
|
|
110 |
pRgnHdr->nRgnSize = 0;
|
|
111 |
pRgnHdr->rcBound.top = 0;
|
|
112 |
pRgnHdr->rcBound.left = 0;
|
|
113 |
pRgnHdr->rcBound.bottom = splash->height;
|
|
114 |
pRgnHdr->rcBound.right = splash->width;
|
|
115 |
|
|
116 |
pRgnHdr->nCount = BitmapToYXBandedRectangles(&maskRect,
|
|
117 |
(RECT *) (((BYTE *) pRgnData) + sizeof(RGNDATAHEADER)));
|
|
118 |
|
|
119 |
splash->frames[imageIndex].hRgn = ExtCreateRegion(NULL,
|
|
120 |
sizeof(RGNDATAHEADER) + sizeof(RECT) * pRgnHdr->nCount, pRgnData);
|
|
121 |
|
|
122 |
free(pRgnData);
|
|
123 |
}
|
|
124 |
|
|
125 |
/* paint current splash screen frame to hdc
|
|
126 |
this function is unused in layered window mode */
|
|
127 |
|
|
128 |
void
|
|
129 |
SplashPaint(Splash * splash, HDC hdc)
|
|
130 |
{
|
|
131 |
unsigned numColors = splash->screenFormat.colorMap ?
|
|
132 |
splash->screenFormat.numColors : 0;
|
|
133 |
unsigned bmiSize;
|
|
134 |
BITMAPV4HEADER *pBmi;
|
|
135 |
HPALETTE hOldPal = NULL;
|
|
136 |
|
|
137 |
if (!splash->frames)
|
|
138 |
return;
|
|
139 |
if (splash->currentFrame < 0 || splash->currentFrame >= splash->frameCount)
|
|
140 |
return;
|
|
141 |
bmiSize = sizeof(BITMAPV4HEADER) + sizeof(RGBQUAD) * numColors;
|
|
142 |
pBmi = (BITMAPV4HEADER *) alloca(bmiSize);
|
|
143 |
memset(pBmi, 0, sizeof(BITMAPV4HEADER));
|
|
144 |
if (splash->screenFormat.colorMap)
|
|
145 |
memcpy(((BYTE *) pBmi) + sizeof(BITMAPV4HEADER),
|
|
146 |
splash->screenFormat.colorMap, sizeof(RGBQUAD) * numColors);
|
|
147 |
|
|
148 |
pBmi->bV4Size = sizeof(BITMAPV4HEADER);
|
|
149 |
pBmi->bV4Width = splash->width;
|
|
150 |
pBmi->bV4Height = -splash->height;
|
|
151 |
pBmi->bV4Planes = 1;
|
|
152 |
pBmi->bV4BitCount = (WORD) (splash->screenFormat.depthBytes * 8);
|
|
153 |
/* we're ALWAYS using BGRA in screenFormat */
|
|
154 |
pBmi->bV4V4Compression = BI_RGB;
|
|
155 |
pBmi->bV4ClrUsed = numColors;
|
|
156 |
pBmi->bV4ClrImportant = numColors;
|
|
157 |
pBmi->bV4AlphaMask = splash->screenFormat.mask[3];
|
|
158 |
pBmi->bV4RedMask = splash->screenFormat.mask[2];
|
|
159 |
pBmi->bV4GreenMask = splash->screenFormat.mask[1];
|
|
160 |
pBmi->bV4BlueMask = splash->screenFormat.mask[0];
|
|
161 |
|
|
162 |
/* creating the palette in SplashInitPlatform does not work, so I'm creating it
|
|
163 |
here on demand */
|
|
164 |
if (!splash->hPalette) {
|
|
165 |
unsigned i;
|
|
166 |
LOGPALETTE *pLogPal =
|
|
167 |
malloc(sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * numColors);
|
|
168 |
|
|
169 |
pLogPal->palVersion = 0x300;
|
|
170 |
pLogPal->palNumEntries = (WORD) numColors;
|
|
171 |
for (i = 0; i < numColors; i++) {
|
|
172 |
pLogPal->palPalEntry[i].peRed = (BYTE)
|
|
173 |
QUAD_RED(splash->colorMap[i]);
|
|
174 |
pLogPal->palPalEntry[i].peGreen = (BYTE)
|
|
175 |
QUAD_GREEN(splash->colorMap[i]);
|
|
176 |
pLogPal->palPalEntry[i].peBlue = (BYTE)
|
|
177 |
QUAD_BLUE(splash->colorMap[i]);
|
|
178 |
pLogPal->palPalEntry[i].peFlags = PC_NOCOLLAPSE;
|
|
179 |
}
|
|
180 |
splash->hPalette = CreatePalette(pLogPal);
|
|
181 |
free(pLogPal);
|
|
182 |
}
|
|
183 |
if (splash->hPalette) {
|
|
184 |
hOldPal = SelectPalette(hdc, splash->hPalette, FALSE);
|
|
185 |
RealizePalette(hdc);
|
|
186 |
}
|
|
187 |
|
|
188 |
StretchDIBits(hdc, 0, 0, splash->width, splash->height, 0, 0,
|
|
189 |
splash->width, splash->height, splash->screenData,
|
|
190 |
(BITMAPINFO *) pBmi, DIB_RGB_COLORS, SRCCOPY);
|
|
191 |
if (hOldPal)
|
|
192 |
SelectPalette(hdc, hOldPal, FALSE);
|
|
193 |
}
|
|
194 |
|
|
195 |
|
|
196 |
/* The function makes the window visible if it is hidden
|
|
197 |
or is not yet shown. */
|
|
198 |
void
|
|
199 |
SplashRedrawWindow(Splash * splash)
|
|
200 |
{
|
|
201 |
SplashUpdateScreenData(splash);
|
|
202 |
if (splash->isLayered) {
|
|
203 |
BLENDFUNCTION bf;
|
|
204 |
POINT ptSrc;
|
|
205 |
HDC hdcSrc = CreateCompatibleDC(NULL), hdcDst;
|
|
206 |
BITMAPINFOHEADER bmi;
|
|
207 |
void *bitmapBits;
|
|
208 |
HBITMAP hBitmap, hOldBitmap;
|
|
209 |
RECT rect;
|
|
210 |
POINT ptDst;
|
|
211 |
SIZE size;
|
|
212 |
|
|
213 |
bf.BlendOp = AC_SRC_OVER;
|
|
214 |
bf.BlendFlags = 0;
|
|
215 |
bf.AlphaFormat = AC_SRC_ALPHA;
|
|
216 |
bf.SourceConstantAlpha = 0xFF;
|
|
217 |
ptSrc.x = ptSrc.y = 0;
|
|
218 |
|
|
219 |
memset(&bmi, 0, sizeof(bmi));
|
|
220 |
bmi.biSize = sizeof(BITMAPINFOHEADER);
|
|
221 |
bmi.biWidth = splash->width;
|
|
222 |
bmi.biHeight = -splash->height;
|
|
223 |
bmi.biPlanes = 1;
|
|
224 |
bmi.biBitCount = 32;
|
|
225 |
bmi.biCompression = BI_RGB;
|
|
226 |
|
|
227 |
// FIXME: this is somewhat ineffective
|
|
228 |
// maybe if we allocate memory for all frames as DIBSections,
|
|
229 |
// then we could select the frames into the DC directly
|
|
230 |
|
|
231 |
hBitmap = CreateDIBSection(NULL, (BITMAPINFO *) & bmi, DIB_RGB_COLORS,
|
|
232 |
&bitmapBits, NULL, 0);
|
|
233 |
memcpy(bitmapBits, splash->screenData,
|
|
234 |
splash->screenStride * splash->height);
|
|
235 |
hOldBitmap = (HBITMAP) SelectObject(hdcSrc, hBitmap);
|
|
236 |
hdcDst = GetDC(splash->hWnd);
|
|
237 |
|
|
238 |
GetWindowRect(splash->hWnd, &rect);
|
|
239 |
|
|
240 |
ptDst.x = rect.left;
|
|
241 |
ptDst.y = rect.top;
|
|
242 |
|
|
243 |
size.cx = splash->width;
|
|
244 |
size.cy = splash->height;
|
|
245 |
|
|
246 |
UpdateLayeredWindow(splash->hWnd, hdcDst, &ptDst, &size,
|
|
247 |
hdcSrc, &ptSrc, 0, &bf, ULW_ALPHA);
|
|
248 |
|
|
249 |
ReleaseDC(splash->hWnd, hdcDst);
|
|
250 |
SelectObject(hdcSrc, hOldBitmap);
|
|
251 |
DeleteObject(hBitmap);
|
|
252 |
DeleteDC(hdcSrc);
|
|
253 |
}
|
|
254 |
else {
|
|
255 |
InvalidateRect(splash->hWnd, NULL, FALSE);
|
|
256 |
if (splash->maskRequired) {
|
|
257 |
HRGN hRgn = CreateRectRgn(0, 0, 0, 0);
|
|
258 |
|
|
259 |
CombineRgn(hRgn, splash->frames[splash->currentFrame].hRgn,
|
|
260 |
splash->frames[splash->currentFrame].hRgn, RGN_COPY);
|
|
261 |
SetWindowRgn(splash->hWnd, hRgn, TRUE);
|
|
262 |
} else {
|
|
263 |
SetWindowRgn(splash->hWnd, NULL, TRUE);
|
|
264 |
}
|
|
265 |
UpdateWindow(splash->hWnd);
|
|
266 |
}
|
|
267 |
if (!IsWindowVisible(splash->hWnd)) {
|
|
268 |
POINT cursorPos;
|
|
269 |
ShowWindow(splash->hWnd, SW_SHOW);
|
|
270 |
// Windows won't update the cursor after the window is shown,
|
|
271 |
// if the cursor is already above the window. need to do this manually.
|
|
272 |
GetCursorPos(&cursorPos);
|
|
273 |
if (WindowFromPoint(cursorPos) == splash->hWnd) {
|
|
274 |
// unfortunately Windows fail to understand that the window
|
|
275 |
// thread should own the cursor, even though the mouse pointer
|
|
276 |
// is over the window, until the mouse has been moved.
|
|
277 |
// we're using SetCursorPos here to fake the mouse movement
|
|
278 |
// and enable proper update of the cursor.
|
|
279 |
SetCursorPos(cursorPos.x, cursorPos.y);
|
|
280 |
SetCursor(LoadCursor(NULL, IDC_WAIT));
|
|
281 |
}
|
|
282 |
}
|
|
283 |
if (SplashIsStillLooping(splash)) {
|
|
284 |
int time = splash->time +
|
|
285 |
splash->frames[splash->currentFrame].delay - SplashTime();
|
|
286 |
|
|
287 |
if (time < 0)
|
|
288 |
time = 0;
|
|
289 |
SetTimer(splash->hWnd, 0, time, NULL);
|
|
290 |
}
|
|
291 |
else {
|
|
292 |
KillTimer(splash->hWnd, 0);
|
|
293 |
}
|
|
294 |
}
|
|
295 |
|
|
296 |
void SplashReconfigureNow(Splash * splash) {
|
|
297 |
splash->x = (GetSystemMetrics(SM_CXSCREEN) - splash->width) / 2;
|
|
298 |
splash->y = (GetSystemMetrics(SM_CYSCREEN) - splash->height) / 2;
|
|
299 |
if (splash->hWnd) {
|
|
300 |
//Fixed 6474657: splash screen image jumps towards left while
|
|
301 |
// setting the new image using setImageURL()
|
|
302 |
// We may safely hide the splash window because SplashRedrawWindow()
|
|
303 |
// will show the window again.
|
|
304 |
ShowWindow(splash->hWnd, SW_HIDE);
|
|
305 |
MoveWindow(splash->hWnd, splash->x, splash->y, splash->width, splash->height, FALSE);
|
|
306 |
}
|
|
307 |
SplashRedrawWindow(splash);
|
|
308 |
}
|
|
309 |
|
|
310 |
static LRESULT CALLBACK
|
|
311 |
SplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
312 |
{
|
|
313 |
PAINTSTRUCT ps;
|
|
314 |
HDC hdc;
|
|
315 |
|
|
316 |
|
|
317 |
switch (message) {
|
|
318 |
|
|
319 |
case WM_ERASEBKGND:
|
|
320 |
return TRUE; // to avoid flicker
|
|
321 |
|
|
322 |
case WM_SYSCOMMAND:
|
|
323 |
if (wParam==SC_CLOSE||wParam==SC_DEFAULT||wParam==SC_HOTKEY||
|
|
324 |
wParam==SC_KEYMENU||wParam==SC_MAXIMIZE||
|
|
325 |
wParam==SC_MINIMIZE||wParam==SC_MOUSEMENU||wParam==SC_MOVE||
|
|
326 |
wParam==SC_RESTORE||wParam==SC_SIZE)
|
|
327 |
{
|
|
328 |
return 0;
|
|
329 |
}
|
|
330 |
|
|
331 |
/* double switch to avoid prologue/epilogue duplication */
|
|
332 |
case WM_TIMER:
|
|
333 |
case WM_SPLASHUPDATE:
|
|
334 |
case WM_PAINT:
|
|
335 |
case WM_SPLASHRECONFIGURE:
|
|
336 |
{
|
|
337 |
Splash *splash = (Splash *) GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
|
338 |
|
|
339 |
SplashLock(splash);
|
|
340 |
if (splash->isVisible>0) {
|
|
341 |
switch(message) {
|
|
342 |
case WM_TIMER:
|
|
343 |
SplashNextFrame(splash);
|
|
344 |
SplashRedrawWindow(splash);
|
|
345 |
break;
|
|
346 |
case WM_SPLASHUPDATE:
|
|
347 |
SplashRedrawWindow(splash);
|
|
348 |
break;
|
|
349 |
case WM_PAINT:
|
|
350 |
hdc = BeginPaint(hWnd, &ps);
|
|
351 |
SplashPaint(splash, hdc);
|
|
352 |
EndPaint(hWnd, &ps);
|
|
353 |
break;
|
|
354 |
case WM_SPLASHRECONFIGURE:
|
|
355 |
SplashReconfigureNow(splash);
|
|
356 |
break;
|
|
357 |
}
|
|
358 |
}
|
|
359 |
SplashUnlock(splash);
|
|
360 |
break;
|
|
361 |
}
|
|
362 |
case WM_DESTROY:
|
|
363 |
PostQuitMessage(0);
|
|
364 |
break;
|
|
365 |
default:
|
|
366 |
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
367 |
|
|
368 |
}
|
|
369 |
return 0;
|
|
370 |
}
|
|
371 |
|
|
372 |
HWND
|
|
373 |
SplashCreateWindow(Splash * splash)
|
|
374 |
{
|
|
375 |
WNDCLASSEX wcex;
|
|
376 |
ATOM wndClass;
|
|
377 |
DWORD style, exStyle;
|
|
378 |
HWND hWnd;
|
|
379 |
|
|
380 |
ZeroMemory(&wcex, sizeof(WNDCLASSEX));
|
|
381 |
|
|
382 |
wcex.cbSize = sizeof(WNDCLASSEX);
|
|
383 |
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
|
384 |
wcex.lpfnWndProc = (WNDPROC) SplashWndProc;
|
|
385 |
wcex.hInstance = GetModuleHandle(NULL);
|
|
386 |
wcex.lpszClassName = "JavaSplash";
|
|
387 |
wcex.hCursor = LoadCursor(NULL, IDC_WAIT);
|
|
388 |
|
|
389 |
wndClass = RegisterClassEx(&wcex);
|
|
390 |
if (!wndClass) {
|
|
391 |
return 0;
|
|
392 |
}
|
|
393 |
|
|
394 |
splash->x = (GetSystemMetrics(SM_CXSCREEN) - splash->width) / 2;
|
|
395 |
splash->y = (GetSystemMetrics(SM_CYSCREEN) - splash->height) / 2;
|
|
396 |
exStyle = splash->isLayered ? WS_EX_LAYERED : 0;
|
|
397 |
exStyle |= WS_EX_TOOLWINDOW; /* don't show the window on taskbar */
|
|
398 |
style = WS_POPUP;
|
|
399 |
hWnd = CreateWindowEx(exStyle, (LPCSTR) wndClass, "", style,
|
|
400 |
splash->x, splash->y, splash->width, splash->height, NULL, NULL,
|
|
401 |
wcex.hInstance, NULL);
|
|
402 |
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) splash);
|
|
403 |
return hWnd;
|
|
404 |
}
|
|
405 |
|
|
406 |
void
|
|
407 |
SplashLock(Splash * splash)
|
|
408 |
{
|
|
409 |
EnterCriticalSection(&splash->lock);
|
|
410 |
}
|
|
411 |
|
|
412 |
void
|
|
413 |
SplashUnlock(Splash * splash)
|
|
414 |
{
|
|
415 |
LeaveCriticalSection(&splash->lock);
|
|
416 |
}
|
|
417 |
|
|
418 |
void
|
|
419 |
SplashInitPlatform(Splash * splash)
|
|
420 |
{
|
|
421 |
HDC hdc;
|
|
422 |
int paletteMode;
|
|
423 |
|
|
424 |
InitializeCriticalSection(&splash->lock);
|
|
425 |
splash->isLayered = FALSE;
|
|
426 |
hdc = GetDC(NULL);
|
|
427 |
paletteMode = (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) != 0;
|
|
428 |
if (UpdateLayeredWindow && !paletteMode) {
|
|
429 |
splash->isLayered = TRUE;
|
|
430 |
}
|
|
431 |
splash->byteAlignment = 4;
|
|
432 |
if (splash->isLayered) {
|
|
433 |
initFormat(&splash->screenFormat,
|
|
434 |
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
|
|
435 |
splash->screenFormat.premultiplied = 1;
|
|
436 |
splash->maskRequired = 0;
|
|
437 |
}
|
|
438 |
else {
|
|
439 |
splash->maskRequired = 1;
|
|
440 |
if (paletteMode) {
|
|
441 |
int numColors = GetDeviceCaps(hdc, SIZEPALETTE) -
|
|
442 |
GetDeviceCaps(hdc, NUMRESERVED);
|
|
443 |
int i;
|
|
444 |
int numComponents[3];
|
|
445 |
|
|
446 |
initFormat(&splash->screenFormat, 0, 0, 0, 0);
|
|
447 |
/* FIXME: maybe remapping to non-reserved colors would improve performance */
|
|
448 |
for (i = 0; i < numColors; i++) {
|
|
449 |
splash->colorIndex[i] = i;
|
|
450 |
}
|
|
451 |
numColors = quantizeColors(numColors, numComponents);
|
|
452 |
initColorCube(numComponents, splash->colorMap, splash->dithers,
|
|
453 |
splash->colorIndex);
|
|
454 |
splash->screenFormat.colorIndex = splash->colorIndex;
|
|
455 |
splash->screenFormat.depthBytes = 1;
|
|
456 |
splash->screenFormat.colorMap = splash->colorMap;
|
|
457 |
splash->screenFormat.dithers = splash->dithers;
|
|
458 |
splash->screenFormat.numColors = numColors;
|
|
459 |
splash->hPalette = NULL;
|
|
460 |
}
|
|
461 |
else {
|
|
462 |
initFormat(&splash->screenFormat,
|
|
463 |
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
|
|
464 |
}
|
|
465 |
}
|
|
466 |
ReleaseDC(NULL, hdc);
|
|
467 |
}
|
|
468 |
|
|
469 |
void
|
|
470 |
SplashCleanupPlatform(Splash * splash)
|
|
471 |
{
|
|
472 |
int i;
|
|
473 |
|
|
474 |
if (splash->frames) {
|
|
475 |
for (i = 0; i < splash->frameCount; i++) {
|
|
476 |
if (splash->frames[i].hRgn) {
|
|
477 |
DeleteObject(splash->frames[i].hRgn);
|
|
478 |
splash->frames[i].hRgn = NULL;
|
|
479 |
}
|
|
480 |
}
|
|
481 |
}
|
|
482 |
if (splash->hPalette)
|
|
483 |
DeleteObject(splash->hPalette);
|
|
484 |
splash->maskRequired = !splash->isLayered;
|
|
485 |
}
|
|
486 |
|
|
487 |
void
|
|
488 |
SplashDonePlatform(Splash * splash)
|
|
489 |
{
|
|
490 |
if (splash->hWnd)
|
|
491 |
DestroyWindow(splash->hWnd);
|
|
492 |
}
|
|
493 |
|
|
494 |
void
|
|
495 |
SplashMessagePump()
|
|
496 |
{
|
|
497 |
MSG msg;
|
|
498 |
|
|
499 |
while (GetMessage(&msg, NULL, 0, 0)) {
|
|
500 |
TranslateMessage(&msg);
|
|
501 |
DispatchMessage(&msg);
|
|
502 |
}
|
|
503 |
}
|
|
504 |
|
|
505 |
DWORD WINAPI
|
|
506 |
SplashScreenThread(LPVOID param)
|
|
507 |
{
|
|
508 |
Splash *splash = (Splash *) param;
|
|
509 |
|
|
510 |
splash->currentFrame = 0;
|
|
511 |
SplashLock(splash);
|
|
512 |
splash->time = SplashTime();
|
|
513 |
splash->hWnd = SplashCreateWindow(splash);
|
|
514 |
if (splash->hWnd) {
|
|
515 |
SplashRedrawWindow(splash);
|
|
516 |
SplashUnlock(splash);
|
|
517 |
SplashMessagePump();
|
|
518 |
SplashLock(splash);
|
|
519 |
}
|
|
520 |
SplashDone(splash);
|
|
521 |
splash->isVisible = -1;
|
|
522 |
SplashUnlock(splash);
|
|
523 |
return 0;
|
|
524 |
}
|
|
525 |
|
|
526 |
void
|
|
527 |
SplashCreateThread(Splash * splash)
|
|
528 |
{
|
|
529 |
DWORD threadId;
|
|
530 |
|
|
531 |
CreateThread(NULL, 0, SplashScreenThread, (LPVOID) splash, 0, &threadId);
|
|
532 |
}
|
|
533 |
|
|
534 |
void
|
|
535 |
SplashClosePlatform(Splash * splash)
|
|
536 |
{
|
|
537 |
PostMessage(splash->hWnd, WM_QUIT, 0, 0);
|
|
538 |
}
|
|
539 |
|
|
540 |
void
|
|
541 |
SplashUpdate(Splash * splash)
|
|
542 |
{
|
|
543 |
PostMessage(splash->hWnd, WM_SPLASHUPDATE, 0, 0);
|
|
544 |
}
|
|
545 |
|
|
546 |
void
|
|
547 |
SplashReconfigure(Splash * splash)
|
|
548 |
{
|
|
549 |
PostMessage(splash->hWnd, WM_SPLASHRECONFIGURE, 0, 0);
|
|
550 |
}
|