Skip to content

Commit b60190b

Browse files
committed
fix of optimization of JSGraphics2D AffineTransform save/restore
1 parent 8a79cd1 commit b60190b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

sources/net.sf.j2s.java.core/src/java/awt/geom/AffineTransform.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3987,6 +3987,22 @@ public boolean equals(Object obj) {
39873987
(m10 == a.m10) && (m11 == a.m11) && (m12 == a.m12));
39883988
}
39893989

3990+
public double[] 秘toArray() {
3991+
return new double[] {m00, m01, m02, m10, m11, m12, state, type };
3992+
}
3993+
3994+
public AffineTransform 秘fromArray(double[] a) {
3995+
m00 = a[0];
3996+
m01 = a[1];
3997+
m02 = a[2];
3998+
m10 = a[3];
3999+
m11 = a[4];
4000+
m12 = a[5];
4001+
state = (int) a[6];
4002+
type = (int) a[7];
4003+
return this;
4004+
}
4005+
39904006
/* Serialization support. A readObject method is neccessary because
39914007
* the state field is part of the implementation of this particular
39924008
* AffineTransform and not part of the public specification. The

sources/net.sf.j2s.java.core/src/swingjs/JSGraphics2D.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ private int mark(boolean isClone) {
12871287
map[SAVE_ALPHA] = (/** @j2sNative 1 ? this.ctx.globalAlpha : */0);//Float.valueOf(ctx.globalAlpha);
12881288
map[SAVE_COMPOSITE] = alphaComposite;
12891289
map[SAVE_STROKE] = currentStroke;
1290-
map[SAVE_TRANSFORM] = transform;
1290+
map[SAVE_TRANSFORM] = transform.秘toArray();
12911291
map[SAVE_FONT] = font;
12921292
map[SAVE_CLIP] = currentClip;
12931293
return HTML5CanvasContext2D.push(ctx, map);
@@ -1360,7 +1360,7 @@ private void setState(Object[] map) {
13601360
setAlpha(/** @j2sNative map[a] || */0);
13611361
shader = null;
13621362
setStroke((Stroke) map[SAVE_STROKE]);
1363-
setTransform((AffineTransform) map[SAVE_TRANSFORM]);
1363+
setTransform(transform.秘fromArray((double[]) map[SAVE_TRANSFORM]));
13641364
setFont((Font) map[SAVE_FONT]);
13651365
currentClip = (Shape) map[SAVE_CLIP];
13661366
}

0 commit comments

Comments
 (0)