Changeset 8861 in josm for trunk/src/org


Ignore:
Timestamp:
2015-10-11T23:54:48+02:00 (4 years ago)
Author:
wiktorn
Message:

Remove MEMORY_SIZE based settings and fix high cpu usage when showing low-zoom
tiles.

  • Remove MEMORY_SIZE settings from common imagery settings panel.
  • When working with low-zoom high CPU might occured. This happend, because

border tiles were not added to MemoryTileCache. Now this is fixed

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r8860 r8861  
    140140    public static final IntegerProperty ZOOM_OFFSET = new IntegerProperty(PREFERENCE_PREFIX + ".zoom_offset", 0);
    141141
    142     /**
    143      * use fairly small memory cache, as cached objects are quite big, as they contain BufferedImages
    144      */
    145     public static final IntegerProperty MEMORY_CACHE_SIZE = new IntegerProperty(PREFERENCE_PREFIX + ".cache.max_objects_ram",
    146             (int) Math.max(200,  200 * Math.pow(4, ZOOM_OFFSET.get())));
    147 
    148142    /*
    149143     *  use MemoryTileCache instead of tileLoader JCS cache, as tileLoader caches only content (byte[] of image)
     
    880874     */
    881875    private Tile getTile(int x, int y, int zoom) {
    882         if (x < 0 || x >= tileSource.getTileXMax(zoom) || y < 0 || y >= tileSource.getTileYMax(zoom))
     876        if (x < 0 || x > tileSource.getTileXMax(zoom) || y < 0 || y > tileSource.getTileYMax(zoom))
    883877            return null;
    884878        return tileCache.getTile(tileSource, x, y, zoom);
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CommonSettingsPanel.java

    r8751 r8861  
    3939    private final JosmTextField tilecacheDir = new JosmTextField();
    4040    private final JSpinner maxElementsOnDisk;
    41     private final JSpinner maxElementsInRam;
    4241    private final JSlider tilesZoom = new JSlider(-2, 2, 0);
    4342
     
    4948        super(new GridBagLayout());
    5049
    51         this.maxElementsInRam = new JSpinner(new SpinnerNumberModel(
    52                 AbstractCachedTileSourceLayer.MEMORY_CACHE_SIZE.get().intValue(), 0, Integer.MAX_VALUE, 1));
    5350        this.maxElementsOnDisk = new JSpinner(new SpinnerNumberModel(
    5451                AbstractCachedTileSourceLayer.MAX_DISK_CACHE_SIZE.get().intValue(), 0, Integer.MAX_VALUE, 1));
     
    9895        add(this.maxElementsOnDisk, GBC.eol());
    9996
    100         add(new JLabel(tr("Maximum number of objects in memory cache: ")), GBC.std());
    101         add(GBC.glue(5, 0), GBC.std());
    102         add(this.maxElementsInRam, GBC.eol());
    103 
    10497        this.tilesZoom.setPaintLabels(true);
    10598        this.tilesZoom.setMajorTickSpacing(2);
     
    122115        this.tilecacheDir.setText(CachedTileLoaderFactory.PROP_TILECACHE_DIR.get());
    123116        this.maxElementsOnDisk.setValue(AbstractCachedTileSourceLayer.MAX_DISK_CACHE_SIZE.get());
    124         this.maxElementsInRam.setValue(AbstractCachedTileSourceLayer.MEMORY_CACHE_SIZE.get());
    125117        this.tilesZoom.setValue(AbstractTileSourceLayer.ZOOM_OFFSET.get());
    126118    }
     
    147139        }
    148140
    149         if (!AbstractCachedTileSourceLayer.MEMORY_CACHE_SIZE.get().equals(this.maxElementsInRam.getValue())) {
    150             AbstractCachedTileSourceLayer.MEMORY_CACHE_SIZE.put((Integer) this.maxElementsInRam.getValue());
    151             restartRequired = true;
    152         }
    153 
    154141        if (!AbstractTileSourceLayer.ZOOM_OFFSET.get().equals(this.tilesZoom.getValue())) {
    155142            // TODO: make warning about too small MEMORY_CACHE_SIZE?
Note: See TracChangeset for help on using the changeset viewer.