< prev index next >

src/java.desktop/share/classes/sun/java2d/marlin/MarlinRenderingEngine.java

```@@ -42,12 +42,12 @@
import sun.security.action.GetPropertyAction;

/**
* Marlin RendererEngine implementation (derived from Pisces)
*/
-public class MarlinRenderingEngine extends RenderingEngine
-                                   implements MarlinConst
+public final class MarlinRenderingEngine extends RenderingEngine
+                                         implements MarlinConst
{
private static enum NormMode {
ON_WITH_AA {
@Override
PathIterator getNormalizingPathIterator(final RendererContext rdrCtx,
```

```@@ -78,11 +78,11 @@

abstract PathIterator getNormalizingPathIterator(RendererContext rdrCtx,
PathIterator src);
}

-    private static final float MIN_PEN_SIZE = 1f / NORM_SUBPIXELS;
+    private static final float MIN_PEN_SIZE = 1.0f / NORM_SUBPIXELS;

static final float UPPER_BND = Float.MAX_VALUE / 2.0f;
static final float LOWER_BND = -UPPER_BND;

/**
```

```@@ -257,11 +257,11 @@
* Trigonometric equalities can then be used to get
* rid of most of the sqrt terms.
*/

double EA = A*A + B*B;          // x^2 coefficient
-            double EB = 2.0*(A*C + B*D);    // xy coefficient
+            double EB = 2.0d * (A*C + B*D); // xy coefficient
double EC = C*C + D*D;          // y^2 coefficient

/*
* There is a lot of calculus omitted here.
*
```

```@@ -285,11 +285,11 @@
* along that axis.
*/

double hypot = Math.sqrt(EB*EB + (EA-EC)*(EA-EC));
// sqrt omitted, compare to squared limits below.
-            double widthsquared = ((EA + EC + hypot)/2.0);
+            double widthsquared = ((EA + EC + hypot) / 2.0d);

widthScale = (float)Math.sqrt(widthsquared);
}

return (lw / widthScale);
```

```@@ -330,11 +330,11 @@
final double b = at.getShearX();
final double c = at.getShearY();
final double d = at.getScaleY();
final double det = a * d - c * b;

-            if (Math.abs(det) <= (2f * Float.MIN_VALUE)) {
+            if (Math.abs(det) <= (2.0f * Float.MIN_VALUE)) {
// this rendering engine takes one dimensional curves and turns
// them into 2D shapes by giving them width.
// However, if everything is to be passed through a singular
// transformation, these 2D shapes will be squashed down to 1D
// again so, nothing can be drawn.
```

```@@ -342,11 +342,11 @@
// Every path needs an initial moveTo and a pathDone. If these
// are not there this causes a SIGSEGV in libawt.so (at the time
// of writing of this comment (September 16, 2010)). Actually,
// I am not sure if the moveTo is necessary to avoid the SIGSEGV
// but the pathDone is definitely needed.
-                pc2d.moveTo(0f, 0f);
+                pc2d.moveTo(0.0f, 0.0f);
pc2d.pathDone();
return;
}

// If the transform is a constant multiple of an orthogonal transformation
```

```@@ -359,21 +359,11 @@
final float scale = (float) Math.sqrt(a*a + c*c);

if (dashes != null) {
recycleDashes = true;
dashLen = dashes.length;
-                    final float[] newDashes;
-                    if (dashLen <= INITIAL_ARRAY) {
-                        newDashes = rdrCtx.dasher.dashes_ref.initial;
-                    } else {
-                        if (DO_STATS) {
-                        }
-                        newDashes = rdrCtx.dasher.dashes_ref.getArray(dashLen);
-                    }
-                    System.arraycopy(dashes, 0, newDashes, 0, dashLen);
-                    dashes = newDashes;
+                    dashes = rdrCtx.dasher.copyDashArray(dashes);
for (int i = 0; i < dashLen; i++) {
dashes[i] *= scale;
}
dashphase *= scale;
}
```

```@@ -443,11 +433,11 @@
* -> pc2d = Renderer (bounding box)
*/
}

private static boolean nearZero(final double num) {
-        return Math.abs(num) < 2.0 * Math.ulp(num);
+        return Math.abs(num) < 2.0d * Math.ulp(num);
}

abstract static class NormalizingPathIterator implements PathIterator {

private PathIterator src;
```

