annotate src/video/win32/SDL_gapirender.c @ 4632:066ce836b80e

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