author | lbourges |
Mon, 11 Dec 2017 21:14:43 +0100 | |
changeset 48284 | fd7fbc929001 |
parent 47971 | 75686e8da573 |
child 49496 | 1ea202af7a97 |
permissions | -rw-r--r-- |
34417 | 1 |
/* |
44655
06871a50a4b5
8177461: Wrong references are used in the javadoc in the java.desktop module
serb
parents:
40421
diff
changeset
|
2 |
* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. |
34417 | 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 |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
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 |
* |
|
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. |
|
24 |
*/ |
|
25 |
||
26 |
package sun.java2d.marlin; |
|
27 |
||
28 |
import java.awt.BasicStroke; |
|
29 |
import java.awt.Shape; |
|
30 |
import java.awt.geom.AffineTransform; |
|
31 |
import java.awt.geom.Path2D; |
|
32 |
import java.awt.geom.PathIterator; |
|
33 |
import java.security.AccessController; |
|
34 |
import static sun.java2d.marlin.MarlinUtils.logInfo; |
|
35 |
import sun.awt.geom.PathConsumer2D; |
|
36458
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
36 |
import sun.java2d.ReentrantContextProvider; |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
37 |
import sun.java2d.ReentrantContextProviderCLQ; |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
38 |
import sun.java2d.ReentrantContextProviderTL; |
34417 | 39 |
import sun.java2d.pipe.AATileGenerator; |
40 |
import sun.java2d.pipe.Region; |
|
41 |
import sun.java2d.pipe.RenderingEngine; |
|
42 |
import sun.security.action.GetPropertyAction; |
|
43 |
||
44 |
/** |
|
45 |
* Marlin RendererEngine implementation (derived from Pisces) |
|
46 |
*/ |
|
47126 | 47 |
public final class MarlinRenderingEngine extends RenderingEngine |
48 |
implements MarlinConst |
|
34417 | 49 |
{ |
40421
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
50 |
private static enum NormMode { |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
51 |
ON_WITH_AA { |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
52 |
@Override |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
53 |
PathIterator getNormalizingPathIterator(final RendererContext rdrCtx, |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
54 |
final PathIterator src) |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
55 |
{ |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
56 |
// NormalizingPathIterator NearestPixelCenter: |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
57 |
return rdrCtx.nPCPathIterator.init(src); |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
58 |
} |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
59 |
}, |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
60 |
ON_NO_AA{ |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
61 |
@Override |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
62 |
PathIterator getNormalizingPathIterator(final RendererContext rdrCtx, |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
63 |
final PathIterator src) |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
64 |
{ |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
65 |
// NearestPixel NormalizingPathIterator: |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
66 |
return rdrCtx.nPQPathIterator.init(src); |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
67 |
} |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
68 |
}, |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
69 |
OFF{ |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
70 |
@Override |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
71 |
PathIterator getNormalizingPathIterator(final RendererContext rdrCtx, |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
72 |
final PathIterator src) |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
73 |
{ |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
74 |
// return original path iterator if normalization is disabled: |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
75 |
return src; |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
76 |
} |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
77 |
}; |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
78 |
|
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
79 |
abstract PathIterator getNormalizingPathIterator(RendererContext rdrCtx, |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
80 |
PathIterator src); |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
81 |
} |
34417 | 82 |
|
47126 | 83 |
private static final float MIN_PEN_SIZE = 1.0f / NORM_SUBPIXELS; |
34417 | 84 |
|
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
85 |
static final float UPPER_BND = Float.MAX_VALUE / 2.0f; |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
86 |
static final float LOWER_BND = -UPPER_BND; |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
87 |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
88 |
static final boolean DO_CLIP = MarlinProperties.isDoClip(); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
89 |
static final boolean DO_CLIP_FILL = true; |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
90 |
|
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
91 |
static final boolean DO_TRACE_PATH = false; |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
92 |
|
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
93 |
static final boolean DO_CLIP_RUNTIME_ENABLE = MarlinProperties.isDoClipRuntimeFlag(); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
94 |
|
34417 | 95 |
/** |
96 |
* Public constructor |
|
97 |
*/ |
|
98 |
public MarlinRenderingEngine() { |
|
99 |
super(); |
|
100 |
logSettings(MarlinRenderingEngine.class.getName()); |
|
101 |
} |
|
102 |
||
103 |
/** |
|
104 |
* Create a widened path as specified by the parameters. |
|
105 |
* <p> |
|
106 |
* The specified {@code src} {@link Shape} is widened according |
|
107 |
* to the specified attribute parameters as per the |
|
108 |
* {@link BasicStroke} specification. |
|
109 |
* |
|
110 |
* @param src the source path to be widened |
|
111 |
* @param width the width of the widened path as per {@code BasicStroke} |
|
112 |
* @param caps the end cap decorations as per {@code BasicStroke} |
|
113 |
* @param join the segment join decorations as per {@code BasicStroke} |
|
114 |
* @param miterlimit the miter limit as per {@code BasicStroke} |
|
115 |
* @param dashes the dash length array as per {@code BasicStroke} |
|
116 |
* @param dashphase the initial dash phase as per {@code BasicStroke} |
|
117 |
* @return the widened path stored in a new {@code Shape} object |
|
118 |
* @since 1.7 |
|
119 |
*/ |
|
120 |
@Override |
|
121 |
public Shape createStrokedShape(Shape src, |
|
122 |
float width, |
|
123 |
int caps, |
|
124 |
int join, |
|
125 |
float miterlimit, |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
126 |
float[] dashes, |
34417 | 127 |
float dashphase) |
128 |
{ |
|
129 |
final RendererContext rdrCtx = getRendererContext(); |
|
130 |
try { |
|
131 |
// initialize a large copyable Path2D to avoid a lot of array growing: |
|
40421
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
132 |
final Path2D.Float p2d = rdrCtx.getPath2D(); |
34417 | 133 |
|
134 |
strokeTo(rdrCtx, |
|
135 |
src, |
|
136 |
null, |
|
137 |
width, |
|
138 |
NormMode.OFF, |
|
139 |
caps, |
|
140 |
join, |
|
141 |
miterlimit, |
|
142 |
dashes, |
|
143 |
dashphase, |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
144 |
rdrCtx.transformerPC2D.wrapPath2D(p2d) |
34417 | 145 |
); |
146 |
||
147 |
// Use Path2D copy constructor (trim) |
|
148 |
return new Path2D.Float(p2d); |
|
149 |
||
150 |
} finally { |
|
151 |
// recycle the RendererContext instance |
|
152 |
returnRendererContext(rdrCtx); |
|
153 |
} |
|
154 |
} |
|
155 |
||
156 |
/** |
|
157 |
* Sends the geometry for a widened path as specified by the parameters |
|
158 |
* to the specified consumer. |
|
159 |
* <p> |
|
160 |
* The specified {@code src} {@link Shape} is widened according |
|
161 |
* to the parameters specified by the {@link BasicStroke} object. |
|
162 |
* Adjustments are made to the path as appropriate for the |
|
44655
06871a50a4b5
8177461: Wrong references are used in the javadoc in the java.desktop module
serb
parents:
40421
diff
changeset
|
163 |
* {@link java.awt.RenderingHints#VALUE_STROKE_NORMALIZE} hint if the |
06871a50a4b5
8177461: Wrong references are used in the javadoc in the java.desktop module
serb
parents:
40421
diff
changeset
|
164 |
* {@code normalize} boolean parameter is true. |
34417 | 165 |
* Adjustments are made to the path as appropriate for the |
44655
06871a50a4b5
8177461: Wrong references are used in the javadoc in the java.desktop module
serb
parents:
40421
diff
changeset
|
166 |
* {@link java.awt.RenderingHints#VALUE_ANTIALIAS_ON} hint if the |
06871a50a4b5
8177461: Wrong references are used in the javadoc in the java.desktop module
serb
parents:
40421
diff
changeset
|
167 |
* {@code antialias} boolean parameter is true. |
34417 | 168 |
* <p> |
169 |
* The geometry of the widened path is forwarded to the indicated |
|
170 |
* {@link PathConsumer2D} object as it is calculated. |
|
171 |
* |
|
172 |
* @param src the source path to be widened |
|
173 |
* @param bs the {@code BasicSroke} object specifying the |
|
174 |
* decorations to be applied to the widened path |
|
175 |
* @param normalize indicates whether stroke normalization should |
|
176 |
* be applied |
|
177 |
* @param antialias indicates whether or not adjustments appropriate |
|
178 |
* to antialiased rendering should be applied |
|
179 |
* @param consumer the {@code PathConsumer2D} instance to forward |
|
180 |
* the widened geometry to |
|
181 |
* @since 1.7 |
|
182 |
*/ |
|
183 |
@Override |
|
184 |
public void strokeTo(Shape src, |
|
185 |
AffineTransform at, |
|
186 |
BasicStroke bs, |
|
187 |
boolean thin, |
|
188 |
boolean normalize, |
|
189 |
boolean antialias, |
|
190 |
final PathConsumer2D consumer) |
|
191 |
{ |
|
192 |
final NormMode norm = (normalize) ? |
|
193 |
((antialias) ? NormMode.ON_WITH_AA : NormMode.ON_NO_AA) |
|
194 |
: NormMode.OFF; |
|
195 |
||
196 |
final RendererContext rdrCtx = getRendererContext(); |
|
197 |
try { |
|
198 |
strokeTo(rdrCtx, src, at, bs, thin, norm, antialias, consumer); |
|
199 |
} finally { |
|
200 |
// recycle the RendererContext instance |
|
201 |
returnRendererContext(rdrCtx); |
|
202 |
} |
|
203 |
} |
|
204 |
||
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
205 |
void strokeTo(final RendererContext rdrCtx, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
206 |
Shape src, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
207 |
AffineTransform at, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
208 |
BasicStroke bs, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
209 |
boolean thin, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
210 |
NormMode normalize, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
211 |
boolean antialias, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
212 |
PathConsumer2D pc2d) |
34417 | 213 |
{ |
214 |
float lw; |
|
215 |
if (thin) { |
|
216 |
if (antialias) { |
|
217 |
lw = userSpaceLineWidth(at, MIN_PEN_SIZE); |
|
218 |
} else { |
|
219 |
lw = userSpaceLineWidth(at, 1.0f); |
|
220 |
} |
|
221 |
} else { |
|
222 |
lw = bs.getLineWidth(); |
|
223 |
} |
|
224 |
strokeTo(rdrCtx, |
|
225 |
src, |
|
226 |
at, |
|
227 |
lw, |
|
228 |
normalize, |
|
229 |
bs.getEndCap(), |
|
230 |
bs.getLineJoin(), |
|
231 |
bs.getMiterLimit(), |
|
232 |
bs.getDashArray(), |
|
233 |
bs.getDashPhase(), |
|
234 |
pc2d); |
|
235 |
} |
|
236 |
||
47971
75686e8da573
8190228: Remove redundant modifiers in java.desktop module.
ssadetsky
parents:
47216
diff
changeset
|
237 |
private float userSpaceLineWidth(AffineTransform at, float lw) { |
34417 | 238 |
|
239 |
float widthScale; |
|
240 |
||
241 |
if (at == null) { |
|
242 |
widthScale = 1.0f; |
|
243 |
} else if ((at.getType() & (AffineTransform.TYPE_GENERAL_TRANSFORM | |
|
244 |
AffineTransform.TYPE_GENERAL_SCALE)) != 0) { |
|
245 |
widthScale = (float)Math.sqrt(at.getDeterminant()); |
|
246 |
} else { |
|
247 |
// First calculate the "maximum scale" of this transform. |
|
248 |
double A = at.getScaleX(); // m00 |
|
249 |
double C = at.getShearX(); // m01 |
|
250 |
double B = at.getShearY(); // m10 |
|
251 |
double D = at.getScaleY(); // m11 |
|
252 |
||
253 |
/* |
|
254 |
* Given a 2 x 2 affine matrix [ A B ] such that |
|
255 |
* [ C D ] |
|
256 |
* v' = [x' y'] = [Ax + Cy, Bx + Dy], we want to |
|
257 |
* find the maximum magnitude (norm) of the vector v' |
|
258 |
* with the constraint (x^2 + y^2 = 1). |
|
259 |
* The equation to maximize is |
|
260 |
* |v'| = sqrt((Ax+Cy)^2+(Bx+Dy)^2) |
|
261 |
* or |v'| = sqrt((AA+BB)x^2 + 2(AC+BD)xy + (CC+DD)y^2). |
|
262 |
* Since sqrt is monotonic we can maximize |v'|^2 |
|
263 |
* instead and plug in the substitution y = sqrt(1 - x^2). |
|
264 |
* Trigonometric equalities can then be used to get |
|
265 |
* rid of most of the sqrt terms. |
|
266 |
*/ |
|
267 |
||
268 |
double EA = A*A + B*B; // x^2 coefficient |
|
47126 | 269 |
double EB = 2.0d * (A*C + B*D); // xy coefficient |
34417 | 270 |
double EC = C*C + D*D; // y^2 coefficient |
271 |
||
272 |
/* |
|
273 |
* There is a lot of calculus omitted here. |
|
274 |
* |
|
275 |
* Conceptually, in the interests of understanding the |
|
276 |
* terms that the calculus produced we can consider |
|
277 |
* that EA and EC end up providing the lengths along |
|
278 |
* the major axes and the hypot term ends up being an |
|
279 |
* adjustment for the additional length along the off-axis |
|
280 |
* angle of rotated or sheared ellipses as well as an |
|
281 |
* adjustment for the fact that the equation below |
|
282 |
* averages the two major axis lengths. (Notice that |
|
283 |
* the hypot term contains a part which resolves to the |
|
284 |
* difference of these two axis lengths in the absence |
|
285 |
* of rotation.) |
|
286 |
* |
|
287 |
* In the calculus, the ratio of the EB and (EA-EC) terms |
|
288 |
* ends up being the tangent of 2*theta where theta is |
|
289 |
* the angle that the long axis of the ellipse makes |
|
290 |
* with the horizontal axis. Thus, this equation is |
|
291 |
* calculating the length of the hypotenuse of a triangle |
|
292 |
* along that axis. |
|
293 |
*/ |
|
294 |
||
295 |
double hypot = Math.sqrt(EB*EB + (EA-EC)*(EA-EC)); |
|
296 |
// sqrt omitted, compare to squared limits below. |
|
47126 | 297 |
double widthsquared = ((EA + EC + hypot) / 2.0d); |
34417 | 298 |
|
299 |
widthScale = (float)Math.sqrt(widthsquared); |
|
300 |
} |
|
301 |
||
302 |
return (lw / widthScale); |
|
303 |
} |
|
304 |
||
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
305 |
void strokeTo(final RendererContext rdrCtx, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
306 |
Shape src, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
307 |
AffineTransform at, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
308 |
float width, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
309 |
NormMode norm, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
310 |
int caps, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
311 |
int join, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
312 |
float miterlimit, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
313 |
float[] dashes, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
314 |
float dashphase, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
315 |
PathConsumer2D pc2d) |
34417 | 316 |
{ |
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
317 |
// We use strokerat so that in Stroker and Dasher we can work only |
34417 | 318 |
// with the pre-transformation coordinates. This will repeat a lot of |
319 |
// computations done in the path iterator, but the alternative is to |
|
320 |
// work with transformed paths and compute untransformed coordinates |
|
321 |
// as needed. This would be faster but I do not think the complexity |
|
322 |
// of working with both untransformed and transformed coordinates in |
|
323 |
// the same code is worth it. |
|
324 |
// However, if a path's width is constant after a transformation, |
|
325 |
// we can skip all this untransforming. |
|
326 |
||
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
327 |
// As pathTo() will check transformed coordinates for invalid values |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
328 |
// (NaN / Infinity) to ignore such points, it is necessary to apply the |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
329 |
// transformation before the path processing. |
34417 | 330 |
AffineTransform strokerat = null; |
331 |
||
332 |
int dashLen = -1; |
|
333 |
boolean recycleDashes = false; |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
334 |
float scale = 1.0f; |
34417 | 335 |
|
336 |
if (at != null && !at.isIdentity()) { |
|
337 |
final double a = at.getScaleX(); |
|
338 |
final double b = at.getShearX(); |
|
339 |
final double c = at.getShearY(); |
|
340 |
final double d = at.getScaleY(); |
|
341 |
final double det = a * d - c * b; |
|
342 |
||
47126 | 343 |
if (Math.abs(det) <= (2.0f * Float.MIN_VALUE)) { |
34417 | 344 |
// this rendering engine takes one dimensional curves and turns |
345 |
// them into 2D shapes by giving them width. |
|
346 |
// However, if everything is to be passed through a singular |
|
347 |
// transformation, these 2D shapes will be squashed down to 1D |
|
348 |
// again so, nothing can be drawn. |
|
349 |
||
350 |
// Every path needs an initial moveTo and a pathDone. If these |
|
351 |
// are not there this causes a SIGSEGV in libawt.so (at the time |
|
352 |
// of writing of this comment (September 16, 2010)). Actually, |
|
353 |
// I am not sure if the moveTo is necessary to avoid the SIGSEGV |
|
354 |
// but the pathDone is definitely needed. |
|
47126 | 355 |
pc2d.moveTo(0.0f, 0.0f); |
34417 | 356 |
pc2d.pathDone(); |
357 |
return; |
|
358 |
} |
|
359 |
||
360 |
// If the transform is a constant multiple of an orthogonal transformation |
|
361 |
// then every length is just multiplied by a constant, so we just |
|
362 |
// need to transform input paths to stroker and tell stroker |
|
363 |
// the scaled width. This condition is satisfied if |
|
364 |
// a*b == -c*d && a*a+c*c == b*b+d*d. In the actual check below, we |
|
365 |
// leave a bit of room for error. |
|
366 |
if (nearZero(a*b + c*d) && nearZero(a*a + c*c - (b*b + d*d))) { |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
367 |
scale = (float) Math.sqrt(a*a + c*c); |
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
368 |
|
34417 | 369 |
if (dashes != null) { |
370 |
recycleDashes = true; |
|
371 |
dashLen = dashes.length; |
|
47126 | 372 |
dashes = rdrCtx.dasher.copyDashArray(dashes); |
34417 | 373 |
for (int i = 0; i < dashLen; i++) { |
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
374 |
dashes[i] *= scale; |
34417 | 375 |
} |
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
376 |
dashphase *= scale; |
34417 | 377 |
} |
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
378 |
width *= scale; |
34417 | 379 |
|
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
380 |
// by now strokerat == null. Input paths to |
34417 | 381 |
// stroker (and maybe dasher) will have the full transform at |
382 |
// applied to them and nothing will happen to the output paths. |
|
383 |
} else { |
|
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
384 |
strokerat = at; |
34417 | 385 |
|
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
386 |
// by now strokerat == at. Input paths to |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
387 |
// stroker (and maybe dasher) will have the full transform at |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
388 |
// applied to them, then they will be normalized, and then |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
389 |
// the inverse of *only the non translation part of at* will |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
390 |
// be applied to the normalized paths. This won't cause problems |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
391 |
// in stroker, because, suppose at = T*A, where T is just the |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
392 |
// translation part of at, and A is the rest. T*A has already |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
393 |
// been applied to Stroker/Dasher's input. Then Ainv will be |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
394 |
// applied. Ainv*T*A is not equal to T, but it is a translation, |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
395 |
// which means that none of stroker's assumptions about its |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
396 |
// input will be violated. After all this, A will be applied |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
397 |
// to stroker's output. |
34417 | 398 |
} |
399 |
} else { |
|
400 |
// either at is null or it's the identity. In either case |
|
401 |
// we don't transform the path. |
|
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
402 |
at = null; |
34417 | 403 |
} |
404 |
||
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
405 |
final TransformingPathConsumer2D transformerPC2D = rdrCtx.transformerPC2D; |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
406 |
|
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
407 |
if (DO_TRACE_PATH) { |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
408 |
// trace Stroker: |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
409 |
pc2d = transformerPC2D.traceStroker(pc2d); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
410 |
} |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
411 |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
412 |
if (USE_SIMPLIFIER) { |
34417 | 413 |
// Use simplifier after stroker before Renderer |
414 |
// to remove collinear segments (notably due to cap square) |
|
415 |
pc2d = rdrCtx.simplifier.init(pc2d); |
|
416 |
} |
|
417 |
||
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
418 |
// deltaTransformConsumer may adjust the clip rectangle: |
34417 | 419 |
pc2d = transformerPC2D.deltaTransformConsumer(pc2d, strokerat); |
420 |
||
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
421 |
// stroker will adjust the clip rectangle (width / miter limit): |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
422 |
pc2d = rdrCtx.stroker.init(pc2d, width, caps, join, miterlimit, scale); |
34417 | 423 |
|
424 |
if (dashes != null) { |
|
425 |
if (!recycleDashes) { |
|
426 |
dashLen = dashes.length; |
|
427 |
} |
|
428 |
pc2d = rdrCtx.dasher.init(pc2d, dashes, dashLen, dashphase, |
|
429 |
recycleDashes); |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
430 |
} else if (rdrCtx.doClip && (caps != Stroker.CAP_BUTT)) { |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
431 |
if (DO_TRACE_PATH) { |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
432 |
pc2d = transformerPC2D.traceClosedPathDetector(pc2d); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
433 |
} |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
434 |
|
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
435 |
// If no dash and clip is enabled: |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
436 |
// detect closedPaths (polygons) for caps |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
437 |
pc2d = transformerPC2D.detectClosedPath(pc2d); |
34417 | 438 |
} |
439 |
pc2d = transformerPC2D.inverseDeltaTransformConsumer(pc2d, strokerat); |
|
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
440 |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
441 |
if (DO_TRACE_PATH) { |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
442 |
// trace Input: |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
443 |
pc2d = transformerPC2D.traceInput(pc2d); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
444 |
} |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
445 |
|
40421
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
446 |
final PathIterator pi = norm.getNormalizingPathIterator(rdrCtx, |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
447 |
src.getPathIterator(at)); |
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
448 |
|
34417 | 449 |
pathTo(rdrCtx, pi, pc2d); |
450 |
||
451 |
/* |
|
452 |
* Pipeline seems to be: |
|
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
453 |
* shape.getPathIterator(at) |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
454 |
* -> (NormalizingPathIterator) |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
455 |
* -> (inverseDeltaTransformConsumer) |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
456 |
* -> (Dasher) |
34417 | 457 |
* -> Stroker |
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
458 |
* -> (deltaTransformConsumer) |
34417 | 459 |
* |
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
460 |
* -> (CollinearSimplifier) to remove redundant segments |
34417 | 461 |
* |
462 |
* -> pc2d = Renderer (bounding box) |
|
463 |
*/ |
|
464 |
} |
|
465 |
||
466 |
private static boolean nearZero(final double num) { |
|
47126 | 467 |
return Math.abs(num) < 2.0d * Math.ulp(num); |
34417 | 468 |
} |
469 |
||
470 |
abstract static class NormalizingPathIterator implements PathIterator { |
|
471 |
||
472 |
private PathIterator src; |
|
473 |
||
474 |
// the adjustment applied to the current position. |
|
475 |
private float curx_adjust, cury_adjust; |
|
476 |
// the adjustment applied to the last moveTo position. |
|
477 |
private float movx_adjust, movy_adjust; |
|
478 |
||
479 |
private final float[] tmp; |
|
480 |
||
481 |
NormalizingPathIterator(final float[] tmp) { |
|
482 |
this.tmp = tmp; |
|
483 |
} |
|
484 |
||
485 |
final NormalizingPathIterator init(final PathIterator src) { |
|
486 |
this.src = src; |
|
487 |
return this; // fluent API |
|
488 |
} |
|
489 |
||
490 |
/** |
|
491 |
* Disposes this path iterator: |
|
492 |
* clean up before reusing this instance |
|
493 |
*/ |
|
494 |
final void dispose() { |
|
495 |
// free source PathIterator: |
|
496 |
this.src = null; |
|
497 |
} |
|
498 |
||
499 |
@Override |
|
500 |
public final int currentSegment(final float[] coords) { |
|
501 |
int lastCoord; |
|
502 |
final int type = src.currentSegment(coords); |
|
503 |
||
504 |
switch(type) { |
|
505 |
case PathIterator.SEG_MOVETO: |
|
506 |
case PathIterator.SEG_LINETO: |
|
507 |
lastCoord = 0; |
|
508 |
break; |
|
509 |
case PathIterator.SEG_QUADTO: |
|
510 |
lastCoord = 2; |
|
511 |
break; |
|
512 |
case PathIterator.SEG_CUBICTO: |
|
513 |
lastCoord = 4; |
|
514 |
break; |
|
515 |
case PathIterator.SEG_CLOSE: |
|
516 |
// we don't want to deal with this case later. We just exit now |
|
517 |
curx_adjust = movx_adjust; |
|
518 |
cury_adjust = movy_adjust; |
|
519 |
return type; |
|
520 |
default: |
|
521 |
throw new InternalError("Unrecognized curve type"); |
|
522 |
} |
|
523 |
||
524 |
// normalize endpoint |
|
525 |
float coord, x_adjust, y_adjust; |
|
526 |
||
527 |
coord = coords[lastCoord]; |
|
528 |
x_adjust = normCoord(coord); // new coord |
|
529 |
coords[lastCoord] = x_adjust; |
|
530 |
x_adjust -= coord; |
|
531 |
||
532 |
coord = coords[lastCoord + 1]; |
|
533 |
y_adjust = normCoord(coord); // new coord |
|
534 |
coords[lastCoord + 1] = y_adjust; |
|
535 |
y_adjust -= coord; |
|
536 |
||
537 |
// now that the end points are done, normalize the control points |
|
538 |
switch(type) { |
|
539 |
case PathIterator.SEG_MOVETO: |
|
540 |
movx_adjust = x_adjust; |
|
541 |
movy_adjust = y_adjust; |
|
542 |
break; |
|
543 |
case PathIterator.SEG_LINETO: |
|
544 |
break; |
|
545 |
case PathIterator.SEG_QUADTO: |
|
47126 | 546 |
coords[0] += (curx_adjust + x_adjust) / 2.0f; |
547 |
coords[1] += (cury_adjust + y_adjust) / 2.0f; |
|
34417 | 548 |
break; |
549 |
case PathIterator.SEG_CUBICTO: |
|
550 |
coords[0] += curx_adjust; |
|
551 |
coords[1] += cury_adjust; |
|
552 |
coords[2] += x_adjust; |
|
553 |
coords[3] += y_adjust; |
|
554 |
break; |
|
555 |
case PathIterator.SEG_CLOSE: |
|
556 |
// handled earlier |
|
557 |
default: |
|
558 |
} |
|
559 |
curx_adjust = x_adjust; |
|
560 |
cury_adjust = y_adjust; |
|
561 |
return type; |
|
562 |
} |
|
563 |
||
564 |
abstract float normCoord(final float coord); |
|
565 |
||
566 |
@Override |
|
567 |
public final int currentSegment(final double[] coords) { |
|
568 |
final float[] _tmp = tmp; // dirty |
|
569 |
int type = this.currentSegment(_tmp); |
|
570 |
for (int i = 0; i < 6; i++) { |
|
571 |
coords[i] = _tmp[i]; |
|
572 |
} |
|
573 |
return type; |
|
574 |
} |
|
575 |
||
576 |
@Override |
|
577 |
public final int getWindingRule() { |
|
578 |
return src.getWindingRule(); |
|
579 |
} |
|
580 |
||
581 |
@Override |
|
582 |
public final boolean isDone() { |
|
583 |
if (src.isDone()) { |
|
584 |
// Dispose this instance: |
|
585 |
dispose(); |
|
586 |
return true; |
|
587 |
} |
|
588 |
return false; |
|
589 |
} |
|
590 |
||
591 |
@Override |
|
592 |
public final void next() { |
|
593 |
src.next(); |
|
594 |
} |
|
595 |
||
596 |
static final class NearestPixelCenter |
|
597 |
extends NormalizingPathIterator |
|
598 |
{ |
|
599 |
NearestPixelCenter(final float[] tmp) { |
|
600 |
super(tmp); |
|
601 |
} |
|
602 |
||
603 |
@Override |
|
604 |
float normCoord(final float coord) { |
|
605 |
// round to nearest pixel center |
|
606 |
return FloatMath.floor_f(coord) + 0.5f; |
|
607 |
} |
|
608 |
} |
|
609 |
||
610 |
static final class NearestPixelQuarter |
|
611 |
extends NormalizingPathIterator |
|
612 |
{ |
|
613 |
NearestPixelQuarter(final float[] tmp) { |
|
614 |
super(tmp); |
|
615 |
} |
|
616 |
||
617 |
@Override |
|
618 |
float normCoord(final float coord) { |
|
619 |
// round to nearest (0.25, 0.25) pixel quarter |
|
620 |
return FloatMath.floor_f(coord + 0.25f) + 0.25f; |
|
621 |
} |
|
622 |
} |
|
623 |
} |
|
624 |
||
625 |
private static void pathTo(final RendererContext rdrCtx, final PathIterator pi, |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
626 |
PathConsumer2D pc2d) |
34417 | 627 |
{ |
628 |
// mark context as DIRTY: |
|
629 |
rdrCtx.dirty = true; |
|
630 |
||
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
631 |
pathToLoop(rdrCtx.float6, pi, pc2d); |
34417 | 632 |
|
633 |
// mark context as CLEAN: |
|
634 |
rdrCtx.dirty = false; |
|
635 |
} |
|
636 |
||
637 |
private static void pathToLoop(final float[] coords, final PathIterator pi, |
|
638 |
final PathConsumer2D pc2d) |
|
639 |
{ |
|
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
640 |
// ported from DuctusRenderingEngine.feedConsumer() but simplified: |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
641 |
// - removed skip flag = !subpathStarted |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
642 |
// - removed pathClosed (ie subpathStarted not set to false) |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
643 |
boolean subpathStarted = false; |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
644 |
|
34417 | 645 |
for (; !pi.isDone(); pi.next()) { |
646 |
switch (pi.currentSegment(coords)) { |
|
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
647 |
case PathIterator.SEG_MOVETO: |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
648 |
/* Checking SEG_MOVETO coordinates if they are out of the |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
649 |
* [LOWER_BND, UPPER_BND] range. This check also handles NaN |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
650 |
* and Infinity values. Skipping next path segment in case of |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
651 |
* invalid data. |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
652 |
*/ |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
653 |
if (coords[0] < UPPER_BND && coords[0] > LOWER_BND && |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
654 |
coords[1] < UPPER_BND && coords[1] > LOWER_BND) |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
655 |
{ |
34417 | 656 |
pc2d.moveTo(coords[0], coords[1]); |
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
657 |
subpathStarted = true; |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
658 |
} |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
659 |
break; |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
660 |
case PathIterator.SEG_LINETO: |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
661 |
/* Checking SEG_LINETO coordinates if they are out of the |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
662 |
* [LOWER_BND, UPPER_BND] range. This check also handles NaN |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
663 |
* and Infinity values. Ignoring current path segment in case |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
664 |
* of invalid data. If segment is skipped its endpoint |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
665 |
* (if valid) is used to begin new subpath. |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
666 |
*/ |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
667 |
if (coords[0] < UPPER_BND && coords[0] > LOWER_BND && |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
668 |
coords[1] < UPPER_BND && coords[1] > LOWER_BND) |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
669 |
{ |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
670 |
if (subpathStarted) { |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
671 |
pc2d.lineTo(coords[0], coords[1]); |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
672 |
} else { |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
673 |
pc2d.moveTo(coords[0], coords[1]); |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
674 |
subpathStarted = true; |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
675 |
} |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
676 |
} |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
677 |
break; |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
678 |
case PathIterator.SEG_QUADTO: |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
679 |
// Quadratic curves take two points |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
680 |
/* Checking SEG_QUADTO coordinates if they are out of the |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
681 |
* [LOWER_BND, UPPER_BND] range. This check also handles NaN |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
682 |
* and Infinity values. Ignoring current path segment in case |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
683 |
* of invalid endpoints's data. Equivalent to the SEG_LINETO |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
684 |
* if endpoint coordinates are valid but there are invalid data |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
685 |
* among other coordinates |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
686 |
*/ |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
687 |
if (coords[2] < UPPER_BND && coords[2] > LOWER_BND && |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
688 |
coords[3] < UPPER_BND && coords[3] > LOWER_BND) |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
689 |
{ |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
690 |
if (subpathStarted) { |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
691 |
if (coords[0] < UPPER_BND && coords[0] > LOWER_BND && |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
692 |
coords[1] < UPPER_BND && coords[1] > LOWER_BND) |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
693 |
{ |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
694 |
pc2d.quadTo(coords[0], coords[1], |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
695 |
coords[2], coords[3]); |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
696 |
} else { |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
697 |
pc2d.lineTo(coords[2], coords[3]); |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
698 |
} |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
699 |
} else { |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
700 |
pc2d.moveTo(coords[2], coords[3]); |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
701 |
subpathStarted = true; |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
702 |
} |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
703 |
} |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
704 |
break; |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
705 |
case PathIterator.SEG_CUBICTO: |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
706 |
// Cubic curves take three points |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
707 |
/* Checking SEG_CUBICTO coordinates if they are out of the |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
708 |
* [LOWER_BND, UPPER_BND] range. This check also handles NaN |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
709 |
* and Infinity values. Ignoring current path segment in case |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
710 |
* of invalid endpoints's data. Equivalent to the SEG_LINETO |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
711 |
* if endpoint coordinates are valid but there are invalid data |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
712 |
* among other coordinates |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
713 |
*/ |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
714 |
if (coords[4] < UPPER_BND && coords[4] > LOWER_BND && |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
715 |
coords[5] < UPPER_BND && coords[5] > LOWER_BND) |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
716 |
{ |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
717 |
if (subpathStarted) { |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
718 |
if (coords[0] < UPPER_BND && coords[0] > LOWER_BND && |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
719 |
coords[1] < UPPER_BND && coords[1] > LOWER_BND && |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
720 |
coords[2] < UPPER_BND && coords[2] > LOWER_BND && |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
721 |
coords[3] < UPPER_BND && coords[3] > LOWER_BND) |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
722 |
{ |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
723 |
pc2d.curveTo(coords[0], coords[1], |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
724 |
coords[2], coords[3], |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
725 |
coords[4], coords[5]); |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
726 |
} else { |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
727 |
pc2d.lineTo(coords[4], coords[5]); |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
728 |
} |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
729 |
} else { |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
730 |
pc2d.moveTo(coords[4], coords[5]); |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
731 |
subpathStarted = true; |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
732 |
} |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
733 |
} |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
734 |
break; |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
735 |
case PathIterator.SEG_CLOSE: |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
736 |
if (subpathStarted) { |
34417 | 737 |
pc2d.closePath(); |
36902
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
738 |
// do not set subpathStarted to false |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
739 |
// in case of missing moveTo() after close() |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
740 |
} |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
741 |
break; |
bb30d89aa00e
8144938: Handle properly coordinate overflow in Marlin Renderer
lbourges
parents:
36458
diff
changeset
|
742 |
default: |
34417 | 743 |
} |
744 |
} |
|
745 |
pc2d.pathDone(); |
|
746 |
} |
|
747 |
||
748 |
/** |
|
749 |
* Construct an antialiased tile generator for the given shape with |
|
750 |
* the given rendering attributes and store the bounds of the tile |
|
751 |
* iteration in the bbox parameter. |
|
752 |
* The {@code at} parameter specifies a transform that should affect |
|
753 |
* both the shape and the {@code BasicStroke} attributes. |
|
754 |
* The {@code clip} parameter specifies the current clip in effect |
|
755 |
* in device coordinates and can be used to prune the data for the |
|
756 |
* operation, but the renderer is not required to perform any |
|
757 |
* clipping. |
|
758 |
* If the {@code BasicStroke} parameter is null then the shape |
|
759 |
* should be filled as is, otherwise the attributes of the |
|
760 |
* {@code BasicStroke} should be used to specify a draw operation. |
|
761 |
* The {@code thin} parameter indicates whether or not the |
|
762 |
* transformed {@code BasicStroke} represents coordinates smaller |
|
763 |
* than the minimum resolution of the antialiasing rasterizer as |
|
764 |
* specified by the {@code getMinimumAAPenWidth()} method. |
|
765 |
* <p> |
|
766 |
* Upon returning, this method will fill the {@code bbox} parameter |
|
767 |
* with 4 values indicating the bounds of the iteration of the |
|
768 |
* tile generator. |
|
769 |
* The iteration order of the tiles will be as specified by the |
|
770 |
* pseudo-code: |
|
771 |
* <pre> |
|
772 |
* for (y = bbox[1]; y < bbox[3]; y += tileheight) { |
|
773 |
* for (x = bbox[0]; x < bbox[2]; x += tilewidth) { |
|
774 |
* } |
|
775 |
* } |
|
776 |
* </pre> |
|
777 |
* If there is no output to be rendered, this method may return |
|
778 |
* null. |
|
779 |
* |
|
780 |
* @param s the shape to be rendered (fill or draw) |
|
781 |
* @param at the transform to be applied to the shape and the |
|
782 |
* stroke attributes |
|
783 |
* @param clip the current clip in effect in device coordinates |
|
784 |
* @param bs if non-null, a {@code BasicStroke} whose attributes |
|
785 |
* should be applied to this operation |
|
786 |
* @param thin true if the transformed stroke attributes are smaller |
|
787 |
* than the minimum dropout pen width |
|
788 |
* @param normalize true if the {@code VALUE_STROKE_NORMALIZE} |
|
789 |
* {@code RenderingHint} is in effect |
|
790 |
* @param bbox returns the bounds of the iteration |
|
791 |
* @return the {@code AATileGenerator} instance to be consulted |
|
792 |
* for tile coverages, or null if there is no output to render |
|
793 |
* @since 1.7 |
|
794 |
*/ |
|
795 |
@Override |
|
796 |
public AATileGenerator getAATileGenerator(Shape s, |
|
797 |
AffineTransform at, |
|
798 |
Region clip, |
|
799 |
BasicStroke bs, |
|
800 |
boolean thin, |
|
801 |
boolean normalize, |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
802 |
int[] bbox) |
34417 | 803 |
{ |
804 |
MarlinTileGenerator ptg = null; |
|
805 |
Renderer r = null; |
|
806 |
||
807 |
final RendererContext rdrCtx = getRendererContext(); |
|
808 |
try { |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
809 |
if (DO_CLIP || (DO_CLIP_RUNTIME_ENABLE && MarlinProperties.isDoClipAtRuntime())) { |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
810 |
// Define the initial clip bounds: |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
811 |
final float[] clipRect = rdrCtx.clipRect; |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
812 |
|
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
813 |
clipRect[0] = clip.getLoY(); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
814 |
clipRect[1] = clip.getLoY() + clip.getHeight(); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
815 |
clipRect[2] = clip.getLoX(); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
816 |
clipRect[3] = clip.getLoX() + clip.getWidth(); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
817 |
|
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
818 |
// Enable clipping: |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
819 |
rdrCtx.doClip = true; |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
820 |
} |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
821 |
|
34417 | 822 |
// Test if at is identity: |
823 |
final AffineTransform _at = (at != null && !at.isIdentity()) ? at |
|
824 |
: null; |
|
825 |
||
826 |
final NormMode norm = (normalize) ? NormMode.ON_WITH_AA : NormMode.OFF; |
|
827 |
||
828 |
if (bs == null) { |
|
829 |
// fill shape: |
|
40421
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
830 |
final PathIterator pi = norm.getNormalizingPathIterator(rdrCtx, |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
831 |
s.getPathIterator(_at)); |
34417 | 832 |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
833 |
// note: Winding rule may be EvenOdd ONLY for fill operations ! |
34417 | 834 |
r = rdrCtx.renderer.init(clip.getLoX(), clip.getLoY(), |
835 |
clip.getWidth(), clip.getHeight(), |
|
836 |
pi.getWindingRule()); |
|
837 |
||
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
838 |
PathConsumer2D pc2d = r; |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
839 |
|
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
840 |
if (DO_CLIP_FILL && rdrCtx.doClip) { |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
841 |
if (DO_TRACE_PATH) { |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
842 |
// trace Filler: |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
843 |
pc2d = rdrCtx.transformerPC2D.traceFiller(pc2d); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
844 |
} |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
845 |
pc2d = rdrCtx.transformerPC2D.pathClipper(pc2d); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
846 |
} |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
847 |
|
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
848 |
if (DO_TRACE_PATH) { |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
849 |
// trace Input: |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
850 |
pc2d = rdrCtx.transformerPC2D.traceInput(pc2d); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
851 |
} |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
852 |
|
34417 | 853 |
// TODO: subdivide quad/cubic curves into monotonic curves ? |
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
854 |
pathTo(rdrCtx, pi, pc2d); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
855 |
|
34417 | 856 |
} else { |
857 |
// draw shape with given stroke: |
|
858 |
r = rdrCtx.renderer.init(clip.getLoX(), clip.getLoY(), |
|
859 |
clip.getWidth(), clip.getHeight(), |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
860 |
WIND_NON_ZERO); |
34417 | 861 |
|
862 |
strokeTo(rdrCtx, s, _at, bs, thin, norm, true, r); |
|
863 |
} |
|
864 |
if (r.endRendering()) { |
|
865 |
ptg = rdrCtx.ptg.init(); |
|
866 |
ptg.getBbox(bbox); |
|
867 |
// note: do not returnRendererContext(rdrCtx) |
|
868 |
// as it will be called later by MarlinTileGenerator.dispose() |
|
869 |
r = null; |
|
870 |
} |
|
871 |
} finally { |
|
872 |
if (r != null) { |
|
47126 | 873 |
// dispose renderer and recycle the RendererContext instance: |
34417 | 874 |
r.dispose(); |
875 |
} |
|
876 |
} |
|
877 |
||
878 |
// Return null to cancel AA tile generation (nothing to render) |
|
879 |
return ptg; |
|
880 |
} |
|
881 |
||
882 |
@Override |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
883 |
public AATileGenerator getAATileGenerator(double x, double y, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
884 |
double dx1, double dy1, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
885 |
double dx2, double dy2, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
886 |
double lw1, double lw2, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
887 |
Region clip, |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
888 |
int[] bbox) |
34417 | 889 |
{ |
890 |
// REMIND: Deal with large coordinates! |
|
891 |
double ldx1, ldy1, ldx2, ldy2; |
|
47126 | 892 |
boolean innerpgram = (lw1 > 0.0d && lw2 > 0.0d); |
34417 | 893 |
|
894 |
if (innerpgram) { |
|
895 |
ldx1 = dx1 * lw1; |
|
896 |
ldy1 = dy1 * lw1; |
|
897 |
ldx2 = dx2 * lw2; |
|
898 |
ldy2 = dy2 * lw2; |
|
47126 | 899 |
x -= (ldx1 + ldx2) / 2.0d; |
900 |
y -= (ldy1 + ldy2) / 2.0d; |
|
34417 | 901 |
dx1 += ldx1; |
902 |
dy1 += ldy1; |
|
903 |
dx2 += ldx2; |
|
904 |
dy2 += ldy2; |
|
47126 | 905 |
if (lw1 > 1.0d && lw2 > 1.0d) { |
34417 | 906 |
// Inner parallelogram was entirely consumed by stroke... |
907 |
innerpgram = false; |
|
908 |
} |
|
909 |
} else { |
|
47126 | 910 |
ldx1 = ldy1 = ldx2 = ldy2 = 0.0d; |
34417 | 911 |
} |
912 |
||
913 |
MarlinTileGenerator ptg = null; |
|
914 |
Renderer r = null; |
|
915 |
||
916 |
final RendererContext rdrCtx = getRendererContext(); |
|
917 |
try { |
|
918 |
r = rdrCtx.renderer.init(clip.getLoX(), clip.getLoY(), |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
919 |
clip.getWidth(), clip.getHeight(), |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
920 |
WIND_EVEN_ODD); |
34417 | 921 |
|
922 |
r.moveTo((float) x, (float) y); |
|
923 |
r.lineTo((float) (x+dx1), (float) (y+dy1)); |
|
924 |
r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2)); |
|
925 |
r.lineTo((float) (x+dx2), (float) (y+dy2)); |
|
926 |
r.closePath(); |
|
927 |
||
928 |
if (innerpgram) { |
|
929 |
x += ldx1 + ldx2; |
|
930 |
y += ldy1 + ldy2; |
|
47126 | 931 |
dx1 -= 2.0d * ldx1; |
932 |
dy1 -= 2.0d * ldy1; |
|
933 |
dx2 -= 2.0d * ldx2; |
|
934 |
dy2 -= 2.0d * ldy2; |
|
34417 | 935 |
r.moveTo((float) x, (float) y); |
936 |
r.lineTo((float) (x+dx1), (float) (y+dy1)); |
|
937 |
r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2)); |
|
938 |
r.lineTo((float) (x+dx2), (float) (y+dy2)); |
|
939 |
r.closePath(); |
|
940 |
} |
|
941 |
r.pathDone(); |
|
942 |
||
943 |
if (r.endRendering()) { |
|
944 |
ptg = rdrCtx.ptg.init(); |
|
945 |
ptg.getBbox(bbox); |
|
946 |
// note: do not returnRendererContext(rdrCtx) |
|
947 |
// as it will be called later by MarlinTileGenerator.dispose() |
|
948 |
r = null; |
|
949 |
} |
|
950 |
} finally { |
|
951 |
if (r != null) { |
|
47126 | 952 |
// dispose renderer and recycle the RendererContext instance: |
34417 | 953 |
r.dispose(); |
954 |
} |
|
955 |
} |
|
956 |
||
957 |
// Return null to cancel AA tile generation (nothing to render) |
|
958 |
return ptg; |
|
959 |
} |
|
960 |
||
961 |
/** |
|
962 |
* Returns the minimum pen width that the antialiasing rasterizer |
|
963 |
* can represent without dropouts occuring. |
|
964 |
* @since 1.7 |
|
965 |
*/ |
|
966 |
@Override |
|
967 |
public float getMinimumAAPenSize() { |
|
968 |
return MIN_PEN_SIZE; |
|
969 |
} |
|
970 |
||
971 |
static { |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
972 |
if (PathIterator.WIND_NON_ZERO != WIND_NON_ZERO || |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
973 |
PathIterator.WIND_EVEN_ODD != WIND_EVEN_ODD || |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
974 |
BasicStroke.JOIN_MITER != JOIN_MITER || |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
975 |
BasicStroke.JOIN_ROUND != JOIN_ROUND || |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
976 |
BasicStroke.JOIN_BEVEL != JOIN_BEVEL || |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
977 |
BasicStroke.CAP_BUTT != CAP_BUTT || |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
978 |
BasicStroke.CAP_ROUND != CAP_ROUND || |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
979 |
BasicStroke.CAP_SQUARE != CAP_SQUARE) |
34417 | 980 |
{ |
981 |
throw new InternalError("mismatched renderer constants"); |
|
982 |
} |
|
983 |
} |
|
984 |
||
985 |
// --- RendererContext handling --- |
|
986 |
// use ThreadLocal or ConcurrentLinkedQueue to get one RendererContext |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
987 |
private static final boolean USE_THREAD_LOCAL; |
34417 | 988 |
|
989 |
// reference type stored in either TL or CLQ |
|
990 |
static final int REF_TYPE; |
|
991 |
||
992 |
// Per-thread RendererContext |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
993 |
private static final ReentrantContextProvider<RendererContext> RDR_CTX_PROVIDER; |
34417 | 994 |
|
995 |
// Static initializer to use TL or CLQ mode |
|
996 |
static { |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
997 |
USE_THREAD_LOCAL = MarlinProperties.isUseThreadLocal(); |
34417 | 998 |
|
999 |
// Soft reference by default: |
|
36458
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1000 |
final String refType = AccessController.doPrivileged( |
34417 | 1001 |
new GetPropertyAction("sun.java2d.renderer.useRef", |
1002 |
"soft")); |
|
1003 |
switch (refType) { |
|
1004 |
default: |
|
1005 |
case "soft": |
|
36458
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1006 |
REF_TYPE = ReentrantContextProvider.REF_SOFT; |
34417 | 1007 |
break; |
1008 |
case "weak": |
|
36458
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1009 |
REF_TYPE = ReentrantContextProvider.REF_WEAK; |
34417 | 1010 |
break; |
1011 |
case "hard": |
|
36458
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1012 |
REF_TYPE = ReentrantContextProvider.REF_HARD; |
34417 | 1013 |
break; |
1014 |
} |
|
36458
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1015 |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1016 |
if (USE_THREAD_LOCAL) { |
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1017 |
RDR_CTX_PROVIDER = new ReentrantContextProviderTL<RendererContext>(REF_TYPE) |
36458
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1018 |
{ |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1019 |
@Override |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1020 |
protected RendererContext newContext() { |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1021 |
return RendererContext.createContext(); |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1022 |
} |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1023 |
}; |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1024 |
} else { |
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1025 |
RDR_CTX_PROVIDER = new ReentrantContextProviderCLQ<RendererContext>(REF_TYPE) |
36458
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1026 |
{ |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1027 |
@Override |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1028 |
protected RendererContext newContext() { |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1029 |
return RendererContext.createContext(); |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1030 |
} |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1031 |
}; |
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1032 |
} |
34417 | 1033 |
} |
1034 |
||
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1035 |
private static boolean SETTINGS_LOGGED = !ENABLE_LOGS; |
34417 | 1036 |
|
1037 |
private static void logSettings(final String reClass) { |
|
1038 |
// log information at startup |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1039 |
if (SETTINGS_LOGGED) { |
34417 | 1040 |
return; |
1041 |
} |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1042 |
SETTINGS_LOGGED = true; |
34417 | 1043 |
|
1044 |
String refType; |
|
1045 |
switch (REF_TYPE) { |
|
1046 |
default: |
|
36458
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1047 |
case ReentrantContextProvider.REF_HARD: |
34417 | 1048 |
refType = "hard"; |
1049 |
break; |
|
36458
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1050 |
case ReentrantContextProvider.REF_SOFT: |
34417 | 1051 |
refType = "soft"; |
1052 |
break; |
|
36458
25786a73a5fc
8148886: SEGV in sun.java2d.marlin.Renderer._endRendering
lbourges
parents:
34417
diff
changeset
|
1053 |
case ReentrantContextProvider.REF_WEAK: |
34417 | 1054 |
refType = "weak"; |
1055 |
break; |
|
1056 |
} |
|
1057 |
||
1058 |
logInfo("==========================================================" |
|
1059 |
+ "====================="); |
|
1060 |
||
1061 |
logInfo("Marlin software rasterizer = ENABLED"); |
|
1062 |
logInfo("Version = [" |
|
1063 |
+ Version.getVersion() + "]"); |
|
1064 |
logInfo("sun.java2d.renderer = " |
|
1065 |
+ reClass); |
|
1066 |
logInfo("sun.java2d.renderer.useThreadLocal = " |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1067 |
+ USE_THREAD_LOCAL); |
34417 | 1068 |
logInfo("sun.java2d.renderer.useRef = " |
1069 |
+ refType); |
|
1070 |
||
40421
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
1071 |
logInfo("sun.java2d.renderer.edges = " |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
1072 |
+ MarlinConst.INITIAL_EDGES_COUNT); |
34417 | 1073 |
logInfo("sun.java2d.renderer.pixelsize = " |
1074 |
+ MarlinConst.INITIAL_PIXEL_DIM); |
|
40421
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
1075 |
|
34417 | 1076 |
logInfo("sun.java2d.renderer.subPixel_log2_X = " |
1077 |
+ MarlinConst.SUBPIXEL_LG_POSITIONS_X); |
|
1078 |
logInfo("sun.java2d.renderer.subPixel_log2_Y = " |
|
1079 |
+ MarlinConst.SUBPIXEL_LG_POSITIONS_Y); |
|
47126 | 1080 |
|
34417 | 1081 |
logInfo("sun.java2d.renderer.tileSize_log2 = " |
47126 | 1082 |
+ MarlinConst.TILE_H_LG); |
1083 |
logInfo("sun.java2d.renderer.tileWidth_log2 = " |
|
1084 |
+ MarlinConst.TILE_W_LG); |
|
34417 | 1085 |
logInfo("sun.java2d.renderer.blockSize_log2 = " |
1086 |
+ MarlinConst.BLOCK_SIZE_LG); |
|
1087 |
||
1088 |
// RLE / blockFlags settings |
|
1089 |
||
1090 |
logInfo("sun.java2d.renderer.forceRLE = " |
|
1091 |
+ MarlinProperties.isForceRLE()); |
|
1092 |
logInfo("sun.java2d.renderer.forceNoRLE = " |
|
1093 |
+ MarlinProperties.isForceNoRLE()); |
|
1094 |
logInfo("sun.java2d.renderer.useTileFlags = " |
|
1095 |
+ MarlinProperties.isUseTileFlags()); |
|
1096 |
logInfo("sun.java2d.renderer.useTileFlags.useHeuristics = " |
|
1097 |
+ MarlinProperties.isUseTileFlagsWithHeuristics()); |
|
1098 |
logInfo("sun.java2d.renderer.rleMinWidth = " |
|
1099 |
+ MarlinCache.RLE_MIN_WIDTH); |
|
1100 |
||
1101 |
// optimisation parameters |
|
1102 |
logInfo("sun.java2d.renderer.useSimplifier = " |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1103 |
+ MarlinConst.USE_SIMPLIFIER); |
34417 | 1104 |
|
48284
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
1105 |
logInfo("sun.java2d.renderer.clip = " |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
1106 |
+ MarlinProperties.isDoClip()); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
1107 |
logInfo("sun.java2d.renderer.clip.runtime.enable = " |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
1108 |
+ MarlinProperties.isDoClipRuntimeFlag()); |
fd7fbc929001
8191814: Marlin rasterizer spends time computing geometry for stroked segments that do not intersect the clip
lbourges
parents:
47971
diff
changeset
|
1109 |
|
34417 | 1110 |
// debugging parameters |
1111 |
logInfo("sun.java2d.renderer.doStats = " |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1112 |
+ MarlinConst.DO_STATS); |
34417 | 1113 |
logInfo("sun.java2d.renderer.doMonitors = " |
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1114 |
+ MarlinConst.DO_MONITORS); |
34417 | 1115 |
logInfo("sun.java2d.renderer.doChecks = " |
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1116 |
+ MarlinConst.DO_CHECKS); |
34417 | 1117 |
|
1118 |
// logging parameters |
|
1119 |
logInfo("sun.java2d.renderer.useLogger = " |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1120 |
+ MarlinConst.USE_LOGGER); |
34417 | 1121 |
logInfo("sun.java2d.renderer.logCreateContext = " |
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1122 |
+ MarlinConst.LOG_CREATE_CONTEXT); |
34417 | 1123 |
logInfo("sun.java2d.renderer.logUnsafeMalloc = " |
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1124 |
+ MarlinConst.LOG_UNSAFE_MALLOC); |
34417 | 1125 |
|
1126 |
// quality settings |
|
47126 | 1127 |
logInfo("sun.java2d.renderer.cubic_dec_d2 = " |
1128 |
+ MarlinProperties.getCubicDecD2()); |
|
1129 |
logInfo("sun.java2d.renderer.cubic_inc_d1 = " |
|
1130 |
+ MarlinProperties.getCubicIncD1()); |
|
1131 |
logInfo("sun.java2d.renderer.quad_dec_d2 = " |
|
1132 |
+ MarlinProperties.getQuadDecD2()); |
|
1133 |
||
34417 | 1134 |
logInfo("Renderer settings:"); |
1135 |
logInfo("CUB_DEC_BND = " + Renderer.CUB_DEC_BND); |
|
1136 |
logInfo("CUB_INC_BND = " + Renderer.CUB_INC_BND); |
|
1137 |
logInfo("QUAD_DEC_BND = " + Renderer.QUAD_DEC_BND); |
|
1138 |
||
40421
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
1139 |
logInfo("INITIAL_EDGES_CAPACITY = " |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
1140 |
+ MarlinConst.INITIAL_EDGES_CAPACITY); |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
1141 |
logInfo("INITIAL_CROSSING_COUNT = " |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
1142 |
+ Renderer.INITIAL_CROSSING_COUNT); |
d5ee65e2b0fb
8159638: Improve array caches and renderer stats in Marlin renderer
lbourges
parents:
39519
diff
changeset
|
1143 |
|
34417 | 1144 |
logInfo("==========================================================" |
1145 |
+ "====================="); |
|
1146 |
} |
|
1147 |
||
1148 |
/** |
|
1149 |
* Get the RendererContext instance dedicated to the current thread |
|
1150 |
* @return RendererContext instance |
|
1151 |
*/ |
|
1152 |
@SuppressWarnings({"unchecked"}) |
|
1153 |
static RendererContext getRendererContext() { |
|
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1154 |
final RendererContext rdrCtx = RDR_CTX_PROVIDER.acquire(); |
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1155 |
if (DO_MONITORS) { |
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1156 |
rdrCtx.stats.mon_pre_getAATileGenerator.start(); |
34417 | 1157 |
} |
1158 |
return rdrCtx; |
|
1159 |
} |
|
1160 |
||
1161 |
/** |
|
1162 |
* Reset and return the given RendererContext instance for reuse |
|
1163 |
* @param rdrCtx RendererContext instance |
|
1164 |
*/ |
|
1165 |
static void returnRendererContext(final RendererContext rdrCtx) { |
|
1166 |
rdrCtx.dispose(); |
|
1167 |
||
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1168 |
if (DO_MONITORS) { |
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1169 |
rdrCtx.stats.mon_pre_getAATileGenerator.stop(); |
34417 | 1170 |
} |
39519
21bfc4452441
8159093: Fix coding conventions in Marlin renderer
lbourges
parents:
36902
diff
changeset
|
1171 |
RDR_CTX_PROVIDER.release(rdrCtx); |
34417 | 1172 |
} |
1173 |
} |