Path: blob/master/src/java.desktop/share/native/libsplashscreen/splashscreen_impl.h
41149 views
/*1* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef SPLASHSCREEN_IMPL_H26#define SPLASHSCREEN_IMPL_H2728#include "splashscreen_config.h"29#include "splashscreen_gfx.h"30#include "jni.h"3132JNIEXPORT int33SplashLoadMemory(void *pdata, int size); /* requires preloading the file */3435JNIEXPORT int36SplashLoadFile(const char *filename); // FIXME: range checking for SplashLoadMemory3738JNIEXPORT int39SplashInit(void);4041JNIEXPORT void42SplashClose(void);4344JNIEXPORT void45SplashSetScaleFactor(float);4647JNIEXPORT jboolean48SplashGetScaledImageName(const char*, const char*,49float*, char*, const size_t scaledImageNameLength);5051JNIEXPORT void52SplashSetFileJarName(const char* fileName, const char* jarName);5354JNIEXPORT int55SplashGetScaledImgNameMaxPstfixLen(const char*);56typedef struct SplashImage57{58rgbquad_t *bitmapBits;59int delay; /* before next image display, in msec */60#if defined(WITH_WIN32)61HRGN hRgn;62#elif defined(WITH_X11)63XRectangle *rects;64int numRects;65#endif66} SplashImage;6768#define SPLASH_COLOR_MAP_SIZE 0x1006970typedef struct Splash71{72ImageFormat screenFormat; /* must be preset before image decoding */73DitherSettings dithers[3];74ImageFormat imageFormat;75rgbquad_t colorMap[SPLASH_COLOR_MAP_SIZE];76int byteAlignment; /* must be preset before image decoding */77int maskRequired; /* must be preset before image decoding */78int width; /* in pixels */79int height; /* in pixels */80int frameCount;81SplashImage *frames; /* dynamically allocated array of frame descriptors */82unsigned time; /* in msec, origin is not important */83rgbquad_t *overlayData; /* overlay image data, always rgbquads */84ImageRect overlayRect;85ImageFormat overlayFormat;86void *screenData;87int screenStride; /* stored scanline length in bytes */88int currentFrame; // currentFrame==-1 means image is not loaded89int loopCount;90int x, y;91rgbquad_t colorIndex[SPLASH_COLOR_MAP_SIZE];92int isVisible;93char* fileName; /* stored in 16-bit unicode (jchars) */94int fileNameLen;95char* jarName; /* stored in 16-bit unicode (jchars) */96int jarNameLen;97float scaleFactor;98#if defined(WITH_WIN32)99BOOL isLayered;100HWND hWnd;101HPALETTE hPalette;102CRITICAL_SECTION lock;103#elif defined(WITH_X11)104int controlpipe[2];105Display *display;106Window window;107Screen *screen;108Visual *visual;109Colormap cmap;110pthread_mutex_t lock;111Cursor cursor;112XWMHints* wmHints;113#elif defined(WITH_MACOSX)114pthread_mutex_t lock;115int controlpipe[2];116NSWindow * window;117#endif118} Splash;119120/* various shared and/or platform dependent splash screen functions */121122/*************** Platform-specific ******************/123124/* To be implemented in the platform-specific native code. */125126127int SplashInitPlatform(Splash * splash);128void SplashCreateThread(Splash * splash);129void SplashCleanupPlatform(Splash * splash);130void SplashDonePlatform(Splash * splash);131132unsigned SplashTime();133char* SplashConvertStringAlloc(const char* in, int *size);134void SplashLock(Splash * splash);135void SplashUnlock(Splash * splash);136137void SplashInitFrameShape(Splash * splash, int imageIndex);138139void SplashUpdate(Splash * splash);140void SplashReconfigure(Splash * splash);141void SplashClosePlatform(Splash * splash);142143144145/********************* Shared **********************/146Splash *SplashGetInstance();147148int SplashIsStillLooping(Splash * splash);149void SplashNextFrame(Splash * splash);150void SplashStart(Splash * splash);151void SplashDone(Splash * splash);152153void SplashUpdateScreenData(Splash * splash);154155void SplashCleanup(Splash * splash);156157void cleanUp(char *fName, char *xName, char *pctName, float *scaleFactor);158jboolean GetScaledImageName(const char *fileName, char *scaledImgName,159float *scaleFactor, const size_t scaledImageLength);160typedef struct SplashStream {161int (*read)(void* pStream, void* pData, int nBytes);162int (*peek)(void* pStream);163void (*close)(void* pStream);164union {165struct {166FILE* f;167} stdio;168struct {169unsigned char* pData;170unsigned char* pDataEnd;171} mem;172} arg;173} SplashStream;174175int SplashStreamInitFile(SplashStream * stream, const char* filename);176int SplashStreamInitMemory(SplashStream * stream, void * pData, int size);177178/* image decoding */179int SplashDecodeGifStream(Splash * splash, SplashStream * stream);180int SplashDecodeJpegStream(Splash * splash, SplashStream * stream);181int SplashDecodePngStream(Splash * splash, SplashStream * stream);182183/* utility functions */184185int BitmapToYXBandedRectangles(ImageRect * pSrcRect, RECT_T * out);186187#define SAFE_TO_ALLOC(c, sz) \188(((c) > 0) && ((sz) > 0) && \189((0xffffffffu / ((unsigned int)(c))) > (unsigned int)(sz)))190191#define dbgprintf printf192193#endif194195196