Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
1281 lines (1071 loc) · 36.5 KB

SDL_gapirender.c

File metadata and controls

1281 lines (1071 loc) · 36.5 KB
 
Jul 28, 2010
Jul 28, 2010
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/***************************************************************************
* Copyright (C) 2010 by Andrey Afletdinov <afletdinov@gmail.com> *
* *
* WinCE RAW/GAPI video driver *
* *
* Part of the SDL - (Simple DirectMedia Layer) *
* http://www.libsdl.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
Jun 7, 2009
Jun 7, 2009
25
26
27
28
29
#include "SDL_config.h"
#if SDL_VIDEO_RENDER_GAPI
#include "SDL_win32video.h"
Jul 28, 2010
Jul 28, 2010
30
#include "SDL_win32window.h"
Jun 7, 2009
Jun 7, 2009
31
32
#include "../SDL_yuv_sw_c.h"
Jul 28, 2010
Jul 28, 2010
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// RawFrameBufferInfo
typedef struct
{
WORD wFormat;
WORD wBPP;
VOID *pFramePointer;
int cxStride;
int cyStride;
int cxPixels;
int cyPixels;
} RawFrameBufferInfo;
// GXDeviceInfo
typedef struct
{
long Version;
void* pvFrameBuffer;
unsigned long cbStride;
unsigned long cxWidth;
unsigned long cyHeight;
unsigned long cBPP;
unsigned long ffFormat;
char unknown[0x84 - 7 * 4];
} GXDeviceInfo;
// wince: GXDisplayProperties
struct GXDisplayProperties
{
DWORD cxWidth;
DWORD cyHeight;
long cbxPitch;
long cbyPitch;
long cBPP;
DWORD ffFormat;
};
Jun 7, 2009
Jun 7, 2009
68
Jul 28, 2010
Jul 28, 2010
69
70
71
72
73
74
75
76
// gx.dll
typedef int (*PFNGXOpenDisplay)(HWND hWnd, DWORD dwFlags);
typedef int (*PFNGXCloseDisplay)();
typedef void* (*PFNGXBeginDraw)();
typedef int (*PFNGXEndDraw)();
typedef struct GXDisplayProperties (*PFNGXGetDisplayProperties)();
typedef int (*PFNGXSuspend)();
typedef int (*PFNGXResume)();
Jun 7, 2009
Jun 7, 2009
77
Jul 28, 2010
Jul 28, 2010
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
typedef struct
{
// gx.dll
HMODULE hGapiLib;
PFNGXOpenDisplay GXOpenDisplay;
PFNGXCloseDisplay GXCloseDisplay;
PFNGXBeginDraw GXBeginDraw;
PFNGXEndDraw GXEndDraw;
PFNGXGetDisplayProperties GXGetDisplayProperties;
PFNGXSuspend GXSuspend;
PFNGXResume GXResume;
} GapiInfo;
//#ifndef DM_DISPLAYORIENTATION
//#define DM_DISPLAYORIENTATION 0x00800000L
//#endif
#define FORMAT_565 1
#define FORMAT_555 2
#define FORMAT_OTHER 3
#define GETRAWFRAMEBUFFER 0x00020001
#define GETGXINFO 0x00020000
#define kfPalette 0x10
#define kfDirect 0x20
#define kfDirect555 0x40
#define kfDirect565 0x80
#define GX_FULLSCREEN 0x01
enum ScreenOrientation { ORIENTATION_UNKNOWN = -1, ORIENTATION_UP = DMDO_0, ORIENTATION_DOWN = DMDO_180, ORIENTATION_LEFT = DMDO_270, ORIENTATION_RIGHT = DMDO_90 };
enum ScreenGeometry { GEOMETRY_UNKNOWN, GEOMETRY_PORTRAIT, GEOMETRY_LANDSCAPE, GEOMETRY_SQUARE };
enum FrameBufferFlags { FB_SKIP_OFFSET = 0x0001, FB_RAW_MODE = 0x0002, FB_SUSPENDED = 0x0004 };
// private framebuffer info
typedef struct
{
int width;
int height;
int xpitch;
int ypitch;
int offset;
} FrameBufferInfo;
// private display data
typedef struct
{
unsigned char* pixels; // video memory
int format; // video format
FrameBufferInfo fb; // framebuffer geometry
GapiInfo* gapi; // GAPI module
int userOrientation;
int systemOrientation;
int hardwareGeometry;
int flags; // fb flags
float scale; // scale pointer position
int debug;
} WINCE_RenderData;
Jun 7, 2009
Jun 7, 2009
138
Jul 28, 2010
Jul 28, 2010
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
typedef struct
{
SDL_SW_YUVTexture *yuv;
Uint32 format;
void *pixels;
int pitch;
} WINCE_TextureData;
// system func
SDL_Renderer* WINCE_CreateRenderer(SDL_Window* window, Uint32 flags);
void WINCE_DestroyRenderer(SDL_Renderer* renderer);
int WINCE_CreateTexture(SDL_Renderer* renderer, SDL_Texture* texture);
void WINCE_DestroyTexture(SDL_Renderer* renderer, SDL_Texture* texture);
int WINCE_QueryTexturePixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch);
int WINCE_UpdateTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch);
int WINCE_LockTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int dirty, void** pixels, int* pitch);
void WINCE_UnlockTexture(SDL_Renderer* renderer, SDL_Texture* texture);
int WINCE_Available(void);
void WINCE_SetupOrientation(WINCE_RenderData* data, int width, int height);
int WINCE_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srect, const SDL_Rect* drect);
void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible);
void WINCE_RenderPresent(SDL_Renderer* renderer);
int WINCE_RenderDrawPoints(SDL_Renderer* renderer, const SDL_Point* points, int count);
int WINCE_RenderDrawLines(SDL_Renderer* renderer, const SDL_Point* points, int count);
int WINCE_RenderDrawRects(SDL_Renderer* renderer, const SDL_Rect ** rects, int count);
int WINCE_RenderFillRects(SDL_Renderer* renderer, const SDL_Rect** rects, int count);
void WINCE_PointerCoordinateTransform(SDL_Window* window, POINT* pt);
void WINCE_DumpVideoInfo(WINCE_RenderData* data);
void WINCE_PortraitTransform(WINCE_RenderData* data, int width, int height);
void WINCE_LandscapeTransform(WINCE_RenderData* data, int width, int height);
void WINCE_SquareTransform(WINCE_RenderData* data, int width, int height);
int WINCE_FixedGeometry(FrameBufferInfo* fb, int bpp, int debug);
int WINCE_GetDMOrientation(void);
int WINCE_SetDMOrientation(int orientation);
void WINCE_UpdateYUVTextureData(SDL_Texture* texture);
// gapi engine specific
int GAPI_Init(WINCE_RenderData* data, HWND hwnd);
void GAPI_Quit(WINCE_RenderData* data);
// raw engine specific
int RAW_Init(WINCE_RenderData* data);
void RAW_Quit(WINCE_RenderData* data);
// tools
void FrameBufferRotate(FrameBufferInfo* src, int orientation);
int GetFrameBufferOrientation(const FrameBufferInfo* src);
void PointerRotate(POINT* pt, const FrameBufferInfo* fb, int orientation);
void FrameBufferInitialize(FrameBufferInfo* fb);
void FrameBufferDumpInfo(const FrameBufferInfo* fb, const char*);
const char* GetOrientationName(int orientation);
void UpdateLine16to16(const FrameBufferInfo* fb, const Uint16* src, Uint16* dst, Uint16 width);
// stdlib
inline int __abs(int x){ return x < 0 ? -x : x; };
inline void __swap(int* a, int* b){ int t = *a; *a = *b; *b = t; };
#define GAPI_RENDER_NAME "gapi"
#define RAW_RENDER_NAME "raw"
//
Jun 7, 2009
Jun 7, 2009
206
SDL_RenderDriver GAPI_RenderDriver = {
Jul 28, 2010
Jul 28, 2010
207
WINCE_CreateRenderer,
Jun 7, 2009
Jun 7, 2009
208
{
Jul 28, 2010
Jul 28, 2010
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
GAPI_RENDER_NAME,
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD),
(SDL_TEXTUREMODULATE_NONE),
(SDL_BLENDMODE_NONE),
(SDL_TEXTURESCALEMODE_NONE),
7,
{
SDL_PIXELFORMAT_RGB555,
SDL_PIXELFORMAT_RGB565,
SDL_PIXELFORMAT_YV12,
SDL_PIXELFORMAT_IYUV,
SDL_PIXELFORMAT_YUY2,
SDL_PIXELFORMAT_UYVY,
SDL_PIXELFORMAT_YVYU
},
0,
0
}
Jun 7, 2009
Jun 7, 2009
227
228
};
Jul 28, 2010
Jul 28, 2010
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
SDL_RenderDriver RAW_RenderDriver = {
WINCE_CreateRenderer,
{
RAW_RENDER_NAME,
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD),
(SDL_TEXTUREMODULATE_NONE),
(SDL_BLENDMODE_NONE),
(SDL_TEXTURESCALEMODE_NONE),
7,
{
SDL_PIXELFORMAT_RGB555,
SDL_PIXELFORMAT_RGB565,
SDL_PIXELFORMAT_YV12,
SDL_PIXELFORMAT_IYUV,
SDL_PIXELFORMAT_YUY2,
SDL_PIXELFORMAT_UYVY,
SDL_PIXELFORMAT_YVYU
},
0,
0
Jun 7, 2009
Jun 7, 2009
249
}
Jul 28, 2010
Jul 28, 2010
250
};
Jun 7, 2009
Jun 7, 2009
251
Jul 28, 2010
Jul 28, 2010
252
int WINCE_Available(void)
Jun 7, 2009
Jun 7, 2009
253
{
Jul 28, 2010
Jul 28, 2010
254
const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
Dec 4, 2009
Dec 4, 2009
255
Jul 28, 2010
Jul 28, 2010
256
257
258
259
260
// raw check
RawFrameBufferInfo rfbi = { 0 };
HDC hdc = GetDC(NULL);
int render_raw = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi);
ReleaseDC(NULL, hdc);
Jun 7, 2009
Jun 7, 2009
261
Jul 28, 2010
Jul 28, 2010
262
263
264
if(render_raw != 0 && rfbi.cxPixels != 0 && rfbi.cyPixels != 0 &&
rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0)
render_raw = 1;
Jun 7, 2009
Jun 7, 2009
265
Jul 28, 2010
Jul 28, 2010
266
if(preferably && 0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME)) return 0 != render_raw;
Jun 7, 2009
Jun 7, 2009
267
Jul 28, 2010
Jul 28, 2010
268
269
270
271
272
// gapi check
HMODULE render_gapi = LoadLibrary(TEXT("\\Windows\\gx.dll"));
if(0 == render_gapi)
render_gapi = LoadLibrary(TEXT("gx.dll"));
FreeLibrary(render_gapi);
Jun 7, 2009
Jun 7, 2009
273
Jul 28, 2010
Jul 28, 2010
274
if(preferably && 0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0 != render_gapi;
Jun 7, 2009
Jun 7, 2009
275
Jul 28, 2010
Jul 28, 2010
276
277
return 0 != render_raw || 0 != render_gapi;
}
Jun 7, 2009
Jun 7, 2009
278
Jul 28, 2010
Jul 28, 2010
279
void WINCE_AddRenderDriver(_THIS)
Jun 7, 2009
Jun 7, 2009
280
{
Jul 28, 2010
Jul 28, 2010
281
282
283
284
HDC hdc;
HMODULE render_gapi;
int render_raw, ii;
const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
Jun 7, 2009
Jun 7, 2009
285
Jul 28, 2010
Jul 28, 2010
286
287
288
289
290
// raw check
RawFrameBufferInfo rfbi = { 0 };
hdc = GetDC(NULL);
render_raw = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi);
ReleaseDC(NULL, hdc);
Jun 7, 2009
Jun 7, 2009
291
Jul 28, 2010
Jul 28, 2010
292
293
294
if(render_raw != 0 && rfbi.cxPixels != 0 && rfbi.cyPixels != 0 &&
rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0)
render_raw = 1;
Jun 7, 2009
Jun 7, 2009
295
Jul 28, 2010
Jul 28, 2010
296
297
298
299
// gapi check
render_gapi = LoadLibrary(TEXT("\\Windows\\gx.dll"));
if(0 == render_gapi)
render_gapi = LoadLibrary(TEXT("gx.dll"));
Jun 7, 2009
Jun 7, 2009
300
Jul 28, 2010
Jul 28, 2010
301
302
if(render_gapi)
FreeLibrary(render_gapi);
Jun 7, 2009
Jun 7, 2009
303
Jul 28, 2010
Jul 28, 2010
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
for(ii = 0; ii < _this->num_displays; ++ii)
{
if(preferably)
{
if(0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME) && render_raw)
SDL_AddRenderDriver(&_this->displays[ii], &RAW_RenderDriver);
else
if(0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME) && render_gapi)
SDL_AddRenderDriver(&_this->displays[ii], &GAPI_RenderDriver);
}
else
{
if(render_raw)
SDL_AddRenderDriver(&_this->displays[ii], &RAW_RenderDriver);
if(render_gapi)
SDL_AddRenderDriver(&_this->displays[ii], &GAPI_RenderDriver);
}
Jun 7, 2009
Jun 7, 2009
321
322
323
}
}
Jul 28, 2010
Jul 28, 2010
324
SDL_Renderer* WINCE_CreateRenderer(SDL_Window* window, Uint32 flags)
Jun 7, 2009
Jun 7, 2009
325
{
Jul 28, 2010
Jul 28, 2010
326
327
328
329
330
331
332
SDL_VideoDisplay* display = window->display;
SDL_DisplayMode* displayMode = &display->current_mode;
SDL_WindowData* windowdata = (SDL_WindowData *) window->driverdata;
SDL_Renderer* renderer;
WINCE_RenderData* data;
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
Jun 7, 2009
Jun 7, 2009
333
Jul 28, 2010
Jul 28, 2010
334
335
if(!(window->flags & SDL_WINDOW_FULLSCREEN))
window->flags |= SDL_WINDOW_FULLSCREEN;
Jun 7, 2009
Jun 7, 2009
336
Jul 28, 2010
Jul 28, 2010
337
338
339
if(!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask))
{
SDL_SetError("Unknown display format");
Jun 7, 2009
Jun 7, 2009
340
341
342
return NULL;
}
Jul 28, 2010
Jul 28, 2010
343
344
345
346
347
switch(window->fullscreen_mode.format)
{
case SDL_PIXELFORMAT_RGB555:
case SDL_PIXELFORMAT_RGB565:
break;
Jun 7, 2009
Jun 7, 2009
348
Jul 28, 2010
Jul 28, 2010
349
350
351
352
default:
SDL_SetError("Support only 16 or 15 bpp");
return NULL;
}
Jun 7, 2009
Jun 7, 2009
353
Jul 28, 2010
Jul 28, 2010
354
355
356
renderer = (SDL_Renderer*) SDL_calloc(1, sizeof(SDL_Renderer));
if(!renderer)
{
Jun 7, 2009
Jun 7, 2009
357
358
359
SDL_OutOfMemory();
return NULL;
}
Jul 28, 2010
Jul 28, 2010
360
361
362
363
364
365
data = (WINCE_RenderData*) SDL_calloc(1, sizeof(WINCE_RenderData));
if(!data)
{
WINCE_DestroyRenderer(renderer);
SDL_OutOfMemory();
Jun 7, 2009
Jun 7, 2009
366
367
return NULL;
}
Jul 28, 2010
Jul 28, 2010
368
369
370
371
372
// initialize internal engine
if(!RAW_Init(data) && !GAPI_Init(data, windowdata->hwnd))
{
WINCE_DestroyRenderer(renderer);
Jun 7, 2009
Jun 7, 2009
373
374
375
376
return NULL;
}
Jul 28, 2010
Jul 28, 2010
377
378
379
380
381
// set debug
data->debug = SDL_getenv("DEBUG_VIDEO_GAPI") || SDL_getenv("GAPI_RENDERER_DEBUG") ? 1 : 0;
#if defined(DEBUG_VIDEO_GAPI) || defined(GAPI_RENDERER_DEBUG)
data->debug = 1;
#endif
Jun 7, 2009
Jun 7, 2009
382
Jul 28, 2010
Jul 28, 2010
383
384
385
386
387
388
389
windowdata->videodata->render = data->gapi ? RENDER_GAPI : RENDER_RAW;
windowdata->videodata->CoordTransform = WINCE_PointerCoordinateTransform;
window->display->device->MaximizeWindow = NULL;
window->display->device->MinimizeWindow = NULL;
WINCE_SetupOrientation(data, window->w, window->h);
Jun 7, 2009
Jun 7, 2009
390
Jul 28, 2010
Jul 28, 2010
391
392
393
394
395
396
renderer->CreateTexture = WINCE_CreateTexture;
renderer->DestroyTexture = WINCE_DestroyTexture;
renderer->QueryTexturePixels = WINCE_QueryTexturePixels;
renderer->UpdateTexture = WINCE_UpdateTexture;
renderer->LockTexture = WINCE_LockTexture;
renderer->UnlockTexture = WINCE_UnlockTexture;
Jun 7, 2009
Jun 7, 2009
397
Jul 28, 2010
Jul 28, 2010
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
renderer->RenderCopy = WINCE_RenderCopy;
renderer->DestroyRenderer = WINCE_DestroyRenderer;
renderer->RenderPresent = WINCE_RenderPresent;
renderer->RenderDrawPoints = WINCE_RenderDrawPoints;
renderer->RenderDrawLines = WINCE_RenderDrawLines;
renderer->RenderDrawRects = WINCE_RenderDrawRects;
renderer->RenderFillRects = WINCE_RenderFillRects;
renderer->info = data->gapi ? GAPI_RenderDriver.info : RAW_RenderDriver.info;
renderer->window = window;
renderer->driverdata = data;
return renderer;
}
void WINCE_DestroyRenderer(SDL_Renderer* renderer)
Jun 7, 2009
Jun 7, 2009
416
{
Jul 28, 2010
Jul 28, 2010
417
WINCE_RenderData *renderdata = (WINCE_RenderData*) renderer->driverdata;
Jun 7, 2009
Jun 7, 2009
418
Jul 28, 2010
Jul 28, 2010
419
420
421
422
423
424
if(renderdata)
{
if(renderdata->gapi)
GAPI_Quit(renderdata);
else
RAW_Quit(renderdata);
Jun 7, 2009
Jun 7, 2009
425
Jul 28, 2010
Jul 28, 2010
426
427
428
429
430
431
432
433
434
435
436
437
438
SDL_free(renderdata);
}
SDL_free(renderer);
}
int WINCE_CreateTexture(SDL_Renderer* renderer, SDL_Texture* texture)
{
WINCE_TextureData* texturedata = (WINCE_TextureData*) SDL_calloc(1, sizeof(WINCE_TextureData));
if(NULL == texturedata)
{
SDL_OutOfMemory();
return -1;
Jun 7, 2009
Jun 7, 2009
439
440
}
Jul 28, 2010
Jul 28, 2010
441
442
443
444
texturedata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
texturedata->pixels = SDL_malloc(texture->h * texturedata->pitch);
if(NULL == texturedata->pixels)
{
Jun 7, 2009
Jun 7, 2009
445
SDL_OutOfMemory();
Jul 28, 2010
Jul 28, 2010
446
return -1;
Jun 7, 2009
Jun 7, 2009
447
448
}
Jul 28, 2010
Jul 28, 2010
449
if(SDL_ISPIXELFORMAT_FOURCC(texture->format))
Jun 7, 2009
Jun 7, 2009
450
{
Jul 28, 2010
Jul 28, 2010
451
452
453
454
455
texturedata->yuv = SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
if(NULL == texturedata->yuv)
{
SDL_OutOfMemory();
return -1;
Jun 7, 2009
Jun 7, 2009
456
}
Jul 28, 2010
Jul 28, 2010
457
458
459
460
461
462
463
464
SDL_Window* window = renderer->window;
SDL_VideoDisplay* display = window->display;
texturedata->format = display->current_mode.format;
}
else
{
texturedata->yuv = NULL;
texturedata->format = texture->format;
Jun 7, 2009
Jun 7, 2009
465
466
}
Jul 28, 2010
Jul 28, 2010
467
texture->driverdata = texturedata;
Jun 7, 2009
Jun 7, 2009
468
Jul 28, 2010
Jul 28, 2010
469
470
471
472
473
474
475
476
477
478
479
480
481
return 0;
}
void WINCE_DestroyTexture(SDL_Renderer* renderer, SDL_Texture* texture)
{
WINCE_TextureData *texturedata = (WINCE_TextureData*) texture->driverdata;
if(texturedata)
{
if(texturedata->yuv) SDL_SW_DestroyYUVTexture(texturedata->yuv);
if(texturedata->pixels) SDL_free(texturedata->pixels);
SDL_free(texturedata);
texture->driverdata = NULL;
Jun 7, 2009
Jun 7, 2009
482
}
Jul 28, 2010
Jul 28, 2010
483
}
Jun 7, 2009
Jun 7, 2009
484
Jul 28, 2010
Jul 28, 2010
485
486
487
int WINCE_QueryTexturePixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch)
{
WINCE_TextureData* texturedata = (WINCE_TextureData*) texture->driverdata;
Jun 7, 2009
Jun 7, 2009
488
Jul 28, 2010
Jul 28, 2010
489
490
if(texturedata->yuv)
return SDL_SW_QueryYUVTexturePixels(texturedata->yuv, pixels, pitch);
Jun 7, 2009
Jun 7, 2009
491
Jul 28, 2010
Jul 28, 2010
492
493
*pixels = texturedata->pixels;
*pitch = texturedata->pitch;
Jun 7, 2009
Jun 7, 2009
494
Jul 28, 2010
Jul 28, 2010
495
496
return 0;
}
Jun 7, 2009
Jun 7, 2009
497
Jul 28, 2010
Jul 28, 2010
498
499
500
int WINCE_UpdateTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch)
{
WINCE_TextureData* texturedata = (WINCE_TextureData*) texture->driverdata;
Jun 7, 2009
Jun 7, 2009
501
Jul 28, 2010
Jul 28, 2010
502
503
504
505
506
507
508
if(texturedata->yuv)
{
if(SDL_SW_UpdateYUVTexture(texturedata->yuv, rect, pixels, pitch) < 0)
return -1;
WINCE_UpdateYUVTextureData(texture);
return 0;
}
Jun 7, 2009
Jun 7, 2009
509
Jul 28, 2010
Jul 28, 2010
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
if(0 < rect->w && 0 < rect->h)
{
const unsigned char *src = ((const unsigned char*) pixels);
unsigned char *dst = ((unsigned char*) texturedata->pixels) +
rect->y * texturedata->pitch +
rect->x * SDL_BYTESPERPIXEL(texture->format);
int length = rect->w * SDL_BYTESPERPIXEL(texture->format);
int height = rect->h;
while(height--)
{
SDL_memcpy(dst, src, length);
dst += texturedata->pitch;
src += pitch;
}
}
return 0;
}
int WINCE_LockTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int dirty, void** pixels, int* pitch)
{
WINCE_TextureData *texturedata = (WINCE_TextureData*) texture->driverdata;
Jun 7, 2009
Jun 7, 2009
533
Jul 28, 2010
Jul 28, 2010
534
535
if(texturedata->yuv)
return SDL_SW_LockYUVTexture(texturedata->yuv, rect, dirty, pixels, pitch);
Jun 7, 2009
Jun 7, 2009
536
Jul 28, 2010
Jul 28, 2010
537
538
539
540
541
*pixels = (void *) ((unsigned char*) texturedata->pixels +
rect->y * texturedata->pitch +
rect->x * SDL_BYTESPERPIXEL(texture->format));
*pitch = texturedata->pitch;
}
Jun 7, 2009
Jun 7, 2009
542
Jul 28, 2010
Jul 28, 2010
543
544
545
void WINCE_UnlockTexture(SDL_Renderer* renderer, SDL_Texture* texture)
{
WINCE_TextureData *texturedata = (WINCE_TextureData*) texture->driverdata;
Jun 7, 2009
Jun 7, 2009
546
Jul 28, 2010
Jul 28, 2010
547
548
549
550
551
552
if(texturedata->yuv)
{
SDL_SW_UnlockYUVTexture(texturedata->yuv);
WINCE_UpdateYUVTextureData(texture);
}
}
Jun 7, 2009
Jun 7, 2009
553
Jul 28, 2010
Jul 28, 2010
554
555
556
557
int WINCE_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srect, const SDL_Rect* drect)
{
WINCE_RenderData* dstdata = (WINCE_RenderData*) renderer->driverdata;
WINCE_TextureData* srcdata = (WINCE_TextureData*) texture->driverdata;
Jun 7, 2009
Jun 7, 2009
558
Jul 28, 2010
Jul 28, 2010
559
560
if((dstdata->flags & FB_SUSPENDED) ||
0 >= srect->w || 0 >= srect->h) return;
Jun 7, 2009
Jun 7, 2009
561
Jul 28, 2010
Jul 28, 2010
562
563
// lock gapi
if(dstdata->gapi) dstdata->gapi->GXBeginDraw();
Jun 7, 2009
Jun 7, 2009
564
Jul 28, 2010
Jul 28, 2010
565
566
567
568
569
570
571
572
573
574
const unsigned char *src = ((const unsigned char*) srcdata->pixels);
unsigned char *dst = dstdata->pixels + (dstdata->flags & FB_SKIP_OFFSET ? 0 : dstdata->fb.offset) +
drect->y * dstdata->fb.ypitch +
drect->x * dstdata->fb.xpitch;
if(srcdata->yuv)
{
return SDL_SW_CopyYUVToRGB(srcdata->yuv,
srect, srcdata->format,
drect->w, drect->h, dst,
dstdata->fb.ypitch);
Jun 7, 2009
Jun 7, 2009
575
}
Jul 28, 2010
Jul 28, 2010
576
577
578
579
else
{
int height = drect->h;
int length = drect->w * SDL_BYTESPERPIXEL(texture->format); // in bytes
Jun 7, 2009
Jun 7, 2009
580
Jul 28, 2010
Jul 28, 2010
581
582
583
584
585
586
587
588
589
590
591
592
while(height--)
{
switch(SDL_BYTESPERPIXEL(texture->format))
{
case 2: UpdateLine16to16(&dstdata->fb, (Uint16*) src, (Uint16*) dst, length >> 1); break;
default: break;
}
dst += dstdata->fb.ypitch;
src += srcdata->pitch;
}
Jun 7, 2009
Jun 7, 2009
593
594
}
Jul 28, 2010
Jul 28, 2010
595
596
// unlock gapi
if(dstdata->gapi) dstdata->gapi->GXEndDraw();
Jun 7, 2009
Jun 7, 2009
597
Jul 28, 2010
Jul 28, 2010
598
return 0;
Jun 7, 2009
Jun 7, 2009
599
600
}
Jul 28, 2010
Jul 28, 2010
601
void WINCE_RenderPresent(SDL_Renderer* renderer)
Jun 7, 2009
Jun 7, 2009
602
{
Jul 28, 2010
Jul 28, 2010
603
}
Jun 7, 2009
Jun 7, 2009
604
Jul 28, 2010
Jul 28, 2010
605
606
607
608
609
int WINCE_RenderDrawPoints(SDL_Renderer* renderer, const SDL_Point* points, int count)
{
SDL_Unsupported();
return -1;
}
Jun 7, 2009
Jun 7, 2009
610
Jul 28, 2010
Jul 28, 2010
611
612
613
614
int WINCE_RenderDrawLines(SDL_Renderer* renderer, const SDL_Point* points, int count)
{
SDL_Unsupported();
return -1;
Jun 7, 2009
Jun 7, 2009
615
616
}
Jul 28, 2010
Jul 28, 2010
617
int WINCE_RenderDrawRects(SDL_Renderer* renderer, const SDL_Rect ** rects, int count)
Jun 7, 2009
Jun 7, 2009
618
{
Jul 28, 2010
Jul 28, 2010
619
620
621
SDL_Unsupported();
return -1;
}
Jun 7, 2009
Jun 7, 2009
622
Jul 28, 2010
Jul 28, 2010
623
624
625
626
int WINCE_RenderFillRects(SDL_Renderer* renderer, const SDL_Rect** rects, int count)
{
SDL_Unsupported();
return -1;
Jun 7, 2009
Jun 7, 2009
627
628
629
}
Jul 28, 2010
Jul 28, 2010
630
631
void WINCE_SetupOrientation(WINCE_RenderData* data, int width, int height)
Jun 7, 2009
Jun 7, 2009
632
{
Jul 28, 2010
Jul 28, 2010
633
634
const float maxW1 = GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN) ? GetSystemMetrics(SM_CXSCREEN) : GetSystemMetrics(SM_CYSCREEN);
const float maxW2 = data->fb.width > data->fb.height ? data->fb.width : data->fb.height;
Jun 7, 2009
Jun 7, 2009
635
Jul 28, 2010
Jul 28, 2010
636
637
// scale define
data->scale = maxW2 / maxW1;
Jun 7, 2009
Jun 7, 2009
638
Jul 28, 2010
Jul 28, 2010
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
// init fb values
FrameBufferInitialize(&data->fb);
// orientation values
data->userOrientation = ORIENTATION_UP;
data->systemOrientation = WINCE_GetDMOrientation();
data->hardwareGeometry = data->fb.width == data->fb.height ? GEOMETRY_SQUARE :
(data->fb.width < data->fb.height ? GEOMETRY_PORTRAIT : GEOMETRY_LANDSCAPE);
if(data->debug)
WINCE_DumpVideoInfo(data);
if(data->systemOrientation == ORIENTATION_UNKNOWN)
data->systemOrientation == ORIENTATION_UP;
data->userOrientation = ORIENTATION_UP;
switch(data->hardwareGeometry)
{
case GEOMETRY_PORTRAIT: WINCE_PortraitTransform(data, width, height); break;
case GEOMETRY_LANDSCAPE: WINCE_LandscapeTransform(data, width, height); break;
case GEOMETRY_SQUARE: WINCE_SquareTransform(data, width, height); break;
default: break;
Jun 7, 2009
Jun 7, 2009
662
663
}
Jul 28, 2010
Jul 28, 2010
664
665
666
667
668
669
670
// debug
if(data->debug)
{
printf("\n");
printf("user video width: %d\n", width);
printf("user video height: %d\n", height);
FrameBufferDumpInfo(&data->fb, "user");
Jun 7, 2009
Jun 7, 2009
671
}
Jul 28, 2010
Jul 28, 2010
672
}
Jun 7, 2009
Jun 7, 2009
673
Jul 28, 2010
Jul 28, 2010
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
void WINCE_DumpVideoInfo(WINCE_RenderData* data)
{
// get oem info
WCHAR oemInfo[48];
SDL_memset(oemInfo, 0, sizeof(oemInfo));
SystemParametersInfo(SPI_GETOEMINFO, sizeof(oemInfo) - sizeof(WCHAR), oemInfo, 0);
printf("hardware oem: ");
wprintf(oemInfo);
printf("\n");
printf("video driver mode: %s\n", (data->flags & FB_RAW_MODE ? RAW_RENDER_NAME : GAPI_RENDER_NAME));
printf("GetSystemMetrics(SM_CXSCREEN): %d\n", GetSystemMetrics(SM_CXSCREEN));
printf("GetSystemMetrics(SM_CYSCREEN): %d\n", GetSystemMetrics(SM_CYSCREEN));
printf("scale coord: %f\n", data->scale);
FrameBufferDumpInfo(&data->fb, "hardware");
printf("display format: %p\n", data->format);
printf("display bits per pixel: %d\n", SDL_BITSPERPIXEL(data->format));
printf("display bytes per pixel: %d\n", SDL_BYTESPERPIXEL(data->format));
printf("display memory: %p\n", data->pixels);
printf("system orientation: %d, %s\n", data->systemOrientation, GetOrientationName(data->systemOrientation));
printf("hardware geometry: %d\n", data->hardwareGeometry);
}
void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible)
{
SDL_WindowData* windowdata = (SDL_WindowData*) window->driverdata;
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
SDL_Renderer* renderer = (SDL_Renderer*) window->renderer;
if(visible)
{
if(window->flags & SDL_WINDOW_FULLSCREEN)
{
if(videodata->SHFullScreen)
videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE);
}
ShowWindow(windowdata->hwnd, SW_SHOW);
SetForegroundWindow(windowdata->hwnd);
if(renderer &&
(videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
{
WINCE_RenderData* renderdata = (WINCE_RenderData*) renderer->driverdata;
renderdata->flags &= ~FB_SUSPENDED;
if(renderdata->gapi) renderdata->gapi->GXResume();
}
Jun 7, 2009
Jun 7, 2009
725
}
Jul 28, 2010
Jul 28, 2010
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
else
{
if(renderer &&
(videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
{
WINCE_RenderData* renderdata = (WINCE_RenderData*) renderer->driverdata;
if(renderdata->gapi) renderdata->gapi->GXSuspend();
renderdata->flags |= FB_SUSPENDED;
}
ShowWindow(windowdata->hwnd, SW_HIDE);
if(window->flags & SDL_WINDOW_FULLSCREEN)
{
if(videodata->SHFullScreen)
videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW);
}
}
}
Jun 7, 2009
Jun 7, 2009
746
747
Jul 28, 2010
Jul 28, 2010
748
749
750
void WINCE_PointerCoordinateTransform(SDL_Window* window, POINT* pt)
{
WINCE_RenderData* data = (WINCE_RenderData*) window->renderer->driverdata;
Jun 7, 2009
Jun 7, 2009
751
Jul 28, 2010
Jul 28, 2010
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
pt->x *= data->scale;
pt->y *= data->scale;
PointerRotate(pt, &data->fb, data->userOrientation);
}
void WINCE_PortraitTransform(WINCE_RenderData* data, int width, int height)
{
if(data->systemOrientation != ORIENTATION_UP)
FrameBufferRotate(&data->fb, data->systemOrientation);
if(data->fb.width != width || data->fb.height != height)
switch(data->systemOrientation)
{
case ORIENTATION_UP:
case ORIENTATION_LEFT: data->userOrientation = ORIENTATION_RIGHT; break;
case ORIENTATION_RIGHT:
case ORIENTATION_DOWN: data->userOrientation = ORIENTATION_LEFT; break;
default: break;
Jun 7, 2009
Jun 7, 2009
771
772
}
Jul 28, 2010
Jul 28, 2010
773
774
if(data->userOrientation != ORIENTATION_UP)
FrameBufferRotate(&data->fb, data->userOrientation);
Jun 7, 2009
Jun 7, 2009
775
776
}
Jul 28, 2010
Jul 28, 2010
777
void WINCE_LandscapeTransform(WINCE_RenderData* data, int width, int height)
Jun 7, 2009
Jun 7, 2009
778
{
Jul 28, 2010
Jul 28, 2010
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
switch(data->systemOrientation)
{
case ORIENTATION_UP: FrameBufferRotate(&data->fb, ORIENTATION_LEFT); break;
case ORIENTATION_LEFT:FrameBufferRotate(&data->fb, ORIENTATION_DOWN); break;
case ORIENTATION_DOWN:FrameBufferRotate(&data->fb, ORIENTATION_RIGHT); break;
default: break;
}
if(data->fb.width != width || data->fb.height != height)
switch(data->systemOrientation)
{
case ORIENTATION_UP:
case ORIENTATION_LEFT: data->userOrientation = ORIENTATION_RIGHT; break;
case ORIENTATION_RIGHT:
case ORIENTATION_DOWN: data->userOrientation = ORIENTATION_LEFT; break;
default: break;
}
if(data->userOrientation != ORIENTATION_UP)
FrameBufferRotate(&data->fb, data->userOrientation);
Jun 7, 2009
Jun 7, 2009
799
800
}
Jul 28, 2010
Jul 28, 2010
801
void WINCE_SquareTransform(WINCE_RenderData* data, int width, int height)
Jun 7, 2009
Jun 7, 2009
802
{
Jul 28, 2010
Jul 28, 2010
803
WINCE_PortraitTransform(data, width, height);
Jan 6, 2010
Jan 6, 2010
804
805
}
Jul 28, 2010
Jul 28, 2010
806
int WINCE_FixedGeometry(FrameBufferInfo* fb, int bpp, int debug)
Jan 6, 2010
Jan 6, 2010
807
{
Jul 28, 2010
Jul 28, 2010
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
// check square
if(GetSystemMetrics(SM_CXSCREEN) == GetSystemMetrics(SM_CYSCREEN) &&
fb->width != fb->height)
{
if(fb->width < fb->height)
fb->height = fb->width;
else
if(fb->height < fb->width)
fb->width = fb->height;
}
// check width
if(__abs(fb->xpitch) == bpp &&
fb->width != __abs(fb->ypitch) / bpp)
{
if(fb->height == __abs(fb->ypitch) / bpp)
{
__swap(&fb->width, &fb->height);
if(debug)
printf("WINCE_FixedGeometry: width: %d, height: %d\n", fb->width, fb->height);
}
else
return -1;
}
else
// check height
if(__abs(fb->ypitch) == bpp &&
fb->height != __abs(fb->xpitch) / bpp)
{
if(fb->width == __abs(fb->xpitch) / bpp)
{
__swap(&fb->width, &fb->height);
if(debug)
printf("WINCE_FixedGeometry: width: %d, height: %d\n", fb->width, fb->height);
}
else
return -1;
}
return 0;
Jun 7, 2009
Jun 7, 2009
850
851
}
Jul 28, 2010
Jul 28, 2010
852
void WINCE_UpdateYUVTextureData(SDL_Texture* texture)
Jun 7, 2009
Jun 7, 2009
853
{
Jul 28, 2010
Jul 28, 2010
854
855
856
857
858
859
860
861
WINCE_TextureData* texturedata = (WINCE_TextureData*) texture->driverdata;
SDL_Rect rect;
rect.x = 0;
rect.y = 0;
rect.w = texture->w;
rect.h = texture->h;
SDL_SW_CopyYUVToRGB(texturedata->yuv, &rect, texturedata->format, texture->w, texture->h, texturedata->pixels, texturedata->pitch);
Jun 7, 2009
Jun 7, 2009
862
863
}
Jul 28, 2010
Jul 28, 2010
864
int GAPI_Init(WINCE_RenderData* data, HWND hwnd)
Jun 7, 2009
Jun 7, 2009
865
{
Jul 28, 2010
Jul 28, 2010
866
867
868
869
870
871
872
873
874
875
876
if(NULL == data->gapi)
{
const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
if(preferably && 0 != SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0;
data->gapi = (GapiInfo *) SDL_calloc(1, sizeof(GapiInfo));
if(NULL == data->gapi)
{
SDL_OutOfMemory();
return 0;
}
Jun 7, 2009
Jun 7, 2009
877
Jul 28, 2010
Jul 28, 2010
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
data->gapi->hGapiLib = LoadLibrary(TEXT("\\Windows\\gx.dll"));
if(0 == data->gapi->hGapiLib)
{
data->gapi->hGapiLib = LoadLibrary(TEXT("gx.dll"));
if(0 == data->gapi->hGapiLib) return 0;
}
// load gapi library
#define LINK(type,name,import) name=(PFN##type)GetProcAddress(data->gapi->hGapiLib,TEXT(import))
LINK(GXOpenDisplay, data->gapi->GXOpenDisplay, "?GXOpenDisplay@@YAHPAUHWND__@@K@Z");
LINK(GXCloseDisplay, data->gapi->GXCloseDisplay, "?GXCloseDisplay@@YAHXZ");
LINK(GXBeginDraw, data->gapi->GXBeginDraw, "?GXBeginDraw@@YAPAXXZ");
LINK(GXEndDraw, data->gapi->GXEndDraw, "?GXEndDraw@@YAHXZ");
LINK(GXGetDisplayProperties,data->gapi->GXGetDisplayProperties,"?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ");
LINK(GXSuspend, data->gapi->GXSuspend, "?GXSuspend@@YAHXZ");
LINK(GXResume, data->gapi->GXResume, "?GXResume@@YAHXZ");
#undef LINK
Jun 7, 2009
Jun 7, 2009
895
Jul 28, 2010
Jul 28, 2010
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
int enable = data->gapi->GXGetDisplayProperties && data->gapi->GXCloseDisplay && data->gapi->GXOpenDisplay &&
data->gapi->GXBeginDraw && data->gapi->GXEndDraw && data->gapi->GXSuspend && data->gapi->GXResume;
if(!enable)
{
SDL_SetError("GAPI_Init: error gx.dll: internal error");
GAPI_Quit(data);
return 0;
}
if(0 == data->gapi->GXOpenDisplay(hwnd, GX_FULLSCREEN))
{
SDL_SetError("GAPI_Init: couldn't initialize GAPI");
GAPI_Quit(data);
return 0;
}
struct GXDisplayProperties gxProperties = data->gapi->GXGetDisplayProperties();
// fill FrameBufferInfo
data->fb.xpitch = gxProperties.cbxPitch;
data->fb.ypitch = gxProperties.cbyPitch;
data->fb.width = gxProperties.cxWidth;
data->fb.height = gxProperties.cyHeight;
data->fb.offset = 0;
if((gxProperties.ffFormat & kfDirect565) || 16 == gxProperties.cBPP)
data->format = SDL_PIXELFORMAT_RGB565;
else
if((gxProperties.ffFormat & kfDirect555) || 15 == gxProperties.cBPP)
data->format = SDL_PIXELFORMAT_RGB555;
else
data->format = 0;
// get pixels
GXDeviceInfo gxInfo = { 0 };
HDC hdc = GetDC(NULL);
gxInfo.Version = 100;
int result = ExtEscape(hdc, GETGXINFO, 0, NULL, sizeof(gxInfo), (char *) &gxInfo);
ReleaseDC(NULL, hdc);
if(result > 0)
{
// more debug
if(data->debug)
{
printf("GXDeviceInfo.pvFrameBuffer: %p\n", gxInfo.pvFrameBuffer);
printf("GXDeviceInfo.cxWidth: %d\n", gxInfo.cxWidth);
printf("GXDeviceInfo.cyHeight: %d\n", gxInfo.cyHeight);
printf("GXDeviceInfo.cbStride: %d\n", gxInfo.cbStride);
printf("GXDeviceInfo.cBPP: %d\n", gxInfo.cBPP);
printf("GXDeviceInfo.ffFormat: 0x%x\n", gxInfo.ffFormat);
printf("GXDeviceInfo.unk:\n");
int ii; for(ii = 0; ii < sizeof(gxInfo.unknown); ++ii)
printf("0x%02hhX,", gxInfo.unknown[ii]);
printf("\n");
}
if(gxInfo.ffFormat && gxInfo.ffFormat != gxProperties.ffFormat)
{
if((gxInfo.ffFormat & kfDirect565) || 16 == gxInfo.cBPP)
data->format = SDL_PIXELFORMAT_RGB565;
else
if((gxInfo.ffFormat & kfDirect555) || 15 == gxInfo.cBPP)
data->format = SDL_PIXELFORMAT_RGB555;
}
data->pixels = gxInfo.pvFrameBuffer;
Jun 7, 2009
Jun 7, 2009
966
}
Jul 28, 2010
Jul 28, 2010
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
else
{
data->flags |= FB_SKIP_OFFSET;
data->pixels = data->gapi->GXBeginDraw();
data->gapi->GXEndDraw();
if(data->debug)
{
printf("GAPI_Init\n");
printf("use GXBeginDraw: %p\n", data->pixels);
printf("use skip offset\n");
}
}
if(0 == data->format ||
0 > WINCE_FixedGeometry(&data->fb, SDL_BYTESPERPIXEL(data->format), data->debug))
{
SDL_SetError("GAPI_Init: unknown hardware");
GAPI_Quit(data);
return 0;
}
Jun 7, 2009
Jun 7, 2009
988
}
Jul 28, 2010
Jul 28, 2010
989
990
return data->gapi && data->pixels ? 1 : 0;
Jun 7, 2009
Jun 7, 2009
991
992
}
Jul 28, 2010
Jul 28, 2010
993
void GAPI_Quit(WINCE_RenderData* data)
Jun 7, 2009
Jun 7, 2009
994
{
Jul 28, 2010
Jul 28, 2010
995
996
997
998
if(data->gapi)
{
if(data->gapi->GXCloseDisplay) data->gapi->GXCloseDisplay();
if(data->gapi->hGapiLib) FreeLibrary(data->gapi->hGapiLib);
Jun 7, 2009
Jun 7, 2009
999
Jul 28, 2010
Jul 28, 2010
1000
SDL_free(data->gapi);