annotate src/video/win32/SDL_gdirender.c @ 2884:9dde605c7540

Date: Fri, 19 Dec 2008 20:17:35 +0100 From: Couriersud Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions > For consistency you'd probably want: > SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a); > SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode); > SDL_RenderLine(int x1, int y1, int x2, int y2); > SDL_RenderFill(SDL_Rect *rect); > > You probably also want to add API functions query the current state. > I have implemented the above api for the opengl, x11, directfb and software renderers. I have also renamed *TEXTUREBLENDMODE* constants to BLENDMODE*. The unix build compiles. The windows renderer still needs to be updated, but I have no windows development machine at hand. Have a look at the x11 renderer for a sample. Vector games now run at 90% both on opengl and directfb in comparison to sdlmame's own opengl renderer. The same applies to raster games. The diff also includes a) Changed XDrawRect to XFillRect in x11 renderer b) A number of changes to fix blending and modulation issues in the directfb renderer.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 20 Dec 2008 12:00:00 +0000
parents 99210400e8b9
children 2f91a3847ae8
rev   line source
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
2859
99210400e8b9 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #if SDL_VIDEO_RENDER_GDI
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #include "SDL_win32video.h"
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
27 #include "../SDL_rect_c.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #include "../SDL_yuv_sw_c.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 /* GDI renderer implementation */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
32 static SDL_Renderer *GDI_CreateRenderer(SDL_Window * window, Uint32 flags);
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
33 static int GDI_DisplayModeChanged(SDL_Renderer * renderer);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
34 static int GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
35 static int GDI_QueryTexturePixels(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
36 SDL_Texture * texture, void **pixels,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
37 int *pitch);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
38 static int GDI_SetTexturePalette(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
39 SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
40 const SDL_Color * colors, int firstcolor,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
41 int ncolors);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
42 static int GDI_GetTexturePalette(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
43 SDL_Texture * texture, SDL_Color * colors,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
44 int firstcolor, int ncolors);
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
45 static int GDI_SetTextureAlphaMod(SDL_Renderer * renderer,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
46 SDL_Texture * texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
47 static int GDI_SetTextureBlendMode(SDL_Renderer * renderer,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
48 SDL_Texture * texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
49 static int GDI_SetTextureScaleMode(SDL_Renderer * renderer,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
50 SDL_Texture * texture);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
51 static int GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
52 const SDL_Rect * rect, const void *pixels,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
53 int pitch);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
54 static int GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
55 const SDL_Rect * rect, int markDirty,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
56 void **pixels, int *pitch);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
57 static void GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
58 static int GDI_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
59 Uint8 a, const SDL_Rect * rect);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
60 static int GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
61 const SDL_Rect * srcrect, const SDL_Rect * dstrect);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
62 static void GDI_RenderPresent(SDL_Renderer * renderer);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
63 static void GDI_DestroyTexture(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
64 SDL_Texture * texture);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
65 static void GDI_DestroyRenderer(SDL_Renderer * renderer);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
68 SDL_RenderDriver GDI_RenderDriver = {
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
69 GDI_CreateRenderer,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 "gdi",
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
72 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
73 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
74 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED),
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
75 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA),
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
76 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND),
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
77 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST),
2811
7af2419ad5b0 Fixed the list of supported YUV formats
Sam Lantinga <slouken@libsdl.org>
parents: 2810
diff changeset
78 14,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
80 SDL_PIXELFORMAT_INDEX8,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
81 SDL_PIXELFORMAT_RGB555,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
82 SDL_PIXELFORMAT_RGB565,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
83 SDL_PIXELFORMAT_RGB888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
84 SDL_PIXELFORMAT_BGR888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
85 SDL_PIXELFORMAT_ARGB8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
86 SDL_PIXELFORMAT_RGBA8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
87 SDL_PIXELFORMAT_ABGR8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
88 SDL_PIXELFORMAT_BGRA8888,
2811
7af2419ad5b0 Fixed the list of supported YUV formats
Sam Lantinga <slouken@libsdl.org>
parents: 2810
diff changeset
89 SDL_PIXELFORMAT_YV12,
7af2419ad5b0 Fixed the list of supported YUV formats
Sam Lantinga <slouken@libsdl.org>
parents: 2810
diff changeset
90 SDL_PIXELFORMAT_IYUV,
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
91 SDL_PIXELFORMAT_YUY2,
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents: 2786
diff changeset
92 SDL_PIXELFORMAT_UYVY,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents: 2786
diff changeset
93 SDL_PIXELFORMAT_YVYU},
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 0,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 0}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 };
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 typedef struct
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 HWND hwnd;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 HDC window_hdc;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 HDC render_hdc;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 HDC memory_hdc;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 HDC current_hdc;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 LPBITMAPINFO bmi;
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
106 HBITMAP hbm[3];
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
107 int current_hbm;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
108 SDL_DirtyRectList dirty;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
109 SDL_bool makedirty;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
110 } GDI_RenderData;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 typedef struct
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 SDL_SW_YUVTexture *yuv;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 Uint32 format;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 HPALETTE hpal;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 HBITMAP hbm;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 void *pixels;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 int pitch;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
120 } GDI_TextureData;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 UpdateYUVTextureData(SDL_Texture * texture)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
125 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 SDL_Rect rect;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 rect.x = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 rect.y = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 rect.w = texture->w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 rect.h = texture->h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 texture->h, data->pixels, data->pitch);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 GDI_AddRenderDriver(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
139 SDL_AddRenderDriver(0, &GDI_RenderDriver);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 SDL_Renderer *
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
143 GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 SDL_Renderer *renderer;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
147 GDI_RenderData *data;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 int bmi_size;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 HBITMAP hbm;
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
150 int i, n;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151
1920
8a162bfdc838 Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents: 1918
diff changeset
152 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 if (!renderer) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 SDL_OutOfMemory();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 return NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157
1920
8a162bfdc838 Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents: 1918
diff changeset
158 data = (GDI_RenderData *) SDL_calloc(1, sizeof(*data));
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 if (!data) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
160 GDI_DestroyRenderer(renderer);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 SDL_OutOfMemory();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 return NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
165 renderer->DisplayModeChanged = GDI_DisplayModeChanged;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
166 renderer->CreateTexture = GDI_CreateTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
167 renderer->QueryTexturePixels = GDI_QueryTexturePixels;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
168 renderer->SetTexturePalette = GDI_SetTexturePalette;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
169 renderer->GetTexturePalette = GDI_GetTexturePalette;
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
170 renderer->SetTextureAlphaMod = GDI_SetTextureAlphaMod;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
171 renderer->SetTextureBlendMode = GDI_SetTextureBlendMode;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
172 renderer->SetTextureScaleMode = GDI_SetTextureScaleMode;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
173 renderer->UpdateTexture = GDI_UpdateTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
174 renderer->LockTexture = GDI_LockTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
175 renderer->UnlockTexture = GDI_UnlockTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
176 renderer->RenderFill = GDI_RenderFill;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
177 renderer->RenderCopy = GDI_RenderCopy;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
178 renderer->RenderPresent = GDI_RenderPresent;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
179 renderer->DestroyTexture = GDI_DestroyTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
180 renderer->DestroyRenderer = GDI_DestroyRenderer;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
181 renderer->info = GDI_RenderDriver.info;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 renderer->window = window->id;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 renderer->driverdata = data;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
185 renderer->info.flags = SDL_RENDERER_ACCELERATED;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
187 data->hwnd = windowdata->hwnd;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
188 data->window_hdc = windowdata->hdc;
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
189 data->render_hdc = CreateCompatibleDC(data->window_hdc);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
190 data->memory_hdc = CreateCompatibleDC(data->window_hdc);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
191
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
192 /* Fill in the compatible bitmap info */
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
193 bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
1920
8a162bfdc838 Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents: 1918
diff changeset
194 data->bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size);
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
195 if (!data->bmi) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
196 GDI_DestroyRenderer(renderer);
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
197 SDL_OutOfMemory();
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
198 return NULL;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
199 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
200 data->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
201
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
202 hbm = CreateCompatibleBitmap(data->window_hdc, 1, 1);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
203 GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
204 GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
205 DeleteObject(hbm);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
206
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
207 if (flags & SDL_RENDERER_SINGLEBUFFER) {
1907
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
208 renderer->info.flags |=
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
209 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY);
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
210 n = 0;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
211 } else if (flags & SDL_RENDERER_PRESENTFLIP2) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
212 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
213 n = 2;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
214 } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
215 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
216 n = 3;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
217 } else {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
218 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
219 n = 1;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
220 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
221 for (i = 0; i < n; ++i) {
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
222 data->hbm[i] =
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
223 CreateCompatibleBitmap(data->window_hdc, window->w, window->h);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
224 if (!data->hbm[i]) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
225 GDI_DestroyRenderer(renderer);
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
226 WIN_SetError("CreateCompatibleBitmap()");
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
227 return NULL;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
228 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
229 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
230 if (n > 0) {
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
231 SelectObject(data->render_hdc, data->hbm[0]);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
232 data->current_hdc = data->render_hdc;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
233 data->makedirty = SDL_TRUE;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
234 } else {
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
235 data->current_hdc = data->window_hdc;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
236 data->makedirty = SDL_FALSE;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
237 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
238 data->current_hbm = 0;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
239
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 return renderer;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 static int
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
244 GDI_DisplayModeChanged(SDL_Renderer * renderer)
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
245 {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
246 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
247 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
248 int i, n;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
249
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
250 if (renderer->info.flags & SDL_RENDERER_SINGLEBUFFER) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
251 n = 0;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
252 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
253 n = 2;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
254 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
255 n = 3;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
256 } else {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
257 n = 1;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
258 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
259 for (i = 0; i < n; ++i) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
260 if (data->hbm[i]) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
261 DeleteObject(data->hbm[i]);
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
262 data->hbm[i] = NULL;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
263 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
264 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
265 for (i = 0; i < n; ++i) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
266 data->hbm[i] =
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
267 CreateCompatibleBitmap(data->window_hdc, window->w, window->h);
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
268 if (!data->hbm[i]) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
269 WIN_SetError("CreateCompatibleBitmap()");
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
270 return -1;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
271 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
272 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
273 if (n > 0) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
274 SelectObject(data->render_hdc, data->hbm[0]);
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
275 }
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents: 2786
diff changeset
276 data->current_hbm = 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents: 2786
diff changeset
277
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
278 return 0;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
279 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
280
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
281 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
282 GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
284 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
287 GDI_TextureData *data;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288
1920
8a162bfdc838 Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents: 1918
diff changeset
289 data = (GDI_TextureData *) SDL_calloc(1, sizeof(*data));
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 if (!data) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 SDL_OutOfMemory();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 texture->driverdata = data;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
2786
Sam Lantinga <slouken@libsdl.org>
parents: 2781
diff changeset
298 data->yuv =
Sam Lantinga <slouken@libsdl.org>
parents: 2781
diff changeset
299 SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 if (!data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 data->format = display->current_mode.format;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 data->format = texture->format;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 data->pitch = (texture->w * SDL_BYTESPERPIXEL(data->format));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308
2222
926294b2bb4e Emphasized the separation between SDL_Surface and SDL_Texture
Sam Lantinga <slouken@libsdl.org>
parents: 1985
diff changeset
309 if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
310 || texture->format != display->current_mode.format) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 int bmi_size;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 LPBITMAPINFO bmi;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
1920
8a162bfdc838 Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents: 1918
diff changeset
315 bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 if (!bmi) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 SDL_OutOfMemory();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 bmi->bmiHeader.biWidth = texture->w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 bmi->bmiHeader.biHeight = -texture->h; /* topdown bitmap */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 bmi->bmiHeader.biPlanes = 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 bmi->bmiHeader.biSizeImage = texture->h * data->pitch;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 bmi->bmiHeader.biXPelsPerMeter = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 bmi->bmiHeader.biYPelsPerMeter = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 bmi->bmiHeader.biClrUsed = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 bmi->bmiHeader.biClrImportant = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 bmi->bmiHeader.biBitCount = SDL_BYTESPERPIXEL(data->format) * 8;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 if (SDL_ISPIXELFORMAT_INDEXED(data->format)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 int i, ncolors;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 LOGPALETTE *palette;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 bmi->bmiHeader.biCompression = BI_RGB;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 ncolors = (1 << SDL_BITSPERPIXEL(data->format));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 palette =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 (LOGPALETTE *) SDL_malloc(sizeof(*palette) +
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 ncolors * sizeof(PALETTEENTRY));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 if (!palette) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 SDL_free(bmi);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 SDL_OutOfMemory();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 palette->palVersion = 0x300;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 palette->palNumEntries = ncolors;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 for (i = 0; i < ncolors; ++i) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 palette->palPalEntry[i].peRed = 0xFF;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 palette->palPalEntry[i].peGreen = 0xFF;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 palette->palPalEntry[i].peBlue = 0xFF;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 palette->palPalEntry[i].peFlags = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 data->hpal = CreatePalette(palette);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 SDL_free(palette);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 int bpp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 Uint32 Rmask, Gmask, Bmask, Amask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 bmi->bmiHeader.biCompression = BI_BITFIELDS;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 SDL_PixelFormatEnumToMasks(data->format, &bpp, &Rmask, &Gmask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 &Bmask, &Amask);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 ((Uint32 *) bmi->bmiColors)[0] = Rmask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 ((Uint32 *) bmi->bmiColors)[1] = Gmask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 ((Uint32 *) bmi->bmiColors)[2] = Bmask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 data->hpal = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 data->hbm =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 CreateDIBSection(renderdata->memory_hdc, bmi, DIB_RGB_COLORS,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 &data->pixels, NULL, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 data->hbm =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 CreateCompatibleBitmap(renderdata->window_hdc, texture->w,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 texture->h);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 data->pixels = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 if (!data->hbm) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 WIN_SetError("Couldn't create bitmap");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
383 GDI_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
384 void **pixels, int *pitch)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
386 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 *pixels = data->pixels;
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
392 *pitch = data->pitch;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
398 GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
399 const SDL_Color * colors, int firstcolor, int ncolors)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
401 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
402 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 SDL_SetError("YUV textures don't have a palette");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408 PALETTEENTRY entries[256];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 int i;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 for (i = 0; i < ncolors; ++i) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 entries[i].peRed = colors[i].r;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 entries[i].peGreen = colors[i].g;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 entries[i].peBlue = colors[i].b;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 entries[i].peFlags = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 if (!SetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 WIN_SetError("SetPaletteEntries()");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
426 GDI_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
427 SDL_Color * colors, int firstcolor, int ncolors)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
429 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 SDL_SetError("YUV textures don't have a palette");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 PALETTEENTRY entries[256];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 int i;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 if (!GetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 WIN_SetError("GetPaletteEntries()");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442 for (i = 0; i < ncolors; ++i) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 colors[i].r = entries[i].peRed;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 colors[i].g = entries[i].peGreen;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 colors[i].b = entries[i].peBlue;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 static int
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
452 GDI_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
453 {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
454 return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
455 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
456
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
457 static int
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
458 GDI_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
459 {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
460 switch (texture->blendMode) {
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
461 case SDL_BLENDMODE_NONE:
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
462 case SDL_BLENDMODE_MASK:
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
463 case SDL_BLENDMODE_BLEND:
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
464 return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
465 default:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
466 SDL_Unsupported();
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
467 texture->blendMode = SDL_BLENDMODE_NONE;
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
468 return -1;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
469 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
470 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
471
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
472 static int
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
473 GDI_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
474 {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
475 switch (texture->scaleMode) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
476 case SDL_TEXTURESCALEMODE_NONE:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
477 case SDL_TEXTURESCALEMODE_FAST:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
478 return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
479 case SDL_TEXTURESCALEMODE_SLOW:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
480 case SDL_TEXTURESCALEMODE_BEST:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
481 SDL_Unsupported();
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
482 texture->scaleMode = SDL_TEXTURESCALEMODE_FAST;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
483 return -1;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
484 default:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
485 SDL_Unsupported();
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
486 texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
487 return -1;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
488 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
489 return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
490 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
491
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
492 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
493 GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
494 const SDL_Rect * rect, const void *pixels, int pitch)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
495 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
496 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 UpdateYUVTextureData(texture);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 } else {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
505 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 if (data->pixels) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508 Uint8 *src, *dst;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 int row;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510 size_t length;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 src = (Uint8 *) pixels;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 dst =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514 (Uint8 *) data->pixels + rect->y * data->pitch +
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 rect->x * SDL_BYTESPERPIXEL(texture->format);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516 length = rect->w * SDL_BYTESPERPIXEL(texture->format);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 for (row = 0; row < rect->h; ++row) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 SDL_memcpy(dst, src, length);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 src += pitch;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 dst += data->pitch;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522 } else if (rect->w == texture->w && pitch == data->pitch) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 if (!SetDIBits
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524 (renderdata->window_hdc, data->hbm, rect->y, rect->h, pixels,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
525 renderdata->bmi, DIB_RGB_COLORS)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
526 WIN_SetError("SetDIBits()");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
527 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
529 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
530 SDL_SetError
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
531 ("FIXME: Need to allocate temporary memory and do GetDIBits() followed by SetDIBits(), since we can only set blocks of scanlines at a time");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534 return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
535 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
539 GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
540 const SDL_Rect * rect, int markDirty, void **pixels,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
541 int *pitch)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
543 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
546 return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 pitch);
1898
f89e49e51e89 Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents: 1897
diff changeset
548 } else if (data->pixels) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549 GdiFlush();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550 *pixels =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551 (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552 rect->x * SDL_BYTESPERPIXEL(texture->format));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
553 *pitch = data->pitch;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 return 0;
1898
f89e49e51e89 Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents: 1897
diff changeset
555 } else {
f89e49e51e89 Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents: 1897
diff changeset
556 SDL_SetError("No pixels available");
f89e49e51e89 Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents: 1897
diff changeset
557 return -1;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
562 GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
564 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567 SDL_SW_UnlockYUVTexture(data->yuv);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568 UpdateYUVTextureData(texture);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
570 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
571
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572 static int
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
573 GDI_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
574 const SDL_Rect * rect)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
575 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
576 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577 RECT rc;
1899
6a11e61bf805 debug cleanup
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
578 HBRUSH brush;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579 int status;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
581 if (data->makedirty) {
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
582 SDL_AddDirtyRect(&data->dirty, rect);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
583 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
584
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
585 rc.left = rect->x;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
586 rc.top = rect->y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
587 rc.right = rect->x + rect->w + 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 rc.bottom = rect->y + rect->h + 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
589
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590 /* Should we cache the brushes? .. it looks like GDI does for us. :) */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591 brush = CreateSolidBrush(RGB(r, g, b));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592 SelectObject(data->current_hdc, brush);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 status = FillRect(data->current_hdc, &rc, brush);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
594 DeleteObject(brush);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
595
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 if (!status) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597 WIN_SetError("FillRect()");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
598 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
599 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
600 return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
601 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
602
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
603 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
604 GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
605 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
606 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
607 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
608 GDI_TextureData *texturedata = (GDI_TextureData *) texture->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
609
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
610 if (data->makedirty) {
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
611 SDL_AddDirtyRect(&data->dirty, dstrect);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
612 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
613
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
614 SelectObject(data->memory_hdc, texturedata->hbm);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615 if (texturedata->hpal) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
616 SelectPalette(data->memory_hdc, texturedata->hpal, TRUE);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
617 RealizePalette(data->memory_hdc);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
618 }
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
619 if (texture->blendMode & (SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND)) {
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
620 BLENDFUNCTION blendFunc = {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
621 AC_SRC_OVER,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
622 0,
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
623 texture->a,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
624 AC_SRC_ALPHA
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
625 };
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
626 /* FIXME: GDI uses premultiplied alpha! */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627 if (!AlphaBlend
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
628 (data->current_hdc, dstrect->x, dstrect->y, dstrect->w,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629 dstrect->h, data->memory_hdc, srcrect->x, srcrect->y, srcrect->w,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
630 srcrect->h, blendFunc)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
631 WIN_SetError("AlphaBlend()");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
632 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
633 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
634 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
635 if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
636 if (!BitBlt
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
637 (data->current_hdc, dstrect->x, dstrect->y, dstrect->w,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
638 srcrect->h, data->memory_hdc, srcrect->x, srcrect->y,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
639 SRCCOPY)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
640 WIN_SetError("BitBlt()");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
641 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
642 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
643 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
644 if (!StretchBlt
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
645 (data->current_hdc, dstrect->x, dstrect->y, dstrect->w,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
646 dstrect->h, data->memory_hdc, srcrect->x, srcrect->y,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
647 srcrect->w, srcrect->h, SRCCOPY)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
648 WIN_SetError("StretchBlt()");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
649 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
650 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
651 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
652 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
653 return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
654 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
655
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
656 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
657 GDI_RenderPresent(SDL_Renderer * renderer)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
659 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
660 SDL_DirtyRect *dirty;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
661
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
662 /* Send the data to the display */
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
663 if (!(renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)) {
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
664 for (dirty = data->dirty.list; dirty; dirty = dirty->next) {
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
665 const SDL_Rect *rect = &dirty->rect;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
666 BitBlt(data->window_hdc, rect->x, rect->y, rect->w, rect->h,
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
667 data->render_hdc, rect->x, rect->y, SRCCOPY);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
668 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
669 SDL_ClearDirtyRects(&data->dirty);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
670 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
671
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
672 /* Update the flipping chain, if any */
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
673 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
674 data->current_hbm = (data->current_hbm + 1) % 2;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
675 SelectObject(data->render_hdc, data->hbm[data->current_hbm]);
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
676 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
677 data->current_hbm = (data->current_hbm + 1) % 3;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
678 SelectObject(data->render_hdc, data->hbm[data->current_hbm]);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
679 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
680 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
681
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
682 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
683 GDI_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
685 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
686
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
687 if (!data) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
688 return;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
689 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
690 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
691 SDL_SW_DestroyYUVTexture(data->yuv);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
692 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
693 if (data->hpal) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
694 DeleteObject(data->hpal);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
695 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
696 if (data->hbm) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
697 DeleteObject(data->hbm);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
698 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
699 SDL_free(data);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
700 texture->driverdata = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
701 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
702
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
703 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
704 GDI_DestroyRenderer(SDL_Renderer * renderer)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
705 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
706 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
707 int i;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
708
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
709 if (data) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
710 DeleteDC(data->render_hdc);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
711 DeleteDC(data->memory_hdc);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
712 if (data->bmi) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
713 SDL_free(data->bmi);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
714 }
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
715 for (i = 0; i < SDL_arraysize(data->hbm); ++i) {
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
716 if (data->hbm[i]) {
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
717 DeleteObject(data->hbm[i]);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
718 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
719 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
720 SDL_FreeDirtyRects(&data->dirty);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
721 SDL_free(data);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
722 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
723 SDL_free(renderer);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
724 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
725
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
726 #endif /* SDL_VIDEO_RENDER_GDI */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
727
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
728 /* vi: set ts=4 sw=4 expandtab: */