- Timestamp:
- 2016-11-30T13:19:01+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r11294 r11351 1795 1795 } 1796 1796 1797 private class ComputeStyleListWorker extends RecursiveTask<List<StyleRecord>> implements Visitor {1797 private static class ComputeStyleListWorker extends RecursiveTask<List<StyleRecord>> implements Visitor { 1798 1798 private final transient List<? extends OsmPrimitive> input; 1799 1799 private final transient List<StyleRecord> output; … … 1801 1801 private final transient ElemStyles styles = MapPaintStyles.getStyles(); 1802 1802 private final int directExecutionTaskSize; 1803 1804 private final boolean drawArea = circum <= Main.pref.getInteger("mappaint.fillareas", 10_000_000); 1805 private final boolean drawMultipolygon = drawArea && Main.pref.getBoolean("mappaint.multipolygon", true); 1806 private final boolean drawRestriction = Main.pref.getBoolean("mappaint.restriction", true); 1803 private final double circum; 1804 private final NavigatableComponent nc; 1805 1806 private final boolean drawArea; 1807 private final boolean drawMultipolygon; 1808 private final boolean drawRestriction; 1807 1809 1808 1810 /** 1809 1811 * Constructs a new {@code ComputeStyleListWorker}. 1812 * @param circum distance on the map in meters that 100 screen pixels represent 1813 * @param nc navigatable component 1810 1814 * @param input the primitives to process 1811 1815 * @param output the list of styles to which styles will be added 1812 1816 * @param directExecutionTaskSize the threshold deciding whether to subdivide the tasks 1813 1817 */ 1814 ComputeStyleListWorker(final List<? extends OsmPrimitive> input, List<StyleRecord> output, int directExecutionTaskSize) { 1818 ComputeStyleListWorker(double circum, NavigatableComponent nc, 1819 final List<? extends OsmPrimitive> input, List<StyleRecord> output, int directExecutionTaskSize) { 1820 this.circum = circum; 1821 this.nc = nc; 1815 1822 this.input = input; 1816 1823 this.output = output; 1817 1824 this.directExecutionTaskSize = directExecutionTaskSize; 1825 this.drawArea = circum <= Main.pref.getInteger("mappaint.fillareas", 10_000_000); 1826 this.drawMultipolygon = drawArea && Main.pref.getBoolean("mappaint.multipolygon", true); 1827 this.drawRestriction = Main.pref.getBoolean("mappaint.restriction", true); 1818 1828 this.styles.setDrawMultipolygon(drawMultipolygon); 1819 1829 } … … 1828 1838 final int toIndex = Math.min(fromIndex + directExecutionTaskSize, input.size()); 1829 1839 final List<StyleRecord> output = new ArrayList<>(directExecutionTaskSize); 1830 tasks.add(new ComputeStyleListWorker( input.subList(fromIndex, toIndex), output, directExecutionTaskSize).fork());1840 tasks.add(new ComputeStyleListWorker(circum, nc, input.subList(fromIndex, toIndex), output, directExecutionTaskSize).fork()); 1831 1841 } 1832 1842 for (ForkJoinTask<List<StyleRecord>> task : tasks) { … … 1938 1948 1939 1949 // Need to process all relations first. 1940 // Reason: Make sure, ElemStyles.getStyleCacheWithRange is 1941 // not called for the same primitive in parallel threads. 1942 // (Could be synchronized, but try to avoid this for 1943 // performance reasons.) 1944 THREAD_POOL.invoke(new ComputeStyleListWorker(relations, allStyleElems, 1950 // Reason: Make sure, ElemStyles.getStyleCacheWithRange is not called for the same primitive in parallel threads. 1951 // (Could be synchronized, but try to avoid this for performance reasons.) 1952 THREAD_POOL.invoke(new ComputeStyleListWorker(circum, nc, relations, allStyleElems, 1945 1953 Math.max(20, relations.size() / THREAD_POOL.getParallelism() / 3))); 1946 THREAD_POOL.invoke(new ComputeStyleListWorker( new CompositeList<>(nodes, ways), allStyleElems,1954 THREAD_POOL.invoke(new ComputeStyleListWorker(circum, nc, new CompositeList<>(nodes, ways), allStyleElems, 1947 1955 Math.max(100, (nodes.size() + ways.size()) / THREAD_POOL.getParallelism() / 3))); 1948 1956
Note:
See TracChangeset
for help on using the changeset viewer.