Home | History | Annotate | Download | only in dga
      1 /*
      2     SDL - Simple DirectMedia Layer
      3     Copyright (C) 1997-2012 Sam Lantinga
      4 
      5     This library is free software; you can redistribute it and/or
      6     modify it under the terms of the GNU Lesser General Public
      7     License as published by the Free Software Foundation; either
      8     version 2.1 of the License, or (at your option) any later version.
      9 
     10     This library is distributed in the hope that it will be useful,
     11     but WITHOUT ANY WARRANTY; without even the implied warranty of
     12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13     Lesser General Public License for more details.
     14 
     15     You should have received a copy of the GNU Lesser General Public
     16     License along with this library; if not, write to the Free Software
     17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     18 
     19     Sam Lantinga
     20     slouken (at) libsdl.org
     21 */
     22 #include "SDL_config.h"
     23 
     24 #ifndef _SDL_dgavideo_h
     25 #define _SDL_dgavideo_h
     26 
     27 #include <X11/Xlib.h>
     28 
     29 /* Apparently some X11 systems can't include this multiple times... */
     30 #ifndef SDL_INCLUDED_XLIBINT_H
     31 #define SDL_INCLUDED_XLIBINT_H 1
     32 #include <X11/Xlibint.h>
     33 #endif
     34 
     35 #include <X11/Xproto.h>
     36 
     37 #include "SDL_mouse.h"
     38 #include "SDL_mutex.h"
     39 #include "../SDL_sysvideo.h"
     40 
     41 /* Hidden "this" pointer for the video functions */
     42 #define _THIS	SDL_VideoDevice *this
     43 
     44 /* Define this if you need the DGA driver to be thread-safe */
     45 #define LOCK_DGA_DISPLAY
     46 #ifdef LOCK_DGA_DISPLAY
     47 #define LOCK_DISPLAY()		SDL_mutexP(event_lock)
     48 #define UNLOCK_DISPLAY()	SDL_mutexV(event_lock)
     49 #else
     50 #define LOCK_DISPLAY()
     51 #define UNLOCK_DISPLAY()
     52 #endif
     53 
     54 
     55 /* This is the structure we use to keep track of video memory */
     56 typedef struct vidmem_bucket {
     57 	struct vidmem_bucket *prev;
     58 	int used;
     59 	int dirty;
     60 	Uint8 *base;
     61 	unsigned int size;
     62 	struct vidmem_bucket *next;
     63 } vidmem_bucket;
     64 
     65 /* Private display data */
     66 struct SDL_PrivateVideoData {
     67 	Display *DGA_Display;
     68 	Colormap DGA_colormap;
     69 	int visualClass;
     70 
     71 #define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
     72 	int SDL_nummodes[NUM_MODELISTS];
     73 	SDL_Rect **SDL_modelist[NUM_MODELISTS];
     74 
     75 	/* Information for the video surface */
     76 	Uint8 *memory_base;
     77 	int memory_pitch;
     78 	SDL_mutex *hw_lock;
     79 	int sync_needed;
     80 	int was_flipped;
     81 
     82 	/* Information for hardware surfaces */
     83 	vidmem_bucket surfaces;
     84 	int surfaces_memtotal;
     85 	int surfaces_memleft;
     86 
     87 	/* Information for double-buffering */
     88 	int flip_page;
     89 	int flip_yoffset[2];
     90 	Uint8 *flip_address[2];
     91 
     92 	/* Used to handle DGA events */
     93 	int event_base;
     94 #ifdef LOCK_DGA_DISPLAY
     95 	SDL_mutex *event_lock;
     96 #endif
     97 
     98 	/* Screensaver settings */
     99 	int allow_screensaver;
    100 };
    101 
    102 /* Old variable names */
    103 #define DGA_Display		(this->hidden->DGA_Display)
    104 #define DGA_Screen		DefaultScreen(DGA_Display)
    105 #define DGA_colormap		(this->hidden->DGA_colormap)
    106 #define DGA_visualClass		(this->hidden->visualClass)
    107 #define memory_base		(this->hidden->memory_base)
    108 #define memory_pitch		(this->hidden->memory_pitch)
    109 #define flip_page		(this->hidden->flip_page)
    110 #define flip_yoffset		(this->hidden->flip_yoffset)
    111 #define flip_address		(this->hidden->flip_address)
    112 #define sync_needed		(this->hidden->sync_needed)
    113 #define was_flipped		(this->hidden->was_flipped)
    114 #define SDL_nummodes		(this->hidden->SDL_nummodes)
    115 #define SDL_modelist		(this->hidden->SDL_modelist)
    116 #define surfaces		(this->hidden->surfaces)
    117 #define surfaces_memtotal	(this->hidden->surfaces_memtotal)
    118 #define surfaces_memleft	(this->hidden->surfaces_memleft)
    119 #define hw_lock			(this->hidden->hw_lock)
    120 #define DGA_event_base		(this->hidden->event_base)
    121 #define event_lock		(this->hidden->event_lock)
    122 #define allow_screensaver	(this->hidden->allow_screensaver)
    123 
    124 #endif /* _SDL_dgavideo_h */
    125