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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [native/] [jawt/] [jawt.c] - Blame information for rev 774

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 774 jeremybenn
/* jawt.c -- X11 implementation of the AWT Native Interface
2
   Copyright (C) 2005 Free Software Foundation, Inc.
3
 
4
   This file is part of GNU Classpath.
5
 
6
   GNU Classpath is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 2, or (at your option)
9
   any later version.
10
 
11
   GNU Classpath is distributed in the hope that it will be useful, but
12
   WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
   General Public License for more details.
15
 
16
   You should have received a copy of the GNU General Public License
17
   along with GNU Classpath; see the file COPYING.  If not, write to the
18
   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
   02110-1301 USA.
20
 
21
   Linking this library statically or dynamically with other modules is
22
   making a combined work based on this library.  Thus, the terms and
23
   conditions of the GNU General Public License cover the whole
24
   combination.
25
 
26
   As a special exception, the copyright holders of this library give you
27
   permission to link this library with independent modules to produce an
28
   executable, regardless of the license terms of these independent
29
   modules, and to copy and distribute the resulting executable under
30
   terms of your choice, provided that you also meet, for each linked
31
   independent module, the terms and conditions of the license of that
32
   module.  An independent module is a module which is not derived from
33
   or based on this library.  If you modify this library, you may extend
34
   this exception to your version of the library, but you are not
35
   obligated to do so.  If you do not wish to do so, delete this
36
   exception statement from your version. */
37
 
38
#include <stdlib.h>
39
#include <jni.h>
40
#include <jawt.h>
41
#include <jawt_md.h>
42
#include "classpath_jawt.h"
43
 
44
#ifndef __GNUC__
45
#define __attribute__(x) /* nothing */
46
#endif
47
 
48
static jint (JNICALL _Jv_Lock) (JAWT_DrawingSurface* surface);
49
static void (JNICALL _Jv_Unlock) (JAWT_DrawingSurface* surface);
50
static JAWT_DrawingSurfaceInfo* (JNICALL _Jv_GetDrawingSurfaceInfo)
51
     (JAWT_DrawingSurface* surface);
52
static void (JNICALL _Jv_FreeDrawingSurfaceInfo)
53
     (JAWT_DrawingSurfaceInfo* surface_info);
54
static JAWT_DrawingSurface* (JNICALL _Jv_GetDrawingSurface) (JNIEnv* env,
55
                                                             jobject canvas);
56
static void (JNICALL _Jv_FreeDrawingSurface) (JAWT_DrawingSurface* surface);
57
static void (JNICALL _Jv_AWTLock) (JNIEnv*);
58
static void (JNICALL _Jv_AWTUnlock) (JNIEnv*);
59
 
60
JNIEXPORT jboolean JNICALL
61
JAWT_GetAWT (JNIEnv* env __attribute__((unused)), JAWT* awt)
62
{
63
  jint retrieved_version;
64
 
65
  retrieved_version = classpath_jawt_get_awt_version ();
66
 
67
  if (awt->version > retrieved_version)
68
    return JNI_FALSE;
69
 
70
  awt->GetDrawingSurface = _Jv_GetDrawingSurface;
71
  awt->FreeDrawingSurface = _Jv_FreeDrawingSurface;
72
  awt->Lock = _Jv_AWTLock;
73
  awt->Unlock = _Jv_AWTUnlock;
74
 
75
  return JNI_TRUE;
76
}
77
 
78
/* JAWT_DrawingSurface functions */
79
 
80
static jint
81
(JNICALL _Jv_Lock) (JAWT_DrawingSurface* surface __attribute__((unused)))
82
{
83
  return classpath_jawt_lock ();
84
}
85
 
86
static void
87
(JNICALL _Jv_Unlock) (JAWT_DrawingSurface* surface __attribute__((unused)))
88
{
89
  classpath_jawt_unlock ();
90
}
91
 
92
static JAWT_DrawingSurfaceInfo*
93
(JNICALL _Jv_GetDrawingSurfaceInfo) (JAWT_DrawingSurface* surface)
94
{
95
  JAWT_DrawingSurfaceInfo* surface_info;
96
  JAWT_X11DrawingSurfaceInfo* surface_info_x11;
97
 
98
  if (surface == NULL || surface->target == NULL)
99
    return NULL;
100
 
101
  surface_info = (JAWT_DrawingSurfaceInfo*) malloc (sizeof (JAWT_DrawingSurfaceInfo));
102
 
103
  if (surface_info == NULL)
104
    return NULL;
105
 
106
  surface_info->platformInfo = malloc (sizeof (JAWT_X11DrawingSurfaceInfo));
107
 
108
  if (surface_info->platformInfo == NULL)
109
    return NULL;
110
 
111
  surface_info_x11 = (JAWT_X11DrawingSurfaceInfo*) surface_info->platformInfo;
112
 
113
  surface_info_x11->display = classpath_jawt_get_default_display (surface->env,
114
                                                                  surface->target);
115
  surface_info_x11->drawable = classpath_jawt_get_drawable (surface->env,
116
                                                            surface->target);
117
  surface_info_x11->visualID = classpath_jawt_get_visualID (surface->env,
118
                                                            surface->target);
119
  surface_info_x11->depth = classpath_jawt_get_depth (surface->env,
120
                                                            surface->target);
121
 
122
  /* FIXME: also include bounding rectangle of drawing surface */
123
  /* FIXME: also include current clipping region */
124
 
125
  return surface_info;
126
}
127
 
128
static void
129
(JNICALL _Jv_FreeDrawingSurfaceInfo) (JAWT_DrawingSurfaceInfo* surface_info)
130
{
131
  JAWT_X11DrawingSurfaceInfo* surface_info_x11;
132
 
133
  if (surface_info == NULL)
134
    return;
135
 
136
  surface_info_x11 = (JAWT_X11DrawingSurfaceInfo*) surface_info->platformInfo;
137
 
138
  surface_info_x11->display = NULL;
139
  surface_info_x11->drawable = 0;
140
  surface_info_x11->visualID = 0;
141
 
142
  free (surface_info->platformInfo);
143
  free (surface_info);
144
  surface_info = NULL;
145
}
146
 
147
/* JAWT functions */
148
 
149
static JAWT_DrawingSurface*
150
(JNICALL _Jv_GetDrawingSurface) (JNIEnv* env, jobject canvas)
151
{
152
  JAWT_DrawingSurface* surface;
153
 
154
  surface = (JAWT_DrawingSurface*) malloc (sizeof (JAWT_DrawingSurface));
155
 
156
  if (surface == NULL)
157
    return NULL;
158
 
159
  surface->env = env;
160
  surface->target = canvas;
161
 
162
  /* initialize function pointers */
163
  surface->GetDrawingSurfaceInfo = _Jv_GetDrawingSurfaceInfo;
164
  surface->FreeDrawingSurfaceInfo = _Jv_FreeDrawingSurfaceInfo;
165
 
166
  surface->Lock = _Jv_Lock;
167
  surface->Unlock = _Jv_Unlock;
168
 
169
  return surface;
170
}
171
 
172
static void
173
(JNICALL _Jv_FreeDrawingSurface) (JAWT_DrawingSurface* surface)
174
{
175
  free (surface);
176
}
177
 
178
static void
179
(JNICALL _Jv_AWTLock) (JNIEnv* env __attribute__((unused)))
180
{
181
  /* FIXME: what is this supposed to do? */
182
}
183
 
184
static void
185
(JNICALL _Jv_AWTUnlock) (JNIEnv* env __attribute__((unused)))
186
{
187
  /* FIXME: what is this supposed to do? */
188
}

powered by: WebSVN 2.1.0

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