jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c
author ceisserer
Tue, 22 Oct 2013 13:47:45 -0700
changeset 21233 a36ed36d3209
parent 20425 5964c0fc5cc0
child 22597 7515a991bb37
permissions -rw-r--r--
8023483: sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java failed with jdk8 on linux platforms Reviewed-by: prr, bae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8506
diff changeset
     2
 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
     4
 *
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6374
e214162c907e 6982137: Rebranding pass 2 - missed copyright changes
ohair
parents: 5579
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
6374
e214162c907e 6982137: Rebranding pass 2 - missed copyright changes
ohair
parents: 5579
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    10
 *
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    15
 * accompanied this code).
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    16
 *
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    20
 *
6374
e214162c907e 6982137: Rebranding pass 2 - missed copyright changes
ohair
parents: 5579
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e214162c907e 6982137: Rebranding pass 2 - missed copyright changes
ohair
parents: 5579
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
e214162c907e 6982137: Rebranding pass 2 - missed copyright changes
ohair
parents: 5579
diff changeset
    23
 * questions.
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    24
 */
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    25
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    26
#include "X11SurfaceData.h"
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    27
#include <jni.h>
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    28
#include <math.h>
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    29
#include "Region.h"
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    30
#include "fontscalerdefs.h"
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    31
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    32
#include <X11/extensions/Xrender.h>
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    33
20416
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
    34
#ifdef __linux__
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
    35
    #include <sys/utsname.h>
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
    36
#endif
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
    37
7933
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    38
/* On Solaris 10 updates 8, 9, the render.h file defines these
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    39
 * protocol values but does not define the structs in Xrender.h.
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    40
 * Thus in order to get these always defined on Solaris 10
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    41
 * we will undefine the symbols if we have determined via the
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    42
 * makefiles that Xrender.h is lacking the structs. This will
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    43
 * trigger providing our own definitions as on earlier updates.
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    44
 * We could assume that *all* Solaris 10 update versions will lack the updated
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    45
 * Xrender.h and do this based solely on O/S being any 5.10 version, but this
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    46
 * could still change and we'd be broken again as we'd be re-defining them.
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    47
 */
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    48
#ifdef SOLARIS10_NO_XRENDER_STRUCTS
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    49
#undef X_RenderCreateLinearGradient
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    50
#undef X_RenderCreateRadialGradient
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    51
#endif
afae9398b405 7001056: JDK 7 fails on to build on Solaris 10 update 9 - updated Xrender header files
prr
parents: 6374
diff changeset
    52
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    53
#ifndef X_RenderCreateLinearGradient
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    54
typedef struct _XLinearGradient {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    55
    XPointFixed p1;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    56
    XPointFixed p2;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    57
} XLinearGradient;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    58
#endif
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    59
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    60
#ifndef X_RenderCreateRadialGradient
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    61
typedef struct _XCircle {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    62
    XFixed x;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    63
    XFixed y;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    64
    XFixed radius;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    65
} XCircle;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    66
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    67
typedef struct _XRadialGradient {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    68
    XCircle inner;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    69
    XCircle outer;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    70
} XRadialGradient;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    71
#endif
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    72
9760
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
    73
#include <dlfcn.h>
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
    74
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    75
#ifdef __solaris__
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    76
/* Solaris 10 will not have these symbols at runtime */
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    77
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    78
typedef Picture (*XRenderCreateLinearGradientFuncType)
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    79
                                     (Display *dpy,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    80
                                     const XLinearGradient *gradient,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    81
                                     const XFixed *stops,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    82
                                     const XRenderColor *colors,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    83
                                     int nstops);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    84
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    85
typedef Picture (*XRenderCreateRadialGradientFuncType)
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    86
                                     (Display *dpy,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    87
                                     const XRadialGradient *gradient,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    88
                                     const XFixed *stops,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    89
                                     const XRenderColor *colors,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    90
                                     int nstops);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    91
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    92
static
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    93
XRenderCreateLinearGradientFuncType XRenderCreateLinearGradientFunc = NULL;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    94
static
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    95
 XRenderCreateRadialGradientFuncType XRenderCreateRadialGradientFunc = NULL;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    96
