< prev index next >

src/java.desktop/share/classes/sun/swing/CachedPainter.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2004, 2006, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2004, 2015, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 51,63 **** * * */ public abstract class CachedPainter { // CacheMap maps from class to ImageCache. ! private static final Map<Object,ImageCache> cacheMap = ! new HashMap<Object,ImageCache>(); ! private static ImageCache getCache(Object key) { synchronized(CachedPainter.class) { ImageCache cache = cacheMap.get(key); if (cache == null) { --- 51,61 ---- * * */ public abstract class CachedPainter { // CacheMap maps from class to ImageCache. ! private static final Map<Object,ImageCache> cacheMap = new HashMap<>(); private static ImageCache getCache(Object key) { synchronized(CachedPainter.class) { ImageCache cache = cacheMap.get(key); if (cache == null) {
*** 94,119 **** public void paint(Component c, Graphics g, int x, int y, int w, int h, Object... args) { if (w <= 0 || h <= 0) { return; } ! if (c != null) { ! synchronized(c.getTreeLock()) { ! synchronized(CachedPainter.class) { ! // If c is non-null, synchronize on the tree lock. ! // This is necessary because asking for the ! // GraphicsConfiguration will grab a tree lock. ! paint0(c, g, x, y, w, h, args); ! } ! } ! } ! else { ! synchronized(CachedPainter.class) { paint0(c, g, x, y, w, h, args); } } - } private void paint0(Component c, Graphics g, int x, int y, int w, int h, Object... args) { Object key = getClass(); GraphicsConfiguration config = getGraphicsConfiguration(c); --- 92,105 ---- public void paint(Component c, Graphics g, int x, int y, int w, int h, Object... args) { if (w <= 0 || h <= 0) { return; } ! synchronized (CachedPainter.class) { paint0(c, g, x, y, w, h, args); } } private void paint0(Component c, Graphics g, int x, int y, int w, int h, Object... args) { Object key = getClass(); GraphicsConfiguration config = getGraphicsConfiguration(c);
< prev index next >