author | prr |
Thu, 27 Apr 2017 14:07:38 -0700 | |
changeset 45017 | 7bd7767129ed |
permissions | -rw-r--r-- |
45017
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
1 |
<!-- |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
2 |
Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
3 |
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
4 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
5 |
This code is free software; you can redistribute it and/or modify it |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
6 |
under the terms of the GNU General Public License version 2 only, as |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
7 |
published by the Free Software Foundation. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
8 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
9 |
This code is distributed in the hope that it will be useful, but WITHOUT |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
10 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
11 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
12 |
version 2 for more details (a copy is included in the LICENSE file that |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
13 |
accompanied this code). |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
14 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
15 |
You should have received a copy of the GNU General Public License version |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
16 |
2 along with this work; if not, write to the Free Software Foundation, |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
17 |
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
18 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
19 |
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
20 |
or visit www.oracle.com if you need additional information or have any |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
21 |
questions. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
22 |
--> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
23 |
<?xml version="1.0" encoding="utf-8"?> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
24 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
25 |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
26 |
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" xml:lang= |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
27 |
"en-US"> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
28 |
<head> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
29 |
<title>Java AWT Native Interface Specification and Guide</title> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
30 |
</head> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
31 |
<body> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
32 |
<h2>The Java AWT Native Interface Specification and Guide</h2> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
33 |
<h3>Introduction</h3> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
34 |
<p>The Java AWT Native Interface (JAWT) comprises a small set of native |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
35 |
(eg C language-based) APIs that provide a standard supported way |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
36 |
for interaction between Java API windows and surfaces, and |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
37 |
platform native API windows and surfaces. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
38 |
Non-Java libraries may then render to a Java owned window. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
39 |
<p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
40 |
Note: in this document the terms "Java AWT Native Interface", |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
41 |
"AWT Native Interface" and "JAWT" are interchangeable and |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
42 |
refer to this same specification. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
43 |
<p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
44 |
The fundamental obstacle to native rendering without JAWT is that |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
45 |
is that the rendering code cannot identify where to draw. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
46 |
The native code needs access to information about a Java |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
47 |
drawing surface (such as a handle to the underlying native ID of a |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
48 |
<tt>Canvas</tt>), but cannot get it.</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
49 |
Without that information (ie without JAWT) an application could |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
50 |
use native rendering only by creating its own top-level window |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
51 |
not shared at all with Java. This is unacceptable for most uses. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
52 |
Except for usage via JAWT, this is considered to be entirely |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
53 |
internal to the Java platform implementation: private, unsupported |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
54 |
and undocumented. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
55 |
<p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
56 |
JAWT should be supported in all headful implementations |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
57 |
where technically possible although this is not enforced by the JCK. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
58 |
There is a platform-specific and a platform |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
59 |
independent portion to the API, to account for the differing |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
60 |
data structures and requirements of each platform. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
61 |
This document specifies the platform independent portions and |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
62 |
also documents the platform dependent portions for the Oracle JDK |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
63 |
supported desktop operating environments. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
64 |
For AWT the term platform is less tied to the underlying operating |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
65 |
system than it is to the desktop windowing environment. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
66 |
<p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
67 |
Reasons for using the AWT Native Interface include |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
68 |
<ul> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
69 |
<li>Use of a 3rd party native library not available in Java |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
70 |
<li>A temporary porting aid before converting legacy code to Java |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
71 |
<li>Rendering performance available only to native hardware accelerated APIs |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
72 |
<li>Interoperation with another toolkit |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
73 |
</ul> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
74 |
<p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
75 |
Drawbacks include |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
76 |
<ul> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
77 |
<li>A more complex application implementation, eg for painting |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
78 |
<li>Potential for application instability if the native library does |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
79 |
not interoperate properly with AWT. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
80 |
<li>Increased application delivery complexity - per platform binaries |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
81 |
</ul> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
82 |
The header file <a href="#jawt.h"> "jawt.h"</a> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
83 |
in the Appendix fully specifies the APIs provided by JAWT. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
84 |
<p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
85 |
An example illustrating how easy it is to use the AWT Native Interface |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
86 |
is presented and discussed later in this document.</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
87 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
88 |
<p><b>JAWT usage depends on JNI</b></p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
89 |
<p>The definition of Java Standard Edition includes JNI, the Java |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
90 |
Native Interface. Many Java developers will never need to use it, |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
91 |
but the interface is the only standard supported way for a Java |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
92 |
language program to interact directly with |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
93 |
application code that has been compiled to the native machine |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
94 |
instructions for the host processor architecture. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
95 |
JNI is used where ever there is a need for mixed languages. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
96 |
These are by no means limited to cases like AWT. For example, you |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
97 |
could use JNI to integrate with native code that communicates with |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
98 |
a peripheral device, such as a scanner, connected to a system via a |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
99 |
USB port.</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
100 |
<p>So JNI is general enough to be used to access almost any |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
101 |
sort of native library. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
102 |
The rest of this document assumes a familiarity with how |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
103 |
to use JNI. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
104 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
105 |
<p><b>How to use JAWT </b></p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
106 |
<p>In this section we describe the most common usage of the AWT |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
107 |
Native Interface — overriding the <tt>paint</tt> method to |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
108 |
direct drawing operations to a native rendering library which then |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
109 |
queries the Java VM to determine the information it needs in order |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
110 |
to render. Note, however, that any native code may use the AWT |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
111 |
Native Interface to learn about a target drawing surface, not just |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
112 |
code in a <tt>paint</tt> method.</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
113 |
<p>The first step in hooking up a native rendering library to a |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
114 |
Java <tt>Canvas</tt> is to define a new class that extends |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
115 |
<tt>Canvas</tt> and overrides the <tt>paint</tt> method. The Java |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
116 |
system routes all drawing operations for a <tt>Canvas</tt> object |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
117 |
through the <tt>paint</tt> method, as it does for all other GUI |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
118 |
objects. Canvas is a good candidate for the rendering surface as |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
119 |
it does not have any content as a Button would.</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
120 |
<p>The new <tt>paint</tt> method, to be implemented in the native |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
121 |
rendering library, must be declared as <tt>public native void</tt> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
122 |
, and the native library itself is loaded at runtime by including a |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
123 |
call to <tt>System.loadLibrary( "myRenderingLib")</tt>in |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
124 |
the <tt>static</tt> block of the class. The <tt>myRenderingLib</tt> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
125 |
name is used for the native shared library; for Linux or the Solaris |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
126 |
operating environment, the actual name for the library file on disk |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
127 |
is <tt>libmyRenderingLib.so</tt> .</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
128 |
<p>Here is a simple example of such a class:</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
129 |
<pre> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
130 |
import java.awt.*; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
131 |
import java.awt.event.*; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
132 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
133 |
public class MyCanvas extends Canvas { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
134 |
static { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
135 |
System.loadLibrary("myRenderingLib"); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
136 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
137 |
public native void paint(Graphics g); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
138 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
139 |
public static void main(String[] args) { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
140 |
Frame f = new Frame(); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
141 |
f.setBounds(0, 0, 500, 110); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
142 |
f.add(new MyCanvas()); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
143 |
f.addWindowListener( new WindowAdapter() { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
144 |
public void windowClosing(WindowEvent ev) { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
145 |
System.exit(0); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
146 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
147 |
} ); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
148 |
f.show(); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
149 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
150 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
151 |
<br /> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
152 |
</pre> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
153 |
<p>Note that this class has a <tt>main</tt> method that can be used |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
154 |
to run this code as an application for testing purposes.</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
155 |
<p>The next step is to run the <tt>javah</tt> tool on the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
156 |
<tt>MyCanvas</tt> class file above to generate a C/C++ header file |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
157 |
that describes the interface to the native <tt>paint</tt> method |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
158 |
that Java expects to be used. <tt>javah</tt> is a standard tool |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
159 |
included with the JDK. NB: <tt>javac -h outputdir</tt> may also be used.</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
160 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
161 |
<p>The final step ­ and the most interesting one ­ is to |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
162 |
write the native rendering method, with an interface that conforms |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
163 |
to the header file that <tt>javah</tt> generated, and build it as a |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
164 |
standard shared library (called <tt>myRenderingLib</tt> in the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
165 |
above example) by linking it, against the appropriate JDK provided |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
166 |
$JDK_HOME/lib/$JAWT_LIB library for the target platform. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
167 |
Where JAWT_LIB has the base name "jawt" and follows platform |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
168 |
shared object naming rules. i.e.: |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
169 |
<ul> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
170 |
<li>Windows: jawt.dll |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
171 |
<li>MacOS: libjawt.dylib |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
172 |
<li>Linux: libjawt.so |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
173 |
<li>Solaris: libjawt.so |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
174 |
</ul> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
175 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
176 |
This code will call back to the Java virtual machine to |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
177 |
get the drawing surface information it needs to access the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
178 |
<tt>MyCanvas</tt> peer. Once this information is available, the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
179 |
code can draw directly to <tt>MyCanvas</tt> using standard drawing |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
180 |
routines supplied by the underlying operating system.</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
181 |
<p>Here is sample source code for a native <tt>paint</tt> method |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
182 |
designed for use in a X11-based drawing environment (Linux |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
183 |
or Solaris) and a Java VM where the AWT Native Interface is present:</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
184 |
<pre> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
185 |
#include "MyCanvas.h" |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
186 |
#include "jawt_md.h" |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
187 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
188 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
189 |
* Class: MyCanvas |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
190 |
* Method: paint |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
191 |
* Signature: (Ljava/awt/Graphics;)V |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
192 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
193 |
JNIEXPORT void JNICALL Java_MyCanvas_paint |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
194 |
(JNIEnv* env, jobject canvas, jobject graphics) |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
195 |
{ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
196 |
JAWT awt; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
197 |
JAWT_DrawingSurface* ds; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
198 |
JAWT_DrawingSurfaceInfo* dsi; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
199 |
JAWT_X11DrawingSurfaceInfo* dsi_x11; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
200 |
jboolean result; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
201 |
jint lock; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
202 |
GC gc; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
203 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
204 |
short i; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
205 |
char *testString = "^^^ rendered from native code ^^^"; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
206 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
207 |
/* Get the AWT */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
208 |
awt.version = JAWT_VERSION_9; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
209 |
if (JAWT_GetAWT(env, &awt) == JNI_FALSE) { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
210 |
printf("AWT Not found\n"); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
211 |
return; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
212 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
213 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
214 |
/* Get the drawing surface */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
215 |
ds = awt.GetDrawingSurface(env, canvas); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
216 |
if (ds == NULL) { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
217 |
printf("NULL drawing surface\n"); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
218 |
return; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
219 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
220 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
221 |
/* Lock the drawing surface */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
222 |
lock = ds->Lock(ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
223 |
if((lock & JAWT_LOCK_ERROR) != 0) { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
224 |
printf("Error locking surface\n"); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
225 |
awt.FreeDrawingSurface(ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
226 |
return; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
227 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
228 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
229 |
/* Get the drawing surface info */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
230 |
dsi = ds->GetDrawingSurfaceInfo(ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
231 |
if (dsi == NULL) { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
232 |
printf("Error getting surface info\n"); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
233 |
ds->Unlock(ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
234 |
awt.FreeDrawingSurface(ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
235 |
return; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
236 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
237 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
238 |
/* Get the platform-specific drawing info */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
239 |
dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
240 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
241 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
242 |
/* Now paint */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
243 |
gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
244 |
XSetBackground(dsi_x11->display, gc, 0); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
245 |
for (i=0; i<36;i++) |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
246 |
{ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
247 |
XSetForeground(dsi_x11->display, gc, 10*i); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
248 |
XFillRectangle(dsi_x11->display, dsi_x11->drawable, gc, |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
249 |
10*i, 5, 90, 90); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
250 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
251 |
XSetForeground(dsi_x11->display, gc, 155); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
252 |
XDrawImageString(dsi_x11->display, dsi_x11->drawable, gc, |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
253 |
100, 110, testString, strlen(testString)); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
254 |
XFreeGC(dsi_x11->display, gc); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
255 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
256 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
257 |
/* Free the drawing surface info */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
258 |
ds->FreeDrawingSurfaceInfo(dsi); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
259 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
260 |
/* Unlock the drawing surface */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
261 |
ds->Unlock(ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
262 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
263 |
/* Free the drawing surface */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
264 |
awt.FreeDrawingSurface(ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
265 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
266 |
</pre> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
267 |
<p>The key data structure here is <tt>JAWT</tt> , which is defined |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
268 |
in <tt>jawt.h</tt> (included by <tt>jawt_md.h)</tt> ; it provides |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
269 |
access to all the information the native code needs to get the job |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
270 |
done. The first part of the native method is boilerplate: it |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
271 |
populates the <tt>JAWT</tt> structure, gets a |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
272 |
<tt>JAWT_DrawingSurface</tt> structure, locks the surface (only one |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
273 |
drawing engine at a time, please!), then gets a |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
274 |
<tt>JAWT_DrawingSurfaceInfo</tt> structure that contains a pointer |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
275 |
(in the <tt>platformInfo</tt> field) to the necessary |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
276 |
platform-specific drawing information. It also includes the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
277 |
bounding rectangle of the drawing surface and the current clipping |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
278 |
region.</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
279 |
<p>The structure of the information pointed to by |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
280 |
<tt>platformInfo</tt> is defined in a machine-dependent header file |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
281 |
called <tt>jawt_md.h</tt>. For X11 drawing, it includes |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
282 |
information about the X11 display and X11 drawable associated with |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
283 |
<tt>MyCanvas</tt>. After the drawing operations are completed, |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
284 |
there is more boilerplate code as <tt>JAWT_DrawingSurfaceInfo</tt> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
285 |
is freed and <tt>JAWT_DrawingSurface</tt> is unlocked and |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
286 |
freed.</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
287 |
<p>The corresponding code for the GDI API on the Microsoft Windows platform would |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
288 |
be structured similarly, but would include the version of |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
289 |
<tt>jawt_md.h</tt> for Microsoft Windows and the structure located |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
290 |
in the <tt>platformInfo</tt> field of drawing surface info would be |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
291 |
cast as a <tt>JAWT_Win32DrawingSurfaceInfo*</tt> . And, of course, |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
292 |
the actual drawing operations would need to be changed to those |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
293 |
appropriate for the Microsoft Windows platform. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
294 |
The same also for MacOS. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
295 |
</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
296 |
<p><b>Summary</b></p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
297 |
<p>The ability to draw directly into a Java <tt>Canvas</tt> from a |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
298 |
native code library is extremely useful for developers planning to |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
299 |
migrate a legacy software system to Java, especially one that |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
300 |
includes a high-performance rendering engine. It makes it much |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
301 |
easier to migrate in stages, leaving performance-sensitive |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
302 |
rendering code alone, while other less-sensitive portions of code |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
303 |
are converted to Java. The result can be a modern Java-centric |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
304 |
application, providing the benefit of portability and development |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
305 |
efficiency, but one that does not sacrifice an investment in |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
306 |
performance of a key piece of native code.</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
307 |
<p><b>References</b></p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
308 |
<p>The definitive reference to the Java Native Interface is <i>The |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
309 |
Java Native Interface: Programmer's Guide and Specification</i> by |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
310 |
Sheng Liang. This book was published in June |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
311 |
1999 by Addison-Wesley. The ISBN is 0-201-32577-2.</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
312 |
<p><b>Appendix</b></p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
313 |
<p><b>Header Files for jawt.h and jawt_md.h</b></p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
314 |
<a name="jawt.h"></a> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
315 |
<p>jawt.h</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
316 |
<pre> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
317 |
#ifndef _JAVASOFT_JAWT_H_ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
318 |
#define _JAVASOFT_JAWT_H_ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
319 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
320 |
#include "jni.h" |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
321 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
322 |
#ifdef __cplusplus |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
323 |
extern "C" { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
324 |
#endif |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
325 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
326 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
327 |
* AWT native interface. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
328 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
329 |
* The AWT native interface allows a native C or C++ application a means |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
330 |
* by which to access native structures in AWT. This is to facilitate moving |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
331 |
* legacy C and C++ applications to Java and to target the needs of the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
332 |
* developers who need to do their own native rendering to canvases |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
333 |
* for performance or other reasons. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
334 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
335 |
* Conversely it also provides mechanisms for an application which already |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
336 |
* has a native window to provide that to AWT for AWT rendering. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
337 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
338 |
* Since every platform may be different in its native data structures |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
339 |
* and APIs for windowing systems the application must necessarily |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
340 |
* provided per-platform source and compile and deliver per-platform |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
341 |
* native code to use this API. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
342 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
343 |
* These interfaces are not part of the Java SE specification and |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
344 |
* a VM is not required to implement this API. However it is strongly |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
345 |
* recommended that all implementations which support headful AWT |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
346 |
* also support these interfaces. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
347 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
348 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
349 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
350 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
351 |
* AWT Native Drawing Surface (JAWT_DrawingSurface). |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
352 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
353 |
* For each platform, there is a native drawing surface structure. This |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
354 |
* platform-specific structure can be found in jawt_md.h. It is recommended |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
355 |
* that additional platforms follow the same model. It is also recommended |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
356 |
* that VMs on all platforms support the existing structures in jawt_md.h. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
357 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
358 |
******************* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
359 |
* EXAMPLE OF USAGE: |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
360 |
******************* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
361 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
362 |
* On Microsoft Windows, a programmer wishes to access the HWND of a canvas |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
363 |
* to perform native rendering into it. The programmer has declared the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
364 |
* paint() method for their canvas subclass to be native: |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
365 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
366 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
367 |
* MyCanvas.java: |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
368 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
369 |
* import java.awt.*; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
370 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
371 |
* public class MyCanvas extends Canvas { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
372 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
373 |
* static { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
374 |
* System.loadLibrary("mylib"); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
375 |
* } |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
376 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
377 |
* public native void paint(Graphics g); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
378 |
* } |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
379 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
380 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
381 |
* myfile.c: |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
382 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
383 |
* #include "jawt_md.h" |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
384 |
* #include <assert.h> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
385 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
386 |
* JNIEXPORT void JNICALL |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
387 |
* Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics) |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
388 |
* { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
389 |
* JAWT awt; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
390 |
* JAWT_DrawingSurface* ds; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
391 |
* JAWT_DrawingSurfaceInfo* dsi; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
392 |
* JAWT_Win32DrawingSurfaceInfo* dsi_win; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
393 |
* jboolean result; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
394 |
* jint lock; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
395 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
396 |
* // Get the AWT. Request version 9 to access features in that release. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
397 |
* awt.version = JAWT_VERSION_9; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
398 |
* result = JAWT_GetAWT(env, &awt); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
399 |
* assert(result != JNI_FALSE); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
400 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
401 |
* // Get the drawing surface |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
402 |
* ds = awt.GetDrawingSurface(env, canvas); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
403 |
* assert(ds != NULL); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
404 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
405 |
* // Lock the drawing surface |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
406 |
* lock = ds->Lock(ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
407 |
* assert((lock & JAWT_LOCK_ERROR) == 0); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
408 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
409 |
* // Get the drawing surface info |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
410 |
* dsi = ds->GetDrawingSurfaceInfo(ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
411 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
412 |
* // Get the platform-specific drawing info |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
413 |
* dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
414 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
415 |
* ////////////////////////////// |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
416 |
* // !!! DO PAINTING HERE !!! // |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
417 |
* ////////////////////////////// |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
418 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
419 |
* // Free the drawing surface info |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
420 |
* ds->FreeDrawingSurfaceInfo(dsi); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
421 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
422 |
* // Unlock the drawing surface |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
423 |
* ds->Unlock(ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
424 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
425 |
* // Free the drawing surface |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
426 |
* awt.FreeDrawingSurface(ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
427 |
* } |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
428 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
429 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
430 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
431 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
432 |
* JAWT_Rectangle |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
433 |
* Structure for a native rectangle. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
434 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
435 |
typedef struct jawt_Rectangle { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
436 |
jint x; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
437 |
jint y; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
438 |
jint width; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
439 |
jint height; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
440 |
} JAWT_Rectangle; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
441 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
442 |
struct jawt_DrawingSurface; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
443 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
444 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
445 |
* JAWT_DrawingSurfaceInfo |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
446 |
* Structure for containing the underlying drawing information of a component. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
447 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
448 |
typedef struct jawt_DrawingSurfaceInfo { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
449 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
450 |
* Pointer to the platform-specific information. This can be safely |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
451 |
* cast to a JAWT_Win32DrawingSurfaceInfo on Microsoft Windows or a |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
452 |
* JAWT_X11DrawingSurfaceInfo on Linux and Solaris. On MacOS this is a |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
453 |
* pointer to a NSObject that conforms to the JAWT_SurfaceLayers protocol. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
454 |
* See jawt_md.h for details. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
455 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
456 |
void* platformInfo; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
457 |
/* Cached pointer to the underlying drawing surface */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
458 |
struct jawt_DrawingSurface* ds; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
459 |
/* Bounding rectangle of the drawing surface */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
460 |
JAWT_Rectangle bounds; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
461 |
/* Number of rectangles in the clip */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
462 |
jint clipSize; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
463 |
/* Clip rectangle array */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
464 |
JAWT_Rectangle* clip; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
465 |
} JAWT_DrawingSurfaceInfo; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
466 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
467 |
#define JAWT_LOCK_ERROR 0x00000001 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
468 |
#define JAWT_LOCK_CLIP_CHANGED 0x00000002 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
469 |
#define JAWT_LOCK_BOUNDS_CHANGED 0x00000004 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
470 |
#define JAWT_LOCK_SURFACE_CHANGED 0x00000008 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
471 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
472 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
473 |
* JAWT_DrawingSurface |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
474 |
* Structure for containing the underlying drawing information of a component. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
475 |
* All operations on a JAWT_DrawingSurface MUST be performed from the same |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
476 |
* thread as the call to GetDrawingSurface. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
477 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
478 |
typedef struct jawt_DrawingSurface { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
479 |
/* Cached reference to the Java environment of the calling thread. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
480 |
* If Lock(), Unlock(), GetDrawingSurfaceInfo() or |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
481 |
* FreeDrawingSurfaceInfo() are called from a different thread, |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
482 |
* this data member should be set before calling those functions. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
483 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
484 |
JNIEnv* env; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
485 |
/* Cached reference to the target object */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
486 |
jobject target; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
487 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
488 |
* Lock the surface of the target component for native rendering. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
489 |
* When finished drawing, the surface must be unlocked with |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
490 |
* Unlock(). This function returns a bitmask with one or more of the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
491 |
* following values: |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
492 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
493 |
* JAWT_LOCK_ERROR - When an error has occurred and the surface could not |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
494 |
* be locked. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
495 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
496 |
* JAWT_LOCK_CLIP_CHANGED - When the clip region has changed. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
497 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
498 |
* JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
499 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
500 |
* JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
501 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
502 |
jint (JNICALL *Lock) |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
503 |
(struct jawt_DrawingSurface* ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
504 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
505 |
* Get the drawing surface info. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
506 |
* The value returned may be cached, but the values may change if |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
507 |
* additional calls to Lock() or Unlock() are made. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
508 |
* Lock() must be called before this can return a valid value. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
509 |
* Returns NULL if an error has occurred. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
510 |
* When finished with the returned value, FreeDrawingSurfaceInfo must be |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
511 |
* called. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
512 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
513 |
JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo) |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
514 |
(struct jawt_DrawingSurface* ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
515 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
516 |
* Free the drawing surface info. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
517 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
518 |
void (JNICALL *FreeDrawingSurfaceInfo) |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
519 |
(JAWT_DrawingSurfaceInfo* dsi); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
520 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
521 |
* Unlock the drawing surface of the target component for native rendering. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
522 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
523 |
void (JNICALL *Unlock) |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
524 |
(struct jawt_DrawingSurface* ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
525 |
} JAWT_DrawingSurface; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
526 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
527 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
528 |
* JAWT |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
529 |
* Structure for containing native AWT functions. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
530 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
531 |
typedef struct jawt { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
532 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
533 |
* Version of this structure. This must always be set before |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
534 |
* calling JAWT_GetAWT(). It affects the functions returned. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
535 |
* Must be one of the known pre-defined versions. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
536 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
537 |
jint version; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
538 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
539 |
* Return a drawing surface from a target jobject. This value |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
540 |
* may be cached. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
541 |
* Returns NULL if an error has occurred. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
542 |
* Target must be a java.awt.Component (should be a Canvas |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
543 |
* or Window for native rendering). |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
544 |
* FreeDrawingSurface() must be called when finished with the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
545 |
* returned JAWT_DrawingSurface. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
546 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
547 |
JAWT_DrawingSurface* (JNICALL *GetDrawingSurface) |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
548 |
(JNIEnv* env, jobject target); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
549 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
550 |
* Free the drawing surface allocated in GetDrawingSurface. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
551 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
552 |
void (JNICALL *FreeDrawingSurface) |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
553 |
(JAWT_DrawingSurface* ds); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
554 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
555 |
* Since 1.4 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
556 |
* Locks the entire AWT for synchronization purposes |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
557 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
558 |
void (JNICALL *Lock)(JNIEnv* env); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
559 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
560 |
* Since 1.4 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
561 |
* Unlocks the entire AWT for synchronization purposes |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
562 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
563 |
void (JNICALL *Unlock)(JNIEnv* env); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
564 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
565 |
* Since 1.4 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
566 |
* Returns a reference to a java.awt.Component from a native |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
567 |
* platform handle. On Windows, this corresponds to an HWND; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
568 |
* on Solaris and Linux, this is a Drawable. For other platforms, |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
569 |
* see the appropriate machine-dependent header file for a description. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
570 |
* The reference returned by this function is a local |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
571 |
* reference that is only valid in this environment. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
572 |
* This function returns a NULL reference if no component could be |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
573 |
* found with matching platform information. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
574 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
575 |
jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
576 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
577 |
/** |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
578 |
* Since 9 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
579 |
* Creates a java.awt.Frame placed in a native container. Container is |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
580 |
* referenced by the native platform handle. For example on Windows this |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
581 |
* corresponds to an HWND. For other platforms, see the appropriate |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
582 |
* machine-dependent header file for a description. The reference returned |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
583 |
* by this function is a local reference that is only valid in this |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
584 |
* environment. This function returns a NULL reference if no frame could be |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
585 |
* created with matching platform information. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
586 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
587 |
jobject (JNICALL *CreateEmbeddedFrame) (JNIEnv *env, void* platformInfo); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
588 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
589 |
/** |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
590 |
* Since 9 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
591 |
* Moves and resizes the embedded frame. The new location of the top-left |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
592 |
* corner is specified by x and y parameters relative to the native parent |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
593 |
* component. The new size is specified by width and height. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
594 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
595 |
* The embedded frame should be created by CreateEmbeddedFrame() method, or |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
596 |
* this function will not have any effect. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
597 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
598 |
* java.awt.Component.setLocation() and java.awt.Component.setBounds() for |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
599 |
* EmbeddedFrame really don't move it within the native parent. These |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
600 |
* methods always locate the embedded frame at (0, 0) for backward |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
601 |
* compatibility. To allow moving embedded frames this method was |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
602 |
* introduced, and it works just the same way as setLocation() and |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
603 |
* setBounds() for usual, non-embedded components. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
604 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
605 |
* Using usual get/setLocation() and get/setBounds() together with this new |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
606 |
* method is not recommended. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
607 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
608 |
void (JNICALL *SetBounds) (JNIEnv *env, jobject embeddedFrame, |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
609 |
jint x, jint y, jint w, jint h); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
610 |
/** |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
611 |
* Since 9 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
612 |
* Synthesize a native message to activate or deactivate an EmbeddedFrame |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
613 |
* window depending on the value of parameter doActivate, if "true" |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
614 |
* activates the window; otherwise, deactivates the window. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
615 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
616 |
* The embedded frame should be created by CreateEmbeddedFrame() method, or |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
617 |
* this function will not have any effect. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
618 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
619 |
void (JNICALL *SynthesizeWindowActivation) (JNIEnv *env, |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
620 |
jobject embeddedFrame, jboolean doActivate); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
621 |
} JAWT; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
622 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
623 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
624 |
* Get the AWT native structure. This function returns JNI_FALSE if |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
625 |
* an error occurs. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
626 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
627 |
_JNI_IMPORT_OR_EXPORT_ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
628 |
jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
629 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
630 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
631 |
* Specify one of these constants as the JAWT.version |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
632 |
* Specifying an earlier version will limit the available functions to |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
633 |
* those provided in that earlier version of JAWT. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
634 |
* See the "Since" note on each API. Methods with no "Since" |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
635 |
* may be presumed to be present in JAWT_VERSION_1_3. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
636 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
637 |
#define JAWT_VERSION_1_3 0x00010003 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
638 |
#define JAWT_VERSION_1_4 0x00010004 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
639 |
#define JAWT_VERSION_1_7 0x00010007 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
640 |
#define JAWT_VERSION_9 0x00090000 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
641 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
642 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
643 |
#ifdef __cplusplus |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
644 |
} /* extern "C" */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
645 |
#endif |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
646 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
647 |
#endif /* !_JAVASOFT_JAWT_H_ */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
648 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
649 |
</pre> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
650 |
<p>jawt_md.h (Linux/Solaris/X11 operating environment version)</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
651 |
<pre> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
652 |
#ifndef _JAVASOFT_JAWT_MD_H_ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
653 |
#define _JAVASOFT_JAWT_MD_H_ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
654 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
655 |
#include <X11/Xlib.h> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
656 |
#include <X11/Xutil.h> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
657 |
#include <X11/Intrinsic.h> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
658 |
#include "jawt.h" |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
659 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
660 |
#ifdef __cplusplus |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
661 |
extern "C" { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
662 |
#endif |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
663 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
664 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
665 |
* X11-specific declarations for AWT native interface. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
666 |
* See notes in jawt.h for an example of use. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
667 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
668 |
typedef struct jawt_X11DrawingSurfaceInfo { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
669 |
Drawable drawable; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
670 |
Display* display; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
671 |
VisualID visualID; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
672 |
Colormap colormapID; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
673 |
int depth; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
674 |
} JAWT_X11DrawingSurfaceInfo; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
675 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
676 |
#ifdef __cplusplus |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
677 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
678 |
#endif |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
679 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
680 |
#endif /* !_JAVASOFT_JAWT_MD_H_ */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
681 |
</pre> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
682 |
<p>jawt_md.h (Microsoft Windows version)</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
683 |
<pre> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
684 |
#ifndef _JAVASOFT_JAWT_MD_H_ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
685 |
#define _JAVASOFT_JAWT_MD_H_ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
686 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
687 |
#include <windows.h> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
688 |
#include "jawt.h" |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
689 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
690 |
#ifdef __cplusplus |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
691 |
extern "C" { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
692 |
#endif |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
693 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
694 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
695 |
* Microsoft Windows specific declarations for AWT native interface. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
696 |
* See notes in jawt.h for an example of use. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
697 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
698 |
typedef struct jawt_Win32DrawingSurfaceInfo { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
699 |
/* Native window, DDB, or DIB handle */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
700 |
union { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
701 |
HWND hwnd; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
702 |
HBITMAP hbitmap; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
703 |
void* pbits; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
704 |
}; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
705 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
706 |
* This HDC should always be used instead of the HDC returned from |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
707 |
* BeginPaint() or any calls to GetDC(). |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
708 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
709 |
HDC hdc; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
710 |
HPALETTE hpalette; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
711 |
} JAWT_Win32DrawingSurfaceInfo; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
712 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
713 |
#ifdef __cplusplus |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
714 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
715 |
#endif |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
716 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
717 |
#endif /* !_JAVASOFT_JAWT_MD_H_ */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
718 |
</pre> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
719 |
<p>jawt_md.h (MacOS version)</p> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
720 |
<pre> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
721 |
#ifndef _JAVASOFT_JAWT_MD_H_ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
722 |
#define _JAVASOFT_JAWT_MD_H_ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
723 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
724 |
#include "jawt.h" |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
725 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
726 |
#ifdef __OBJC__ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
727 |
#import <QuartzCore/CALayer.h> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
728 |
#endif |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
729 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
730 |
#ifdef __cplusplus |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
731 |
extern "C" { |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
732 |
#endif |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
733 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
734 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
735 |
* MacOS specific declarations for AWT native interface. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
736 |
* See notes in jawt.h for an example of use. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
737 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
738 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
739 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
740 |
* When calling JAWT_GetAWT with a JAWT version less than 1.7, you must pass this |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
741 |
* flag or you will not be able to get a valid drawing surface and JAWT_GetAWT will |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
742 |
* return false. This is to maintain compatibility with applications that used the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
743 |
* interface with Java 6 which had multiple rendering models. This flag is not necessary |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
744 |
* when JAWT version 1.7 or greater is used as this is the only supported rendering mode. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
745 |
* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
746 |
* Example: |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
747 |
* JAWT awt; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
748 |
* awt.version = JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
749 |
* jboolean success = JAWT_GetAWT(env, &awt); |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
750 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
751 |
#define JAWT_MACOSX_USE_CALAYER 0x80000000 |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
752 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
753 |
/* |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
754 |
* When the native Cocoa toolkit is in use, the pointer stored in |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
755 |
* JAWT_DrawingSurfaceInfo->platformInfo points to a NSObject that conforms to the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
756 |
* JAWT_SurfaceLayers protocol. Setting the layer property of this object will cause the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
757 |
* specified layer to be overlaid on the Components rectangle. If the window the |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
758 |
* Component belongs to has a CALayer attached to it, this layer will be accessible via |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
759 |
* the windowLayer property. |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
760 |
*/ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
761 |
#ifdef __OBJC__ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
762 |
@protocol JAWT_SurfaceLayers |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
763 |
@property (readwrite, retain) CALayer *layer; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
764 |
@property (readonly) CALayer *windowLayer; |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
765 |
@end |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
766 |
#endif |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
767 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
768 |
#ifdef __cplusplus |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
769 |
} |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
770 |
#endif |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
771 |
|
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
772 |
#endif /* !_JAVASOFT_JAWT_MD_H_ */ |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
773 |
</pre> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
774 |
<!-- Body text ends here --> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
775 |
</body> |
7bd7767129ed
8179365: JAWT (AWT Native Interface) specification needs to be updated for JDK 9
prr
parents:
diff
changeset
|
776 |
</html> |