jawt.h revision 2362
1472N/A * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved. 1010N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1010N/A * This code is free software; you can redistribute it and/or modify it 1010N/A * under the terms of the GNU General Public License version 2 only, as 1010N/A * published by the Free Software Foundation. Oracle designates this 1472N/A * particular file as subject to the "Classpath" exception as provided 1010N/A * by Oracle in the LICENSE file that accompanied this code. 1010N/A * This code is distributed in the hope that it will be useful, but WITHOUT 1010N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1010N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1010N/A * version 2 for more details (a copy is included in the LICENSE file that 1010N/A * You should have received a copy of the GNU General Public License version 1010N/A * 2 along with this work; if not, write to the Free Software Foundation, 1010N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1010N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1010N/A * AWT native interface (new in JDK 1.3) 1010N/A * The AWT native interface allows a native C or C++ application a means * by which to access native structures in AWT. This is to facilitate moving * legacy C and C++ applications to Java and to target the needs of the * community who, at present, wish to do their own native rendering to canvases * for performance reasons. Standard extensions such as Java3D also require a * means to access the underlying native data structures of AWT. * There may be future extensions to this API depending on demand. * A VM does not have to implement this API in order to pass the JCK. * It is recommended, however, that this API is implemented on VMs that support * standard extensions, such as Java3D. * Since this is a native API, any program which uses it cannot be considered * AWT Native Drawing Surface (JAWT_DrawingSurface). * For each platform, there is a native drawing surface structure. This * platform-specific structure can be found in jawt_md.h. It is recommended * that additional platforms follow the same model. It is also recommended * that VMs on Win32 and Solaris support the existing structures in jawt_md.h. * In Win32, a programmer wishes to access the HWND of a canvas to perform * native rendering into it. The programmer has declared the paint() method * for their canvas subclass to be native: * public class MyCanvas extends Canvas { * System.loadLibrary("mylib"); * public native void paint(Graphics g); * Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics) * JAWT_DrawingSurface* ds; * JAWT_DrawingSurfaceInfo* dsi; * JAWT_Win32DrawingSurfaceInfo* dsi_win; * awt.version = JAWT_VERSION_1_3; * result = JAWT_GetAWT(env, &awt); * assert(result != JNI_FALSE); * // Get the drawing surface * ds = awt.GetDrawingSurface(env, canvas); * // Lock the drawing surface * assert((lock & JAWT_LOCK_ERROR) == 0); * // Get the drawing surface info * dsi = ds->GetDrawingSurfaceInfo(ds); * // Get the platform-specific drawing info * dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; * ////////////////////////////// * // !!! DO PAINTING HERE !!! // * ////////////////////////////// * // Free the drawing surface info * ds->FreeDrawingSurfaceInfo(dsi); * // Unlock the drawing surface * // Free the drawing surface * awt.FreeDrawingSurface(ds); * Structure for a native rectangle. * JAWT_DrawingSurfaceInfo * Structure for containing the underlying drawing information of a component. * Pointer to the platform-specific information. This can be safely * cast to a JAWT_Win32DrawingSurfaceInfo on Windows or a * JAWT_X11DrawingSurfaceInfo on Solaris. See jawt_md.h for details. /* Cached pointer to the underlying drawing surface */ /* Bounding rectangle of the drawing surface */ /* Number of rectangles in the clip */ /* Clip rectangle array */ * Structure for containing the underlying drawing information of a component. * All operations on a JAWT_DrawingSurface MUST be performed from the same * thread as the call to GetDrawingSurface. * Cached reference to the Java environment of the calling thread. * If Lock(), Unlock(), GetDrawingSurfaceInfo() or * FreeDrawingSurfaceInfo() are called from a different thread, * this data member should be set before calling those functions. /* Cached reference to the target object */ * Lock the surface of the target component for native rendering. * When finished drawing, the surface must be unlocked with * Unlock(). This function returns a bitmask with one or more of the * JAWT_LOCK_ERROR - When an error has occurred and the surface could not * JAWT_LOCK_CLIP_CHANGED - When the clip region has changed. * JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed. * JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed * Get the drawing surface info. * The value returned may be cached, but the values may change if * additional calls to Lock() or Unlock() are made. * Lock() must be called before this can return a valid value. * Returns NULL if an error has occurred. * When finished with the returned value, FreeDrawingSurfaceInfo must be * Free the drawing surface info. * Unlock the drawing surface of the target component for native rendering. * Structure for containing native AWT functions. * Version of this structure. This must always be set before * Return a drawing surface from a target jobject. This value * Returns NULL if an error has occurred. * Target must be a java.awt.Component (should be a Canvas * or Window for native rendering). * FreeDrawingSurface() must be called when finished with the * returned JAWT_DrawingSurface. * Free the drawing surface allocated in GetDrawingSurface. * Locks the entire AWT for synchronization purposes * Unlocks the entire AWT for synchronization purposes * Returns a reference to a java.awt.Component from a native * platform handle. On Windows, this corresponds to an HWND; * on Solaris and Linux, this is a Drawable. For other platforms, * see the appropriate machine-dependent header file for a description. * The reference returned by this function is a local * reference that is only valid in this environment. * This function returns a NULL reference if no component could be * found with matching platform information. * Get the AWT native structure. This function returns JNI_FALSE if #
endif /* !_JAVASOFT_JAWT_H_ */