19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Lesser General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2.1 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Lesser General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Lesser General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free Software 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@libsdl.org 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h" 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef _SDL_dgavideo_h 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define _SDL_dgavideo_h 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <X11/Xlib.h> 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Apparently some X11 systems can't include this multiple times... */ 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef SDL_INCLUDED_XLIBINT_H 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_INCLUDED_XLIBINT_H 1 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <X11/Xlibint.h> 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <X11/Xproto.h> 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_mouse.h" 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_mutex.h" 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_sysvideo.h" 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Hidden "this" pointer for the video functions */ 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define _THIS SDL_VideoDevice *this 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Define this if you need the DGA driver to be thread-safe */ 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define LOCK_DGA_DISPLAY 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef LOCK_DGA_DISPLAY 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define LOCK_DISPLAY() SDL_mutexP(event_lock) 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define UNLOCK_DISPLAY() SDL_mutexV(event_lock) 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define LOCK_DISPLAY() 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define UNLOCK_DISPLAY() 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* This is the structure we use to keep track of video memory */ 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct vidmem_bucket { 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall struct vidmem_bucket *prev; 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int used; 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int dirty; 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 *base; 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall unsigned int size; 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall struct vidmem_bucket *next; 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} vidmem_bucket; 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Private display data */ 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstruct SDL_PrivateVideoData { 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Display *DGA_Display; 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Colormap DGA_colormap; 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int visualClass; 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */ 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int SDL_nummodes[NUM_MODELISTS]; 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Rect **SDL_modelist[NUM_MODELISTS]; 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Information for the video surface */ 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 *memory_base; 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int memory_pitch; 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_mutex *hw_lock; 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int sync_needed; 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int was_flipped; 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Information for hardware surfaces */ 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall vidmem_bucket surfaces; 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int surfaces_memtotal; 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int surfaces_memleft; 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Information for double-buffering */ 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int flip_page; 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int flip_yoffset[2]; 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 *flip_address[2]; 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Used to handle DGA events */ 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int event_base; 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef LOCK_DGA_DISPLAY 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_mutex *event_lock; 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Screensaver settings */ 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int allow_screensaver; 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}; 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Old variable names */ 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define DGA_Display (this->hidden->DGA_Display) 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define DGA_Screen DefaultScreen(DGA_Display) 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define DGA_colormap (this->hidden->DGA_colormap) 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define DGA_visualClass (this->hidden->visualClass) 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define memory_base (this->hidden->memory_base) 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define memory_pitch (this->hidden->memory_pitch) 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define flip_page (this->hidden->flip_page) 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define flip_yoffset (this->hidden->flip_yoffset) 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define flip_address (this->hidden->flip_address) 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define sync_needed (this->hidden->sync_needed) 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define was_flipped (this->hidden->was_flipped) 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_nummodes (this->hidden->SDL_nummodes) 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SDL_modelist (this->hidden->SDL_modelist) 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define surfaces (this->hidden->surfaces) 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define surfaces_memtotal (this->hidden->surfaces_memtotal) 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define surfaces_memleft (this->hidden->surfaces_memleft) 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define hw_lock (this->hidden->hw_lock) 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define DGA_event_base (this->hidden->event_base) 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define event_lock (this->hidden->event_lock) 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define allow_screensaver (this->hidden->allow_screensaver) 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* _SDL_dgavideo_h */ 125