annotate src/video/win32/SDL_gapirender.c @ 3709:bf49b4a57dcf

Removed reference to compatibility function
author Sam Lantinga <slouken@libsdl.org>
date Fri, 26 Feb 2010 04:50:38 +0000
parents f7b03b6838cb
children e1664f94f026
rev   line source
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
3697
f7b03b6838cb Fixed bug #926
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 Stefan Klug
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 klug.stefan@gmx.de
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #include "SDL_config.h"
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 #if SDL_VIDEO_RENDER_GAPI
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #include "SDL_win32video.h"
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 //#include "../SDL_sysvideo.h"
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include "../SDL_yuv_sw_c.h"
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include "../SDL_renderer_sw.h"
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 #include "SDL_gapirender_c.h"
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #define GAPI_RENDERER_DEBUG 1
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 /* GAPI renderer implementation */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 static SDL_Renderer *GAPI_CreateRenderer(SDL_Window * window, Uint32 flags);
3612
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
41 static int GAPI_RenderDrawPoints(SDL_Renderer * renderer,
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
42 const SDL_Point * points, int count);
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
43 static int GAPI_RenderDrawLines(SDL_Renderer * renderer,
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
44 const SDL_Point * points, int count);
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
45 static int GAPI_RenderDrawRects(SDL_Renderer * renderer,
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
46 const SDL_Rect ** rects, int count);
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
47 static int GAPI_RenderFillRects(SDL_Renderer * renderer,
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
48 const SDL_Rect ** rects, int count);
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 static int GAPI_RenderCopy(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 const SDL_Rect * srcrect,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 const SDL_Rect * dstrect);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 static void GAPI_RenderPresent(SDL_Renderer * renderer);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 static void GAPI_DestroyRenderer(SDL_Renderer * renderer);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 SDL_RenderDriver GAPI_RenderDriver = {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 GAPI_CreateRenderer,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 "gapi",
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 (SDL_RENDERER_SINGLEBUFFER),
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 };
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 static HMODULE g_hGapiLib = 0;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 // for testing with GapiEmu
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 #define USE_GAPI_EMU 0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 #define EMULATE_AXIM_X30 0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 #if 0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 #define GAPI_LOG(...) printf(__VA_ARGS__)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 #else
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 #define GAPI_LOG(...)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 #endif
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 #if USE_GAPI_EMU && !REPORT_VIDEO_INFO
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 #pragma message("Warning: Using GapiEmu in release build. I assume you'd like to set USE_GAPI_EMU to zero.")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 #endif
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 static void
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 GAPI_SetError(const char *prefix, HRESULT result)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 const char *error;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 switch (result) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 default:
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 error = "UNKNOWN";
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 break;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 SDL_SetError("%s: %s", prefix, error);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 void
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 GAPI_AddRenderDriver(_THIS)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 {
3520
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3168
diff changeset
99 int i;
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3168
diff changeset
100
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 /* TODO: should we check for support of GetRawFramebuffer here?
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 #if USE_GAPI_EMU
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 g_hGapiLib = LoadLibrary(L"GAPI_Emu.dll");
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 #else
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 g_hGapiLib = LoadLibrary(L"\\Windows\\gx.dll");
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 #endif
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 if (g_hGapiLib) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 #define LINK(name,import) gx.name = (PFN##name)GetProcAddress( g_hGapiLib, L##import );
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 LINK(GXOpenDisplay, "?GXOpenDisplay@@YAHPAUHWND__@@K@Z")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 LINK(GXCloseDisplay, "?GXCloseDisplay@@YAHXZ")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 LINK(GXBeginDraw, "?GXBeginDraw@@YAPAXXZ")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 LINK(GXEndDraw, "?GXEndDraw@@YAHXZ")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 LINK(GXOpenInput, "?GXOpenInput@@YAHXZ")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 LINK(GXCloseInput, "?GXCloseInput@@YAHXZ")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 LINK(GXGetDisplayProperties,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 "?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 LINK(GXGetDefaultKeys, "?GXGetDefaultKeys@@YA?AUGXKeyList@@H@Z")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 LINK(GXSuspend, "?GXSuspend@@YAHXZ")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 LINK(GXResume, "?GXResume@@YAHXZ")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 LINK(GXSetViewport, "?GXSetViewport@@YAHKKKK@Z")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 LINK(GXIsDisplayDRAMBuffer, "?GXIsDisplayDRAMBuffer@@YAHXZ")
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 /* wrong gapi.dll */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 if (!gx.GXOpenDisplay) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 FreeLibrary(g_hGapiLib);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 g_hGapiLib = 0;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 #undef LINK
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133
3520
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3168
diff changeset
134 for (i = 0; i < _this->num_displays; ++i) {
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3168
diff changeset
135 SDL_AddRenderDriver(&_this->displays[i], &GAPI_RenderDriver);
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3168
diff changeset
136 }
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 typedef enum
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 USAGE_GX_FUNCS = 0x0001, /* enable to use GXOpen/GXClose/GXBeginDraw... */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 USAGE_DATA_PTR_CONSTANT = 0x0002 /* the framebuffer is at a constant location, don't use values from GXBeginDraw() */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 } GAPI_UsageFlags;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 typedef struct
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 int w;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 int h;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 int xPitch; /* bytes to move to go to the next pixel */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 int yPitch; /* bytes to move to go to the next line */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 int offset; /* data offset, to add to the data returned from GetFramebuffer, before processing */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 void *data;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 Uint32 usageFlags; /* these flags contain options to define screen handling and to reliably workarounds */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 Uint32 format; /* pixel format as defined in SDL_pixels.h */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 } GAPI_RenderData;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 static Uint32
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 GuessPixelFormatFromBpp(int bpp)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 switch (bpp) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 case 15:
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 return SDL_PIXELFORMAT_RGB555;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 case 16:
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 return SDL_PIXELFORMAT_RGB565;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 default:
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 return SDL_PIXELFORMAT_UNKNOWN;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 break;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 static GAPI_RenderData *
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 FillRenderDataRawFramebuffer(SDL_Window * window)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 RawFrameBufferInfo rbi;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 GAPI_RenderData *renderdata;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 HDC hdc;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 //TODO should we use the hdc of the window?
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 hdc = GetDC(NULL);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 int result = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 sizeof(RawFrameBufferInfo),
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 (char *) &rbi);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 ReleaseDC(NULL, hdc);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 if (!(result > 0)) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 /* Asus A696 returns wrong results so we do a sanity check
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 See:
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 http://groups.google.com/group/microsoft.public.smartphone.developer/browse_thread/thread/4fde5bddd477de81
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 if (rbi.cxPixels <= 0 ||
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 rbi.cyPixels <= 0 ||
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 rbi.cxStride == 0 || rbi.cyStride == 0 || rbi.pFramePointer == 0) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 renderdata = (GAPI_RenderData *) SDL_calloc(1, sizeof(*renderdata));
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 if (!renderdata) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 //Try to match the window size
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 //TODO add rotation support
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 if (rbi.cxPixels != window->w || rbi.cyPixels != window->h) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 SDL_free(renderdata);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 //Check that the display uses a known display format
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 switch (rbi.wFormat) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 case FORMAT_565:
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 renderdata->format = SDL_PIXELFORMAT_RGB565;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 break;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 case FORMAT_555:
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 renderdata->format = SDL_PIXELFORMAT_RGB555;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 break;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 default:
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 //TODO we should add support for other formats
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 SDL_free(renderdata);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 renderdata->usageFlags = USAGE_DATA_PTR_CONSTANT;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 renderdata->data = rbi.pFramePointer;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 renderdata->w = rbi.cxPixels;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 renderdata->h = rbi.cyPixels;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 renderdata->xPitch = rbi.cxStride;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 renderdata->yPitch = rbi.cyStride;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 return renderdata;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 static GAPI_RenderData *
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 FillRenderDataGAPI(SDL_Window * window)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 GAPI_RenderData *renderdata;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 struct GXDisplayProperties gxdp;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 int tmp;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 #ifdef _ARM_
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 WCHAR oemstr[100];
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 #endif
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 if (!g_hGapiLib) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 renderdata = (GAPI_RenderData *) SDL_calloc(1, sizeof(GAPI_RenderData));
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 if (!renderdata) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 gxdp = gx.GXGetDisplayProperties();
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 renderdata->usageFlags = USAGE_GX_FUNCS;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 renderdata->w = gxdp.cxWidth;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 renderdata->h = gxdp.cyHeight;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 renderdata->xPitch = gxdp.cbxPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 renderdata->yPitch = gxdp.cbyPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 //Check that the display uses a known display format
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 if (gxdp.ffFormat & kfDirect565) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 renderdata->format = SDL_PIXELFORMAT_RGB565;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 } else if (gxdp.ffFormat & kfDirect555) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 renderdata->format = SDL_PIXELFORMAT_RGB555;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 } else {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 renderdata->format = SDL_PIXELFORMAT_UNKNOWN;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 /* apply some device specific corrections */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 #ifdef _ARM_
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 SystemParametersInfo(SPI_GETOEMINFO, sizeof(oemstr), oemstr, 0);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 // buggy iPaq38xx
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 if ((oemstr[12] == 'H') && (oemstr[13] == '3')
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 && (oemstr[14] == '8')
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 && (gxdp.cbxPitch > 0)) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 renderdata->data = (void *) 0xac0755a0;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 renderdata->xPitch = -640;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 renderdata->yPitch = 2;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 #if (EMULATE_AXIM_X30 == 0)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 // buggy Dell Axim X30
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 if (_tcsncmp(oemstr, L"Dell Axim X30", 13) == 0)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 #endif
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 GXDeviceInfo gxInfo = { 0 };
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 HDC hdc = GetDC(NULL);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 int result;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 gxInfo.Version = 100;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 result =
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 ExtEscape(hdc, GETGXINFO, 0, NULL, sizeof(gxInfo),
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 (char *) &gxInfo);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 if (result > 0) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 renderdata->usageFlags = USAGE_DATA_PTR_CONSTANT; /* no more GAPI usage from now */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 renderdata->data = gxInfo.pvFrameBuffer;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 this->hidden->needUpdate = 0;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 renderdata->xPitch = 2;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 renderdata->yPitch = 480;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 renderdata->w = gxInfo.cxWidth;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 renderdata->h = gxInfo.cyHeight;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 //Check that the display uses a known display format
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 switch (rbi->wFormat) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 case FORMAT_565:
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 renderdata->format = SDL_PIXELFORMAT_RGB565;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 break;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 case FORMAT_555:
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 renderdata->format = SDL_PIXELFORMAT_RGB555;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 break;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 default:
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 //TODO we should add support for other formats
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 SDL_free(renderdata);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 #endif
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 if (renderdata->format == SDL_PIXELFORMAT_UNKNOWN) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 SDL_SetError("Gapi Pixelformat is unknown");
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 SDL_free(renderdata);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 /* Gapi always returns values in standard orientation, so we manually apply
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 the current orientation
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 DEVMODE settings;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 SDL_memset(&settings, 0, sizeof(DEVMODE));
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 settings.dmSize = sizeof(DEVMODE);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 settings.dmFields = DM_DISPLAYORIENTATION;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 if (settings.dmDisplayOrientation == DMDO_90) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 tmp = renderdata->w;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 renderdata->w = renderdata->h;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 renderdata->h = tmp;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 tmp = renderdata->xPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 renderdata->xPitch = -renderdata->yPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 renderdata->yPitch = tmp;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 renderdata->offset = -renderdata->w * renderdata->xPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 } else if (settings.dmDisplayOrientation == DMDO_180) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 renderdata->xPitch = -renderdata->xPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 renderdata->yPitch = -renderdata->yPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 renderdata->offset = -renderdata->h * renderdata->yPitch
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 - renderdata->w * renderdata->xPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 } else if (settings.dmDisplayOrientation == DMDO_270) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 tmp = renderdata->w;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 renderdata->w = renderdata->h;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 renderdata->h = tmp;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 tmp = renderdata->xPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 renderdata->xPitch = renderdata->yPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 renderdata->yPitch = -tmp;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 renderdata->offset = -renderdata->h * renderdata->yPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 if (renderdata->w != window->w || renderdata->h != window->h) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 GAPI_LOG("GAPI open failed, wrong size %i %i %i %i\n", renderdata->w,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 renderdata->h, renderdata->xPitch, renderdata->yPitch);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 SDL_free(renderdata);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 return renderdata;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 /* This function does the whole encapsulation of Gapi/RAWFRAMEBUFFER
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 it should handle all the device dependent details and fill the device INDEPENDENT
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 RenderData structure.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 GAPI_RenderData *
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 FillRenderData(SDL_Window * window)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 /* We try to match the requested window to the modes available by GAPI and RAWFRAMEBUFFER.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 First RAWFRAMEBUFFER is tried, as it is the most reliable one
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 Look here for detailed discussions:
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 http://pdaphonehome.com/forums/samsung-i700/28087-just-saw.html
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 http://blogs.msdn.com/windowsmobile/archive/2007/08/13/have-you-migrated-to-directdraw-yet.aspx
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 GAPI_RenderData *res;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 res = FillRenderDataRawFramebuffer(window);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 GAPI_LOG("FillRenderDataRawFramebuffer: %p\n", res);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 if (res) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 return res;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 //Now we try gapi
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 res = FillRenderDataGAPI(window);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 GAPI_LOG("FillRenderDataGAPI: %p\n", res);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 return res;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 void *
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 GetFramebuffer()
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 SDL_Renderer *
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 GAPI_CreateRenderer(SDL_Window * window, Uint32 flags)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3612
diff changeset
433 SDL_VideoDisplay *display = window->display;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 SDL_DisplayMode *displayMode = &display->current_mode;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 SDL_Renderer *renderer;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 GAPI_RenderData *data;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 int i, n;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 int bpp;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 Uint32 Rmask, Gmask, Bmask, Amask;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442 if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 SDL_SetError("Gapi supports only fullscreen windows");
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 if (!SDL_PixelFormatEnumToMasks
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 SDL_SetError("Unknown display format");
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 if (!renderer) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 data = FillRenderData(window);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 if (!data) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461 GAPI_DestroyRenderer(renderer);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462 SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465
3612
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
466 renderer->RenderDrawPoints = GAPI_RenderDrawPoints;
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
467 renderer->RenderDrawLines = GAPI_RenderDrawLines;
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
468 renderer->RenderDrawRects = GAPI_RenderDrawRects;
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
469 renderer->RenderFillRects = GAPI_RenderFillRects;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470 renderer->RenderCopy = GAPI_RenderCopy;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 renderer->RenderPresent = GAPI_RenderPresent;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 renderer->DestroyRenderer = GAPI_DestroyRenderer;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 renderer->info.name = GAPI_RenderDriver.info.name;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474 renderer->info.flags = 0;
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3612
diff changeset
475 renderer->window = window;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 renderer->driverdata = data;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478 /* Gapi provides only a framebuffer so lets use software implementation */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 Setup_SoftwareRenderer(renderer);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 #ifdef GAPI_RENDERER_DEBUG
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 printf("Created gapi renderer\n");
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 printf("use GX functions: %i\n", data->usageFlags & USAGE_GX_FUNCS);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 printf("framebuffer is constant: %i\n",
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 data->usageFlags & USAGE_DATA_PTR_CONSTANT);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486 printf("w: %i h: %i\n", data->w, data->h);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487 printf("data ptr: %p\n", data->data); /* this can be 0 in case of GAPI usage */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 printf("xPitch: %i\n", data->xPitch);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 printf("yPitch: %i\n", data->yPitch);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490 printf("offset: %i\n", data->offset);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 printf("format: %x\n", data->format);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 #endif
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 if (data->usageFlags & USAGE_GX_FUNCS) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
495 if (gx.GXOpenDisplay(windowdata->hwnd, GX_FULLSCREEN) == 0) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 GAPI_DestroyRenderer(renderer);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 return renderer;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 static int
3612
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
505 GAPI_RenderDrawPoints(SDL_Renderer * renderer,
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
506 const SDL_Point * points, int count)
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 {
3612
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
508 // TODO implement
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
509 SDL_Unsupported();
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510 return -1;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 static int
3612
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
514 GAPI_RenderDrawLines(SDL_Renderer * renderer,
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
515 const SDL_Point * points, int count)
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516 {
3612
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
517 // TODO implement
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
518 SDL_Unsupported();
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
519 return -1;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522 static int
3612
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
523 GAPI_RenderDrawRects(SDL_Renderer * renderer,
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
524 const SDL_Rect ** rects, int count)
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
525 {
3612
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
526 // TODO implement
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
527 SDL_Unsupported();
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
528 return -1;
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
529 }
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
530
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
531 static int
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
532 GAPI_RenderFillRects(SDL_Renderer * renderer,
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
533 const SDL_Rect ** rects, int count)
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
534 {
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
535 // TODO implement
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
536 SDL_Unsupported();
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537 return -1;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 /* Video memory is very slow so lets optimize as much as possible */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 static void
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 updateLine16to16(char *src, int srcXPitch, int srcYPitch,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
543 char *dst, int dstXPitch, int dstYPitch, int width,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544 int height)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
546 char *srcLine, *dstLine;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 char *srcPix, *dstPix;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549 int x, y;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551 //First dumb solution
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552 if (srcXPitch == 2 && dstXPitch == 2) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
553 srcLine = src;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 dstLine = dst;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555 y = height;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556 while (y--) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
557 SDL_memcpy(dstLine, srcLine, width * sizeof(Uint16));
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 srcLine += srcYPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 dstLine += dstYPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561 } else {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
562 //printf("GAPI uses slow blit path %i, %i\n", dstXPitch, dstYPitch);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563 srcLine = src;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
564 dstLine = dst;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565 y = height;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566 while (y--) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567 srcPix = srcLine;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568 dstPix = dstLine;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 x = width;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
570 while (x--) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
571 *((Uint16 *) dstPix) = *((Uint16 *) srcPix);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572 dstPix += dstXPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 srcPix += srcXPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
575 srcLine += srcYPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
576 dstLine += dstYPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
581 static int
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
582 GAPI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
583 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
584 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
585 GAPI_RenderData *data = (GAPI_RenderData *) renderer->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
586 int bpp;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
587 int bytespp;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 int status;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
589 Uint32 Rmask, Gmask, Bmask, Amask;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591 if (texture->format != data->format) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592 SDL_SetError("Gapi got wrong texture");
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 return -1;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
594 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
595
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 GAPI_LOG("GAPI_RenderCopy\n");
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
598 if (data->usageFlags & USAGE_GX_FUNCS) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
599 char *buffer;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
600 buffer = gx.GXBeginDraw();
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
601 if (!(data->usageFlags & USAGE_DATA_PTR_CONSTANT)) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
602 data->data = buffer;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
603 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
604 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
605
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
606 GAPI_LOG("GAPI_RenderCopy blit\n");
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
607 /* If our framebuffer has an xPitch which matches the pixelsize, we
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
608 can convert the framebuffer to a SDL_surface and blit there,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
609 otherwise, we have to use our own blitting routine
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
610 */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
611 SDL_PixelFormatEnumToMasks(data->format, &bpp, &Rmask, &Gmask, &Bmask,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
612 &Amask);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 bytespp = bpp >> 3;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
614 if (data->xPitch == bytespp && 0) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615 SDL_Surface *screen =
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
616 SDL_CreateRGBSurfaceFrom(data->data, data->w, data->h,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
617 bpp, data->yPitch, Rmask, Gmask, Bmask,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
618 Amask);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
619 status =
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
620 SDL_UpperBlit((SDL_Surface *) texture->driverdata, srcrect,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
621 screen, dstrect);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
622 SDL_FreeSurface(screen);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
623 } else { /* screen is rotated, we have to blit on our own */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
624 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
625
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
626 char *src, *dst;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627 src = surface->pixels;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
628 src += srcrect->y * surface->pitch + srcrect->x * 2;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
630 dst = data->data + data->offset;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
631 dst += dstrect->y * data->yPitch + dstrect->x * data->xPitch;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
632
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
633 updateLine16to16(src, 2, surface->pitch,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
634 dst, data->xPitch, data->yPitch,
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
635 srcrect->w, srcrect->h);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
636
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
637 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
638
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
639 Uint32 ticks = SDL_GetTicks();
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
640 if (data->usageFlags & USAGE_GX_FUNCS) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
641 gx.GXEndDraw();
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
642 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
643 GAPI_LOG("GAPI_RenderCopy %i\n", SDL_GetTicks() - ticks);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
644 return status;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
645 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
646
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
647 static void
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
648 GAPI_RenderPresent(SDL_Renderer * renderer)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
649 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
650 /* Nothing todo as we rendered directly to the screen on RenderCopy */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
651 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
652
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
653 static void
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
654 GAPI_DestroyRenderer(SDL_Renderer * renderer)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
655 {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
656 GAPI_RenderData *data = (GAPI_RenderData *) renderer->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
657
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658 if (data->usageFlags & USAGE_GX_FUNCS) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
659 gx.GXCloseDisplay();
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
660 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
661
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
662 if (data) {
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
663 SDL_free(data);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
664 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
665 SDL_free(renderer);
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
666 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
667
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
668 #endif /* SDL_VIDEO_RENDER_GAPI */
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
669
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
670 /* vi: set ts=4 sw=4 expandtab: */