Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/native/sun/jdga/jdgadevice.h
32287 views
/*1* Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef _JDGADEVICE_H_26#define _JDGADEVICE_H_2728/*29* Interface for Supporting DGA to Framebuffers under Java30* -------------------------------------------------------31*32* This interface will allow third party (and Sun) framebuffers which33* support the Direct Graphics Access (DGA) interface to be accessed with34* DGA in Java applications.35*36* It coexists with the existing device-independent interfaces provided in37* libsunwjdga.so.38*39* Framebuffers desiring access to Java DGA must supply a dynamically40* loaded library named "libjdga<fbname>.so", where <fbname> is the name41* returned by the VIS_GETIDENTIFIER ioctl as defined in the Solaris42* VISUAL environment (visual_io(7i)). For example, the Java DGA library43* for Sun's cg6 framebuffer will be named libjdgaSUNWcg6.so.44*45* Because multiple instances of a framebuffer type may exist on a system,46* the device-dependent library must avoid the use of static or global47* variables for any framebuffer-related variables. In other words it48* must be reentrant.49*50* The device-independent function Solaris_JDga_LibInit() is called in the51* static initializer for X11Graphics.java. Solaris_JDga_LibInit() will be52* modified to seek out a device-dependent DGA library as follows.53*54* - DGA grab the DefaultRootWindow to get a Dga_drawable.55*56* - Use the Dga_drawable ID to get the device file descriptor57* fd = dga_win_devfd(dga_draw_id)58*59* - Use the VIS_GETIDENTIFIER ioctl to get the device name string.60*61* - Construct the library path name using the device name string.62* The device-dependent library must be located in a location specified63* in the LD_LIBRARY_PATH.64*65* - The device-dependent library will be dlopen'ed and then a dlsym will66* be performed for the function "SolarisJDgaDevOpen", which must67* be implemented by the device-dependent library writer.68*69* - The function SolarisJDgaDevOpen() will then be called with a70* pointer to a SolarisJDgaDevInfo structure. This structure will71* have its major and minor version numbers filled in with their72* current values by the device-independent calling code. The73* device-dependent library must examine these version numbers and74* act as follows:75*76* - In all cases, the device-dependent code should reset the77* supplied major and minor version numbers to those of the78* device-dependent library.79*80* - If the supplied major version number is not the same as that81* of the device library, the open must fail and return JDGA_FAILED.82*83* - If the supplied minor version number is less than or equal to84* the device minor version number, then backward compatibility85* is assumed and the open should return JDGA_SUCCESS.86*87* - If the supplied minor version number is greater than the88* device minor version number, the open should also return89* JDGA_SUCCESS. The returned device minor version number will90* indicate to the device-independent code what features are91* supported in the device library.92*93* - The function SolarisJDgaDevOpen() must also return a structure94* containing function pointers as given in the SolarisJDgaDevFunc95* structure below. The winlock and winunlock functions are96* required only if there is some device-specific locking to be done97* in addition to the DGA lock. If this is not required for the device98* these function pointers may be specified as NULL pointers.99*100*/101102#include <dga/dga.h>103#include <unistd.h> /* ioctl */104#include <stdlib.h>105#include <sys/mman.h> /* mmap */106#include <sys/visual_io.h>107#include <X11/Xlib.h>108109/*110* Status return codes111*/112#ifndef _DEFINE_JDGASTATUS_113#define _DEFINE_JDGASTATUS_114typedef enum {115JDGA_SUCCESS = 0, /* operation succeeded */116JDGA_FAILED = 1 /* unable to complete operation */117} JDgaStatus;118#endif119120/*121* Structure to be filled in by device-dependent library's122* SolarisJDgaDevOpen() function123*/124typedef struct {125char * visidName; /* device name from ioctl */126int majorVersion;127int minorVersion;128struct _SolarisJDgaDevFuncList* function; /* Device function pointers */129} SolarisJDgaDevInfo;130131/*132* Structure returned by device-dependent library for a window133*/134typedef struct {135SolarisJDgaDevInfo* devInfo; /* Supplied by caller */136Dga_drawable dgaDraw; /* Supplied by caller */137caddr_t mapAddr; /* FB mapping for this window */138int mapDepth; /* Depth in bits */139int mapWidth; /* Width in pixels */140int mapHeight; /* Height in lines */141int mapLineStride; /* Byte stride line-to-line */142int mapPixelStride; /* Byte stride pixel-to-pixel */143void* privateData; /* Handle for device-dependent library */144} SolarisJDgaWinInfo;145146typedef JDgaStatus (*SolarisJDgaDevFunction)(SolarisJDgaDevInfo*);147typedef JDgaStatus (*SolarisJDgaWinFunction)(SolarisJDgaWinInfo*);148149/*150* Structure for device-dependent functions151*/152typedef struct _SolarisJDgaDevFuncList {153SolarisJDgaDevFunction devclose;154SolarisJDgaWinFunction winopen;155SolarisJDgaWinFunction winclose;156SolarisJDgaWinFunction winlock;157SolarisJDgaWinFunction winunlock;158} SolarisJDgaDevFuncList;159160/*161* Function to be supplied by the device-dependent library implementor.162* It will accept a SolarisJDgaDevInfo structure with a filled-in163* major and minor version number and will return updated version164* numbers and the function pointers described below.165*/166typedef JDgaStatus SolarisJDgaDevOpenFunc(SolarisJDgaDevInfo* devInfo);167168JDgaStatus SolarisJDgaDevOpen(SolarisJDgaDevInfo* devInfo);169170/*171* Functions supplied by the device-dependent library.172* These function pointers will be returned to the173* device-independent code in the SolarisJDgaDevFunc structure.174*/175176JDgaStatus (*winopen)(SolarisJDgaWinInfo* info);177178/*179* Fills in window-specific information in the supplied SolarisJDgaWinInfo180* structure. Because multiple windows may be open concurrently,181* implementations should avoid the use of static structures.182*/183184JDgaStatus (*winclose)(SolarisJDgaWinInfo* info);185186/*187* Frees any resources allocated by the device-dependent library for188* this window. It may also perform an unmap if this is the last189* window using this particular memory map. Devices, such as the FFB,190* which support multiple depths, can have different device memory191* mappings for different depths.192*/193194JDgaStatus (*winlock)(SolarisJDgaWinInfo* info);195196/*197* Performs any device-specific locking needed for the framebuffer.198* In most cases it will be unnecessary. In those cases, the199* device-dependent library can supply NULL for this function pointer.200*/201202JDgaStatus (*winunlock)(SolarisJDgaWinInfo* info);203204/*205* Performs any device-specific unlocking needed for the framebuffer.206* In most cases it will be unnecessary. In those cases, the207* device-dependent library can supply NULL for this function pointer.208*/209210JDgaStatus (*devclose)(SolarisJDgaDevInfo* info);211212/*213* This function will be called at the last usage of the framebuffer214* device to allow the library to clean up any remaining resources.215*/216217#endif /* _JDGADEVICE_H_ */218219220