|
31 | 31 | package java.awt; |
32 | 32 |
|
33 | 33 | import java.awt.image.ColorModel; |
| 34 | +import java.awt.image.Raster; |
| 35 | +import java.awt.image.WritableRaster; |
| 36 | +import java.util.Arrays; |
| 37 | + |
| 38 | +import sun.awt.image.IntegerComponentRaster; |
34 | 39 |
|
35 | 40 | class ColorPaintContext implements PaintContext { |
36 | 41 | int color; |
37 | | -// WritableRaster savedTile; |
| 42 | + WritableRaster savedTile; |
38 | 43 |
|
39 | 44 | protected ColorPaintContext(int color, ColorModel cm) { |
40 | 45 | this.color = color; |
@@ -65,20 +70,21 @@ public ColorModel getColorModel() { |
65 | 70 | return ColorModel.getRGBdefault(); |
66 | 71 | } |
67 | 72 |
|
68 | | -// public synchronized Raster getRaster(int x, int y, int w, int h) { |
69 | | -// WritableRaster t = savedTile; |
70 | | -// |
71 | | -// if (t == null || w > t.getWidth() || h > t.getHeight()) { |
72 | | -// t = getColorModel().createCompatibleWritableRaster(w, h); |
73 | | -// IntegerComponentRaster icr = (IntegerComponentRaster) t; |
74 | | -// Arrays.fill(icr.getDataStorage(), color); |
75 | | -// // Note - markDirty is probably unnecessary since icr is brand new |
76 | | -// icr.markDirty(); |
77 | | -// if (w <= 64 && h <= 64) { |
78 | | -// savedTile = t; |
79 | | -// } |
80 | | -// } |
81 | | -// |
82 | | -// return t; |
83 | | -// } |
| 73 | + @Override |
| 74 | + public synchronized Raster getRaster(int x, int y, int w, int h) { |
| 75 | + WritableRaster t = savedTile; |
| 76 | + |
| 77 | + if (t == null || w > t.getWidth() || h > t.getHeight()) { |
| 78 | + t = getColorModel().createCompatibleWritableRaster(w, h); |
| 79 | + IntegerComponentRaster icr = (IntegerComponentRaster) t; |
| 80 | + Arrays.fill(icr.getDataStorage(), color); |
| 81 | + // Note - markDirty is probably unnecessary since icr is brand new |
| 82 | + icr.markDirty(); |
| 83 | + if (w <= 64 && h <= 64) { |
| 84 | + savedTile = t; |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + return t; |
| 89 | + } |
84 | 90 | } |
0 commit comments