More synchronization is needed! The dangers of multithreaded programming.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2485 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: FastImageIO.java,v 1.1 2003/04/27 06:32:15 mdb Exp $
|
||||
// $Id: FastImageIO.java,v 1.2 2003/04/28 17:38:06 mdb Exp $
|
||||
|
||||
package com.threerings.media.image;
|
||||
|
||||
@@ -113,12 +113,17 @@ public class FastImageIO
|
||||
width + "x" + height);
|
||||
}
|
||||
|
||||
// make sure our colormap array is big enough
|
||||
if (_cmap == null || _cmap.length < msize) {
|
||||
_cmap = new int[msize];
|
||||
IndexColorModel cmodel;
|
||||
synchronized (_origin) { // any old object will do
|
||||
// make sure our colormap array is big enough
|
||||
if (_cmap == null || _cmap.length < msize) {
|
||||
_cmap = new int[msize];
|
||||
}
|
||||
// read in the data and create our colormap
|
||||
ibuf.get(_cmap, 0, msize);
|
||||
cmodel = new IndexColorModel(
|
||||
8, msize, _cmap, 0, DataBuffer.TYPE_BYTE, null);
|
||||
}
|
||||
// read in the colormap
|
||||
ibuf.get(_cmap, 0, msize);
|
||||
|
||||
// advance the byte buffer accordingly
|
||||
mbuf.position(ibuf.position() * 4);
|
||||
@@ -133,12 +138,8 @@ public class FastImageIO
|
||||
PixelInterleavedSampleModel smodel =
|
||||
new PixelInterleavedSampleModel(
|
||||
DataBuffer.TYPE_BYTE, width, height, 1, width, offsets);
|
||||
|
||||
WritableRaster raster = WritableRaster.createWritableRaster(
|
||||
smodel, dbuf, _origin);
|
||||
IndexColorModel cmodel = new IndexColorModel(
|
||||
8, msize, _cmap, 0, DataBuffer.TYPE_BYTE, null);
|
||||
|
||||
return new BufferedImage(cmodel, raster, false, null);
|
||||
|
||||
} finally {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ImageManager.java,v 1.52 2003/04/27 07:33:15 mdb Exp $
|
||||
// $Id: ImageManager.java,v 1.53 2003/04/28 17:38:06 mdb Exp $
|
||||
|
||||
package com.threerings.media.image;
|
||||
|
||||
@@ -119,7 +119,9 @@ public class ImageManager
|
||||
*/
|
||||
public void setCanFlushCache (boolean enabled)
|
||||
{
|
||||
_ccache.setCanFlush(enabled);
|
||||
synchronized (_ccache) {
|
||||
_ccache.setCanFlush(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TileSet.java,v 1.48 2003/04/27 07:33:15 mdb Exp $
|
||||
// $Id: TileSet.java,v 1.49 2003/04/28 17:38:06 mdb Exp $
|
||||
|
||||
package com.threerings.media.tile;
|
||||
|
||||
@@ -335,7 +335,9 @@ public abstract class TileSet
|
||||
public static void setCanFlushCache (boolean enabled)
|
||||
{
|
||||
if (_tiles != null) {
|
||||
_tiles.setCanFlush(enabled);
|
||||
synchronized (_tiles) {
|
||||
_tiles.setCanFlush(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user