internal static WritableRaster MakeRaster(ColorModel cm, Raster srcRas, int w, int h) { lock (typeof(TexturePaintContext)) { if (Xrgbmodel == cm) { if (XrgbRasRef != null) { WritableRaster wr = (WritableRaster)XrgbRasRef.get(); if (wr != null && wr.Width >= w && wr.Height >= h) { XrgbRasRef = null; return(wr); } } // If we are going to cache this Raster, make it non-tiny if (w <= 32 && h <= 32) { w = h = 32; } } else if (Argbmodel == cm) { if (ArgbRasRef != null) { WritableRaster wr = (WritableRaster)ArgbRasRef.get(); if (wr != null && wr.Width >= w && wr.Height >= h) { ArgbRasRef = null; return(wr); } } // If we are going to cache this Raster, make it non-tiny if (w <= 32 && h <= 32) { w = h = 32; } } if (srcRas != null) { return(srcRas.CreateCompatibleWritableRaster(w, h)); } else { return(cm.CreateCompatibleWritableRaster(w, h)); } } }
internal static WritableRaster MakeByteRaster(Raster srcRas, int w, int h) { lock (typeof(TexturePaintContext)) { if (ByteRasRef != null) { WritableRaster wr = (WritableRaster)ByteRasRef.get(); if (wr != null && wr.Width >= w && wr.Height >= h) { ByteRasRef = null; return(wr); } } // If we are going to cache this Raster, make it non-tiny if (w <= 32 && h <= 32) { w = h = 32; } return(srcRas.CreateCompatibleWritableRaster(w, h)); } }