src/java.desktop/share/native/libsplashscreen/splashscreen_gfx.h
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 25859 jdk/src/java.desktop/share/native/libsplashscreen/splashscreen_gfx.h@3317bb8137f4
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
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: 2
diff changeset
     2
 * Copyright (c) 2005, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef SPLASHSCREEN_GFX_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define SPLASHSCREEN_GFX_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/*  splashscreen_gfx is a general purpose code for converting pixmaps between various visuals
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
    it is not very effective, but is universal and concise */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "splashscreen_config.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
enum
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    BYTE_ORDER_LSBFIRST = 0,    // least significant byte first
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    BYTE_ORDER_MSBFIRST = 1,    // most significant byte first
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    BYTE_ORDER_NATIVE = 2       // exactly the same as the arch we're running this on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
        // will behave identical to _LSBFIRST or _MSBFIRST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        // but more effective
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
enum
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    DITHER_SIZE = 16,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    DITHER_MASK = 15
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
typedef struct DitherSettings
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    int numColors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    rgbquad_t colorTable[512];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    unsigned matrix[DITHER_SIZE][DITHER_SIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
} DitherSettings;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
/* this structure is similar to Xlib's Visual */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
typedef struct ImageFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    rgbquad_t mask[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    int shift[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    int depthBytes;             // 1,2,3 or 4. 3 is not supported for XCVT_BYTE_ORDER_NATIVE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    int byteOrder;              // see BYTE_ORDER_LSBFIRST, BYTE_ORDER_MSBFIRST or BYTE_ORDER_NATIVE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    int fixedBits;              // this value is or'ed with the color value on get or put, non-indexed only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                                // for indexed color, may be used when pre-decoding the colormap
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    rgbquad_t *colorMap;        // colormap should be pre-decoded (i.e. an array of rgbquads)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                                // when colormap is non-NULL, the source color is an index to a colormap, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                                // masks/shifts are unused.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    unsigned transparentColor;  // only for indexed colors. this is transparent color _INDEX_.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                                // use a more-than-max value when you don't need transparency.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    int premultiplied;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    DitherSettings *dithers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    int numColors;              // in the colormap, only for indexed color
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    rgbquad_t *colorIndex;      // color remapping index for dithering mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
} ImageFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
/* this structure defines a rectangular portion of an image buffer. height and/or width may be inverted. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
typedef struct ImageRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    int numLines;               // number of scanlines in the rectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    int numSamples;             // number of samples in the line
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    int stride;                 // distance between first samples of n'th and n+1'th scanlines, in bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    int depthBytes;             // distance between n'th and n+1'th sample in a scanline, in bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    void *pBits;                // points to sample 0, scanline 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    ImageFormat *format;        // format of the samples
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    int row, col, jump;         // dithering indexes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
} ImageRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
enum
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    CVT_COPY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    CVT_ALPHATEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    CVT_BLEND
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
#define  MAX_COLOR_VALUE    255
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
#define  QUAD_ALPHA_MASK    0xFF000000
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
#define  QUAD_RED_MASK      0x00FF0000
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#define  QUAD_GREEN_MASK    0x0000FF00
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
#define  QUAD_BLUE_MASK     0x000000FF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
#define  QUAD_ALPHA_SHIFT   24
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
#define  QUAD_RED_SHIFT     16
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
#define  QUAD_GREEN_SHIFT   8
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
#define  QUAD_BLUE_SHIFT    0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
#define QUAD_ALPHA(value) (((value)&QUAD_ALPHA_MASK)>>QUAD_ALPHA_SHIFT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
#define QUAD_RED(value) (((value)&QUAD_RED_MASK)>>QUAD_RED_SHIFT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
#define QUAD_GREEN(value) (((value)&QUAD_GREEN_MASK)>>QUAD_GREEN_SHIFT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
#define QUAD_BLUE(value) (((value)&QUAD_BLUE_MASK)>>QUAD_BLUE_SHIFT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
#define MAKE_QUAD(r,g,b,a) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    (((a)<<QUAD_ALPHA_SHIFT)&QUAD_ALPHA_MASK)| \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    (((r)<<QUAD_RED_SHIFT)&QUAD_RED_MASK)| \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    (((g)<<QUAD_GREEN_SHIFT)&QUAD_GREEN_MASK)| \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    (((b)<<QUAD_BLUE_SHIFT)&QUAD_BLUE_MASK) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
/* alpha testing threshold. what's >= the threshold is considered non-transparent when doing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
   conversion operation with CVT_ALPHATEST and when generating shapes/regions with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
   BitmapToYXBandedRectangles */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
#define ALPHA_THRESHOLD     0x80000000
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
void initRect(ImageRect * pRect, int x, int y, int width, int height, int jump,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        int stride, void *pBits, ImageFormat * format);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
int convertRect2(ImageRect * pSrcRect, ImageRect * pDstRect, int mode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        ImageRect * pSrcRect2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
int convertRect(ImageRect * pSrcRect, ImageRect * pDstRect, int mode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
void convertLine(void *pSrc, int incSrc, void *pDst, int incDst, int n,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        ImageFormat * srcFormat, ImageFormat * dstFormat, int mode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        void *pSrc2, int incSrc2, ImageFormat * srcFormat2, int row, int col);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
void initFormat(ImageFormat * format, int redMask, int greenMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        int blueMask, int alphaMask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
int fillRect(rgbquad_t color, ImageRect * pDstRect);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
void dumpFormat(ImageFormat * format);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
void optimizeFormat(ImageFormat * format);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
void initDither(DitherSettings * pDither, int numColors, int scale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
int quantizeColors(int maxNumColors, int *numColors);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
void initColorCube(int *numColors, rgbquad_t * pColorMap,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        DitherSettings * pDithers, rgbquad_t * colorIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
int platformByteOrder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
#endif