@@ -143,8 +143,6 @@ protected void allocate() {
143
143
if (bitmap != null ) bitmap .recycle ();
144
144
bitmap = Bitmap .createBitmap (width , height , Config .ARGB_8888 );
145
145
canvas = new Canvas (bitmap );
146
- // image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
147
- // canvas = (Graphics2D) image.getGraphics();
148
146
}
149
147
150
148
@@ -448,7 +446,7 @@ public void breakShape() {
448
446
@ Override
449
447
public void endShape (int mode ) {
450
448
if (shape == POINTS && stroke && vertexCount > 0 ) {
451
- Matrix m = canvas . getMatrix ();
449
+ Matrix m = getMatrixImp ();
452
450
if (strokeWeight == 1 && m .isIdentity ()) {
453
451
if (screenPoint == null ) {
454
452
screenPoint = new float [2 ];
@@ -1516,12 +1514,8 @@ public PMatrix2D getMatrix(PMatrix2D target) {
1516
1514
if (target == null ) {
1517
1515
target = new PMatrix2D ();
1518
1516
}
1519
- // canvas.getTransform().getMatrix(transform);
1520
- Matrix m = new Matrix ();
1521
- canvas .getMatrix (m );
1517
+ Matrix m = getMatrixImp ();
1522
1518
m .getValues (transform );
1523
- // target.set((float) transform[0], (float) transform[2], (float) transform[4],
1524
- // (float) transform[1], (float) transform[3], (float) transform[5]);
1525
1519
target .set ((float ) transform [0 ], (float ) transform [1 ], (float ) transform [2 ],
1526
1520
(float ) transform [3 ], (float ) transform [4 ], (float ) transform [5 ]);
1527
1521
return target ;
@@ -1565,6 +1559,11 @@ public void printMatrix() {
1565
1559
}
1566
1560
1567
1561
1562
+ protected Matrix getMatrixImp () {
1563
+ return parent .getSurfaceView ().getMatrix ();
1564
+ // return canvas.getMatrix();
1565
+ }
1566
+
1568
1567
1569
1568
//////////////////////////////////////////////////////////////
1570
1569
@@ -1609,7 +1608,7 @@ public float screenX(float x, float y) {
1609
1608
}
1610
1609
screenPoint [0 ] = x ;
1611
1610
screenPoint [1 ] = y ;
1612
- canvas . getMatrix ().mapPoints (screenPoint );
1611
+ getMatrixImp ().mapPoints (screenPoint );
1613
1612
return screenPoint [0 ];
1614
1613
}
1615
1614
@@ -1623,7 +1622,7 @@ public float screenY(float x, float y) {
1623
1622
}
1624
1623
screenPoint [0 ] = x ;
1625
1624
screenPoint [1 ] = y ;
1626
- canvas . getMatrix ().mapPoints (screenPoint );
1625
+ getMatrixImp ().mapPoints (screenPoint );
1627
1626
return screenPoint [1 ];
1628
1627
}
1629
1628
@@ -2046,35 +2045,31 @@ public void set(int x, int y, PImage src) {
2046
2045
}
2047
2046
2048
2047
if (src .bitmap == null ) {
2049
- // hopefully this will do the work to figure out what's on/offscreen
2050
- // in spite of the offset and stride that's been provided
2051
- canvas .drawBitmap (src .pixels , 0 , src .width ,
2052
- x , y , src .width , src .height , false , null );
2053
- // hasAlpha is set to false since we don't want blending.
2054
- // however that may be incorrect if it winds up copying only the RGB
2055
- // (without the A) portion of the pixels.
2056
-
2057
- } else { // src.bitmap != null
2058
- if (src .width != src .bitmap .getWidth () ||
2059
- src .height != src .bitmap .getHeight ()) {
2048
+ src .bitmap = Bitmap .createBitmap (src .width , src .height , Config .ARGB_8888 );
2049
+ src .modified = true ;
2050
+ }
2051
+
2052
+ if (src .width != src .bitmap .getWidth () ||
2053
+ src .height != src .bitmap .getHeight ()) {
2054
+ src .bitmap .recycle ();
2055
+ src .bitmap = Bitmap .createBitmap (src .width , src .height , Config .ARGB_8888 );
2056
+ src .modified = true ;
2057
+ }
2058
+ if (src .modified ) {
2059
+ if (!src .bitmap .isMutable ()) {
2060
2060
src .bitmap .recycle ();
2061
2061
src .bitmap = Bitmap .createBitmap (src .width , src .height , Config .ARGB_8888 );
2062
- src .modified = true ;
2063
- }
2064
- if (src .modified ) {
2065
- if (!src .bitmap .isMutable ()) {
2066
- src .bitmap .recycle ();
2067
- src .bitmap = Bitmap .createBitmap (src .width , src .height , Config .ARGB_8888 );
2068
- }
2069
- src .bitmap .setPixels (src .pixels , 0 , src .width , 0 , 0 , src .width , src .height );
2070
- src .modified = false ;
2071
2062
}
2072
- // set() happens in screen coordinates, so need to clear the ctm
2073
- canvas .save (Canvas .MATRIX_SAVE_FLAG );
2074
- canvas .setMatrix (null ); // set to identity
2075
- canvas .drawBitmap (src .bitmap , x , y , null );
2076
- canvas .restore ();
2063
+ src .bitmap .setPixels (src .pixels , 0 , src .width , 0 , 0 , src .width , src .height );
2064
+ src .modified = false ;
2077
2065
}
2066
+
2067
+ // set() happens in screen coordinates, so need to clear the ctm
2068
+ canvas .save (Canvas .MATRIX_SAVE_FLAG );
2069
+ canvas .setMatrix (null ); // set to identity
2070
+ canvas .drawBitmap (src .bitmap , x , y , null );
2071
+ canvas .restore ();
2072
+
2078
2073
}
2079
2074
2080
2075
0 commit comments