J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. |
| 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 |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 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 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | #ifndef SPLASHSCREEN_IMPL_H |
| 27 | #define SPLASHSCREEN_IMPL_H |
| 28 | |
| 29 | #include "splashscreen_config.h" |
| 30 | #include "splashscreen_gfx.h" |
| 31 | |
| 32 | SPLASHEXPORT int SplashLoadMemory(void *pdata, int size); /* requires preloading the file */ |
| 33 | SPLASHEXPORT int SplashLoadFile(const char *filename); // FIXME: range checking for SplashLoadMemory |
| 34 | |
| 35 | SPLASHEXPORT void SplashInit(void); |
| 36 | SPLASHEXPORT void SplashClose(void); |
| 37 | |
| 38 | SPLASHEXPORT void |
| 39 | SplashSetFileJarName(const char* fileName, const char* jarName); |
| 40 | |
| 41 | typedef struct SplashImage |
| 42 | { |
| 43 | rgbquad_t *bitmapBits; |
| 44 | int delay; /* before next image display, in msec */ |
| 45 | #if defined(WITH_WIN32) |
| 46 | HRGN hRgn; |
| 47 | #elif defined(WITH_X11) |
| 48 | XRectangle *rects; |
| 49 | int numRects; |
| 50 | #endif |
| 51 | } SplashImage; |
| 52 | |
| 53 | #define SPLASH_COLOR_MAP_SIZE 0x100 |
| 54 | |
| 55 | typedef struct Splash |
| 56 | { |
| 57 | ImageFormat screenFormat; /* must be preset before image decoding */ |
| 58 | DitherSettings dithers[3]; |
| 59 | ImageFormat imageFormat; |
| 60 | rgbquad_t colorMap[SPLASH_COLOR_MAP_SIZE]; |
| 61 | int byteAlignment; /* must be preset before image decoding */ |
| 62 | int maskRequired; /* must be preset before image decoding */ |
| 63 | int width; /* in pixels */ |
| 64 | int height; /* in pixels */ |
| 65 | int frameCount; |
| 66 | SplashImage *frames; /* dynamically allocated array of frame descriptors */ |
| 67 | unsigned time; /* in msec, origin is not important */ |
| 68 | rgbquad_t *overlayData; /* overlay image data, always rgbquads */ |
| 69 | ImageRect overlayRect; |
| 70 | ImageFormat overlayFormat; |
| 71 | void *screenData; |
| 72 | int screenStride; /* stored scanline length in bytes */ |
| 73 | int currentFrame; // currentFrame==-1 means image is not loaded |
| 74 | int loopCount; |
| 75 | int x, y; |
| 76 | rgbquad_t colorIndex[SPLASH_COLOR_MAP_SIZE]; |
| 77 | int isVisible; |
| 78 | char* fileName; /* stored in 16-bit unicode (jchars) */ |
| 79 | int fileNameLen; |
| 80 | char* jarName; /* stored in 16-bit unicode (jchars) */ |
| 81 | int jarNameLen; |
| 82 | #if defined(WITH_WIN32) |
| 83 | BOOL isLayered; |
| 84 | HWND hWnd; |
| 85 | HPALETTE hPalette; |
| 86 | CRITICAL_SECTION lock; |
| 87 | #elif defined(WITH_X11) |
| 88 | int controlpipe[2]; |
| 89 | Display *display; |
| 90 | Window window; |
| 91 | Screen *screen; |
| 92 | Visual *visual; |
| 93 | Colormap cmap; |
| 94 | pthread_mutex_t lock; |
| 95 | Cursor cursor; |
| 96 | XWMHints* wmHints; |
| 97 | #endif |
| 98 | } Splash; |
| 99 | |
| 100 | /* various shared and/or platform dependent splash screen functions */ |
| 101 | |
| 102 | Splash *SplashGetInstance(); |
| 103 | |
| 104 | int SplashIsStillLooping(Splash * splash); |
| 105 | void SplashNextFrame(Splash * splash); |
| 106 | void SplashStart(Splash * splash); |
| 107 | void SplashCreateThread(Splash * splash); |
| 108 | unsigned SplashTime(); |
| 109 | void SplashDone(Splash * splash); |
| 110 | |
| 111 | void SplashInitPlatform(Splash * splash); |
| 112 | void SplashDonePlatform(Splash * splash); |
| 113 | void SplashDone(Splash * splash); |
| 114 | void SplashUpdate(Splash * splash); |
| 115 | void SplashUpdateScreenData(Splash * splash); |
| 116 | |
| 117 | void SplashLock(Splash * splash); |
| 118 | void SplashUnlock(Splash * splash); |
| 119 | |
| 120 | void SplashCleanup(Splash * splash); |
| 121 | void SplashCleanupPlatform(Splash * splash); |
| 122 | |
| 123 | void SplashClosePlatform(); |
| 124 | |
| 125 | void SplashReconfigure(); |
| 126 | |
| 127 | char* SplashConvertStringAlloc(const char* in, int *size); |
| 128 | |
| 129 | typedef struct SplashStream { |
| 130 | int (*read)(void* pStream, void* pData, int nBytes); |
| 131 | int (*peek)(void* pStream); |
| 132 | void (*close)(void* pStream); |
| 133 | union { |
| 134 | struct { |
| 135 | FILE* f; |
| 136 | } stdio; |
| 137 | struct { |
| 138 | unsigned char* pData; |
| 139 | unsigned char* pDataEnd; |
| 140 | } mem; |
| 141 | } arg; |
| 142 | } SplashStream; |
| 143 | |
| 144 | int SplashStreamInitFile(SplashStream * stream, const char* filename); |
| 145 | int SplashStreamInitMemory(SplashStream * stream, void * pData, int size); |
| 146 | |
| 147 | /* image decoding */ |
| 148 | int SplashDecodeGifStream(Splash * splash, SplashStream * stream); |
| 149 | int SplashDecodeJpegStream(Splash * splash, SplashStream * stream); |
| 150 | int SplashDecodePngStream(Splash * splash, SplashStream * stream); |
| 151 | |
| 152 | /* utility functions */ |
| 153 | |
| 154 | int BitmapToYXBandedRectangles(ImageRect * pSrcRect, RECT_T * out); |
| 155 | |
| 156 | void SplashInitFrameShape(Splash * splash, int imageIndex); |
| 157 | |
| 158 | #define dbgprintf printf |
| 159 | |
| 160 | #endif |