Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/java2d/pisces/TransformingPathConsumer2D.java
38918 views
1
/*
2
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
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.pisces;
27
28
import sun.awt.geom.PathConsumer2D;
29
import java.awt.geom.AffineTransform;
30
31
final class TransformingPathConsumer2D {
32
public static PathConsumer2D
33
transformConsumer(PathConsumer2D out,
34
AffineTransform at)
35
{
36
if (at == null) {
37
return out;
38
}
39
float Mxx = (float) at.getScaleX();
40
float Mxy = (float) at.getShearX();
41
float Mxt = (float) at.getTranslateX();
42
float Myx = (float) at.getShearY();
43
float Myy = (float) at.getScaleY();
44
float Myt = (float) at.getTranslateY();
45
if (Mxy == 0f && Myx == 0f) {
46
if (Mxx == 1f && Myy == 1f) {
47
if (Mxt == 0f && Myt == 0f) {
48
return out;
49
} else {
50
return new TranslateFilter(out, Mxt, Myt);
51
}
52
} else {
53
if (Mxt == 0f && Myt == 0f) {
54
return new DeltaScaleFilter(out, Mxx, Myy);
55
} else {
56
return new ScaleFilter(out, Mxx, Myy, Mxt, Myt);
57
}
58
}
59
} else if (Mxt == 0f && Myt == 0f) {
60
return new DeltaTransformFilter(out, Mxx, Mxy, Myx, Myy);
61
} else {
62
return new TransformFilter(out, Mxx, Mxy, Mxt, Myx, Myy, Myt);
63
}
64
}
65
66
public static PathConsumer2D
67
deltaTransformConsumer(PathConsumer2D out,
68
AffineTransform at)
69
{
70
if (at == null) {
71
return out;
72
}
73
float Mxx = (float) at.getScaleX();
74
float Mxy = (float) at.getShearX();
75
float Myx = (float) at.getShearY();
76
float Myy = (float) at.getScaleY();
77
if (Mxy == 0f && Myx == 0f) {
78
if (Mxx == 1f && Myy == 1f) {
79
return out;
80
} else {
81
return new DeltaScaleFilter(out, Mxx, Myy);
82
}
83
} else {
84
return new DeltaTransformFilter(out, Mxx, Mxy, Myx, Myy);
85
}
86
}
87
88
public static PathConsumer2D
89
inverseDeltaTransformConsumer(PathConsumer2D out,
90
AffineTransform at)
91
{
92
if (at == null) {
93
return out;
94
}
95
float Mxx = (float) at.getScaleX();
96
float Mxy = (float) at.getShearX();
97
float Myx = (float) at.getShearY();
98
float Myy = (float) at.getScaleY();
99
if (Mxy == 0f && Myx == 0f) {
100
if (Mxx == 1f && Myy == 1f) {
101
return out;
102
} else {
103
return new DeltaScaleFilter(out, 1.0f/Mxx, 1.0f/Myy);
104
}
105
} else {
106
float det = Mxx * Myy - Mxy * Myx;
107
return new DeltaTransformFilter(out,
108
Myy / det,
109
-Mxy / det,
110
-Myx / det,
111
Mxx / det);
112
}
113
}
114
115
static final class TranslateFilter implements PathConsumer2D {
116
private final PathConsumer2D out;
117
private final float tx;
118
private final float ty;
119
120
TranslateFilter(PathConsumer2D out,
121
float tx, float ty)
122
{
123
this.out = out;
124
this.tx = tx;
125
this.ty = ty;
126
}
127
128
public void moveTo(float x0, float y0) {
129
out.moveTo(x0 + tx, y0 + ty);
130
}
131
132
public void lineTo(float x1, float y1) {
133
out.lineTo(x1 + tx, y1 + ty);
134
}
135
136
public void quadTo(float x1, float y1,
137
float x2, float y2)
138
{
139
out.quadTo(x1 + tx, y1 + ty,
140
x2 + tx, y2 + ty);
141
}
142
143
public void curveTo(float x1, float y1,
144
float x2, float y2,
145
float x3, float y3)
146
{
147
out.curveTo(x1 + tx, y1 + ty,
148
x2 + tx, y2 + ty,
149
x3 + tx, y3 + ty);
150
}
151
152
public void closePath() {
153
out.closePath();
154
}
155
156
public void pathDone() {
157
out.pathDone();
158
}
159
160
public long getNativeConsumer() {
161
return 0;
162
}
163
}
164
165
static final class ScaleFilter implements PathConsumer2D {
166
private final PathConsumer2D out;
167
private final float sx;
168
private final float sy;
169
private final float tx;
170
private final float ty;
171
172
ScaleFilter(PathConsumer2D out,
173
float sx, float sy, float tx, float ty)
174
{
175
this.out = out;
176
this.sx = sx;
177
this.sy = sy;
178
this.tx = tx;
179
this.ty = ty;
180
}
181
182
public void moveTo(float x0, float y0) {
183
out.moveTo(x0 * sx + tx, y0 * sy + ty);
184
}
185
186
public void lineTo(float x1, float y1) {
187
out.lineTo(x1 * sx + tx, y1 * sy + ty);
188
}
189
190
public void quadTo(float x1, float y1,
191
float x2, float y2)
192
{
193
out.quadTo(x1 * sx + tx, y1 * sy + ty,
194
x2 * sx + tx, y2 * sy + ty);
195
}
196
197
public void curveTo(float x1, float y1,
198
float x2, float y2,
199
float x3, float y3)
200
{
201
out.curveTo(x1 * sx + tx, y1 * sy + ty,
202
x2 * sx + tx, y2 * sy + ty,
203
x3 * sx + tx, y3 * sy + ty);
204
}
205
206
public void closePath() {
207
out.closePath();
208
}
209
210
public void pathDone() {
211
out.pathDone();
212
}
213
214
public long getNativeConsumer() {
215
return 0;
216
}
217
}
218
219
static final class TransformFilter implements PathConsumer2D {
220
private final PathConsumer2D out;
221
private final float Mxx;
222
private final float Mxy;
223
private final float Mxt;
224
private final float Myx;
225
private final float Myy;
226
private final float Myt;
227
228
TransformFilter(PathConsumer2D out,
229
float Mxx, float Mxy, float Mxt,
230
float Myx, float Myy, float Myt)
231
{
232
this.out = out;
233
this.Mxx = Mxx;
234
this.Mxy = Mxy;
235
this.Mxt = Mxt;
236
this.Myx = Myx;
237
this.Myy = Myy;
238
this.Myt = Myt;
239
}
240
241
public void moveTo(float x0, float y0) {
242
out.moveTo(x0 * Mxx + y0 * Mxy + Mxt,
243
x0 * Myx + y0 * Myy + Myt);
244
}
245
246
public void lineTo(float x1, float y1) {
247
out.lineTo(x1 * Mxx + y1 * Mxy + Mxt,
248
x1 * Myx + y1 * Myy + Myt);
249
}
250
251
public void quadTo(float x1, float y1,
252
float x2, float y2)
253
{
254
out.quadTo(x1 * Mxx + y1 * Mxy + Mxt,
255
x1 * Myx + y1 * Myy + Myt,
256
x2 * Mxx + y2 * Mxy + Mxt,
257
x2 * Myx + y2 * Myy + Myt);
258
}
259
260
public void curveTo(float x1, float y1,
261
float x2, float y2,
262
float x3, float y3)
263
{
264
out.curveTo(x1 * Mxx + y1 * Mxy + Mxt,
265
x1 * Myx + y1 * Myy + Myt,
266
x2 * Mxx + y2 * Mxy + Mxt,
267
x2 * Myx + y2 * Myy + Myt,
268
x3 * Mxx + y3 * Mxy + Mxt,
269
x3 * Myx + y3 * Myy + Myt);
270
}
271
272
public void closePath() {
273
out.closePath();
274
}
275
276
public void pathDone() {
277
out.pathDone();
278
}
279
280
public long getNativeConsumer() {
281
return 0;
282
}
283
}
284
285
static final class DeltaScaleFilter implements PathConsumer2D {
286
private final float sx, sy;
287
private final PathConsumer2D out;
288
289
public DeltaScaleFilter(PathConsumer2D out, float Mxx, float Myy) {
290
sx = Mxx;
291
sy = Myy;
292
this.out = out;
293
}
294
295
public void moveTo(float x0, float y0) {
296
out.moveTo(x0 * sx, y0 * sy);
297
}
298
299
public void lineTo(float x1, float y1) {
300
out.lineTo(x1 * sx, y1 * sy);
301
}
302
303
public void quadTo(float x1, float y1,
304
float x2, float y2)
305
{
306
out.quadTo(x1 * sx, y1 * sy,
307
x2 * sx, y2 * sy);
308
}
309
310
public void curveTo(float x1, float y1,
311
float x2, float y2,
312
float x3, float y3)
313
{
314
out.curveTo(x1 * sx, y1 * sy,
315
x2 * sx, y2 * sy,
316
x3 * sx, y3 * sy);
317
}
318
319
public void closePath() {
320
out.closePath();
321
}
322
323
public void pathDone() {
324
out.pathDone();
325
}
326
327
public long getNativeConsumer() {
328
return 0;
329
}
330
}
331
332
static final class DeltaTransformFilter implements PathConsumer2D {
333
private PathConsumer2D out;
334
private final float Mxx;
335
private final float Mxy;
336
private final float Myx;
337
private final float Myy;
338
339
DeltaTransformFilter(PathConsumer2D out,
340
float Mxx, float Mxy,
341
float Myx, float Myy)
342
{
343
this.out = out;
344
this.Mxx = Mxx;
345
this.Mxy = Mxy;
346
this.Myx = Myx;
347
this.Myy = Myy;
348
}
349
350
public void moveTo(float x0, float y0) {
351
out.moveTo(x0 * Mxx + y0 * Mxy,
352
x0 * Myx + y0 * Myy);
353
}
354
355
public void lineTo(float x1, float y1) {
356
out.lineTo(x1 * Mxx + y1 * Mxy,
357
x1 * Myx + y1 * Myy);
358
}
359
360
public void quadTo(float x1, float y1,
361
float x2, float y2)
362
{
363
out.quadTo(x1 * Mxx + y1 * Mxy,
364
x1 * Myx + y1 * Myy,
365
x2 * Mxx + y2 * Mxy,
366
x2 * Myx + y2 * Myy);
367
}
368
369
public void curveTo(float x1, float y1,
370
float x2, float y2,
371
float x3, float y3)
372
{
373
out.curveTo(x1 * Mxx + y1 * Mxy,
374
x1 * Myx + y1 * Myy,
375
x2 * Mxx + y2 * Mxy,
376
x2 * Myx + y2 * Myy,
377
x3 * Mxx + y3 * Mxy,
378
x3 * Myx + y3 * Myy);
379
}
380
381
public void closePath() {
382
out.closePath();
383
}
384
385
public void pathDone() {
386
out.pathDone();
387
}
388
389
public long getNativeConsumer() {
390
return 0;
391
}
392
}
393
}
394
395