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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [gnu/] [gcj/] [xlib/] [Visual.java] - Blame information for rev 756

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 756 jeremybenn
/* Copyright (C) 2000  Free Software Foundation
2
 
3
   This file is part of libgcj.
4
 
5
This software is copyrighted work licensed under the terms of the
6
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
7
details.  */
8
 
9
package gnu.gcj.xlib;
10
 
11
import gnu.gcj.RawData;
12
 
13
/**
14
 * A visual determines how a color is encoded into a pixel/bitfield
15
 * value.  It does not determine how the pixel/bitfield value is
16
 * encoded into the image data.
17
 *
18
 * <p>This class encapsulates all three Xlib representations of a
19
 * visual.
20
 *
21
 * <ul>
22
 *
23
 * <li>int: visual id.
24
 *
25
 * <li>Visual: opaque data structure used by a lot of Xlib functions.
26
 *
27
 * <li>VisualInfo: transparent data structure that binds the visual to
28
 * a certain screen and depth.
29
 *
30
 * </ul>
31
 *
32
 * <p>Implementation note: This class does not examine nor manipulate
33
 * the Visual structure, since the X manual says the structure is
34
 * opaque, and that XVisualInfo should be used instead.</p>
35
 *
36
 * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
37
 */
38
public final class Visual
39
{
40
  public static final int VC_STATIC_GRAY  = 0,
41
                          VC_GRAY_SCALE   = 1,
42
                          VC_STATIC_COLOR = 2,
43
                          VC_PSEUDO_COLOR = 3,
44
                          VC_TRUE_COLOR   = 4,
45
                          VC_DIRECT_COLOR = 5;
46
 
47
  protected static final int MASK_ID            = 1 << 0,
48
                             MASK_SCREEN        = 1 << 1,
49
                             MASK_DEPTH         = 1 << 2,
50
                             MASK_CLASS         = 1 << 3,
51
                             MASK_RED           = 1 << 4,
52
                             MASK_GREEN         = 1 << 5,
53
                             MASK_BLUE          = 1 << 6,
54
                             MASK_COLORMAP_SIZE = 1 << 7,
55
                             MASK_BITS_PER_RGB  = 1 << 8;
56
 
57
  protected static final int MASK_ALL = MASK_ID
58
      | MASK_SCREEN
59
      | MASK_DEPTH
60
      | MASK_CLASS
61
      | MASK_RED
62
      | MASK_GREEN
63
      | MASK_BLUE
64
      | MASK_COLORMAP_SIZE
65
      | MASK_BITS_PER_RGB;
66
 
67
  private static final int MASK_VISUAL_STRUCTURE = 1 << 31;
68
 
69
  Display display;
70
  RawData xVisualInfo;
71
  int infoMask;
72
  Screen screen;
73
 
74
  Visual(RawData structure, Screen screen, int depth )
75
  {
76
    this.display = screen.getDisplay();
77
    this.screen = screen;
78
    init(structure, depth);
79
  }
80
 
81
  Visual(Display display, RawData structure, int depth )
82
  {
83
    this.display = display;
84
    init(structure, depth);
85
  }
86
 
87
  protected native void init(RawData structure, int depth);
88
 
89
  protected native void finalize();
90
 
91
  /**
92
   *
93
   * Returns the a reference to the visual structure.  This method has
94
   * package accessibility since the data visual structure is only
95
   * useful for direct Xlib calls.
96
   *
97
   * @return a pointer to the visual structure.
98
   */
99
  native RawData getVisualStructure();
100
 
101
 
102
  // These methods only make sense if the visual is decomposed:
103
 
104
  public native int getRedMask();
105
  public native int getGreenMask();
106
  public native int getBlueMask();
107
 
108
  public native int getScreenNumber();
109
  public native int getDepth();
110
 
111
  public Screen getScreen()
112
  {
113
    if (screen == null)
114
      screen = new Screen(display, getScreenNumber());
115
    return screen;
116
  }
117
 
118
  public native int getVisualClass();
119
 
120
  public boolean hasRGBSubfields()
121
  {
122
    switch (getVisualClass())
123
      {
124
      case VC_TRUE_COLOR:
125
      case VC_DIRECT_COLOR:
126
        return true;
127
      default:
128
        return false;
129
      }
130
  }
131
 
132
  protected native void ensureXVisualInfo(int requiredMask);
133
 
134
 
135
  public String toString()
136
  {
137
    int missingInfo = ~infoMask;
138
    boolean hasSubfieldInfo =
139
      (missingInfo & (MASK_CLASS|MASK_RED|MASK_GREEN|MASK_BLUE)) == 0;
140
 
141
    boolean hasDepth = (missingInfo & MASK_DEPTH) == 0;
142
 
143
    return getClass().getName() + "[" +
144
      (hasDepth ? "depth=" + getDepth() : "") +
145
      (hasRGBSubfields() ?
146
       (", redMask=" + Integer.toHexString(getRedMask()) +
147
        ", greenMask=" + Integer.toHexString(getGreenMask()) +
148
        ", blueMask=" + Integer.toHexString(getBlueMask())) :
149
       ", no-subfields") + ", class=" + getVisualClass() +
150
      "]";
151
  }
152
}

powered by: WebSVN 2.1.0

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