--- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/RendererContext.java Tue Feb 23 09:11:19 2016 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/RendererContext.java Tue Feb 23 22:07:27 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,9 +26,10 @@
package sun.java2d.marlin;
import java.awt.geom.Path2D;
-import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.concurrent.atomic.AtomicInteger;
+import sun.java2d.ReentrantContext;
+import sun.java2d.ReentrantContextProvider;
import static sun.java2d.marlin.ArrayCache.*;
import sun.java2d.marlin.MarlinRenderingEngine.NormalizingPathIterator;
import static sun.java2d.marlin.MarlinUtils.logInfo;
@@ -36,7 +37,7 @@
/**
* This class is a renderer context dedicated to a single thread
*/
-final class RendererContext implements MarlinConst {
+final class RendererContext extends ReentrantContext implements MarlinConst {
// RendererContext creation counter
private static final AtomicInteger contextCount = new AtomicInteger(1);
@@ -45,7 +46,7 @@
? RendererStats.getInstance(): null;
private static final boolean USE_CACHE_HARD_REF = doStats
- || (MarlinRenderingEngine.REF_TYPE == MarlinRenderingEngine.REF_WEAK);
+ || (MarlinRenderingEngine.REF_TYPE == ReentrantContextProvider.REF_WEAK);
/**
* Create a new renderer context
@@ -55,6 +56,7 @@
static RendererContext createContext() {
final RendererContext newCtx = new RendererContext("ctx"
+ Integer.toString(contextCount.getAndIncrement()));
+
if (RendererContext.stats != null) {
RendererContext.stats.allContexts.add(newCtx);
}
@@ -63,11 +65,6 @@
// context name (debugging purposes)
final String name;
- /*
- * Reference to this instance (hard, soft or weak).
- * @see MarlinRenderingEngine#REF_TYPE
- */
- final Object reference;
// Smallest object used as Cleaner's parent reference
final Object cleanerObj = new Object();
// dirty flag indicating an exception occured during pipeline in pathTo()
@@ -101,7 +98,7 @@
/**
* Constructor
*
- * @param name
+ * @param name context name (debugging)
*/
RendererContext(final String name) {
if (logCreateContext) {
@@ -124,20 +121,6 @@
stroker = new Stroker(this);
dasher = new Dasher(this);
-
- // Create the reference to this instance (hard, soft or weak):
- switch (MarlinRenderingEngine.REF_TYPE) {
- default:
- case MarlinRenderingEngine.REF_HARD:
- reference = this;
- break;
- case MarlinRenderingEngine.REF_SOFT:
- reference = new SoftReference<RendererContext>(this);
- break;
- case MarlinRenderingEngine.REF_WEAK:
- reference = new WeakReference<RendererContext>(this);
- break;
- }
}
/**