2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
|
26 |
#include <math.h>
|
|
27 |
#include <float.h>
|
|
28 |
#include "jni_util.h"
|
|
29 |
|
|
30 |
#include "GraphicsPrimitiveMgr.h"
|
|
31 |
#include "LineUtils.h"
|
|
32 |
#include "ProcessPath.h"
|
|
33 |
#include "DrawPath.h"
|
|
34 |
|
|
35 |
#include "sun_java2d_loops_FillPath.h"
|
|
36 |
|
|
37 |
static void drawScanline(DrawHandler* hnd, jint x0, jint x1, jint y0) {
|
|
38 |
DHND(hnd)->pPrim->funcs.drawline(
|
|
39 |
DHND(hnd)->pRasInfo, x0, y0, DHND(hnd)->pixel, x1 - x0 + 1, 0,
|
|
40 |
BUMP_POS_PIXEL, 0, BUMP_NOOP, 0,
|
|
41 |
DHND(hnd)->pPrim, DHND(hnd)->pCompInfo);
|
|
42 |
}
|
|
43 |
|
|
44 |
/*
|
|
45 |
* Class: sun_java2d_loops_FillPath
|
|
46 |
* Method: FillPath
|
|
47 |
* Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;IILjava/awt/geom/Path2D.Float;)V
|
|
48 |
*/
|
|
49 |
JNIEXPORT void JNICALL Java_sun_java2d_loops_FillPath_FillPath
|
|
50 |
(JNIEnv *env, jobject self,
|
|
51 |
jobject sg2d, jobject sData,
|
|
52 |
jint transX, jint transY, jobject p2df)
|
|
53 |
{
|
|
54 |
jarray typesArray;
|
|
55 |
jarray coordsArray;
|
|
56 |
jint numTypes;
|
|
57 |
jint fillRule;
|
|
58 |
jboolean ok = JNI_TRUE;
|
|
59 |
jint pixel = GrPrim_Sg2dGetPixel(env, sg2d);
|
|
60 |
jint maxCoords;
|
|
61 |
jfloat *coords;
|
|
62 |
SurfaceDataOps *sdOps;
|
|
63 |
SurfaceDataRasInfo rasInfo;
|
|
64 |
CompositeInfo compInfo;
|
|
65 |
jint ret;
|
|
66 |
NativePrimitive *pPrim = GetNativePrim(env, self);
|
|
67 |
jint stroke = (*env)->GetIntField(env, sg2d, sg2dStrokeHintID);
|
|
68 |
|
|
69 |
if (pPrim == NULL) {
|
|
70 |
return;
|
|
71 |
}
|
|
72 |
if (pPrim->pCompType->getCompInfo != NULL) {
|
|
73 |
GrPrim_Sg2dGetCompInfo(env, sg2d, pPrim, &compInfo);
|
|
74 |
}
|
|
75 |
|
|
76 |
sdOps = SurfaceData_GetOps(env, sData);
|
|
77 |
if (sdOps == 0) {
|
|
78 |
return;
|
|
79 |
}
|
|
80 |
|
|
81 |
typesArray = (jarray)(*env)->GetObjectField(env, p2df, path2DTypesID);
|
|
82 |
coordsArray = (jarray)(*env)->GetObjectField(env, p2df,
|
|
83 |
path2DFloatCoordsID);
|
|
84 |
if (coordsArray == NULL) {
|
|
85 |
JNU_ThrowNullPointerException(env, "coordinates array");
|
|
86 |
return;
|
|
87 |
}
|
|
88 |
numTypes = (*env)->GetIntField(env, p2df, path2DNumTypesID);
|
|
89 |
fillRule = (*env)->GetIntField(env, p2df, path2DWindingRuleID);
|
|
90 |
if ((*env)->GetArrayLength(env, typesArray) < numTypes) {
|
|
91 |
JNU_ThrowArrayIndexOutOfBoundsException(env, "types array");
|
|
92 |
return;
|
|
93 |
}
|
|
94 |
|
|
95 |
GrPrim_Sg2dGetClip(env, sg2d, &rasInfo.bounds);
|
|
96 |
|
|
97 |
ret = sdOps->Lock(env, sdOps, &rasInfo, SD_LOCK_FASTEST | pPrim->dstflags);
|
|
98 |
if (ret == SD_FAILURE) {
|
|
99 |
return;
|
|
100 |
}
|
|
101 |
|
|
102 |
maxCoords = (*env)->GetArrayLength(env, coordsArray);
|
|
103 |
coords = (jfloat*)(*env)->GetPrimitiveArrayCritical(
|
|
104 |
env, coordsArray, NULL);
|
|
105 |
|
|
106 |
if (ret == SD_SLOWLOCK) {
|
|
107 |
GrPrim_RefineBounds(&rasInfo.bounds, transX, transY,
|
|
108 |
coords, maxCoords);
|
|
109 |
ok = (rasInfo.bounds.x2 > rasInfo.bounds.x1 &&
|
|
110 |
rasInfo.bounds.y2 > rasInfo.bounds.y1);
|
|
111 |
}
|
|
112 |
|
|
113 |
if (ok) {
|
|
114 |
sdOps->GetRasInfo(env, sdOps, &rasInfo);
|
|
115 |
if (rasInfo.rasBase) {
|
|
116 |
if (rasInfo.bounds.x2 > rasInfo.bounds.x1 &&
|
|
117 |
rasInfo.bounds.y2 > rasInfo.bounds.y1)
|
|
118 |
{
|
|
119 |
DrawHandlerData dHData;
|
|
120 |
DrawHandler drawHandler = {
|
|
121 |
NULL,
|
|
122 |
NULL,
|
|
123 |
&drawScanline,
|
|
124 |
0, 0, 0, 0,
|
|
125 |
0, 0, 0, 0,
|
|
126 |
NULL
|
|
127 |
};
|
|
128 |
|
|
129 |
jbyte *types = (jbyte*)(*env)->GetPrimitiveArrayCritical(
|
|
130 |
env, typesArray, NULL);
|
|
131 |
|
|
132 |
/* Initialization of the following fields in the declaration of
|
|
133 |
* the dHData and drawHandler above causes warnings on sun
|
|
134 |
* studio compiler with
|
|
135 |
* -xc99=%none option applied (this option means compliance
|
|
136 |
* with C90 standard instead of C99)
|
|
137 |
*/
|
|
138 |
dHData.pRasInfo = &rasInfo;
|
|
139 |
dHData.pixel = pixel;
|
|
140 |
dHData.pPrim = pPrim;
|
|
141 |
dHData.pCompInfo = &compInfo;
|
|
142 |
|
|
143 |
drawHandler.xMin = rasInfo.bounds.x1;
|
|
144 |
drawHandler.yMin = rasInfo.bounds.y1;
|
|
145 |
drawHandler.xMax = rasInfo.bounds.x2;
|
|
146 |
drawHandler.yMax = rasInfo.bounds.y2;
|
|
147 |
drawHandler.pData = &dHData;
|
|
148 |
|
|
149 |
if (!doFillPath(&drawHandler,
|
|
150 |
transX, transY, coords,
|
|
151 |
maxCoords, types, numTypes,
|
|
152 |
(stroke == sunHints_INTVAL_STROKE_PURE)?
|
|
153 |
PH_STROKE_PURE : PH_STROKE_DEFAULT,
|
|
154 |
fillRule))
|
|
155 |
{
|
|
156 |
JNU_ThrowArrayIndexOutOfBoundsException(env,
|
|
157 |
"coords array");
|
|
158 |
}
|
|
159 |
|
|
160 |
(*env)->ReleasePrimitiveArrayCritical(env, typesArray, types,
|
|
161 |
JNI_ABORT);
|
|
162 |
}
|
|
163 |
}
|
|
164 |
SurfaceData_InvokeRelease(env, sdOps, &rasInfo);
|
|
165 |
}
|
|
166 |
(*env)->ReleasePrimitiveArrayCritical(env, coordsArray, coords,
|
|
167 |
JNI_ABORT);
|
|
168 |
SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
|
|
169 |
}
|