< prev index next >
src/java.desktop/unix/native/common/java2d/x11/X11Renderer.c
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -223,17 +223,17 @@
(JNIEnv *env, jobject xr,
jlong pXSData, jlong xgc,
jint x1, jint y1, jint x2, jint y2)
{
#ifndef HEADLESS
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
if (xsdo == NULL) {
return;
}
- XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
+ XDrawLine(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
CLAMP_TO_SHORT(x1), CLAMP_TO_SHORT(y1),
CLAMP_TO_SHORT(x2), CLAMP_TO_SHORT(y2));
X11SD_DirectRenderNotify(env, xsdo);
#endif /* !HEADLESS */
}
@@ -247,11 +247,11 @@
(JNIEnv *env, jobject xr,
jlong pXSData, jlong xgc,
jint x, jint y, jint w, jint h)
{
#ifndef HEADLESS
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
if (xsdo == NULL || w < 0 || h < 0) {
return;
}
@@ -261,15 +261,15 @@
* This optimization not only simplifies the processing
* of a particular degenerate case, but it protects against
* the anomalies of various X11 implementations that draw
* nothing for degenerate Polygons and Rectangles.
*/
- XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
+ XFillRectangle(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
CLAMP_TO_SHORT(x), CLAMP_TO_SHORT(y),
CLAMP_TO_USHORT(w+1), CLAMP_TO_USHORT(h+1));
} else {
- XDrawRectangle(awt_display, xsdo->drawable, (GC) xgc,
+ XDrawRectangle(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
CLAMP_TO_SHORT(x), CLAMP_TO_SHORT(y),
CLAMP_TO_USHORT(w), CLAMP_TO_USHORT(h));
}
X11SD_DirectRenderNotify(env, xsdo);
#endif /* !HEADLESS */
@@ -287,11 +287,11 @@
jint arcW, jint arcH)
{
#ifndef HEADLESS
long ty1, ty2, tx1, tx2, cx, cy, cxw, cyh,
halfW, halfH, leftW, rightW, topH, bottomH;
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
if (xsdo == NULL || w < 0 || h < 0) {
return;
}
@@ -332,36 +332,36 @@
leftW = (tx1 - cx) * 2;
rightW = (cxw - tx2) * 2;
topH = (ty1 - cy) * 2;
bottomH = (cyh - ty2) * 2;
- awt_drawArc(env, xsdo->drawable, (GC) xgc,
+ awt_drawArc(env, xsdo->drawable, (GC) jlong_to_ptr(xgc),
cx, cy, leftW, topH,
90, 90, JNI_FALSE);
- awt_drawArc(env, xsdo->drawable, (GC) xgc,
+ awt_drawArc(env, xsdo->drawable, (GC) jlong_to_ptr(xgc),
cxw - rightW, cy, rightW, topH,
0, 90, JNI_FALSE);
- awt_drawArc(env, xsdo->drawable, (GC) xgc,
+ awt_drawArc(env, xsdo->drawable, (GC) jlong_to_ptr(xgc),
cx, cyh - bottomH, leftW, bottomH,
180, 90, JNI_FALSE);
- awt_drawArc(env, xsdo->drawable, (GC) xgc,
+ awt_drawArc(env, xsdo->drawable, (GC) jlong_to_ptr(xgc),
cxw - rightW, cyh - bottomH, rightW, bottomH,
270, 90, JNI_FALSE);
if (tx1 <= tx2) {
- XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
+ XDrawLine(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
tx1, cy, tx2, cy);
if (h > 0) {
- XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
+ XDrawLine(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
tx1, cyh, tx2, cyh);
}
}
if (ty1 <= ty2) {
- XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
+ XDrawLine(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
cx, ty1, cx, ty2);
if (w > 0) {
- XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
+ XDrawLine(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
cxw, ty1, cxw, ty2);
}
}
X11SD_DirectRenderNotify(env, xsdo);
#endif /* !HEADLESS */
@@ -376,11 +376,11 @@
(JNIEnv *env, jobject xr,
jlong pXSData, jlong xgc,
jint x, jint y, jint w, jint h)
{
#ifndef HEADLESS
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
if (xsdo == NULL) {
return;
}
@@ -391,15 +391,15 @@
* Really small ovals degenerate to simple rectangles as they
* have no curvature or enclosed area. Use XFillRectangle
* for speed and to deal better with degenerate sizes.
*/
if (w >= 0 && h >= 0) {
- XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
+ XFillRectangle(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
x, y, w+1, h+1);
}
} else {
- awt_drawArc(env, xsdo->drawable, (GC) xgc,
+ awt_drawArc(env, xsdo->drawable, (GC) jlong_to_ptr(xgc),
x, y, w, h, 0, 360, JNI_FALSE);
}
X11SD_DirectRenderNotify(env, xsdo);
#endif /* !HEADLESS */
}
@@ -414,17 +414,17 @@
jlong pXSData, jlong xgc,
jint x, jint y, jint w, jint h,
jint angleStart, jint angleExtent)
{
#ifndef HEADLESS
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
if (xsdo == NULL) {
return;
}
- awt_drawArc(env, xsdo->drawable, (GC) xgc,
+ awt_drawArc(env, xsdo->drawable, (GC) jlong_to_ptr(xgc),
x, y, w, h, angleStart, angleExtent, JNI_FALSE);
X11SD_DirectRenderNotify(env, xsdo);
#endif /* !HEADLESS */
}
@@ -440,11 +440,11 @@
jintArray xcoordsArray, jintArray ycoordsArray, jint npoints,
jboolean isclosed)
{
#ifndef HEADLESS
XPoint pTmp[POLYTEMPSIZE], *points;
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
if (xsdo == NULL) {
return;
}
@@ -474,15 +474,15 @@
* specification. For simplicity we will dispatch all
* 2 point polygons through XDrawLine even if they are
* non-degenerate as this may invoke less processing
* down the line than a Poly primitive anyway.
*/
- XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
+ XDrawLine(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
points[0].x, points[0].y,
points[1].x, points[1].y);
} else {
- XDrawLines(awt_display, xsdo->drawable, (GC) xgc,
+ XDrawLines(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
points, npoints, CoordModeOrigin);
}
if (points != pTmp) {
free(points);
}
@@ -567,11 +567,11 @@
Java_sun_java2d_x11_X11Renderer_XDoPath
(JNIEnv *env, jobject self, jobject sg2d, jlong pXSData, jlong xgc,
jint transX, jint transY, jobject p2df, jboolean isFill)
{
#ifndef HEADLESS
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
jarray typesArray;
jobject pointArray;
jarray coordsArray;
jint numTypes;
jint fillRule;
@@ -607,11 +607,11 @@
if ((*env)->GetArrayLength(env, typesArray) < numTypes) {
JNU_ThrowArrayIndexOutOfBoundsException(env, "types array");
return;
}
- XDHD_INIT(&dHData, (GC)xgc, xsdo->drawable);
+ XDHD_INIT(&dHData, (GC) jlong_to_ptr(xgc), xsdo->drawable);
drawHandler.pData = &dHData;
stroke = (((*env)->GetIntField(env, sg2d, sg2dStrokeHintID) ==
sunHints_INTVAL_STROKE_PURE)
? PH_STROKE_PURE
@@ -664,17 +664,17 @@
(JNIEnv *env, jobject xr,
jlong pXSData, jlong xgc,
jint x, jint y, jint w, jint h)
{
#ifndef HEADLESS
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
if (xsdo == NULL) {
return;
}
- XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
+ XFillRectangle(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
CLAMP_TO_SHORT(x), CLAMP_TO_SHORT(y),
CLAMP_TO_USHORT(w), CLAMP_TO_USHORT(h));
X11SD_DirectRenderNotify(env, xsdo);
#endif /* !HEADLESS */
}
@@ -691,11 +691,11 @@
jint arcW, jint arcH)
{
#ifndef HEADLESS
long ty1, ty2, tx1, tx2, cx, cy, cxw, cyh,
halfW, halfH, leftW, rightW, topH, bottomH;
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
if (xsdo == NULL || w <= 0 || h <= 0) {
return;
}
@@ -736,35 +736,35 @@
leftW = (tx1 - cx) * 2;
rightW = (cxw - tx2) * 2;
topH = (ty1 - cy) * 2;
bottomH = (cyh - ty2) * 2;
- awt_drawArc(env, xsdo->drawable, (GC) xgc,
+ awt_drawArc(env, xsdo->drawable, (GC) jlong_to_ptr(xgc),
cx, cy, leftW, topH,
90, 90, JNI_TRUE);
- awt_drawArc(env, xsdo->drawable, (GC) xgc,
+ awt_drawArc(env, xsdo->drawable, (GC) jlong_to_ptr(xgc),
cxw - rightW, cy, rightW, topH,
0, 90, JNI_TRUE);
- awt_drawArc(env, xsdo->drawable, (GC) xgc,
+ awt_drawArc(env, xsdo->drawable, (GC) jlong_to_ptr(xgc),
cx, cyh - bottomH, leftW, bottomH,
180, 90, JNI_TRUE);
- awt_drawArc(env, xsdo->drawable, (GC) xgc,
+ awt_drawArc(env, xsdo->drawable, (GC) jlong_to_ptr(xgc),
cxw - rightW, cyh - bottomH, rightW, bottomH,
270, 90, JNI_TRUE);
if (tx1 < tx2) {
if (cy < ty1) {
- XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
+ XFillRectangle(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
tx1, cy, tx2 - tx1, ty1 - cy);
}
if (ty2 < cyh) {
- XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
+ XFillRectangle(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
tx1, ty2, tx2 - tx1, cyh - ty2);
}
}
if (ty1 < ty2) {
- XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
+ XFillRectangle(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
cx, ty1, cxw - cx, ty2 - ty1);
}
X11SD_DirectRenderNotify(env, xsdo);
#endif /* !HEADLESS */
}
@@ -778,11 +778,11 @@
(JNIEnv *env, jobject xr,
jlong pXSData, jlong xgc,
jint x, jint y, jint w, jint h)
{
#ifndef HEADLESS
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
if (xsdo == NULL) {
return;
}
@@ -818,14 +818,14 @@
y += (h-adjh)/2;
h = adjh;
}
#undef SQRT_3_4
if (w > 0 && h > 0) {
- XFillRectangle(awt_display, xsdo->drawable, (GC) xgc, x, y, w, h);
+ XFillRectangle(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc), x, y, w, h);
}
} else {
- awt_drawArc(env, xsdo->drawable, (GC) xgc,
+ awt_drawArc(env, xsdo->drawable, (GC) jlong_to_ptr(xgc),
x, y, w, h, 0, 360, JNI_TRUE);
}
X11SD_DirectRenderNotify(env, xsdo);
#endif /* !HEADLESS */
}
@@ -840,17 +840,17 @@
jlong pXSData, jlong xgc,
jint x, jint y, jint w, jint h,
jint angleStart, jint angleExtent)
{
#ifndef HEADLESS
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
if (xsdo == NULL) {
return;
}
- awt_drawArc(env, xsdo->drawable, (GC) xgc,
+ awt_drawArc(env, xsdo->drawable, (GC) jlong_to_ptr(xgc),
x, y, w, h, angleStart, angleExtent, JNI_TRUE);
X11SD_DirectRenderNotify(env, xsdo);
#endif /* !HEADLESS */
}
@@ -865,11 +865,11 @@
jint transx, jint transy,
jintArray xcoordsArray, jintArray ycoordsArray, jint npoints)
{
#ifndef HEADLESS
XPoint pTmp[POLYTEMPSIZE], *points;
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
if (xsdo == NULL) {
return;
}
@@ -890,11 +890,11 @@
points = transformPoints(env, xcoordsArray, ycoordsArray, transx, transy,
pTmp, (int *)&npoints, JNI_FALSE);
if (points != 0) {
if (npoints > 2) {
- XFillPolygon(awt_display, xsdo->drawable, (GC) xgc,
+ XFillPolygon(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
points, npoints, Complex, CoordModeOrigin);
X11SD_DirectRenderNotify(env, xsdo);
}
if (points != pTmp) {
free(points);
@@ -917,11 +917,11 @@
#ifndef HEADLESS
SpanIteratorFuncs *pFuncs = (SpanIteratorFuncs *) jlong_to_ptr(pIterator);
void *srData;
jint x, y, w, h;
jint spanbox[4];
- X11SDOps *xsdo = (X11SDOps *) pXSData;
+ X11SDOps *xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
if (xsdo == NULL) {
return;
}
@@ -938,11 +938,11 @@
while ((*pFuncs->nextSpan)(srData, spanbox)) {
x = spanbox[0] + transx;
y = spanbox[1] + transy;
w = spanbox[2] - spanbox[0];
h = spanbox[3] - spanbox[1];
- XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
+ XFillRectangle(awt_display, xsdo->drawable, (GC) jlong_to_ptr(xgc),
CLAMP_TO_SHORT(x), CLAMP_TO_SHORT(y),
CLAMP_TO_USHORT(w), CLAMP_TO_USHORT(h));
}
(*pFuncs->close)(env, srData);
X11SD_DirectRenderNotify(env, xsdo);
@@ -964,16 +964,16 @@
{
#ifndef HEADLESS
X11SDOps *xsdo;
GC xgc;
- xsdo = (X11SDOps *)jlong_to_ptr(xsd);
+ xsdo = (X11SDOps *) jlong_to_ptr(xsd);
if (xsdo == NULL) {
return;
}
- xgc = (GC)gc;
+ xgc = (GC) jlong_to_ptr(gc);
if (xgc == NULL) {
return;
}
XCopyArea(awt_display, xsdo->drawable, xsdo->drawable, xgc,
< prev index next >