Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/awt/splashscreen/splashscreen_impl.h
38918 views
/*1* Copyright (c) 2005, 2012, 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"3031SPLASHEXPORT int SplashLoadMemory(void *pdata, int size); /* requires preloading the file */32SPLASHEXPORT int SplashLoadFile(const char *filename); // FIXME: range checking for SplashLoadMemory3334SPLASHEXPORT void SplashInit(void);35SPLASHEXPORT void SplashClose(void);3637SPLASHEXPORT void SplashSetScaleFactor(float);38SPLASHEXPORT char* SplashGetScaledImageName(const char*, const char*, float*);3940SPLASHEXPORT void41SplashSetFileJarName(const char* fileName, const char* jarName);4243typedef struct SplashImage44{45rgbquad_t *bitmapBits;46int delay; /* before next image display, in msec */47#if defined(WITH_WIN32)48HRGN hRgn;49#elif defined(WITH_X11)50XRectangle *rects;51int numRects;52#endif53} SplashImage;5455#define SPLASH_COLOR_MAP_SIZE 0x1005657typedef struct Splash58{59ImageFormat screenFormat; /* must be preset before image decoding */60DitherSettings dithers[3];61ImageFormat imageFormat;62rgbquad_t colorMap[SPLASH_COLOR_MAP_SIZE];63int byteAlignment; /* must be preset before image decoding */64int maskRequired; /* must be preset before image decoding */65int width; /* in pixels */66int height; /* in pixels */67int frameCount;68SplashImage *frames; /* dynamically allocated array of frame descriptors */69unsigned time; /* in msec, origin is not important */70rgbquad_t *overlayData; /* overlay image data, always rgbquads */71ImageRect overlayRect;72ImageFormat overlayFormat;73void *screenData;74int screenStride; /* stored scanline length in bytes */75int currentFrame; // currentFrame==-1 means image is not loaded76int loopCount;77int x, y;78rgbquad_t colorIndex[SPLASH_COLOR_MAP_SIZE];79int isVisible;80char* fileName; /* stored in 16-bit unicode (jchars) */81int fileNameLen;82char* jarName; /* stored in 16-bit unicode (jchars) */83int jarNameLen;84float scaleFactor;85#if defined(WITH_WIN32)86BOOL isLayered;87HWND hWnd;88HPALETTE hPalette;89CRITICAL_SECTION lock;90#elif defined(WITH_X11)91int controlpipe[2];92Display *display;93Window window;94Screen *screen;95Visual *visual;96Colormap cmap;97pthread_mutex_t lock;98Cursor cursor;99XWMHints* wmHints;100#elif defined(WITH_MACOSX)101pthread_mutex_t lock;102int controlpipe[2];103NSWindow * window;104#endif105} Splash;106107/* various shared and/or platform dependent splash screen functions */108109/*************** Platform-specific ******************/110111/* To be implemented in the platform-specific native code. */112113114void SplashInitPlatform(Splash * splash);115void SplashCreateThread(Splash * splash);116void SplashCleanupPlatform(Splash * splash);117void SplashDonePlatform(Splash * splash);118119unsigned SplashTime();120char* SplashConvertStringAlloc(const char* in, int *size);121char* SplashGetScaledImageName(const char* jarName,122const char* fileName, float *scaleFactor);123124void SplashLock(Splash * splash);125void SplashUnlock(Splash * splash);126127void SplashInitFrameShape(Splash * splash, int imageIndex);128129void SplashUpdate(Splash * splash);130void SplashReconfigure(Splash * splash);131void SplashClosePlatform(Splash * splash);132133134135/********************* Shared **********************/136Splash *SplashGetInstance();137138int SplashIsStillLooping(Splash * splash);139void SplashNextFrame(Splash * splash);140void SplashStart(Splash * splash);141void SplashDone(Splash * splash);142143void SplashUpdateScreenData(Splash * splash);144145void SplashCleanup(Splash * splash);146void SplashSetScaleFactor(float scaleFactor);147148149typedef struct SplashStream {150int (*read)(void* pStream, void* pData, int nBytes);151int (*peek)(void* pStream);152void (*close)(void* pStream);153union {154struct {155FILE* f;156} stdio;157struct {158unsigned char* pData;159unsigned char* pDataEnd;160} mem;161} arg;162} SplashStream;163164int SplashStreamInitFile(SplashStream * stream, const char* filename);165int SplashStreamInitMemory(SplashStream * stream, void * pData, int size);166167/* image decoding */168int SplashDecodeGifStream(Splash * splash, SplashStream * stream);169int SplashDecodeJpegStream(Splash * splash, SplashStream * stream);170int SplashDecodePngStream(Splash * splash, SplashStream * stream);171172/* utility functions */173174int BitmapToYXBandedRectangles(ImageRect * pSrcRect, RECT_T * out);175176#define SAFE_TO_ALLOC(c, sz) \177(((c) > 0) && ((sz) > 0) && \178((0xffffffffu / ((unsigned int)(c))) > (unsigned int)(sz)))179180#define dbgprintf printf181182#endif183184185