summaryrefslogtreecommitdiff
path: root/src/video/win32
diff options
context:
space:
mode:
authorSam Lantinga <slouken@libsdl.org>2010-01-21 06:21:52 +0000
committerSam Lantinga <slouken@libsdl.org>2010-01-21 06:21:52 +0000
commite0a31b4dbb3ca6231640bdf8fa5934b4f01a4cac (patch)
treeb9c8869edeedb417bfb247f1e3c838a905a36c5f /src/video/win32
parentb4fc8d890d2b4717b3a57193738175d567996791 (diff)
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Diffstat (limited to 'src/video/win32')
-rw-r--r--src/video/win32/SDL_ceddrawrender.c14
-rw-r--r--src/video/win32/SDL_d3drender.c16
-rw-r--r--src/video/win32/SDL_gapirender.c4
-rw-r--r--src/video/win32/SDL_gdirender.c24
-rw-r--r--src/video/win32/SDL_win32events.c41
-rw-r--r--src/video/win32/SDL_win32window.c10
-rw-r--r--src/video/win32/SDL_win32window.h2
7 files changed, 54 insertions, 57 deletions
diff --git a/src/video/win32/SDL_ceddrawrender.c b/src/video/win32/SDL_ceddrawrender.c
index 424a313eef..ccdbb43fac 100644
--- a/src/video/win32/SDL_ceddrawrender.c
+++ b/src/video/win32/SDL_ceddrawrender.c
@@ -391,7 +391,7 @@ DDRAW_AddRenderDriver(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_RendererInfo *info = &DDRAW_RenderDriver.info;
- SDL_DisplayMode *mode = &SDL_CurrentDisplay.desktop_mode;
+ SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode;
if (data->ddraw) {
int i;
@@ -437,7 +437,7 @@ DDRAW_AddRenderDriver(_THIS)
SDL_Renderer *
DDRAW_CreateRenderer(SDL_Window * window, Uint32 flags)
{
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_VideoDisplay *display = window->display;
SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata;
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
SDL_Renderer *renderer;
@@ -479,7 +479,7 @@ DDRAW_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->DestroyTexture = DDRAW_DestroyTexture;
renderer->DestroyRenderer = DDRAW_DestroyRenderer;
renderer->info = DDRAW_RenderDriver.info;
- renderer->window = window->id;
+ renderer->window = window;
renderer->driverdata = data;
renderer->info.flags = SDL_RENDERER_ACCELERATED;
@@ -568,8 +568,8 @@ DDRAW_DisplayModeChanged(SDL_Renderer * renderer)
{
//TODO implement
/*D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_Window *window = renderer->window;
+ SDL_VideoDisplay *display = window->display;
data->pparams.BackBufferWidth = window->w;
data->pparams.BackBufferHeight = window->h;
@@ -587,8 +587,8 @@ static int
DDRAW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
DDRAW_RenderData *renderdata = (DDRAW_RenderData *) renderer->driverdata;
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_Window *window = renderer->window;
+ SDL_VideoDisplay *display = window->display;
Uint32 display_format = display->current_mode.format;
DDRAW_TextureData *data;
DDSURFACEDESC ddsd;
diff --git a/src/video/win32/SDL_d3drender.c b/src/video/win32/SDL_d3drender.c
index 83f910c578..3afbaa77f4 100644
--- a/src/video/win32/SDL_d3drender.c
+++ b/src/video/win32/SDL_d3drender.c
@@ -427,7 +427,7 @@ D3D_AddRenderDriver(_THIS)
SDL_Renderer *
D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
{
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_VideoDisplay *display = window->display;
SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata;
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
SDL_Renderer *renderer;
@@ -475,7 +475,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->DestroyTexture = D3D_DestroyTexture;
renderer->DestroyRenderer = D3D_DestroyRenderer;
renderer->info = D3D_RenderDriver.info;
- renderer->window = window->id;
+ renderer->window = window;
renderer->driverdata = data;
renderer->info.flags = SDL_RENDERER_ACCELERATED;
@@ -677,8 +677,8 @@ static int
D3D_DisplayModeChanged(SDL_Renderer * renderer)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_Window *window = renderer->window;
+ SDL_VideoDisplay *display = window->display;
data->pparams.BackBufferWidth = window->w;
data->pparams.BackBufferHeight = window->h;
@@ -695,8 +695,8 @@ static int
D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_Window *window = renderer->window;
+ SDL_VideoDisplay *display = window->display;
Uint32 display_format = display->current_mode.format;
D3D_TextureData *data;
HRESULT result;
@@ -1398,8 +1398,8 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 format, void * pixels, int pitch)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_Window *window = renderer->window;
+ SDL_VideoDisplay *display = window->display;
D3DSURFACE_DESC desc;
LPDIRECT3DSURFACE9 backBuffer;
LPDIRECT3DSURFACE9 surface;
diff --git a/src/video/win32/SDL_gapirender.c b/src/video/win32/SDL_gapirender.c
index b1af3a90f9..257d5282c2 100644
--- a/src/video/win32/SDL_gapirender.c
+++ b/src/video/win32/SDL_gapirender.c
@@ -430,7 +430,7 @@ GetFramebuffer()
SDL_Renderer *
GAPI_CreateRenderer(SDL_Window * window, Uint32 flags)
{
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_VideoDisplay *display = window->display;
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
SDL_DisplayMode *displayMode = &display->current_mode;
SDL_Renderer *renderer;
@@ -472,7 +472,7 @@ GAPI_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->DestroyRenderer = GAPI_DestroyRenderer;
renderer->info.name = GAPI_RenderDriver.info.name;
renderer->info.flags = 0;
- renderer->window = window->id;
+ renderer->window = window;
renderer->driverdata = data;
/* Gapi provides only a framebuffer so lets use software implementation */
diff --git a/src/video/win32/SDL_gdirender.c b/src/video/win32/SDL_gdirender.c
index 07766043ff..9df73f8914 100644
--- a/src/video/win32/SDL_gdirender.c
+++ b/src/video/win32/SDL_gdirender.c
@@ -207,7 +207,7 @@ GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->DestroyTexture = GDI_DestroyTexture;
renderer->DestroyRenderer = GDI_DestroyRenderer;
renderer->info = GDI_RenderDriver.info;
- renderer->window = window->id;
+ renderer->window = window;
renderer->driverdata = data;
renderer->info.flags = SDL_RENDERER_ACCELERATED;
@@ -274,7 +274,7 @@ static int
GDI_DisplayModeChanged(SDL_Renderer * renderer)
{
GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
+ SDL_Window *window = renderer->window;
int i, n;
if (renderer->info.flags & SDL_RENDERER_SINGLEBUFFER) {
@@ -378,8 +378,8 @@ static int
GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_Window *window = renderer->window;
+ SDL_VideoDisplay *display = window->display;
GDI_TextureData *data;
data = (GDI_TextureData *) SDL_calloc(1, sizeof(*data));
@@ -699,7 +699,7 @@ GDI_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
if (data->makedirty) {
/* Get the smallest rectangle that contains everything */
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
+ SDL_Window *window = renderer->window;
SDL_Rect rect;
rect.x = 0;
@@ -732,7 +732,7 @@ GDI_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
if (data->makedirty) {
/* Get the smallest rectangle that contains everything */
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
+ SDL_Window *window = renderer->window;
SDL_Rect clip, rect;
clip.x = 0;
@@ -787,7 +787,7 @@ GDI_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
int i, status = 1;
if (data->makedirty) {
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
+ SDL_Window *window = renderer->window;
SDL_Rect clip, rect;
clip.x = 0;
@@ -844,7 +844,7 @@ GDI_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
int i, status = 1;
if (data->makedirty) {
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
+ SDL_Window *window = renderer->window;
SDL_Rect clip, rect;
clip.x = 0;
@@ -943,8 +943,8 @@ GDI_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 format, void * pixels, int pitch)
{
GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_Window *window = renderer->window;
+ SDL_VideoDisplay *display = window->display;
struct {
HBITMAP hbm;
void *pixels;
@@ -984,8 +984,8 @@ GDI_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 format, const void * pixels, int pitch)
{
GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
- SDL_Window *window = SDL_GetWindowFromID(renderer->window);
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_Window *window = renderer->window;
+ SDL_VideoDisplay *display = window->display;
struct {
HBITMAP hbm;
void *pixels;
diff --git a/src/video/win32/SDL_win32events.c b/src/video/win32/SDL_win32events.c
index b6aff45c09..e9b7a66f7f 100644
--- a/src/video/win32/SDL_win32events.c
+++ b/src/video/win32/SDL_win32events.c
@@ -169,11 +169,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_SHOWWINDOW:
{
if (wParam) {
- SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, 0,
- 0);
+ SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
} else {
- SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_HIDDEN, 0,
- 0);
+ SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0);
}
}
break;
@@ -188,26 +186,25 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
index = data->videodata->keyboard;
keyboard = SDL_GetKeyboard(index);
if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
- SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN,
- 0, 0);
- SDL_SendWindowEvent(data->windowID,
+ SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
+ SDL_SendWindowEvent(data->window,
SDL_WINDOWEVENT_RESTORED, 0, 0);
#ifndef _WIN32_WCE /* WinCE misses IsZoomed() */
if (IsZoomed(hwnd)) {
- SDL_SendWindowEvent(data->windowID,
+ SDL_SendWindowEvent(data->window,
SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
}
#endif
- if (keyboard && keyboard->focus != data->windowID) {
- SDL_SetKeyboardFocus(index, data->windowID);
+ if (keyboard && keyboard->focus != data->window) {
+ SDL_SetKeyboardFocus(index, data->window);
}
/* FIXME: Update keyboard state */
} else {
- if (keyboard && keyboard->focus == data->windowID) {
+ if (keyboard && keyboard->focus == data->window) {
SDL_SetKeyboardFocus(index, 0);
}
if (minimized) {
- SDL_SendWindowEvent(data->windowID,
+ SDL_SendWindowEvent(data->window,
SDL_WINDOWEVENT_MINIMIZED, 0, 0);
}
}
@@ -272,9 +269,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
GetCursorPos(&point);
ScreenToClient(hwnd, &point);
- SDL_GetWindowSize(data->windowID, &w, &h);
+ SDL_GetWindowSize(data->window, &w, &h);
if (point.x >= 0 && point.y >= 0 && point.x < w && point.y < h) {
- SDL_SetMouseFocus(index, data->windowID);
+ SDL_SetMouseFocus(index, data->window);
} else {
SDL_SetMouseFocus(index, 0);
/* FIXME: Should we be doing anything else here? */
@@ -330,7 +327,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
for (i = 0; i < SDL_GetNumMice(); ++i) {
SDL_Mouse *mouse = SDL_GetMouse(i);
- if (mouse->focus == data->windowID) {
+ if (mouse->focus == data->window) {
SDL_SetMouseFocus(i, 0);
}
}
@@ -490,7 +487,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
BOOL menu;
/* If we allow resizing, let the resize happen naturally */
- if (SDL_GetWindowFlags(data->windowID) & SDL_WINDOW_RESIZABLE) {
+ if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
returnCode = 0;
break;
}
@@ -501,7 +498,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
y = size.top;
/* Calculate current size of our window */
- SDL_GetWindowSize(data->windowID, &w, &h);
+ SDL_GetWindowSize(data->window, &w, &h);
size.top = 0;
size.left = 0;
size.bottom = h;
@@ -551,7 +548,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
ClientToScreen(hwnd, (LPPOINT) & rect);
ClientToScreen(hwnd, (LPPOINT) & rect + 1);
- window_flags = SDL_GetWindowFlags(data->windowID);
+ window_flags = SDL_GetWindowFlags(data->window);
if ((window_flags & SDL_WINDOW_INPUT_GRABBED) &&
(window_flags & SDL_WINDOW_INPUT_FOCUS)) {
ClipCursor(&rect);
@@ -559,11 +556,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
x = rect.left;
y = rect.top;
- SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_MOVED, x, y);
+ SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, x, y);
w = rect.right - rect.left;
h = rect.bottom - rect.top;
- SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_RESIZED, w,
+ SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, w,
h);
}
break;
@@ -610,7 +607,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
RECT rect;
if (GetUpdateRect(hwnd, &rect, FALSE)) {
ValidateRect(hwnd, &rect);
- SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_EXPOSED,
+ SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED,
0, 0);
}
}
@@ -637,7 +634,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_CLOSE:
{
- SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_CLOSE, 0, 0);
+ SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
}
returnCode = 0;
break;
diff --git a/src/video/win32/SDL_win32window.c b/src/video/win32/SDL_win32window.c
index da2dc6576d..895f6877d5 100644
--- a/src/video/win32/SDL_win32window.c
+++ b/src/video/win32/SDL_win32window.c
@@ -86,7 +86,7 @@ static int
SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
{
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_VideoDisplay *display = window->display;
SDL_WindowData *data;
/* Allocate the window data */
@@ -95,7 +95,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
SDL_OutOfMemory();
return -1;
}
- data->windowID = window->id;
+ data->window = window;
data->hwnd = hwnd;
data->hdc = GetDC(hwnd);
data->created = created;
@@ -167,7 +167,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
if (GetFocus() == hwnd) {
int index = data->videodata->keyboard;
window->flags |= SDL_WINDOW_INPUT_FOCUS;
- SDL_SetKeyboardFocus(index, data->windowID);
+ SDL_SetKeyboardFocus(index, data->window);
if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
RECT rect;
@@ -187,7 +187,7 @@ int
WIN_CreateWindow(_THIS, SDL_Window * window)
{
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_VideoDisplay *display = window->display;
RAWINPUTDEVICE Rid;
AXIS TabX, TabY;
LOGCONTEXTA lc;
@@ -429,7 +429,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
void
WIN_SetWindowPosition(_THIS, SDL_Window * window)
{
- SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+ SDL_VideoDisplay *display = window->display;
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
RECT rect;
SDL_Rect bounds;
diff --git a/src/video/win32/SDL_win32window.h b/src/video/win32/SDL_win32window.h
index bfd9670a65..8ad888e33f 100644
--- a/src/video/win32/SDL_win32window.h
+++ b/src/video/win32/SDL_win32window.h
@@ -26,7 +26,7 @@
typedef struct
{
- SDL_WindowID windowID;
+ SDL_Window *window;
HWND hwnd;
HDC hdc;
WNDPROC wndproc;