author | ihse |
Wed, 28 Mar 2018 23:56:08 +0200 | |
changeset 49440 | 396ea30afbd5 |
parent 47216 | 71c04702a3d5 |
child 49843 | e0af66d6e968 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
49440 | 2 |
* Copyright (c) 2005, 2018, 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 |
||
26 |
#ifndef SPLASHSCREEN_IMPL_H |
|
27 |
#define SPLASHSCREEN_IMPL_H |
|
28 |
||
29 |
#include "splashscreen_config.h" |
|
30 |
#include "splashscreen_gfx.h" |
|
36907 | 31 |
#include "jni.h" |
2 | 32 |
|
49440 | 33 |
JNIEXPORT int JNICALL |
34 |
SplashLoadMemory(void *pdata, int size); /* requires preloading the file */ |
|
35 |
||
36 |
JNIEXPORT int JNICALL |
|
37 |
SplashLoadFile(const char *filename); // FIXME: range checking for SplashLoadMemory |
|
38 |
||
39 |
JNIEXPORT void JNICALL |
|
40 |
SplashInit(void); |
|
2 | 41 |
|
49440 | 42 |
JNIEXPORT void JNICALL |
43 |
SplashClose(void); |
|
2 | 44 |
|
49440 | 45 |
JNIEXPORT void JNICALL |
46 |
SplashSetScaleFactor(float); |
|
47 |
||
48 |
JNIEXPORT jboolean JNICALL |
|
49 |
SplashGetScaledImageName(const char*, const char*, |
|
36907 | 50 |
float*, char*, const size_t scaledImageNameLength); |
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23010
diff
changeset
|
51 |
|
49440 | 52 |
JNIEXPORT void JNICALL |
2 | 53 |
SplashSetFileJarName(const char* fileName, const char* jarName); |
54 |
||
49440 | 55 |
JNIEXPORT int JNICALL |
36907 | 56 |
SplashGetScaledImgNameMaxPstfixLen(const char*); |
2 | 57 |
typedef struct SplashImage |
58 |
{ |
|
59 |
rgbquad_t *bitmapBits; |
|
60 |
int delay; /* before next image display, in msec */ |
|
61 |
#if defined(WITH_WIN32) |
|
62 |
HRGN hRgn; |
|
63 |
#elif defined(WITH_X11) |
|
64 |
XRectangle *rects; |
|
65 |
int numRects; |
|
66 |
#endif |
|
67 |
} SplashImage; |
|
68 |
||
69 |
#define SPLASH_COLOR_MAP_SIZE 0x100 |
|
70 |
||
71 |
typedef struct Splash |
|
72 |
{ |
|
73 |
ImageFormat screenFormat; /* must be preset before image decoding */ |
|
74 |
DitherSettings dithers[3]; |
|
75 |
ImageFormat imageFormat; |
|
76 |
rgbquad_t colorMap[SPLASH_COLOR_MAP_SIZE]; |
|
77 |
int byteAlignment; /* must be preset before image decoding */ |
|
78 |
int maskRequired; /* must be preset before image decoding */ |
|
79 |
int width; /* in pixels */ |
|
80 |
int height; /* in pixels */ |
|
81 |
int frameCount; |
|
82 |
SplashImage *frames; /* dynamically allocated array of frame descriptors */ |
|
83 |
unsigned time; /* in msec, origin is not important */ |
|
84 |
rgbquad_t *overlayData; /* overlay image data, always rgbquads */ |
|
85 |
ImageRect overlayRect; |
|
86 |
ImageFormat overlayFormat; |
|
87 |
void *screenData; |
|
88 |
int screenStride; /* stored scanline length in bytes */ |
|
89 |
int currentFrame; // currentFrame==-1 means image is not loaded |
|
90 |
int loopCount; |
|
91 |
int x, y; |
|
92 |
rgbquad_t colorIndex[SPLASH_COLOR_MAP_SIZE]; |
|
93 |
int isVisible; |
|
94 |
char* fileName; /* stored in 16-bit unicode (jchars) */ |
|
95 |
int fileNameLen; |
|
96 |
char* jarName; /* stored in 16-bit unicode (jchars) */ |
|
97 |
int jarNameLen; |
|
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23010
diff
changeset
|
98 |
float scaleFactor; |
2 | 99 |
#if defined(WITH_WIN32) |
100 |
BOOL isLayered; |
|
101 |
HWND hWnd; |
|
102 |
HPALETTE hPalette; |
|
103 |
CRITICAL_SECTION lock; |
|
104 |
#elif defined(WITH_X11) |
|
105 |
int controlpipe[2]; |
|
106 |
Display *display; |
|
107 |
Window window; |
|
108 |
Screen *screen; |
|
109 |
Visual *visual; |
|
110 |
Colormap cmap; |
|
111 |
pthread_mutex_t lock; |
|
112 |
Cursor cursor; |
|
113 |
XWMHints* wmHints; |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
114 |
#elif defined(WITH_MACOSX) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
115 |
pthread_mutex_t lock; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
116 |
int controlpipe[2]; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
117 |
NSWindow * window; |
2 | 118 |
#endif |
119 |
} Splash; |
|
120 |
||
121 |
/* various shared and/or platform dependent splash screen functions */ |
|
122 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
123 |
/*************** Platform-specific ******************/ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
124 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
125 |
/* To be implemented in the platform-specific native code. */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
126 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
127 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
128 |
void SplashInitPlatform(Splash * splash); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
129 |
void SplashCreateThread(Splash * splash); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
130 |
void SplashCleanupPlatform(Splash * splash); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
131 |
void SplashDonePlatform(Splash * splash); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
132 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
133 |
unsigned SplashTime(); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
134 |
char* SplashConvertStringAlloc(const char* in, int *size); |
36907 | 135 |
jboolean SplashGetScaledImageName(const char* jarName, |
136 |
const char* fileName, float *scaleFactor, |
|
137 |
char *scaleImageName, const size_t scaledImageNameLength); |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
138 |
void SplashLock(Splash * splash); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
139 |
void SplashUnlock(Splash * splash); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
140 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
141 |
void SplashInitFrameShape(Splash * splash, int imageIndex); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
142 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
143 |
void SplashUpdate(Splash * splash); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
144 |
void SplashReconfigure(Splash * splash); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
145 |
void SplashClosePlatform(Splash * splash); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
146 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
147 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
148 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
149 |
/********************* Shared **********************/ |
2 | 150 |
Splash *SplashGetInstance(); |
151 |
||
152 |
int SplashIsStillLooping(Splash * splash); |
|
153 |
void SplashNextFrame(Splash * splash); |
|
154 |
void SplashStart(Splash * splash); |
|
155 |
void SplashDone(Splash * splash); |
|
156 |
||
157 |
void SplashUpdateScreenData(Splash * splash); |
|
158 |
||
159 |
void SplashCleanup(Splash * splash); |
|
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23010
diff
changeset
|
160 |
void SplashSetScaleFactor(float scaleFactor); |
36907 | 161 |
int SplashGetScaledImgNameMaxPstfixLen(const char *fileName); |
41776
71e2575dd727
8151787: Unify the HiDPI splash screen image naming convention
rchamyal
parents:
36907
diff
changeset
|
162 |
void cleanUp(char *fName, char *xName, char *pctName, float *scaleFactor); |
71e2575dd727
8151787: Unify the HiDPI splash screen image naming convention
rchamyal
parents:
36907
diff
changeset
|
163 |
jboolean GetScaledImageName(const char *fileName, char *scaledImgName, |
71e2575dd727
8151787: Unify the HiDPI splash screen image naming convention
rchamyal
parents:
36907
diff
changeset
|
164 |
float *scaleFactor, const size_t scaledImageLength); |
2 | 165 |
typedef struct SplashStream { |
166 |
int (*read)(void* pStream, void* pData, int nBytes); |
|
167 |
int (*peek)(void* pStream); |
|
168 |
void (*close)(void* pStream); |
|
169 |
union { |
|
170 |
struct { |
|
171 |
FILE* f; |
|
172 |
} stdio; |
|
173 |
struct { |
|
174 |
unsigned char* pData; |
|
175 |
unsigned char* pDataEnd; |
|
176 |
} mem; |
|
177 |
} arg; |
|
178 |
} SplashStream; |
|
179 |
||
180 |
int SplashStreamInitFile(SplashStream * stream, const char* filename); |
|
181 |
int SplashStreamInitMemory(SplashStream * stream, void * pData, int size); |
|
182 |
||
183 |
/* image decoding */ |
|
184 |
int SplashDecodeGifStream(Splash * splash, SplashStream * stream); |
|
185 |
int SplashDecodeJpegStream(Splash * splash, SplashStream * stream); |
|
186 |
int SplashDecodePngStream(Splash * splash, SplashStream * stream); |
|
187 |
||
188 |
/* utility functions */ |
|
189 |
||
190 |
int BitmapToYXBandedRectangles(ImageRect * pSrcRect, RECT_T * out); |
|
191 |
||
2608
fe2af56a83d3
6804996: JWS PNG Decoding Integer Overflow [V-flrhat2ln8]
bae
parents:
2
diff
changeset
|
192 |
#define SAFE_TO_ALLOC(c, sz) \ |
fe2af56a83d3
6804996: JWS PNG Decoding Integer Overflow [V-flrhat2ln8]
bae
parents:
2
diff
changeset
|
193 |
(((c) > 0) && ((sz) > 0) && \ |
fe2af56a83d3
6804996: JWS PNG Decoding Integer Overflow [V-flrhat2ln8]
bae
parents:
2
diff
changeset
|
194 |
((0xffffffffu / ((unsigned int)(c))) > (unsigned int)(sz))) |
fe2af56a83d3
6804996: JWS PNG Decoding Integer Overflow [V-flrhat2ln8]
bae
parents:
2
diff
changeset
|
195 |
|
2 | 196 |
#define dbgprintf printf |
197 |
||
198 |
#endif |