Index: trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/ComputeStyleListWorker.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/ComputeStyleListWorker.java	(revision 12963)
+++ trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/ComputeStyleListWorker.java	(revision 12964)
@@ -36,5 +36,5 @@
     private final transient List<StyleRecord> output;
 
-    private final transient ElemStyles styles = MapPaintStyles.getStyles();
+    private final transient ElemStyles styles;
     private final int directExecutionTaskSize;
     private final double circum;
@@ -55,4 +55,20 @@
     ComputeStyleListWorker(double circum, NavigatableComponent nc,
             final List<? extends OsmPrimitive> input, List<StyleRecord> output, int directExecutionTaskSize) {
+        this(circum, nc, input, output, directExecutionTaskSize, MapPaintStyles.getStyles());
+    }
+
+    /**
+     * Constructs a new {@code ComputeStyleListWorker}.
+     * @param circum distance on the map in meters that 100 screen pixels represent
+     * @param nc navigatable component
+     * @param input the primitives to process
+     * @param output the list of styles to which styles will be added
+     * @param directExecutionTaskSize the threshold deciding whether to subdivide the tasks
+     * @param styles the {@link ElemStyles} instance used to generate primitive {@link StyleElement}s.
+     * @since 12964
+     */
+    ComputeStyleListWorker(double circum, NavigatableComponent nc,
+            final List<? extends OsmPrimitive> input, List<StyleRecord> output, int directExecutionTaskSize,
+            ElemStyles styles) {
         this.circum = circum;
         this.nc = nc;
@@ -60,4 +76,5 @@
         this.output = output;
         this.directExecutionTaskSize = directExecutionTaskSize;
+        this.styles = styles;
         this.drawArea = circum <= Config.getPref().getInt("mappaint.fillareas", 10_000_000);
         this.drawMultipolygon = drawArea && Config.getPref().getBoolean("mappaint.multipolygon", true);
@@ -75,5 +92,5 @@
                 final int toIndex = Math.min(fromIndex + directExecutionTaskSize, input.size());
                 tasks.add(new ComputeStyleListWorker(circum, nc, input.subList(fromIndex, toIndex),
-                        new ArrayList<>(directExecutionTaskSize), directExecutionTaskSize).fork());
+                        new ArrayList<>(directExecutionTaskSize), directExecutionTaskSize, styles).fork());
             }
             for (ForkJoinTask<List<StyleRecord>> task : tasks) {
Index: trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java	(revision 12963)
+++ trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java	(revision 12964)
@@ -65,4 +65,6 @@
 import org.openstreetmap.josm.gui.draw.MapViewPath;
 import org.openstreetmap.josm.gui.draw.MapViewPositionAndRotation;
+import org.openstreetmap.josm.gui.mappaint.ElemStyles;
+import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
 import org.openstreetmap.josm.gui.mappaint.styleelement.BoxTextElement;
 import org.openstreetmap.josm.gui.mappaint.styleelement.BoxTextElement.HorizontalTextAlignment;
@@ -261,4 +263,5 @@
 
     private MapPaintSettings paintSettings;
+    private ElemStyles styles;
 
     private Color highlightColorTransparent;
@@ -345,4 +348,13 @@
         Component focusOwner = FocusManager.getCurrentManager().getFocusOwner();
         useWiderHighlight = !(focusOwner instanceof AbstractButton || focusOwner == nc);
+        this.styles = MapPaintStyles.getStyles();
+    }
+
+    /**
+     * Set the {@link ElemStyles} instance to use for this renderer.
+     * @param styles the {@code ElemStyles} instance to use
+     */
+    public void setStyles(ElemStyles styles) {
+        this.styles = styles;
     }
 
@@ -1626,7 +1638,7 @@
             // (Could be synchronized, but try to avoid this for performance reasons.)
             THREAD_POOL.invoke(new ComputeStyleListWorker(circum, nc, relations, allStyleElems,
-                    Math.max(20, relations.size() / THREAD_POOL.getParallelism() / 3)));
+                    Math.max(20, relations.size() / THREAD_POOL.getParallelism() / 3), styles));
             THREAD_POOL.invoke(new ComputeStyleListWorker(circum, nc, new CompositeList<>(nodes, ways), allStyleElems,
-                    Math.max(100, (nodes.size() + ways.size()) / THREAD_POOL.getParallelism() / 3)));
+                    Math.max(100, (nodes.size() + ways.size()) / THREAD_POOL.getParallelism() / 3), styles));
 
             if (!benchmark.renderSort()) {
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingHelper.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingHelper.java	(revision 12963)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingHelper.java	(revision 12964)
@@ -23,6 +23,4 @@
 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
-import org.openstreetmap.josm.data.preferences.sources.SourceEntry;
-import org.openstreetmap.josm.data.preferences.sources.SourceType;
 import org.openstreetmap.josm.data.projection.Projection;
 import org.openstreetmap.josm.gui.NavigatableComponent;
@@ -100,11 +98,11 @@
     public void render() throws IOException, IllegalDataException {
         // load the styles
+        ElemStyles elemStyles = new ElemStyles();
         MapCSSStyleSource.STYLE_SOURCE_LOCK.writeLock().lock();
         try {
-            MapPaintStyles.getStyles().clear();
             for (StyleData sd : styles) {
-                SourceEntry se = new SourceEntry(SourceType.MAP_PAINT_STYLE, sd.styleUrl,
-                            "cliRenderingStyle", "cli rendering style '" + sd.styleUrl + "'", true /* active */);
-                StyleSource source = MapPaintStyles.addStyle(se);
+                MapCSSStyleSource source = new MapCSSStyleSource(sd.styleUrl, "cliRenderingStyle", "cli rendering style '" + sd.styleUrl + "'");
+                source.loadStyleSource();
+                elemStyles.add(source);
                 if (!source.getErrors().isEmpty()) {
                     throw new IllegalDataException("Failed to load style file. Errors: " + source.getErrors());
@@ -156,5 +154,7 @@
         g.setColor(PaintColors.getBackgroundColor());
         g.fillRect(0, 0, imgDimPx.width, imgDimPx.height);
-        new StyledMapRenderer(g, nc, false).render(ds, false, bounds);
+        StyledMapRenderer smr = new StyledMapRenderer(g, nc, false);
+        smr.setStyles(elemStyles);
+        smr.render(ds, false, bounds);
 
         // write to file
