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