```@@ -522,12 +512,12 @@
break;
case PathIterator.SEG_LINETO:
break;
break;
case PathIterator.SEG_CUBICTO:
```

```@@ -822,14 +812,12 @@
// as it will be called later by MarlinTileGenerator.dispose()
r = null;
}
} finally {
if (r != null) {
-                // dispose renderer:
+                // dispose renderer and recycle the RendererContext instance:
r.dispose();
-                // recycle the RendererContext instance
-                MarlinRenderingEngine.returnRendererContext(rdrCtx);
}
}

// Return null to cancel AA tile generation (nothing to render)
return ptg;
```

```@@ -843,29 +831,29 @@
Region clip,
int[] bbox)
{
// REMIND: Deal with large coordinates!
double ldx1, ldy1, ldx2, ldy2;
-        boolean innerpgram = (lw1 > 0.0 && lw2 > 0.0);
+        boolean innerpgram = (lw1 > 0.0d && lw2 > 0.0d);

if (innerpgram) {
ldx1 = dx1 * lw1;
ldy1 = dy1 * lw1;
ldx2 = dx2 * lw2;
ldy2 = dy2 * lw2;
-            x -= (ldx1 + ldx2) / 2.0;
-            y -= (ldy1 + ldy2) / 2.0;
+            x -= (ldx1 + ldx2) / 2.0d;
+            y -= (ldy1 + ldy2) / 2.0d;
dx1 += ldx1;
dy1 += ldy1;
dx2 += ldx2;
dy2 += ldy2;
-            if (lw1 > 1.0 && lw2 > 1.0) {
+            if (lw1 > 1.0d && lw2 > 1.0d) {
// Inner parallelogram was entirely consumed by stroke...
innerpgram = false;
}
} else {
-            ldx1 = ldy1 = ldx2 = ldy2 = 0.0;
+            ldx1 = ldy1 = ldx2 = ldy2 = 0.0d;
}

MarlinTileGenerator ptg = null;
Renderer r = null;

```

```@@ -882,14 +870,14 @@
r.closePath();

if (innerpgram) {
x += ldx1 + ldx2;
y += ldy1 + ldy2;
-                dx1 -= 2.0 * ldx1;
-                dy1 -= 2.0 * ldy1;
-                dx2 -= 2.0 * ldx2;
-                dy2 -= 2.0 * ldy2;
+                dx1 -= 2.0d * ldx1;
+                dy1 -= 2.0d * ldy1;
+                dx2 -= 2.0d * ldx2;
+                dy2 -= 2.0d * ldy2;
r.moveTo((float) x, (float) y);
r.lineTo((float) (x+dx1), (float) (y+dy1));
r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
r.lineTo((float) (x+dx2), (float) (y+dy2));
r.closePath();
```

```@@ -903,14 +891,12 @@
// as it will be called later by MarlinTileGenerator.dispose()
r = null;
}
} finally {
if (r != null) {
-                // dispose renderer:
+                // dispose renderer and recycle the RendererContext instance:
r.dispose();
-                // recycle the RendererContext instance
-                MarlinRenderingEngine.returnRendererContext(rdrCtx);
}
}

// Return null to cancel AA tile generation (nothing to render)
return ptg;
```

```@@ -1033,16 +1019,15 @@

+ MarlinConst.SUBPIXEL_LG_POSITIONS_X);
+ MarlinConst.SUBPIXEL_LG_POSITIONS_Y);
-                + MarlinConst.TILE_SIZE_LG);
-
-                + MarlinConst.BLOCK_SIZE_LG);

+                + MarlinConst.TILE_H_LG);
+                + MarlinConst.TILE_W_LG);
+ MarlinConst.BLOCK_SIZE_LG);

// RLE / blockFlags settings

```

```@@ -1076,12 +1061,18 @@
+ MarlinConst.LOG_CREATE_CONTEXT);
+ MarlinConst.LOG_UNSAFE_MALLOC);

// quality settings
+                + MarlinProperties.getCubicDecD2());