Mercurial > sdl-ios-xcode
annotate src/video/qnxgf/SDL_gf_render.c @ 5148:2f44e6969a59
Split the rendering API out into a separate header file.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 01 Feb 2011 15:02:21 -0800 |
parents | 31e7f523ab3d |
children | be02be2ea897 |
rev | line source |
---|---|
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
21 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
22 QNX Graphics Framework SDL driver |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
23 Copyright (C) 2009 Mike Gorchak |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
24 (mike@malva.ua, lestat@i.com.ua) |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 #include "SDL_config.h" |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include "../SDL_pixels_c.h" |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #include "../SDL_yuv_sw_c.h" |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #include "SDL_video.h" |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #include "SDL_gf_render.h" |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
35 #include "SDL_qnxgf.h" |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
3139 | 37 static SDL_Renderer *gf_createrenderer(SDL_Window * window, Uint32 flags); |
38 static int gf_displaymodechanged(SDL_Renderer * renderer); | |
39 static int gf_activaterenderer(SDL_Renderer * renderer); | |
40 static int gf_createtexture(SDL_Renderer * renderer, SDL_Texture * texture); | |
41 static int gf_querytexturepixels(SDL_Renderer * renderer, | |
42 SDL_Texture * texture, void **pixels, | |
43 int *pitch); | |
44 static int gf_settexturepalette(SDL_Renderer * renderer, | |
45 SDL_Texture * texture, | |
46 const SDL_Color * colors, int firstcolor, | |
47 int ncolors); | |
48 static int gf_gettexturepalette(SDL_Renderer * renderer, | |
49 SDL_Texture * texture, SDL_Color * colors, | |
50 int firstcolor, int ncolors); | |
51 static int gf_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
52 const SDL_Rect * rect, const void *pixels, | |
53 int pitch); | |
54 static int gf_locktexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
55 const SDL_Rect * rect, int markDirty, void **pixels, | |
56 int *pitch); | |
57 static void gf_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture); | |
58 static void gf_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
59 int numrects, const SDL_Rect * rects); | |
60 static int gf_renderpoint(SDL_Renderer * renderer, int x, int y); | |
61 static int gf_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, | |
62 int y2); | |
63 static int gf_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect); | |
64 static int gf_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture, | |
65 const SDL_Rect * srcrect, const SDL_Rect * dstrect); | |
66 static void gf_renderpresent(SDL_Renderer * renderer); | |
67 static void gf_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture); | |
68 static void gf_destroyrenderer(SDL_Renderer * renderer); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
69 |
3139 | 70 SDL_RenderDriver gf_renderdriver = { |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
71 gf_createrenderer, |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 { |
3139 | 73 "qnxgf", |
74 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | | |
75 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | | |
76 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD | | |
77 SDL_RENDERER_ACCELERATED), | |
78 13, | |
79 { | |
80 SDL_PIXELFORMAT_INDEX8, | |
81 SDL_PIXELFORMAT_RGB555, | |
82 SDL_PIXELFORMAT_RGB565, | |
83 SDL_PIXELFORMAT_RGB888, | |
84 SDL_PIXELFORMAT_BGR888, | |
85 SDL_PIXELFORMAT_ARGB8888, | |
86 SDL_PIXELFORMAT_RGBA8888, | |
87 SDL_PIXELFORMAT_ABGR8888, | |
88 SDL_PIXELFORMAT_BGRA8888, | |
89 SDL_PIXELFORMAT_YV12, | |
90 SDL_PIXELFORMAT_YUY2, | |
91 SDL_PIXELFORMAT_UYVY, | |
92 SDL_PIXELFORMAT_YVYU}, | |
93 0, | |
94 0} | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 }; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
96 |
3139 | 97 static SDL_Renderer * |
98 gf_createrenderer(SDL_Window * window, Uint32 flags) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
99 { |
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:
3500
diff
changeset
|
100 SDL_VideoDisplay *display = window->display; |
3139 | 101 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; |
102 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
103 SDL_Renderer *renderer = NULL; | |
104 SDL_RenderData *rdata = NULL; | |
105 uint32_t it; | |
106 int32_t jt; | |
107 int32_t status; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
108 |
3139 | 109 /* Check if it is OpenGL ES window */ |
110 if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) { | |
111 /* No error, just no need to create 2D renderer for OpenGL ES window */ | |
112 return NULL; | |
113 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
114 |
3139 | 115 /* Allocate new renderer structure */ |
116 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(SDL_Renderer)); | |
117 if (renderer == NULL) { | |
118 SDL_OutOfMemory(); | |
119 return NULL; | |
120 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
121 |
3139 | 122 /* Allocate renderer data */ |
123 rdata = (SDL_RenderData *) SDL_calloc(1, sizeof(SDL_RenderData)); | |
124 if (rdata == NULL) { | |
125 SDL_free(renderer); | |
126 SDL_OutOfMemory(); | |
127 return NULL; | |
128 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
129 |
3139 | 130 renderer->DisplayModeChanged = gf_displaymodechanged; |
131 renderer->ActivateRenderer = gf_activaterenderer; | |
132 renderer->CreateTexture = gf_createtexture; | |
133 renderer->QueryTexturePixels = gf_querytexturepixels; | |
134 renderer->SetTexturePalette = gf_settexturepalette; | |
135 renderer->GetTexturePalette = gf_gettexturepalette; | |
136 renderer->UpdateTexture = gf_updatetexture; | |
137 renderer->LockTexture = gf_locktexture; | |
138 renderer->UnlockTexture = gf_unlocktexture; | |
139 renderer->DirtyTexture = gf_dirtytexture; | |
140 renderer->RenderPoint = gf_renderpoint; | |
141 renderer->RenderLine = gf_renderline; | |
142 renderer->RenderFill = gf_renderfill; | |
143 renderer->RenderCopy = gf_rendercopy; | |
144 renderer->RenderPresent = gf_renderpresent; | |
145 renderer->DestroyTexture = gf_destroytexture; | |
146 renderer->DestroyRenderer = gf_destroyrenderer; | |
147 renderer->info = gf_renderdriver.info; | |
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:
3500
diff
changeset
|
148 renderer->window = window; |
3139 | 149 renderer->driverdata = rdata; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
150 |
3139 | 151 /* Set render acceleration flag in case it is accelerated */ |
152 if ((didata->caps & SDL_GF_ACCELERATED) == SDL_GF_ACCELERATED) { | |
153 renderer->info.flags = SDL_RENDERER_ACCELERATED; | |
154 } else { | |
155 renderer->info.flags &= ~(SDL_RENDERER_ACCELERATED); | |
156 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
157 |
3139 | 158 rdata->window = window; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
159 |
3139 | 160 /* Check if upper level requested synchronization on vsync signal */ |
161 if ((flags & SDL_RENDERER_PRESENTVSYNC) == SDL_RENDERER_PRESENTVSYNC) { | |
162 rdata->enable_vsync = SDL_TRUE; | |
163 } else { | |
164 rdata->enable_vsync = SDL_FALSE; | |
165 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
166 |
3139 | 167 /* Check what buffer copy/flip scheme is requested */ |
168 rdata->surfaces_count = 0; | |
169 if ((flags & SDL_RENDERER_SINGLEBUFFER) == SDL_RENDERER_SINGLEBUFFER) { | |
170 if ((flags & SDL_RENDERER_PRESENTDISCARD) == | |
171 SDL_RENDERER_PRESENTDISCARD) { | |
172 renderer->info.flags |= | |
173 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD; | |
174 } else { | |
175 renderer->info.flags |= | |
176 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY; | |
177 } | |
178 rdata->surfaces_count = 1; | |
179 rdata->surface_visible_idx = 0; | |
180 rdata->surface_render_idx = 0; | |
181 } else { | |
182 if ((flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) { | |
183 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; | |
184 rdata->surfaces_count = 2; | |
185 rdata->surface_visible_idx = 0; | |
186 rdata->surface_render_idx = 1; | |
187 } else { | |
188 if ((flags & SDL_RENDERER_PRESENTFLIP3) == | |
189 SDL_RENDERER_PRESENTFLIP3) { | |
190 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; | |
191 rdata->surfaces_count = 3; | |
192 rdata->surface_visible_idx = 0; | |
193 rdata->surface_render_idx = 1; | |
194 } else { | |
195 renderer->info.flags |= | |
196 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY; | |
197 rdata->surfaces_count = 1; | |
198 rdata->surface_visible_idx = 0; | |
199 rdata->surface_render_idx = 0; | |
200 } | |
201 } | |
202 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
203 |
3139 | 204 /* Create layer surfaces, which could be visible */ |
205 for (it = 0; it < rdata->surfaces_count; it++) { | |
206 /* TODO: add palette creation */ | |
207 | |
208 /* Create displayable surfaces */ | |
209 status = | |
210 gf_surface_create_layer(&rdata->surface[it], &didata->layer, 1, 0, | |
211 didata->current_mode.w, | |
212 didata->current_mode.h, | |
213 qnxgf_sdl_to_gf_pixelformat(didata-> | |
214 current_mode. | |
215 format), NULL, | |
216 GF_SURFACE_CREATE_2D_ACCESSIBLE); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
217 |
3139 | 218 if (status != GF_ERR_OK) { |
219 /* Free already allocated surfaces */ | |
220 for (jt = it - 1; jt > 0; jt--) { | |
221 gf_surface_free(rdata->surface[jt]); | |
222 rdata->surface[jt] = NULL; | |
223 } | |
224 SDL_free(rdata); | |
225 SDL_free(renderer); | |
226 if (status == GF_ERR_MEM) { | |
227 SDL_SetError("unsufficient free video memory"); | |
228 } else { | |
229 SDL_SetError("error during displayable surface creation"); | |
230 } | |
231 return NULL; | |
232 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
233 |
3139 | 234 /* Get detailed information about allocated surface */ |
235 gf_surface_get_info(rdata->surface[it], &rdata->surface_info[it]); | |
236 } | |
237 | |
238 return renderer; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
239 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
240 |
3139 | 241 void |
242 gf_addrenderdriver(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
243 { |
3139 | 244 uint32_t it; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
245 |
3139 | 246 for (it = 0; it < _this->num_displays; it++) { |
3500
4b594623401b
Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
247 SDL_AddRenderDriver(&_this->displays[it], &gf_renderdriver); |
3139 | 248 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
249 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
250 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
251 /****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
252 /* SDL render interface */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
253 /****************************************************************************/ |
3139 | 254 static int |
255 gf_displaymodechanged(SDL_Renderer * renderer) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
256 { |
3139 | 257 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
258 |
3139 | 259 /* Remove all allocated surfaces, they are no more valid */ |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
260 |
3139 | 261 /* TODO: Add video mode change detection and new parameters detection */ |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
262 |
3139 | 263 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
264 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
265 |
3139 | 266 static int |
267 gf_activaterenderer(SDL_Renderer * renderer) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
268 { |
3139 | 269 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
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:
3500
diff
changeset
|
270 SDL_VideoDisplay *display = rdata->window->display; |
3139 | 271 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
272 |
3139 | 273 /* Setup current surface as visible */ |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
274 // gf_layer_set_surfaces(didata->layer, &rdata->surface[rdata->surface_visible_idx], 1); |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
275 |
3139 | 276 /* Set visible surface when hardware in idle state */ |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
277 // gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE); |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
278 |
3139 | 279 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
280 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
281 |
3139 | 282 static int |
283 gf_createtexture(SDL_Renderer * renderer, SDL_Texture * texture) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
284 { |
3139 | 285 SDL_RenderData *renderdata = (SDL_RenderData *) renderer->driverdata; |
286 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | |
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:
3500
diff
changeset
|
287 SDL_VideoDisplay *display = window->display; |
3139 | 288 SDL_TextureData *tdata = NULL; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
289 |
3139 | 290 /* Allocate texture driver data */ |
291 tdata = (SDL_TextureData *) SDL_calloc(1, sizeof(SDL_TextureData)); | |
292 if (tdata == NULL) { | |
293 SDL_OutOfMemory(); | |
294 return -1; | |
295 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
296 |
3139 | 297 /* Set texture driver data */ |
298 texture->driverdata = tdata; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
299 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
300 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
301 |
3139 | 302 static int |
303 gf_querytexturepixels(SDL_Renderer * renderer, SDL_Texture * texture, | |
304 void **pixels, int *pitch) | |
305 { | |
306 } | |
307 | |
308 static int | |
309 gf_settexturepalette(SDL_Renderer * renderer, SDL_Texture * texture, | |
310 const SDL_Color * colors, int firstcolor, int ncolors) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
311 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
312 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
313 |
3139 | 314 static int |
315 gf_gettexturepalette(SDL_Renderer * renderer, SDL_Texture * texture, | |
316 SDL_Color * colors, int firstcolor, int ncolors) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
317 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
318 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
319 |
3139 | 320 static int |
321 gf_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
322 const SDL_Rect * rect, const void *pixels, int pitch) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
323 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
324 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
325 |
3139 | 326 static int |
327 gf_locktexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
328 const SDL_Rect * rect, int markDirty, void **pixels, | |
329 int *pitch) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
330 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
331 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
332 |
3139 | 333 static void |
334 gf_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
335 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
336 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
337 |
3139 | 338 static void |
339 gf_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects, | |
340 const SDL_Rect * rects) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
341 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
342 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
343 |
3139 | 344 static int |
345 gf_renderpoint(SDL_Renderer * renderer, int x, int y) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
346 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
347 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
348 |
3139 | 349 static int |
350 gf_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
351 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
352 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
353 |
3139 | 354 static int |
355 gf_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
356 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
357 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
358 |
3139 | 359 static int |
360 gf_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture, | |
361 const SDL_Rect * srcrect, const SDL_Rect * dstrect) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
362 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
363 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
364 |
3139 | 365 static void |
366 gf_renderpresent(SDL_Renderer * renderer) | |
367 { | |
368 } | |
369 | |
370 static void | |
371 gf_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
372 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
373 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
374 |
3139 | 375 static void |
376 gf_destroyrenderer(SDL_Renderer * renderer) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
377 { |
3139 | 378 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
379 uint32_t it; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
380 |
3139 | 381 for (it = 0; it < rdata->surfaces_count; it++) { |
382 if (rdata->surface[it] != NULL) { | |
383 gf_surface_free(rdata->surface[it]); | |
384 } | |
385 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
386 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
387 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
388 /* vi: set ts=4 sw=4 expandtab: */ |