OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [gnu/] [java/] [awt/] [peer/] [x/] [ZPixmapDataBuffer.java] - Blame information for rev 769

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 769 jeremybenn
package gnu.java.awt.peer.x;
2
 
3
import gnu.x11.Display;
4
import gnu.x11.image.ZPixmap;
5
 
6
import java.awt.GraphicsEnvironment;
7
import java.awt.image.DataBuffer;
8
 
9
/**
10
 * A DataBuffer implementation that is based on a ZPixmap. This is used
11
 * as backing store for BufferedImages.
12
 */
13
class ZPixmapDataBuffer
14
  extends DataBuffer
15
{
16
 
17
  /**
18
   * The backing ZPixmap.
19
   */
20
  private ZPixmap zpixmap;
21
 
22
  /**
23
   * Creates a new ZPixmapDataBuffer with a specified width and height.
24
   *
25
   * @param d the X display
26
   * @param w the width
27
   * @param h the height
28
   */
29
  ZPixmapDataBuffer(int w, int h)
30
  {
31
    super(TYPE_BYTE, w * h * 3); // TODO: Support non-24-bit-resolutions.
32
    GraphicsEnvironment env =
33
      GraphicsEnvironment.getLocalGraphicsEnvironment();
34
    XGraphicsDevice dev = (XGraphicsDevice) env.getDefaultScreenDevice();
35
    Display d = dev.getDisplay();
36
    zpixmap = new ZPixmap(d, w, h, d.default_pixmap_format);
37
  }
38
 
39
  /**
40
   * Creates a ZPixmapDataBuffer from an existing ZPixmap.
41
   *
42
   * @param zpixmap the ZPixmap to wrap
43
   */
44
  ZPixmapDataBuffer(ZPixmap zpixmap)
45
  {
46
    super(TYPE_BYTE, zpixmap.get_data_length());
47
    this.zpixmap = zpixmap;
48
  }
49
 
50
  @Override
51
  public int getElem(int bank, int i)
52
  {
53
    return 0xff & zpixmap.get_data_element(i);
54
  }
55
 
56
  @Override
57
  public void setElem(int bank, int i, int val)
58
  {
59
    zpixmap.set_data_element(i, (byte) val);
60
  }
61
 
62
  ZPixmap getZPixmap()
63
  {
64
    return zpixmap;
65
  }
66
 
67
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.