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