#endif
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    97
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    98
#define BUILD_TRANSFORM_MATRIX(TRANSFORM, M00, M01, M02, M10, M11, M12)                        \
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
    99
    {                                                                                          \
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   100
      TRANSFORM.matrix[0][0] = M00;                                                            \
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   101
      TRANSFORM.matrix[0][1] = M01;                                                            \
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   102
      TRANSFORM.matrix[0][2] = M02;                                                            \
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   103
      TRANSFORM.matrix[1][0] = M10;                                                            \
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   104
      TRANSFORM.matrix[1][1] = M11;                                                            \
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   105
      TRANSFORM.matrix[1][2] = M12;                                                            \
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   106
      TRANSFORM.matrix[2][0] = 0;                                                              \
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   107
      TRANSFORM.matrix[2][1] = 0;                                                              \
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   108
      TRANSFORM.matrix[2][2] = 1<<16;                                                          \
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   109
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   110
9760
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   111
/* The xrender pipleine requires libXrender.so version 0.9.3 or later. */
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   112
#define REQUIRED_XRENDER_VER1 0
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   113
#define REQUIRED_XRENDER_VER2 9
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   114
#define REQUIRED_XRENDER_VER3 3
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   115
9760
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   116
#define PKGINFO_LINE_LEN_MAX 256
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   117
#define PKGINFO_LINE_CNT_MAX 50
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   118
19009
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   119
/*
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   120
 * X protocol uses (u_int16)length to specify the length in 4 bytes quantities
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   121
 * of the whole request.  Both XRenderFillRectangles() and XFillRectangles()
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   122
 * have provisions to fragment into several requests if the number of rectangles
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   123
 * plus the current x request does not fit into 65535*4 bytes.  While
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   124
 * XRenderCreateLinearGradient() and XRenderCreateRadialGradient() have
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   125
 * provisions to gracefully degrade if the resulting request would exceed
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   126
 * 65535*4 bytes.
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   127
 *
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   128
 * Below, we define a cap of 65535*4 bytes for the maximum X request payload
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   129
 * allowed for Non-(XRenderFillRectangles() or XFillRectangles()) API calls,
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   130
 * just to be conservative.  This is offset by the size of our maximum x*Req
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   131
 * type in this compilation unit, which is xRenderCreateRadiaGradientReq.
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   132
 *
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   133
 * Note that sizeof(xRenderCreateRadiaGradientReq) = 36
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   134
 */
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   135
#define MAX_PAYLOAD (262140u - 36u)
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   136
#define MAXUINT (0xffffffffu)
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   137
20416
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   138
static jboolean IsXRenderAvailable(jboolean verbose, jboolean ignoreLinuxVersion) {
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   139
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   140
    void *xrenderlib;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   141
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   142
    int major_opcode, first_event, first_error;
9760
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   143
    jboolean available = JNI_TRUE;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   144
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   145
    if (!XQueryExtension(awt_display, "RENDER",
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   146
                         &major_opcode, &first_event, &first_error)) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   147
        return JNI_FALSE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   148
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   149
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   150
#ifdef __solaris__
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   151
    xrenderlib = dlopen("libXrender.so",RTLD_GLOBAL|RTLD_LAZY);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   152
    if (xrenderlib != NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   153
9760
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   154
      XRenderCreateLinearGradientFunc =
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   155
        (XRenderCreateLinearGradientFuncType)
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   156
        dlsym(xrenderlib, "XRenderCreateLinearGradient");
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   157
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   158
      XRenderCreateRadialGradientFunc =
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   159
        (XRenderCreateRadialGradientFuncType)
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   160
        dlsym(xrenderlib, "XRenderCreateRadialGradient");
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   161
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   162
      if (XRenderCreateLinearGradientFunc == NULL ||
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   163
          XRenderCreateRadialGradientFunc == NULL)
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   164
      {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   165
        available = JNI_FALSE;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   166
      }
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   167
      dlclose(xrenderlib);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   168
    } else {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   169
      available = JNI_FALSE;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   170
    }
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   171
#else
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   172
    Dl_info info;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   173
    jboolean versionInfoIsFound = JNI_FALSE;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   174
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   175
    memset(&info, 0, sizeof(Dl_info));
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   176
    if (dladdr(&XRenderChangePicture, &info) && info.dli_fname != NULL) {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   177
      char pkgInfoPath[FILENAME_MAX];
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   178
      char *pkgFileName = "/pkgconfig/xrender.pc";
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   179
      size_t pkgFileNameLen = strlen(pkgFileName);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   180
      size_t pos, len = strlen(info.dli_fname);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   181
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   182
      pos = len;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   183
      while (pos > 0 && info.dli_fname[pos] != '/') {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   184
        pos -= 1;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   185
      }
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   186
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   187
      if (pos > 0 && pos < (FILENAME_MAX - pkgFileNameLen - 1)) {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   188
        struct stat stat_info;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   189
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   190
        // compose absolute filename to package config
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   191
        strncpy(pkgInfoPath, info.dli_fname, pos);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   192
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   193
        strcpy(pkgInfoPath + pos, pkgFileName);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   194
        pkgInfoPath[pos + pkgFileNameLen] = '\0';
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   195
9760
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   196
        // check whether the config file exist and is a regular file
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   197
        if ((stat(pkgInfoPath, &stat_info)== 0) &&
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   198
            S_ISREG(stat_info.st_mode))
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   199
        {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   200
          FILE *fp = fopen(pkgInfoPath, "r");
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   201
          if (fp != NULL) {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   202
            char line[PKGINFO_LINE_LEN_MAX];
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   203
            int lineCount = PKGINFO_LINE_CNT_MAX;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   204
            char *versionPrefix = "Version: ";
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   205
            size_t versionPrefixLen = strlen(versionPrefix);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   206
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   207
            // look for version
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   208
            while(fgets(line,sizeof(line),fp) != NULL && --lineCount > 0) {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   209
              size_t lineLen = strlen(line);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   210
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   211
              if (lineLen > versionPrefixLen &&
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   212
                  strncmp(versionPrefix, line, versionPrefixLen) == 0)
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   213
              {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   214
                int v1 = 0, v2 = 0, v3 = 0;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   215
                int numNeeded = 3,numProcessed;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   216
                char* version = line + versionPrefixLen;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   217
                numProcessed = sscanf(version, "%d.%d.%d", &v1, &v2, &v3);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   218
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   219
                if (numProcessed == numNeeded) {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   220
                  // we successfuly read the library version
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   221
                  versionInfoIsFound = JNI_TRUE;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   222
9760
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   223
                  if (REQUIRED_XRENDER_VER1 == v1 &&
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   224
                      ((REQUIRED_XRENDER_VER2 > v2) ||
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   225
                       ((REQUIRED_XRENDER_VER2 == v2) && (REQUIRED_XRENDER_VER3 > v3))))
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   226
                  {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   227
                    available = JNI_FALSE;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   228
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   229
                    if (verbose) {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   230
                      printf("INFO: the version %d.%d.%d of libXrender.so is "
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   231
                             "not supported.\n\tSee release notes for more details.\n",
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   232
                             v1, v2, v3);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   233
                      fflush(stdout);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   234
                    }
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   235
                  } else {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   236
                    if (verbose) {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   237
                      printf("INFO: The version of libXrender.so "
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   238
                             "is detected as %d.%d%d\n", v1, v2, v3);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   239
                      fflush(stdout);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   240
                    }
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   241
                  }
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   242
                }
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   243
                break;
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   244
              }
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   245
            }
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   246
            fclose(fp);
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   247
          }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   248
        }
9760
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   249
      }
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   250
    }
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   251
    if (verbose && !versionInfoIsFound) {
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   252
      printf("WARNING: The version of libXrender.so cannot be detected.\n,"
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   253
             "The pipe line will be enabled, but note that versions less than 0.9.3\n"
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   254
             "may cause hangs and crashes\n"
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   255
             "\tSee the release notes for more details.\n");
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   256
      fflush(stdout);
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   257
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   258
#endif
9760
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   259
20416
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   260
#ifdef __linux__
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   261
    /*
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   262
     * Check for Linux >= 3.5 (Ubuntu 12.04.02 LTS) to avoid hitting
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   263
     * https://bugs.freedesktop.org/show_bug.cgi?id=48045
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   264
     */
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   265
    struct utsname utsbuf;
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   266
    if(uname(&utsbuf) >= 0) {
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   267
        int major, minor, revision;
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   268
        if(sscanf(utsbuf.release, "%i.%i.%i", &major, &minor, &revision) == 3) {
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   269
            if(major < 3 || (major == 3 && minor < 5)) {
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   270
                if(!ignoreLinuxVersion) {
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   271
                    available = JNI_FALSE;
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   272
                }
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   273
                else if(verbose) {
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   274
                 printf("WARNING: Linux < 3.5 detected.\n"
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   275
                        "The pipeline will be enabled, but graphical "
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   276
                        "artifacts can occur with old graphic drivers.\n"
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   277
                        "See the release notes for more details.\n");
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   278
                        fflush(stdout);
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   279
                }
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   280
            }
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   281
        }
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   282
    }
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   283
#endif // __linux__
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   284
9760
5c5883cf6c96 7032904: XRender: Java2Demo : Infinite loop in Java_sun_java2d_loops_MaskBlit_MaskBlit on OEL 5.6 x64
bae
parents: 9050
diff changeset
   285
    return available;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   286
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   287
/*
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   288
 * Class:     sun_awt_X11GraphicsEnvironment
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   289
 * Method:    initGLX
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   290
 * Signature: ()Z
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   291
 */
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   292
JNIEXPORT jboolean JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   293
Java_sun_awt_X11GraphicsEnvironment_initXRender
20416
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   294
(JNIEnv *env, jclass x11ge, jboolean verbose, jboolean ignoreLinuxVersion)
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   295
{
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   296
#ifndef HEADLESS
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   297
    static jboolean xrenderAvailable = JNI_FALSE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   298
    static jboolean firstTime = JNI_TRUE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   299
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   300
    if (firstTime) {
19171
14d41f09941b 8014883: java.awt.container.add(component comp object constraints) doesn't work as expected on some linux platforms
prr
parents: 19009
diff changeset
   301
#ifdef DISABLE_XRENDER_BY_DEFAULT
14d41f09941b 8014883: java.awt.container.add(component comp object constraints) doesn't work as expected on some linux platforms
prr
parents: 19009
diff changeset
   302
        if (verbose == JNI_FALSE) {
14d41f09941b 8014883: java.awt.container.add(component comp object constraints) doesn't work as expected on some linux platforms
prr
parents: 19009
diff changeset
   303
            xrenderAvailable = JNI_FALSE;
14d41f09941b 8014883: java.awt.container.add(component comp object constraints) doesn't work as expected on some linux platforms
prr
parents: 19009
diff changeset
   304
            firstTime = JNI_FALSE;
14d41f09941b 8014883: java.awt.container.add(component comp object constraints) doesn't work as expected on some linux platforms
prr
parents: 19009
diff changeset
   305
            return xrenderAvailable;
14d41f09941b 8014883: java.awt.container.add(component comp object constraints) doesn't work as expected on some linux platforms
prr
parents: 19009
diff changeset
   306
        }
14d41f09941b 8014883: java.awt.container.add(component comp object constraints) doesn't work as expected on some linux platforms
prr
parents: 19009
diff changeset
   307
#endif
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   308
        AWT_LOCK();
20416
c09e67746b08 8007386: On physical machine (video card is Intel Q45) the text is blank.
prr
parents: 19782
diff changeset
   309
        xrenderAvailable = IsXRenderAvailable(verbose, ignoreLinuxVersion);
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   310
        AWT_UNLOCK();
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   311
        firstTime = JNI_FALSE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   312
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   313
    return xrenderAvailable;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   314
#else
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   315
    return JNI_FALSE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   316
#endif /* !HEADLESS */
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   317
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   318
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   319
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   320
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   321
Java_sun_java2d_xr_XRBackendNative_initIDs(JNIEnv *env, jclass cls) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   322
    char *maskData;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   323
    XImage* defaultImg;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   324
    jfieldID maskImgID;
19006
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 17404
diff changeset
   325
    jlong fmt8;
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 17404
diff changeset
   326
    jlong fmt32;
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 17404
diff changeset
   327
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   328
    jfieldID a8ID = (*env)->GetStaticFieldID(env, cls, "FMTPTR_A8", "J");
20425
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 20418
diff changeset
   329
    if (a8ID == NULL) {
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 20418
diff changeset
   330
        return;
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 20418
diff changeset
   331
    }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   332
    jfieldID argb32ID = (*env)->GetStaticFieldID(env, cls, "FMTPTR_ARGB32", "J");
20425
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 20418
diff changeset
   333
    if (argb32ID == NULL) {
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 20418
diff changeset
   334
        return;
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 20418
diff changeset
   335
    }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   336
19006
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 17404
diff changeset
   337
    if (awt_display == (Display *)NULL) {
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 17404
diff changeset
   338
        return;
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 17404
diff changeset
   339
    }
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 17404
diff changeset
   340
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 17404
diff changeset
   341
    fmt8 = ptr_to_jlong(XRenderFindStandardFormat(awt_display, PictStandardA8));
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 17404
diff changeset
   342
    fmt32 = ptr_to_jlong(XRenderFindStandardFormat(awt_display, PictStandardARGB32));
fcda25164f7d 7196866: CTW fails on all Solaris platforms
prr
parents: 17404
diff changeset
   343
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   344
    (*env)->SetStaticLongField(env, cls, a8ID, fmt8);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   345
    (*env)->SetStaticLongField(env, cls, argb32ID, fmt32);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   346
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   347
    maskData = (char *) malloc(32*32);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   348
    if (maskData == NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   349
       return;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   350
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   351
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   352
    defaultImg = XCreateImage(awt_display, NULL, 8, ZPixmap, 0, maskData, 32, 32, 8, 0);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   353
    defaultImg->data = maskData; //required?
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   354
    maskImgID = (*env)->GetStaticFieldID(env, cls, "MASK_XIMG", "J");
20425
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 20418
diff changeset
   355
    if (maskImgID == NULL) {
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 20418
diff changeset
   356
       return;
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 20418
diff changeset
   357
    }
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 20418
diff changeset
   358
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   359
    (*env)->SetStaticLongField(env, cls, maskImgID, ptr_to_jlong(defaultImg));
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   360
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   361
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   362
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   363
Java_sun_java2d_xr_XRBackendNative_freeGC
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   364
 (JNIEnv *env, jobject this, jlong gc) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   365
    XFreeGC(awt_display, (GC) jlong_to_ptr(gc));
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   366
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   367
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   368
JNIEXPORT jlong JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   369
Java_sun_java2d_xr_XRBackendNative_createGC
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   370
 (JNIEnv *env, jobject this, jint drawable) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   371
  GC xgc = XCreateGC(awt_display, (Drawable) drawable, 0L, NULL);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   372
  return ptr_to_jlong(xgc);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   373
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   374
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   375
JNIEXPORT jint JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   376
Java_sun_java2d_xr_XRBackendNative_createPixmap(JNIEnv *env, jobject this,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   377
                                                jint drawable, jint depth,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   378
                                                jint width, jint height) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   379
    return (jint) XCreatePixmap(awt_display, (Drawable) drawable,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   380
                                width, height, depth);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   381
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   382
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   383
JNIEXPORT jint JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   384
Java_sun_java2d_xr_XRBackendNative_createPictureNative
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   385
 (JNIEnv *env, jclass cls, jint drawable, jlong formatPtr) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   386
  XRenderPictureAttributes pict_attr;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   387
  return XRenderCreatePicture(awt_display, (Drawable) drawable,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   388
                              (XRenderPictFormat *) jlong_to_ptr(formatPtr),
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   389
                               0, &pict_attr);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   390
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   391
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   392
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   393
Java_sun_java2d_xr_XRBackendNative_freePicture
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   394
 (JNIEnv *env, jobject this, jint picture) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   395
      XRenderFreePicture(awt_display, (Picture) picture);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   396
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   397
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   398
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   399
Java_sun_java2d_xr_XRBackendNative_freePixmap
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   400
 (JNIEnv *env, jobject this, jint pixmap) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   401
   XFreePixmap(awt_display, (Pixmap) pixmap);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   402
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   403
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   404
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   405
Java_sun_java2d_xr_XRBackendNative_setPictureRepeat
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   406
 (JNIEnv *env, jobject this, jint picture, jint repeat) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   407
    XRenderPictureAttributes pict_attr;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   408
    pict_attr.repeat = repeat;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   409
    XRenderChangePicture (awt_display, (Picture) picture, CPRepeat, &pict_attr);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   410
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   411
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   412
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   413
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   414
Java_sun_java2d_xr_XRBackendNative_setGCExposures
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   415
 (JNIEnv *env, jobject this, jlong gc, jboolean exposure) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   416
    XSetGraphicsExposures(awt_display,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   417
                         (GC) jlong_to_ptr(gc), exposure ? True : False); //TODO: ????
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   418
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   419
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   420
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   421
Java_sun_java2d_xr_XRBackendNative_setGCForeground
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   422
 (JNIEnv *env, jobject this, jlong gc, jint pixel) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   423
    XSetForeground(awt_display, (GC) jlong_to_ptr(gc), (unsigned long) pixel);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   424
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   425
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   426
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   427
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   428
Java_sun_java2d_xr_XRBackendNative_copyArea
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   429
 (JNIEnv *env, jobject this, jint src, jint dst, jlong gc,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   430
  jint srcx, jint srcy, jint width, jint height, jint dstx, jint dsty) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   431
    XCopyArea(awt_display, (Drawable) src, (Drawable) dst,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   432
             (GC) jlong_to_ptr(gc), srcx, srcy, width, height, dstx, dsty);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   433
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   434
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   435
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   436
Java_sun_java2d_xr_XRBackendNative_renderComposite
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   437
 (JNIEnv *env, jobject this, jbyte op, jint src, jint mask, jint dst,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   438
  jint srcX, jint srcY, jint maskX, jint maskY,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   439
  jint dstX, jint dstY, jint width, jint height) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   440
    XRenderComposite (awt_display, op,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   441
                      (Picture)src, (Picture)mask, (Picture)dst,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   442
                       srcX, srcY, maskX, maskY, dstX, dstY, width, height);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   443
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   444
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   445
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   446
Java_sun_java2d_xr_XRBackendNative_renderRectangle
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   447
 (JNIEnv *env, jobject this, jint dst, jbyte op,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   448
  jshort red, jshort green, jshort blue, jshort alpha,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   449
  jint x, jint y, jint width, jint height) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   450
    XRenderColor color;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   451
    color.alpha = alpha;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   452
    color.red = red;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   453
    color.green = green;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   454
    color.blue = blue;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   455
    XRenderFillRectangle(awt_display, op, (Picture) dst, &color,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   456
                         x, y, width, height);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   457
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   458
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   459
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   460
Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   461
 (JNIEnv *env, jclass xsd, jint dst, jbyte op,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   462
  jshort red, jshort green, jshort blue, jshort alpha,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   463
  jintArray rectArray, jint rectCnt) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   464
    int i;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   465
    jint* rects;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   466
    XRectangle *xRects;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   467
    XRectangle sRects[256];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   468
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   469
    XRenderColor color;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   470
    color.alpha = alpha;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   471
    color.red = red;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   472
    color.green = green;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   473
    color.blue = blue;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   474
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   475
    if (rectCnt <= 256) {
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   476
        xRects = &sRects[0];
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   477
    } else {
19009
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   478
        if (MAXUINT / sizeof(XRectangle) < (unsigned)rectCnt) {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   479
            /* rectCnt too big, integer overflow */
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   480
            return;
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   481
        }
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   482
        xRects = (XRectangle *) malloc(sizeof(XRectangle) * rectCnt);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   483
        if (xRects == NULL) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   484
            return;
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   485
        }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   486
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   487
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   488
    if ((rects = (jint *)
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   489
         (*env)->GetPrimitiveArrayCritical(env, rectArray, NULL)) == NULL) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   490
        if (xRects != &sRects[0]) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   491
            free(xRects);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   492
        }
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   493
        return;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   494
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   495
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   496
    for (i=0; i < rectCnt; i++) {
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   497
        xRects[i].x = rects[i*4 + 0];
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   498
        xRects[i].y = rects[i*4 + 1];
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   499
        xRects[i].width = rects[i*4 + 2];
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   500
        xRects[i].height = rects[i*4 + 3];
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   501
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   502
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   503
    XRenderFillRectangles(awt_display, op,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   504
                          (Picture) dst, &color, xRects, rectCnt);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   505
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   506
    (*env)->ReleasePrimitiveArrayCritical(env, rectArray, rects, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   507
    if (xRects != &sRects[0]) {
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   508
        free(xRects);
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   509
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   510
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   511
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   512
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   513
Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   514
 (JNIEnv *env, jclass xsd, jint pic,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   515
  jint m00, jint m01, jint m02, jint m10, jint m11, jint m12) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   516
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   517
  XTransform tr;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   518
  BUILD_TRANSFORM_MATRIX(tr, m00, m01, m02, m10, m11, m12);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   519
  XRenderSetPictureTransform (awt_display, (Picture) pic, &tr);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   520
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   521
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   522
JNIEXPORT jint JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   523
Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   524
    (JNIEnv *env, jclass xsd, jfloatArray fractionsArray,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   525
     jshortArray pixelsArray, jint x1, jint y1, jint x2, jint y2,
21233
a36ed36d3209 8023483: sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java failed with jdk8 on linux platforms
ceisserer
parents: 20425
diff changeset
   526
     jint numStops, jint repeat) {
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   527
   jint i;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   528
   jshort* pixels;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   529
   jfloat* fractions;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   530
   XRenderPictureAttributes pict_attr;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   531
   Picture gradient = 0;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   532
   XRenderColor *colors;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   533
   XFixed *stops;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   534
   XLinearGradient grad;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   535
19009
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   536
   if (MAX_PAYLOAD / (sizeof(XRenderColor) + sizeof(XFixed))
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   537
       < (unsigned)numStops) {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   538
       /* numStops too big, payload overflow */
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   539
       return -1;
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   540
   }
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   541
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   542
   if ((pixels = (jshort *)
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   543
        (*env)->GetPrimitiveArrayCritical(env, pixelsArray, NULL)) == NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   544
       return -1;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   545
   }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   546
   if ((fractions = (jfloat *)
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   547
       (*env)->GetPrimitiveArrayCritical(env, fractionsArray, NULL)) == NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   548
       (*env)->ReleasePrimitiveArrayCritical(env,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   549
                                              pixelsArray, pixels, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   550
       return -1;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   551
   }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   552
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   553
    grad.p1.x = x1;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   554
    grad.p1.y = y1;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   555
    grad.p2.x = x2;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   556
    grad.p2.y = y2;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   557
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   558
    /*TODO optimized & malloc check*/
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   559
    colors = (XRenderColor *) malloc(numStops * sizeof(XRenderColor));
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   560
    stops =  (XFixed *) malloc(numStops * sizeof(XFixed));
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   561
19009
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   562
    if (colors == NULL || stops == NULL) {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   563
        if (colors != NULL) {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   564
            free(colors);
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   565
        }
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   566
        if (stops != NULL) {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   567
            free(stops);
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   568
        }
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   569
        (*env)->ReleasePrimitiveArrayCritical(env, pixelsArray, pixels, JNI_ABORT);
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   570
        (*env)->ReleasePrimitiveArrayCritical(env, fractionsArray, fractions, JNI_ABORT);
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   571
        return -1;
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   572
    }
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   573
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   574
    for (i=0; i < numStops; i++) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   575
      stops[i] = XDoubleToFixed(fractions[i]);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   576
      colors[i].alpha = pixels[i*4 + 0];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   577
      colors[i].red = pixels[i*4 + 1];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   578
      colors[i].green = pixels[i*4 + 2];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   579
      colors[i].blue = pixels[i*4 + 3];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   580
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   581
#ifdef __solaris__
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   582
    if (XRenderCreateLinearGradientFunc!=NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   583
      gradient = (*XRenderCreateLinearGradientFunc)(awt_display, &grad, stops, colors, numStops);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   584
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   585
#else
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   586
    gradient = XRenderCreateLinearGradient(awt_display, &grad, stops, colors, numStops);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   587
#endif
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   588
    free(colors);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   589
    free(stops);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   590
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   591
   (*env)->ReleasePrimitiveArrayCritical(env, pixelsArray, pixels, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   592
   (*env)->ReleasePrimitiveArrayCritical(env, fractionsArray, fractions, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   593
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   594
    if (gradient != 0) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   595
        pict_attr.repeat = repeat;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   596
        XRenderChangePicture (awt_display, gradient, CPRepeat, &pict_attr);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   597
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   598
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   599
   return (jint) gradient;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   600
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   601
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   602
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   603
JNIEXPORT jint JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   604
Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   605
    (JNIEnv *env, jclass xsd, jfloatArray fractionsArray,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   606
     jshortArray pixelsArray, jint numStops,
21233
a36ed36d3209 8023483: sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java failed with jdk8 on linux platforms
ceisserer
parents: 20425
diff changeset
   607
     jint centerX, jint centerY,
a36ed36d3209 8023483: sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java failed with jdk8 on linux platforms
ceisserer
parents: 20425
diff changeset
   608
     jint innerRadius, jint outerRadius, jint repeat) {
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   609
   jint i;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   610
   jshort* pixels;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   611
   jfloat* fractions;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   612
   XRenderPictureAttributes pict_attr;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   613
   Picture gradient = 0;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   614
   XRenderColor *colors;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   615
   XFixed *stops;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   616
   XRadialGradient grad;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   617
19009
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   618
   if (MAX_PAYLOAD / (sizeof(XRenderColor) + sizeof(XFixed))
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   619
       < (unsigned)numStops) {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   620
       /* numStops too big, payload overflow */
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   621
       return -1;
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   622
   }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   623
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   624
   if ((pixels =
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   625
       (jshort *)(*env)->GetPrimitiveArrayCritical(env, pixelsArray, NULL)) == NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   626
       return -1;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   627
   }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   628
   if ((fractions = (jfloat *)
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   629
        (*env)->GetPrimitiveArrayCritical(env, fractionsArray, NULL)) == NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   630
       (*env)->ReleasePrimitiveArrayCritical(env,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   631
                                             pixelsArray, pixels, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   632
       return -1; //TODO release pixels first
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   633
   }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   634
21233
a36ed36d3209 8023483: sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java failed with jdk8 on linux platforms
ceisserer
parents: 20425
diff changeset
   635
    grad.inner.x = centerX;
a36ed36d3209 8023483: sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java failed with jdk8 on linux platforms
ceisserer
parents: 20425
diff changeset
   636
    grad.inner.y = centerY;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   637
    grad.inner.radius = innerRadius;
21233
a36ed36d3209 8023483: sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java failed with jdk8 on linux platforms
ceisserer
parents: 20425
diff changeset
   638
    grad.outer.x = centerX;
a36ed36d3209 8023483: sun/java2d/DirectX/TransformedPaintTest/TransformedPaintTest.java failed with jdk8 on linux platforms
ceisserer
parents: 20425
diff changeset
   639
    grad.outer.y = centerY;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   640
    grad.outer.radius = outerRadius;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   641
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   642
    /*TODO optimized & malloc check*/
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   643
    colors = (XRenderColor *) malloc(numStops * sizeof(XRenderColor));
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   644
    stops =  (XFixed *) malloc(numStops * sizeof(XFixed));
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   645
19009
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   646
    if (colors == NULL || stops == NULL) {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   647
        if (colors != NULL) {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   648
            free(colors);
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   649
        }
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   650
        if (stops != NULL) {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   651
            free(stops);
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   652
        }
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   653
        (*env)->ReleasePrimitiveArrayCritical(env, pixelsArray, pixels, JNI_ABORT);
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   654
        (*env)->ReleasePrimitiveArrayCritical(env, fractionsArray, fractions, JNI_ABORT);
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   655
        return -1;
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   656
    }
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   657
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   658
    for (i=0; i < numStops; i++) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   659
      stops[i] = XDoubleToFixed(fractions[i]);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   660
      colors[i].alpha = pixels[i*4 + 0];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   661
      colors[i].red = pixels[i*4 + 1];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   662
      colors[i].green = pixels[i*4 + 2];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   663
      colors[i].blue = pixels[i*4 + 3];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   664
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   665
#ifdef __solaris__
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   666
    if (XRenderCreateRadialGradientFunc != NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   667
        gradient = (jint) (*XRenderCreateRadialGradientFunc)(awt_display, &grad, stops, colors, numStops);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   668
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   669
#else
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   670
    gradient = (jint) XRenderCreateRadialGradient(awt_display, &grad, stops, colors, numStops);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   671
#endif
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   672
    free(colors);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   673
    free(stops);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   674
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   675
   (*env)->ReleasePrimitiveArrayCritical(env, pixelsArray, pixels, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   676
   (*env)->ReleasePrimitiveArrayCritical(env, fractionsArray, fractions, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   677
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   678
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   679
    if (gradient != 0) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   680
        pict_attr.repeat = repeat;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   681
        XRenderChangePicture (awt_display, gradient, CPRepeat, &pict_attr);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   682
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   683
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   684
   return (jint) gradient;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   685
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   686
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   687
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   688
Java_sun_java2d_xr_XRBackendNative_setFilter
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   689
 (JNIEnv *env, jobject this, jint picture, jint filter) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   690
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   691
  char * filterName = "fast";
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   692
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   693
  switch(filter) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   694
    case 0:
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   695
      filterName = "fast";
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   696
      break;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   697
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   698
    case 1:
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   699
      filterName = "good";
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   700
      break;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   701
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   702
    case 2:
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   703
      filterName = "best";
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   704
      break;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   705
  }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   706
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   707
    XRenderSetPictureFilter(awt_display, (Picture) picture, filterName, NULL, 0);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   708
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   709
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   710
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   711
Java_sun_java2d_xr_XRBackendNative_XRSetClipNative
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   712
    (JNIEnv *env, jclass xsd, jlong dst,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   713
     jint x1, jint y1, jint x2, jint y2,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   714
     jobject complexclip, jboolean isGC)
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   715
{
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   716
    int numrects;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   717
    XRectangle rects[256];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   718
    XRectangle *pRect = rects;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   719
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   720
    numrects = RegionToYXBandedRectangles(env,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   721
            x1, y1, x2, y2, complexclip,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   722
            &pRect, 256);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   723
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   724
    if (isGC == JNI_TRUE) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   725
      if (dst != (jlong) 0) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   726
          XSetClipRectangles(awt_display, (GC) jlong_to_ptr(dst), 0, 0, pRect, numrects, YXBanded);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   727
      }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   728
    } else {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   729
       XRenderSetPictureClipRectangles (awt_display, (Picture) dst, 0, 0, pRect, numrects);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   730
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   731
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   732
    if (pRect != rects) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   733
        free(pRect);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   734
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   735
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   736
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   737
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   738
Java_sun_java2d_xr_XRBackendNative_putMaskNative
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   739
 (JNIEnv *env, jclass cls, jint drawable, jlong gc, jbyteArray imageData,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   740
  jint sx, jint sy, jint dx, jint dy, jint width, jint height,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   741
  jint maskOff, jint maskScan, jfloat ea, jlong imgPtr) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   742
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   743
    int line, pix;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   744
    char *mask;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   745
    char *defaultData;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   746
    XImage *defaultImg, *img;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   747
    jboolean imageFits;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   748
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   749
    if ((mask = (char *)
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   750
         (*env)->GetPrimitiveArrayCritical(env, imageData, NULL)) == NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   751
        return;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   752
     }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   753
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   754
    defaultImg = (XImage *) jlong_to_ptr(imgPtr);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   755
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   756
    if (ea != 1.0f) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   757
        for (line=0; line < height; line++) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   758
            for (pix=0; pix < width; pix++) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   759
                int index = maskScan*line + pix + maskOff;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   760
                mask[index] = (((unsigned char) mask[index])*ea);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   761
            }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   762
        }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   763
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   764
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   765
    /*
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   766
    * 1. If existing XImage and supplied buffer match, only adjust the data pointer
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   767
    * 2. If existing XImage is large enough to hold the data but does not match in
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   768
    *    scan the data is copied to fit the XImage.
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   769
    * 3. If data is larger than the existing XImage a new temporary XImage is
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   770
    *    allocated.
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   771
    * The default XImage is optimized for the AA tiles, which are currently 32x32.
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   772
    */
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   773
    defaultData = defaultImg->data;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   774
    img = defaultImg;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   775
    imageFits = defaultImg->width >= width && defaultImg->height >= height;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   776
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   777
    if (imageFits &&
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   778
        maskOff == defaultImg->xoffset && maskScan == defaultImg->bytes_per_line) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   779
        defaultImg->data = mask;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   780
    } else {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   781
        if (imageFits) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   782
            for (line=0; line < height; line++) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   783
                for (pix=0; pix < width; pix++) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   784
                    img->data[line*img->bytes_per_line + pix] =
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   785
                        (unsigned char) (mask[maskScan*line + pix + maskOff]);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   786
                }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   787
            }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   788
        } else {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   789
            img = XCreateImage(awt_display, NULL, 8, ZPixmap,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   790
                               maskOff, mask, maskScan, height, 8, 0);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   791
        }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   792
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   793
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   794
    XPutImage(awt_display, (Pixmap) drawable, (GC) jlong_to_ptr(gc),
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   795
              img, 0, 0, 0, 0, width, height);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   796
    (*env)->ReleasePrimitiveArrayCritical(env, imageData, mask, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   797
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   798
    if (img != defaultImg) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   799
        img->data = NULL;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   800
        XDestroyImage(img);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   801
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   802
    defaultImg->data = defaultData;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   803
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   804
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   805
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   806
Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   807
 (JNIEnv *env, jclass cls, jint glyphSet,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   808
  jlongArray glyphInfoPtrsArray, jint glyphCnt,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   809
  jbyteArray pixelDataArray, int pixelDataLength) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   810
    jlong *glyphInfoPtrs;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   811
    unsigned char *pixelData;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   812
    int i;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   813
19009
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   814
    if (MAX_PAYLOAD / (sizeof(XGlyphInfo) + sizeof(Glyph))
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   815
        < (unsigned)glyphCnt) {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   816
        /* glyphCnt too big, payload overflow */
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   817
        return;
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   818
    }
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   819
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   820
    XGlyphInfo *xginfo = (XGlyphInfo *) malloc(sizeof(XGlyphInfo) * glyphCnt);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   821
    Glyph *gid = (Glyph *) malloc(sizeof(Glyph) * glyphCnt);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   822
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   823
    if (xginfo == NULL || gid == NULL) {
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   824
        if (xginfo != NULL) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   825
            free(xginfo);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   826
        }
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   827
        if (gid != NULL) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   828
            free(gid);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   829
        }
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   830
        return;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   831
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   832
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   833
    if ((glyphInfoPtrs = (jlong *)(*env)->
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   834
        GetPrimitiveArrayCritical(env, glyphInfoPtrsArray, NULL)) == NULL)
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   835
    {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   836
        free(xginfo);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   837
        free(gid);
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   838
        return;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   839
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   840
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   841
    if ((pixelData = (unsigned char *)
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   842
        (*env)->GetPrimitiveArrayCritical(env, pixelDataArray, NULL)) == NULL)
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   843
    {
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   844
        (*env)->ReleasePrimitiveArrayCritical(env,
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   845
                                glyphInfoPtrsArray, glyphInfoPtrs, JNI_ABORT);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   846
        free(xginfo);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   847
        free(gid);
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   848
        return;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   849
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   850
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   851
    for (i=0; i < glyphCnt; i++) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   852
      GlyphInfo *jginfo = (GlyphInfo *) jlong_to_ptr(glyphInfoPtrs[i]);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   853
17404
47af135a3e95 7191872: Xrender: No text displayed using 64 bit JDK on solaris11-sparc
simonis
parents: 12389
diff changeset
   854
      // 'jginfo->cellInfo' is of type 'void*'
47af135a3e95 7191872: Xrender: No text displayed using 64 bit JDK on solaris11-sparc
simonis
parents: 12389
diff changeset
   855
      // (see definition of 'GlyphInfo' in fontscalerdefs.h)
47af135a3e95 7191872: Xrender: No text displayed using 64 bit JDK on solaris11-sparc
simonis
parents: 12389
diff changeset
   856
      // 'Glyph' is typedefed to 'unsigned long'
47af135a3e95 7191872: Xrender: No text displayed using 64 bit JDK on solaris11-sparc
simonis
parents: 12389
diff changeset
   857
      // (see http://www.x.org/releases/X11R7.7/doc/libXrender/libXrender.txt)
47af135a3e95 7191872: Xrender: No text displayed using 64 bit JDK on solaris11-sparc
simonis
parents: 12389
diff changeset
   858
      // Maybe we should assert that (sizeof(void*) == sizeof(Glyph)) ?
47af135a3e95 7191872: Xrender: No text displayed using 64 bit JDK on solaris11-sparc
simonis
parents: 12389
diff changeset
   859
      gid[i] = (Glyph) (jginfo->cellInfo);
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   860
      xginfo[i].x = (-jginfo->topLeftX);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   861
      xginfo[i].y = (-jginfo->topLeftY);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   862
      xginfo[i].width = jginfo->width;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   863
      xginfo[i].height = jginfo->height;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   864
      xginfo[i].xOff = round(jginfo->advanceX);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   865
      xginfo[i].yOff = round(jginfo->advanceY);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   866
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   867
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   868
    XRenderAddGlyphs(awt_display, glyphSet, &gid[0], &xginfo[0], glyphCnt,
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   869
                     (const char*)pixelData, pixelDataLength);
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   870
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   871
    (*env)->ReleasePrimitiveArrayCritical(env, glyphInfoPtrsArray, glyphInfoPtrs, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   872
    (*env)->ReleasePrimitiveArrayCritical(env, pixelDataArray, pixelData, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   873
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   874
    free(xginfo);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   875
    free(gid);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   876
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   877
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   878
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   879
Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   880
 (JNIEnv *env, jclass cls, jint glyphSet, jintArray gidArray, jint glyphCnt) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   881
19009
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   882
    if (MAX_PAYLOAD / sizeof(Glyph) < (unsigned)glyphCnt) {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   883
        /* glyphCnt too big, payload overflow */
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   884
        return;
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   885
    }
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   886
8944
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   887
    /* The glyph ids are 32 bit but may be stored in a 64 bit long on
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   888
     * a 64 bit architecture. So optimise the 32 bit case to avoid
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   889
     * extra stack or heap allocations by directly referencing the
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   890
     * underlying Java array and only allocate on 64 bit.
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   891
     */
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   892
    if (sizeof(jint) == sizeof(Glyph)) {
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   893
        jint *gids =
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   894
            (*env)->GetPrimitiveArrayCritical(env, gidArray, NULL);
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   895
        if (gids == NULL) {
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   896
            return;
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   897
        } else {
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   898
             XRenderFreeGlyphs(awt_display,
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   899
                               (GlyphSet)glyphSet, (Glyph *)gids, glyphCnt);
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   900
             (*env)->ReleasePrimitiveArrayCritical(env, gidArray,
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   901
                                                   gids, JNI_ABORT);
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   902
        }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   903
        return;
8944
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   904
    } else {
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   905
        Glyph stack_ids[64];
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   906
        Glyph *gids = NULL;
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   907
        jint* jgids = NULL;
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   908
        int i;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   909
8944
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   910
        if (glyphCnt <= 64) {
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   911
            gids = stack_ids;
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   912
        } else {
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   913
            gids = (Glyph *)malloc(sizeof(Glyph) * glyphCnt);
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   914
            if (gids == NULL) {
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   915
                return;
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   916
            }
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   917
        }
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   918
        jgids = (*env)->GetPrimitiveArrayCritical(env, gidArray, NULL);
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   919
        if (jgids == NULL) {
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   920
            if (gids != stack_ids) {
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   921
                free(gids);
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   922
            }
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   923
            return;
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   924
        }
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   925
        for (i=0; i < glyphCnt; i++) {
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   926
            gids[i] = jgids[i];
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   927
        }
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   928
        XRenderFreeGlyphs(awt_display,
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   929
                          (GlyphSet) glyphSet, gids, glyphCnt);
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   930
        (*env)->ReleasePrimitiveArrayCritical(env, gidArray,
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   931
                                              jgids, JNI_ABORT);
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   932
        if (gids != stack_ids) {
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   933
            free(gids);
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   934
        }
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   935
    }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   936
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   937
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   938
JNIEXPORT jint JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   939
Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   940
 (JNIEnv *env, jclass cls, jlong format) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   941
  return XRenderCreateGlyphSet(awt_display, (XRenderPictFormat *) jlong_to_ptr(format));
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   942
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   943
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   944
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   945
Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative
19782
ce9a620fe879 7189452: XRender pipeline does ignore source-surface offset for text rendering
ceisserer
parents: 19171
diff changeset
   946
 (JNIEnv *env, jclass cls, jint op, jint src, jint dst,
ce9a620fe879 7189452: XRender pipeline does ignore source-surface offset for text rendering
ceisserer
parents: 19171
diff changeset
   947
  jint sx, jint sy, jlong maskFmt, jintArray eltArray,
ce9a620fe879 7189452: XRender pipeline does ignore source-surface offset for text rendering
ceisserer
parents: 19171
diff changeset
   948
  jintArray  glyphIDArray, jint eltCnt, jint glyphCnt) {
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   949
    jint i;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   950
    jint *ids;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   951
    jint *elts;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   952
    XGlyphElt32 *xelts;
8944
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   953
    unsigned int *xids;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   954
    XGlyphElt32 selts[24];
8944
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   955
    unsigned int sids[256];
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   956
    int charCnt = 0;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   957
19009
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   958
    if ((MAX_PAYLOAD / sizeof(XGlyphElt32) < (unsigned)eltCnt)
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   959
        || (MAX_PAYLOAD / sizeof(unsigned int) < (unsigned)glyphCnt)
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   960
        || ((MAX_PAYLOAD - sizeof(XGlyphElt32)*(unsigned)eltCnt) /
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   961
            sizeof(unsigned int) < (unsigned)glyphCnt))
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   962
    {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   963
        /* (eltCnt, glyphCnt) too big, payload overflow */
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   964
        return;
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   965
    }
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
   966
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   967
    if (eltCnt <= 24) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   968
      xelts = &selts[0];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   969
    }else {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   970
      xelts = (XGlyphElt32 *) malloc(sizeof(XGlyphElt32) * eltCnt);
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   971
      if (xelts == NULL) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   972
          return;
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   973
      }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   974
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   975
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   976
    if (glyphCnt <= 256) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   977
      xids = &sids[0];
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   978
    } else {
8944
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
   979
      xids = (unsigned int*)malloc(sizeof(unsigned int) * glyphCnt);
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   980
      if (xids == NULL) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   981
          if (xelts != &selts[0]) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   982
            free(xelts);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   983
          }
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   984
          return;
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   985
      }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   986
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   987
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   988
    if ((ids = (jint *)
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   989
         (*env)->GetPrimitiveArrayCritical(env, glyphIDArray, NULL)) == NULL) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   990
        if (xelts != &selts[0]) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   991
            free(xelts);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   992
        }
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   993
        if (xids != &sids[0]) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   994
            free(xids);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   995
        }
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
   996
        return;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   997
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   998
    if ((elts = (jint *)
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
   999
          (*env)->GetPrimitiveArrayCritical(env, eltArray, NULL)) == NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1000
        (*env)->ReleasePrimitiveArrayCritical(env,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1001
                                              glyphIDArray, ids, JNI_ABORT);
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1002
        if (xelts != &selts[0]) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1003
            free(xelts);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1004
        }
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1005
        if (xids != &sids[0]) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1006
            free(xids);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1007
        }
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1008
        return;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1009
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1010
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1011
    for (i=0; i < glyphCnt; i++) {
8944
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
  1012
      xids[i] = ids[i];
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1013
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1014
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1015
    for (i=0; i < eltCnt; i++) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1016
      xelts[i].nchars = elts[i*4 + 0];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1017
      xelts[i].xOff = elts[i*4 + 1];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1018
      xelts[i].yOff = elts[i*4 + 2];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1019
      xelts[i].glyphset = (GlyphSet) elts[i*4 + 3];
8944
740a7da888ba 7029934: Xrender: Text is truncated with 64 bit Linux JRE
prr
parents: 8506
diff changeset
  1020
      xelts[i].chars = &xids[charCnt];
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1021
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1022
      charCnt += xelts[i].nchars;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1023
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1024
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1025
    XRenderCompositeText32(awt_display, op, (Picture) src, (Picture) dst,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1026
                           (XRenderPictFormat *) jlong_to_ptr(maskFmt),
19782
ce9a620fe879 7189452: XRender pipeline does ignore source-surface offset for text rendering
ceisserer
parents: 19171
diff changeset
  1027
                            sx, sy, 0, 0, xelts, eltCnt);
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1028
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1029
    (*env)->ReleasePrimitiveArrayCritical(env, glyphIDArray, ids, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1030
    (*env)->ReleasePrimitiveArrayCritical(env, eltArray, elts, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1031
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1032
    if (xelts != &selts[0]) {
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1033
        free(xelts);
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1034
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1035
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1036
    if (xids != &sids[0]) {
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1037
        free(xids);
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1038
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1039
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1040
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1041
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1042
Java_sun_java2d_xr_XRBackendNative_setGCMode
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1043
 (JNIEnv *env, jobject this, jlong gc, jboolean copy) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1044
  GC xgc = (GC) jlong_to_ptr(gc);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1045
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1046
  if (copy == JNI_TRUE) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1047
    XSetFunction(awt_display, xgc, GXcopy);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1048
  } else {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1049
    XSetFunction(awt_display, xgc, GXxor);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1050
  }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1051
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1052
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1053
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1054
Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1055
 (JNIEnv *env, jclass xsd, jint dst, jlong gc,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1056
  jintArray rectArray, jint rectCnt) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1057
    int i;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1058
    jint* rects;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1059
    XRectangle *xRects;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1060
    XRectangle sRects[256];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1061
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1062
    if (rectCnt <= 256) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1063
      xRects = &sRects[0];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1064
    } else {
19009
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
  1065
      if (MAXUINT / sizeof(XRectangle) < (unsigned)rectCnt) {
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
  1066
        /* rectCnt too big, integer overflow */
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
  1067
        return;
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
  1068
      }
1f1914231324 8005126: [parfait] #418 - #428 XRBackendNative.c Integer overflow
jchen
parents: 19006
diff changeset
  1069
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1070
      xRects = (XRectangle *) malloc(sizeof(XRectangle) * rectCnt);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1071
      if (xRects == NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1072
        return;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1073
      }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1074
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1075
8506
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1076
    if ((rects = (jint*)
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1077
         (*env)->GetPrimitiveArrayCritical(env, rectArray, NULL)) == NULL) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1078
        if (xRects != &sRects[0]) {
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1079
            free(xRects);
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1080
        }
04d00feba488 7004728: [parfait] potential memory leaks in XRender code
prr
parents: 7933
diff changeset
  1081
        return;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1082
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1083
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1084
    for (i=0; i < rectCnt; i++) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1085
      xRects[i].x = rects[i*4 + 0];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1086
      xRects[i].y = rects[i*4 + 1];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1087
      xRects[i].width = rects[i*4 + 2];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1088
      xRects[i].height = rects[i*4 + 3];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1089
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1090
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1091
    XFillRectangles(awt_display, (Drawable) dst, (GC) jlong_to_ptr(gc), xRects, rectCnt);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1092
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1093
    (*env)->ReleasePrimitiveArrayCritical(env, rectArray, rects, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1094
    if (xRects != &sRects[0]) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1095
      free(xRects);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1096
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1097
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1098
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1099
JNIEXPORT void JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1100
Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1101
 (JNIEnv *env, jclass cls, jbyte op, jint src, jlong maskFmt,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1102
 jint dst, jint srcX, jint srcY, jintArray  trapArray) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1103
    jint *traps;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1104
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1105
    if ((traps = (jint *) (*env)->GetPrimitiveArrayCritical(env, trapArray, NULL)) == NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1106
      return;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1107
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1108
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1109
    XRenderCompositeTrapezoids(awt_display, op, (Picture) src, (Picture) dst,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1110
                               (XRenderPictFormat *) jlong_to_ptr(maskFmt),
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1111
                               srcX, srcY, (XTrapezoid *) (traps+5), traps[0]);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1112
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1113
    (*env)->ReleasePrimitiveArrayCritical(env, trapArray, traps, JNI_ABORT);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents:
diff changeset
  1114
}