MappedRaster.java 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Copyright (C) 2000 Free Software Foundation
  2. This file is part of libgcj.
  3. This software is copyrighted work licensed under the terms of the
  4. Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
  5. details. */
  6. package gnu.awt.j2d;
  7. import java.awt.image.WritableRaster;
  8. import java.awt.image.ColorModel;
  9. /* The raster and associated properties of a mapped screen region.
  10. * The compositing capabilities of backends are often insufficient.
  11. * The backend may not support alpha blending, or may not support some
  12. * other special compositing rule. This means that compositing must
  13. * sometimes be done within the rendering pipeline. The general
  14. * compositing operation consists of combining new color and alpha
  15. * values with existing color values on the drawing surface, to find
  16. * the new color values for the drawing surface. The way the values
  17. * are combined, determines what kind of compositing operation that is
  18. * performed. The default compositing operation is alpha compositing.
  19. *
  20. * <p>In order to perform alpha compositing and other compositing
  21. * operations, we need access to the color values of the imagery that
  22. * has already been drawn on the drawing surface. The
  23. * DirectRasterGraphics interface must therefore contain methods that
  24. * makes it possible to gain access to the pixel values of the drawing
  25. * surface. The methods are modeled after the POSIX mmap() and
  26. * munmap() functions. But, instead of mapping and unmapping portions
  27. * of data from a file descriptor to memory, the methods in
  28. * DirectRasterGraphics maps and unmaps portions of the drawing
  29. * surface to data arrays within writable raster objects. A call to
  30. * mapRaster() will return a writable raster object, encapsulating the
  31. * image data of the drawing surface in the requested domain. The data
  32. * encapsulated by this raster object can be modified using the
  33. * WritableRaster API, or the data buffers can be retrieved from the
  34. * raster, so that the data arrays can be manipulated directly. When
  35. * the raster image has been modified as desired, the data can be
  36. * resynchronized with the drawing surface by calling mapRaster().
  37. *
  38. * <p>As with mmap() and munmap() the methods may work by direct
  39. * manipulation of shared memory, (i.e. the raster object directly
  40. * wraps the actual image data of the drawing surface), or may make a
  41. * private copy that is resynched when the raster is unmapped. The
  42. * backend may choose to implement either mechanism, and the pipeline
  43. * code should not care what mechanism is actually used. This design
  44. * allows us to make full use of speedups such as X shared memory
  45. * extentions when available.
  46. */
  47. public class MappedRaster
  48. {
  49. WritableRaster raster;
  50. ColorModel cm;
  51. public MappedRaster(WritableRaster raster, ColorModel cm)
  52. {
  53. this.raster = raster;
  54. this.cm = cm;
  55. }
  56. public final WritableRaster getRaster()
  57. {
  58. return raster;
  59. }
  60. public final ColorModel getColorModel()
  61. {
  62. return cm;
  63. }
  64. }