Print this page
Added gradle and cmake project
Split |
Close |
Expand all |
Collapse all |
--- old/src/java.desktop/share/native/libawt/java2d/loops/FillParallelogram.c
+++ new/src/java.desktop/share/native/libawt/java2d/loops/FillParallelogram.c
1 1 /*
2 2 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation. Oracle designates this
8 8 * particular file as subject to the "Classpath" exception as provided
9 9 * by Oracle in the LICENSE file that accompanied this code.
10 10 *
11 11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 14 * version 2 for more details (a copy is included in the LICENSE file that
15 15 * accompanied this code).
16 16 *
17 17 * You should have received a copy of the GNU General Public License version
18 18 * 2 along with this work; if not, write to the Free Software Foundation,
19 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 20 *
21 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 22 * or visit www.oracle.com if you need additional information or have any
23 23 * questions.
24 24 */
25 25
26 26 #include "math.h"
27 27 #include "GraphicsPrimitiveMgr.h"
28 28 #include "ParallelogramUtils.h"
29 29
30 30 #include "sun_java2d_loops_FillParallelogram.h"
31 31
32 32 /*
33 33 * Class: sun_java2d_loops_FillParallelogram
34 34 * Method: FillParallelogram
35 35 * Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;DDDDDD)V
36 36 */
37 37 JNIEXPORT void JNICALL
38 38 Java_sun_java2d_loops_FillParallelogram_FillParallelogram
39 39 (JNIEnv *env, jobject self,
40 40 jobject sg2d, jobject sData,
↓ open down ↓ |
40 lines elided |
↑ open up ↑ |
41 41 jdouble x0, jdouble y0,
42 42 jdouble dx1, jdouble dy1,
43 43 jdouble dx2, jdouble dy2)
44 44 {
45 45 SurfaceDataOps *sdOps;
46 46 SurfaceDataRasInfo rasInfo;
47 47 NativePrimitive *pPrim;
48 48 CompositeInfo compInfo;
49 49 jint pixel;
50 50 jint ix1, iy1, ix2, iy2;
51 -
52 51 if ((dy1 == 0 && dx1 == 0) || (dy2 == 0 && dx2 == 0)) {
53 52 return;
54 53 }
55 54
56 55 /*
57 56 * Sort parallelogram by y values, ensure that each delta vector
58 57 * has a non-negative y delta.
59 58 */
60 59 SORT_PGRAM(x0, y0, dx1, dy1, dx2, dy2, );
61 60
62 61 PGRAM_MIN_MAX(ix1, ix2, x0, dx1, dx2, JNI_FALSE);
63 62 iy1 = (jint) floor(y0 + 0.5);
64 63 iy2 = (jint) floor(y0 + dy1 + dy2 + 0.5);
65 64
66 65 pPrim = GetNativePrim(env, self);
67 66 if (pPrim == NULL) {
68 67 return;
69 68 }
70 69 pixel = GrPrim_Sg2dGetPixel(env, sg2d);
71 70 if (pPrim->pCompType->getCompInfo != NULL) {
72 71 GrPrim_Sg2dGetCompInfo(env, sg2d, pPrim, &compInfo);
73 72 }
74 73
75 74 sdOps = SurfaceData_GetOps(env, sData);
76 75 if (sdOps == NULL) {
77 76 return;
78 77 }
79 78
80 79 GrPrim_Sg2dGetClip(env, sg2d, &rasInfo.bounds);
81 80 SurfaceData_IntersectBoundsXYXY(&rasInfo.bounds, ix1, iy1, ix2, iy2);
82 81 if (rasInfo.bounds.y2 <= rasInfo.bounds.y1 ||
83 82 rasInfo.bounds.x2 <= rasInfo.bounds.x1)
84 83 {
85 84 return;
86 85 }
87 86
88 87 if (sdOps->Lock(env, sdOps, &rasInfo, pPrim->dstflags) != SD_SUCCESS) {
89 88 return;
90 89 }
91 90
92 91 ix1 = rasInfo.bounds.x1;
93 92 iy1 = rasInfo.bounds.y1;
94 93 ix2 = rasInfo.bounds.x2;
95 94 iy2 = rasInfo.bounds.y2;
96 95 if (ix2 > ix1 && iy2 > iy1) {
97 96 sdOps->GetRasInfo(env, sdOps, &rasInfo);
98 97 if (rasInfo.rasBase) {
99 98 jdouble lslope = (dy1 == 0) ? 0 : dx1 / dy1;
100 99 jdouble rslope = (dy2 == 0) ? 0 : dx2 / dy2;
101 100 jlong ldx = DblToLong(lslope);
102 101 jlong rdx = DblToLong(rslope);
103 102 jint cy1, cy2, loy, hiy;
104 103 dx1 += x0;
105 104 dy1 += y0;
106 105 dx2 += x0;
107 106 dy2 += y0;
108 107 cy1 = (jint) floor(dy1 + 0.5);
109 108 cy2 = (jint) floor(dy2 + 0.5);
110 109
111 110 /* Top triangular portion. */
112 111 loy = iy1;
113 112 hiy = (cy1 < cy2) ? cy1 : cy2;
114 113 if (hiy > iy2) hiy = iy2;
115 114 if (loy < hiy) {
116 115 jlong lx = PGRAM_INIT_X(loy, x0, y0, lslope);
117 116 jlong rx = PGRAM_INIT_X(loy, x0, y0, rslope);
118 117 (*pPrim->funcs.fillparallelogram)(&rasInfo,
119 118 ix1, loy, ix2, hiy,
120 119 lx, ldx, rx, rdx,
121 120 pixel, pPrim, &compInfo);
122 121 }
123 122
124 123 /* Middle parallelogram portion, which way does it slant? */
125 124 if (cy1 < cy2) {
126 125 /* Middle parallelogram portion, slanted to right. */
127 126 /* left leg turned a corner at y0+dy1 */
128 127 /* right leg continuing on its initial trajectory from y0 */
129 128 loy = cy1;
130 129 hiy = cy2;
131 130 if (loy < iy1) loy = iy1;
132 131 if (hiy > iy2) hiy = iy2;
133 132 if (loy < hiy) {
134 133 jlong lx = PGRAM_INIT_X(loy, dx1, dy1, rslope);
135 134 jlong rx = PGRAM_INIT_X(loy, x0, y0, rslope);
136 135 (*pPrim->funcs.fillparallelogram)(&rasInfo,
137 136 ix1, loy, ix2, hiy,
138 137 lx, rdx, rx, rdx,
139 138 pixel, pPrim, &compInfo);
140 139 }
141 140 } else if (cy2 < cy1) {
142 141 /* Middle parallelogram portion, slanted to left. */
143 142 /* left leg continuing on its initial trajectory from y0 */
144 143 /* right leg turned a corner at y0+dy2 */
145 144 loy = cy2;
146 145 hiy = cy1;
147 146 if (loy < iy1) loy = iy1;
148 147 if (hiy > iy2) hiy = iy2;
149 148 if (loy < hiy) {
150 149 jlong lx = PGRAM_INIT_X(loy, x0, y0, lslope);
151 150 jlong rx = PGRAM_INIT_X(loy, dx2, dy2, lslope);
152 151 (*pPrim->funcs.fillparallelogram)(&rasInfo,
153 152 ix1, loy, ix2, hiy,
154 153 lx, ldx, rx, ldx,
155 154 pixel, pPrim, &compInfo);
156 155 }
157 156 }
158 157
159 158 /* Bottom triangular portion. */
160 159 loy = (cy1 > cy2) ? cy1 : cy2;
161 160 if (loy < iy1) loy = iy1;
162 161 hiy = iy2;
163 162 if (loy < hiy) {
164 163 /* left leg turned its corner at y0+dy1, now moving right */
165 164 /* right leg turned its corner at y0+dy2, now moving left */
166 165 jlong lx = PGRAM_INIT_X(loy, dx1, dy1, rslope);
167 166 jlong rx = PGRAM_INIT_X(loy, dx2, dy2, lslope);
168 167 (*pPrim->funcs.fillparallelogram)(&rasInfo,
169 168 ix1, loy, ix2, hiy,
170 169 lx, rdx, rx, ldx,
171 170 pixel, pPrim, &compInfo);
172 171 }
173 172 }
174 173 SurfaceData_InvokeRelease(env, sdOps, &rasInfo);
175 174 }
176 175 SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
177 176 }
↓ open down ↓ |
116 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX