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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [gnu/] [gcj/] [xlib/] [natVisual.cc] - 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
#include <X11/Xlib.h>
10
#include <X11/Xutil.h>
11
 
12
#include <gcj/cni.h>
13
#include <gnu/gcj/xlib/Visual.h>
14
#include <gnu/gcj/xlib/Screen.h>
15
#include <gnu/gcj/xlib/Display.h>
16
#include <gnu/gcj/xlib/XException.h>
17
#include <gnu/gcj/RawData.h>
18
 
19
using namespace gnu::gcj;
20
 
21
void gnu::gcj::xlib::Visual::init(RawData* visual, jint depth)
22
{
23
  XVisualInfo* info = new XVisualInfo;
24
  xVisualInfo = reinterpret_cast<gnu::gcj::RawData*>(info);
25
  infoMask = 0;
26
 
27
  if (visual != 0)
28
    {
29
      ::Visual* visualStructure = (::Visual*) visual;
30
      info->visual = visualStructure;
31
      info->visualid = XVisualIDFromVisual(visualStructure);
32
      infoMask |= MASK_ID | MASK_VISUAL_STRUCTURE;
33
    }
34
 
35
  if (depth  != 0)
36
    {
37
      info->depth = depth;
38
      infoMask |= MASK_DEPTH;
39
    }
40
}
41
 
42
void gnu::gcj::xlib::Visual::finalize()
43
{
44
  if (xVisualInfo != 0)
45
    {
46
      delete xVisualInfo;
47
      xVisualInfo = 0;
48
    }
49
}
50
 
51
RawData* gnu::gcj::xlib::Visual::getVisualStructure()
52
{
53
    ensureXVisualInfo(MASK_ALL); // Make sure structure is set
54
    XVisualInfo* info = (XVisualInfo*) xVisualInfo;
55
    return reinterpret_cast<gnu::gcj::RawData*>(info->visual);
56
}
57
 
58
jint gnu::gcj::xlib::Visual::getRedMask()
59
{
60
  ensureXVisualInfo(MASK_RED);
61
  XVisualInfo* info = (XVisualInfo*) xVisualInfo;
62
  return info->red_mask;
63
}
64
 
65
jint gnu::gcj::xlib::Visual::getGreenMask()
66
{
67
  ensureXVisualInfo(MASK_GREEN);
68
  XVisualInfo* info = (XVisualInfo*) xVisualInfo;
69
  return info->green_mask;
70
}
71
 
72
jint gnu::gcj::xlib::Visual::getBlueMask()
73
{
74
  ensureXVisualInfo(MASK_BLUE);
75
  XVisualInfo* info = (XVisualInfo*) xVisualInfo;
76
  return info->blue_mask;
77
}
78
 
79
jint gnu::gcj::xlib::Visual::getScreenNumber()
80
{
81
  if (screen != 0)
82
    return screen->getScreenNumber();
83
 
84
  ensureXVisualInfo(MASK_SCREEN);
85
  XVisualInfo* info = (XVisualInfo*) xVisualInfo;
86
  return info->screen;
87
}
88
 
89
jint gnu::gcj::xlib::Visual::getDepth()
90
{
91
  ensureXVisualInfo(MASK_DEPTH);
92
 
93
  XVisualInfo* info = (XVisualInfo*) xVisualInfo;
94
  return info->depth;
95
}
96
 
97
jint gnu::gcj::xlib::Visual::getVisualClass()
98
{
99
  ensureXVisualInfo(MASK_CLASS);
100
  ::XVisualInfo* info = (::XVisualInfo*) xVisualInfo;
101
  return info->c_class;
102
}
103
 
104
void gnu::gcj::xlib::Visual::ensureXVisualInfo(jint requiredMask)
105
{
106
  int missingInformation = ~infoMask;
107
  if ((missingInformation & requiredMask) == 0)
108
    return;
109
 
110
  // We need more info...
111
 
112
  XVisualInfo* info = (XVisualInfo*) xVisualInfo;
113
 
114
  // Store everything we know into template
115
  if (screen != 0)
116
    {
117
      info->screen = screen->getScreenNumber();
118
      infoMask |= MASK_SCREEN;
119
    }
120
 
121
  // Aquire info using the current info as template for matching
122
  ::Display* dpy = (::Display*) display->display;
123
  int visualInfoCount;
124
 
125
  long mask = infoMask & MASK_ALL & (~MASK_VISUAL_STRUCTURE);
126
  XVisualInfo* matches = XGetVisualInfo(dpy, mask,
127
                                          info, &visualInfoCount);
128
  if (matches != 0)
129
    {
130
      (*info) = matches[0];
131
 
132
      // redundant?
133
      xVisualInfo = reinterpret_cast<gnu::gcj::RawData*>(info);
134
 
135
      infoMask = ~0; // ALL
136
      XFree(matches);
137
    }
138
  else
139
    {
140
      char msg[] =
141
        "XGetVisualInfo failed to find any matching visuals. The template "
142
        "describes a combination of properties that does not exist on "
143
        "this X server.";
144
      throw new XException(JvNewStringLatin1(msg));
145
    }
146
}

powered by: WebSVN 2.1.0

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