jdk/src/java.desktop/share/native/libawt/awt/image/awt_parseImage.h
author prr
Fri, 19 Sep 2014 09:41:05 -0700
changeset 26751 70bac69b37c9
parent 25859 jdk/src/java.desktop/share/native/libawt/sun/awt/image/awt_parseImage.h@3317bb8137f4
permissions -rw-r--r--
8056216: Remove "sun" directory layer from libawt and common Reviewed-by: erikj, ihse, coffeys
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20799
diff changeset
     2
 * Copyright (c) 1997, 2013, 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 AWT_PARSE_IMAGE_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define AWT_PARSE_IMAGE_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include <jni_util.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/***************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *                               Definitions                               *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 ***************************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#ifndef TRUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#define TRUE (1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#ifndef FALSE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#define FALSE (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
typedef enum {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    IMG_SUCCESS=0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    IMG_FAILURE=-1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
} ImgStatus_t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#define UNKNOWN_DATA_TYPE  0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define BYTE_DATA_TYPE     1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#define SHORT_DATA_TYPE    2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#define INT_DATA_TYPE      3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#define UNKNOWN_RASTER_TYPE   0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#define COMPONENT_RASTER_TYPE 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#define BANDED_RASTER_TYPE    2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#define PACKED_RASTER_TYPE    3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#define UNKNOWN_CM_TYPE   0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#define COMPONENT_CM_TYPE 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
#define DIRECT_CM_TYPE    2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
#define INDEX_CM_TYPE     3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
#define PACKED_CM_TYPE    4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
/* Packing types */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define UNKNOWN_PACKING         0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#define BYTE_COMPONENTS         0x1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#define SHORT_COMPONENTS        0x2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
#define PACKED_INT              0x3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#define PACKED_SHORT            0x4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
#define PACKED_BYTE             0x5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
/* Interleaving */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#define INTERLEAVED     0x10
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
#define BANDED          0x20
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#define SINGLE_BAND     0x30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
#define PACKED_BAND     0x40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
#define BYTE_INTERLEAVED   (BYTE_COMPONENTS  | INTERLEAVED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
#define SHORT_INTERLEAVED  (SHORT_COMPONENTS | INTERLEAVED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#define BYTE_SINGLE_BAND   (BYTE_COMPONENTS  | SINGLE_BAND)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
#define BYTE_PACKED_BAND   (BYTE_COMPONENTS  | PACKED_BAND)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
#define SHORT_SINGLE_BAND  (SHORT_COMPONENTS | SINGLE_BAND)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#define BYTE_BANDED        (BYTE_COMPONENTS  | BANDED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
#define SHORT_BANDED       (SHORT_COMPONENTS | BANDED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#define PACKED_BYTE_INTER  (PACKED_BYTE      | INTERLEAVED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
#define PACKED_SHORT_INTER (PACKED_SHORT     | INTERLEAVED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#define PACKED_INT_INTER   (PACKED_INT       | INTERLEAVED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
#define MAX_NUMBANDS 32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
/* Struct that holds information about a SinglePixelPackedModel object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    jint maskArray[MAX_NUMBANDS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    jint offsets[MAX_NUMBANDS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    jint nBits[MAX_NUMBANDS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    jint  maxBitSize;
16096
a4397a7163e3 8002325: Improve management of images
bae
parents: 5506
diff changeset
    98
    jint isUsed; // flag to indicate whether the raster sample model is SPPSM
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
} SPPSampleModelS_t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
/* Struct that holds information for the Raster object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    jobject jraster;       /* The raster object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    jobject jdata;         /* Data storage object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    jobject jsampleModel;   /* The sample model */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    SPPSampleModelS_t sppsm; /* SinglePixelPackedSampleModel mask/offsets */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    jint *chanOffsets;      /* Array of channel offsets (or bit offsets) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    int width;             /* Width of the raster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    int height;            /* Height of the raster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    int minX;              /* origin of this raster x */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    int minY;              /* origin of this raster x */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    int baseOriginX;       /* origin of base raster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    int baseOriginY;       /* origin of base raster x */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    int baseRasterWidth;   /* size of baseRaster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    int baseRasterHeight;  /* size of baseRaster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    int numDataElements;   /* Number of data bands in raster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    int numBands;          /* Number of bands in the raster  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    int scanlineStride;    /* Scanline Stride */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    int pixelStride;       /* Pixel stride (or pixel bit stride) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    int dataIsShared;      /* If TRUE, data is shared */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    int rasterType;        /* Type of raster */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    int dataType;          /* Data type of the raster data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    int dataSize;          /* Number of bytes per data element */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    int type;               /* Raster type */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
} RasterS_t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
/* Struct that holds information about the ColorModel object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    jobject jrgb;          /* For ICM, rgb lut object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    jobject jcmodel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    jobject jcspace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    jint *nBits;            /* Number of bits per component */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    int cmType;            /* Type of color model */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    int isDefaultCM;       /* If TRUE, it is the default color model */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    int isDefaultCompatCM; /* If TRUE, it is compatible with the default CM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                           /* Might be 4 byte and band order different */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    int is_sRGB;           /* If TRUE, the color space is sRGB */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    int numComponents;     /* Total number of components */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    int supportsAlpha;     /* If it supports alpha */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    int isAlphaPre;        /* If TRUE, alpha is premultiplied */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    int csType;            /* Type of ColorSpace */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    int transparency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    int maxNbits;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    int transIdx;          /* For ICM, transparent pixel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    int mapSize;           /* For ICM, size of the lut */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
} ColorModelS_t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    int *colorOrder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    int channelOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    int dataOffset;        /* # bytes into the data array */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    int sStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    int pStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    int packing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    int numChans;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    int alphaIndex;        /* -1 if no alpha */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    int needToExpand;      /* If true, the pixels are packed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    int expandToNbits;     /* If needToExpand, how many bits to allocate */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
} HintS_t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
/* Struct that holds information for the BufferedImage object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    jobject jimage;        /* The BufferedImage object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    RasterS_t raster;      /* The raster structure */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    ColorModelS_t cmodel;  /* The color model structure */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    HintS_t hints;         /* Hint structure */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    int     imageType;     /* Type of image */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
} BufImageS_t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
/***************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
 *                      Function Prototypes                                *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 ***************************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
int awt_parseImage(JNIEnv *env, jobject jimage, BufImageS_t **imagePP,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                   int handleCustom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
int awt_parseRaster(JNIEnv *env, jobject jraster, RasterS_t *rasterP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                         ColorModelS_t *cmP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
void awt_freeParsedRaster(RasterS_t *rasterP, int freeRasterP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
void awt_freeParsedImage(BufImageS_t *imageP, int freeImageP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
20799
4820649a142d 8014093: Improve parsing of images
bae
parents: 16096
diff changeset
   191
int awt_getPixels(JNIEnv *env, RasterS_t *rasterP, void *bufferP);
4820649a142d 8014093: Improve parsing of images
bae
parents: 16096
diff changeset
   192
4820649a142d 8014093: Improve parsing of images
bae
parents: 16096
diff changeset
   193
int awt_setPixels(JNIEnv *env, RasterS_t *rasterP, void *bufferP);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
#endif /* AWT_PARSE_IMAGE_H */