Don't free the surface since the application might be still using it.
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2010 Sam Lantinga
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.
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.
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
22 #include "SDL_config.h"
24 #ifndef _SDL_sysvideo_h
25 #define _SDL_sysvideo_h
27 #include "SDL_shape.h"
29 /* The SDL video driver */
31 typedef struct SDL_WindowShaper SDL_WindowShaper;
32 typedef struct SDL_ShapeDriver SDL_ShapeDriver;
33 typedef struct SDL_VideoDisplay SDL_VideoDisplay;
34 typedef struct SDL_VideoDevice SDL_VideoDevice;
36 /* Define the SDL window-shaper structure */
37 struct SDL_WindowShaper
39 /* The window associated with the shaper */
42 /* The user's specified coordinates for the window, for once we give it a shape. */
45 /* The parameters for shape calculation. */
46 SDL_WindowShapeMode mode;
48 /* Has this window been assigned a shape? */
54 /* Define the SDL shape driver structure */
55 struct SDL_ShapeDriver
57 SDL_WindowShaper *(*CreateShaper)(SDL_Window * window);
58 int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
59 int (*ResizeWindowShape)(SDL_Window *window);
62 typedef struct SDL_WindowUserData
66 struct SDL_WindowUserData *next;
69 /* Define the SDL window structure, corresponding to toplevel windows */
79 SDL_VideoDisplay *display;
81 SDL_DisplayMode fullscreen_mode;
84 SDL_bool surface_valid;
86 SDL_WindowShaper *shaper;
88 SDL_WindowUserData *data;
95 #define FULLSCREEN_VISIBLE(W) \
96 (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
97 ((W)->flags & SDL_WINDOW_SHOWN) && \
98 !((W)->flags & SDL_WINDOW_MINIMIZED))
101 * Define the SDL display structure This corresponds to physical monitors
102 * attached to the system.
104 struct SDL_VideoDisplay
106 int max_display_modes;
107 int num_display_modes;
108 SDL_DisplayMode *display_modes;
109 SDL_DisplayMode desktop_mode;
110 SDL_DisplayMode current_mode;
111 SDL_bool updating_fullscreen;
114 Uint16 *saved_gamma; /* (just offset into gamma) */
117 SDL_Window *fullscreen_window;
119 SDL_VideoDevice *device;
124 /* Define the SDL video driver structure */
125 #define _THIS SDL_VideoDevice *_this
127 struct SDL_VideoDevice
130 /* The name of this video driver */
134 /* Initialization/Query functions */
137 * Initialize the native video subsystem, filling in the list of
138 * displays for this driver, returning 0 or -1 if there's an error.
140 int (*VideoInit) (_THIS);
143 * Reverse the effects VideoInit() -- called if VideoInit() fails or
144 * if the application is shutting down the video subsystem.
146 void (*VideoQuit) (_THIS);
154 * Get the bounds of a display
156 int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
159 * Get a list of the available display modes. e.g.
160 * SDL_AddDisplayMode(_this->current_display, mode)
162 void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
165 * Setting the display mode is independent of creating windows, so
166 * when the display mode is changed, all existing windows should have
167 * their data updated accordingly, including the display surfaces
168 * associated with them.
170 int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
172 /* Set the gamma ramp */
173 int (*SetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
175 /* Get the gamma ramp */
176 int (*GetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
182 int (*CreateWindow) (_THIS, SDL_Window * window);
183 int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
184 void (*SetWindowTitle) (_THIS, SDL_Window * window);
185 void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
186 void (*SetWindowPosition) (_THIS, SDL_Window * window);
187 void (*SetWindowSize) (_THIS, SDL_Window * window);
188 void (*ShowWindow) (_THIS, SDL_Window * window);
189 void (*HideWindow) (_THIS, SDL_Window * window);
190 void (*RaiseWindow) (_THIS, SDL_Window * window);
191 void (*MaximizeWindow) (_THIS, SDL_Window * window);
192 void (*MinimizeWindow) (_THIS, SDL_Window * window);
193 void (*RestoreWindow) (_THIS, SDL_Window * window);
194 void (*SetWindowGrab) (_THIS, SDL_Window * window);
195 void (*DestroyWindow) (_THIS, SDL_Window * window);
196 int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
197 int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, int numrects, SDL_Rect * rects);
198 void (*DestroyWindowFramebuffer) (_THIS, SDL_Window * window);
202 * Shaped-window functions
204 SDL_ShapeDriver shape_driver;
206 /* Get some platform dependent window information */
207 SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
208 struct SDL_SysWMinfo * info);
214 int (*GL_LoadLibrary) (_THIS, const char *path);
215 void *(*GL_GetProcAddress) (_THIS, const char *proc);
216 void (*GL_UnloadLibrary) (_THIS);
217 SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
218 int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
219 int (*GL_SetSwapInterval) (_THIS, int interval);
220 int (*GL_GetSwapInterval) (_THIS);
221 void (*GL_SwapWindow) (_THIS, SDL_Window * window);
222 void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
226 * Event manager functions
228 void (*PumpEvents) (_THIS);
230 /* Suspend the screensaver */
231 void (*SuspendScreenSaver) (_THIS);
234 void (*StartTextInput) (_THIS);
235 void (*StopTextInput) (_THIS);
236 void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
239 int (*SetClipboardText) (_THIS, const char *text);
240 char * (*GetClipboardText) (_THIS);
241 SDL_bool (*HasClipboardText) (_THIS);
244 /* Data common to all drivers */
245 SDL_bool suspend_screensaver;
247 SDL_VideoDisplay *displays;
250 Uint32 next_object_id;
251 char * clipboard_text;
254 /* Data used by the GL drivers */
266 int accum_green_size;
268 int accum_alpha_size;
270 int multisamplebuffers;
271 int multisamplesamples;
275 int retained_backing;
277 char driver_path[256];
282 /* Data private to this driver */
284 struct SDL_GLDriverData *gl_data;
286 #if SDL_VIDEO_DRIVER_PANDORA
287 struct SDL_PrivateGLESData *gles_data;
291 /* The function used to dispose of this structure */
292 void (*free) (_THIS);
295 typedef struct VideoBootStrap
299 int (*available) (void);
300 SDL_VideoDevice *(*create) (int devindex);
303 #if SDL_VIDEO_DRIVER_COCOA
304 extern VideoBootStrap COCOA_bootstrap;
306 #if SDL_VIDEO_DRIVER_X11
307 extern VideoBootStrap X11_bootstrap;
309 #if SDL_VIDEO_DRIVER_DIRECTFB
310 extern VideoBootStrap DirectFB_bootstrap;
312 #if SDL_VIDEO_DRIVER_WINDOWS
313 extern VideoBootStrap WINDOWS_bootstrap;
315 #if SDL_VIDEO_DRIVER_BWINDOW
316 extern VideoBootStrap BWINDOW_bootstrap;
318 #if SDL_VIDEO_DRIVER_PANDORA
319 extern VideoBootStrap PND_bootstrap;
321 #if SDL_VIDEO_DRIVER_NDS
322 extern VideoBootStrap NDS_bootstrap;
324 #if SDL_VIDEO_DRIVER_UIKIT
325 extern VideoBootStrap UIKIT_bootstrap;
327 #if SDL_VIDEO_DRIVER_ANDROID
328 extern VideoBootStrap Android_bootstrap;
330 #if SDL_VIDEO_DRIVER_DUMMY
331 extern VideoBootStrap DUMMY_bootstrap;
334 #define SDL_CurrentDisplay (&_this->displays[_this->current_display])
336 extern SDL_VideoDevice *SDL_GetVideoDevice(void);
337 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
338 extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
339 extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
340 extern int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display);
341 extern int SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode);
342 extern int SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
343 extern int SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
344 extern SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
345 extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode);
346 extern int SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue);
347 extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue);
349 extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
351 extern void SDL_OnWindowShown(SDL_Window * window);
352 extern void SDL_OnWindowHidden(SDL_Window * window);
353 extern void SDL_OnWindowResized(SDL_Window * window);
354 extern void SDL_OnWindowMinimized(SDL_Window * window);
355 extern void SDL_OnWindowRestored(SDL_Window * window);
356 extern void SDL_OnWindowFocusGained(SDL_Window * window);
357 extern void SDL_OnWindowFocusLost(SDL_Window * window);
358 extern SDL_Window * SDL_GetFocusWindow(void);
360 #endif /* _SDL_sysvideo_h */
362 /* vi: set ts=4 sw=4 expandtab: */