Mercurial > sdl-ios-xcode
annotate src/video/qnxgf/SDL_gf_render.c @ 3345:437378d409b1
Split out ltoptions.m4
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 04 Oct 2009 21:00:33 +0000 |
parents | 7f684f249ec9 |
children | 4b594623401b |
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 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2009 Sam Lantinga |
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_settexturecolormod(SDL_Renderer * renderer, | |
52 SDL_Texture * texture); | |
53 static int gf_settexturealphamod(SDL_Renderer * renderer, | |
54 SDL_Texture * texture); | |
55 static int gf_settextureblendmode(SDL_Renderer * renderer, | |
56 SDL_Texture * texture); | |
57 static int gf_settexturescalemode(SDL_Renderer * renderer, | |
58 SDL_Texture * texture); | |
59 static int gf_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
60 const SDL_Rect * rect, const void *pixels, | |
61 int pitch); | |
62 static int gf_locktexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
63 const SDL_Rect * rect, int markDirty, void **pixels, | |
64 int *pitch); | |
65 static void gf_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture); | |
66 static void gf_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
67 int numrects, const SDL_Rect * rects); | |
68 static int gf_renderpoint(SDL_Renderer * renderer, int x, int y); | |
69 static int gf_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, | |
70 int y2); | |
71 static int gf_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect); | |
72 static int gf_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture, | |
73 const SDL_Rect * srcrect, const SDL_Rect * dstrect); | |
74 static void gf_renderpresent(SDL_Renderer * renderer); | |
75 static void gf_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture); | |
76 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
|
77 |
3139 | 78 SDL_RenderDriver gf_renderdriver = { |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
79 gf_createrenderer, |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 { |
3139 | 81 "qnxgf", |
82 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | | |
83 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | | |
84 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD | | |
85 SDL_RENDERER_ACCELERATED), | |
86 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | | |
87 SDL_TEXTUREMODULATE_ALPHA), | |
88 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | | |
89 SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), | |
90 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW), | |
91 13, | |
92 { | |
93 SDL_PIXELFORMAT_INDEX8, | |
94 SDL_PIXELFORMAT_RGB555, | |
95 SDL_PIXELFORMAT_RGB565, | |
96 SDL_PIXELFORMAT_RGB888, | |
97 SDL_PIXELFORMAT_BGR888, | |
98 SDL_PIXELFORMAT_ARGB8888, | |
99 SDL_PIXELFORMAT_RGBA8888, | |
100 SDL_PIXELFORMAT_ABGR8888, | |
101 SDL_PIXELFORMAT_BGRA8888, | |
102 SDL_PIXELFORMAT_YV12, | |
103 SDL_PIXELFORMAT_YUY2, | |
104 SDL_PIXELFORMAT_UYVY, | |
105 SDL_PIXELFORMAT_YVYU}, | |
106 0, | |
107 0} | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 }; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
109 |
3139 | 110 static SDL_Renderer * |
111 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
|
112 { |
3139 | 113 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
114 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; | |
115 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
116 SDL_Renderer *renderer = NULL; | |
117 SDL_RenderData *rdata = NULL; | |
118 uint32_t it; | |
119 int32_t jt; | |
120 int32_t status; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
121 |
3139 | 122 /* Check if it is OpenGL ES window */ |
123 if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) { | |
124 /* No error, just no need to create 2D renderer for OpenGL ES window */ | |
125 return NULL; | |
126 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
127 |
3139 | 128 /* Allocate new renderer structure */ |
129 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(SDL_Renderer)); | |
130 if (renderer == NULL) { | |
131 SDL_OutOfMemory(); | |
132 return NULL; | |
133 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
134 |
3139 | 135 /* Allocate renderer data */ |
136 rdata = (SDL_RenderData *) SDL_calloc(1, sizeof(SDL_RenderData)); | |
137 if (rdata == NULL) { | |
138 SDL_free(renderer); | |
139 SDL_OutOfMemory(); | |
140 return NULL; | |
141 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
142 |
3139 | 143 renderer->DisplayModeChanged = gf_displaymodechanged; |
144 renderer->ActivateRenderer = gf_activaterenderer; | |
145 renderer->CreateTexture = gf_createtexture; | |
146 renderer->QueryTexturePixels = gf_querytexturepixels; | |
147 renderer->SetTexturePalette = gf_settexturepalette; | |
148 renderer->GetTexturePalette = gf_gettexturepalette; | |
149 renderer->SetTextureAlphaMod = gf_settexturealphamod; | |
150 renderer->SetTextureColorMod = gf_settexturecolormod; | |
151 renderer->SetTextureBlendMode = gf_settextureblendmode; | |
152 renderer->SetTextureScaleMode = gf_settexturescalemode; | |
153 renderer->UpdateTexture = gf_updatetexture; | |
154 renderer->LockTexture = gf_locktexture; | |
155 renderer->UnlockTexture = gf_unlocktexture; | |
156 renderer->DirtyTexture = gf_dirtytexture; | |
157 renderer->RenderPoint = gf_renderpoint; | |
158 renderer->RenderLine = gf_renderline; | |
159 renderer->RenderFill = gf_renderfill; | |
160 renderer->RenderCopy = gf_rendercopy; | |
161 renderer->RenderPresent = gf_renderpresent; | |
162 renderer->DestroyTexture = gf_destroytexture; | |
163 renderer->DestroyRenderer = gf_destroyrenderer; | |
164 renderer->info = gf_renderdriver.info; | |
165 renderer->window = window->id; | |
166 renderer->driverdata = rdata; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
167 |
3139 | 168 /* Set render acceleration flag in case it is accelerated */ |
169 if ((didata->caps & SDL_GF_ACCELERATED) == SDL_GF_ACCELERATED) { | |
170 renderer->info.flags = SDL_RENDERER_ACCELERATED; | |
171 } else { | |
172 renderer->info.flags &= ~(SDL_RENDERER_ACCELERATED); | |
173 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
174 |
3139 | 175 rdata->window = window; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
176 |
3139 | 177 /* Check if upper level requested synchronization on vsync signal */ |
178 if ((flags & SDL_RENDERER_PRESENTVSYNC) == SDL_RENDERER_PRESENTVSYNC) { | |
179 rdata->enable_vsync = SDL_TRUE; | |
180 } else { | |
181 rdata->enable_vsync = SDL_FALSE; | |
182 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
183 |
3139 | 184 /* Check what buffer copy/flip scheme is requested */ |
185 rdata->surfaces_count = 0; | |
186 if ((flags & SDL_RENDERER_SINGLEBUFFER) == SDL_RENDERER_SINGLEBUFFER) { | |
187 if ((flags & SDL_RENDERER_PRESENTDISCARD) == | |
188 SDL_RENDERER_PRESENTDISCARD) { | |
189 renderer->info.flags |= | |
190 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD; | |
191 } else { | |
192 renderer->info.flags |= | |
193 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY; | |
194 } | |
195 rdata->surfaces_count = 1; | |
196 rdata->surface_visible_idx = 0; | |
197 rdata->surface_render_idx = 0; | |
198 } else { | |
199 if ((flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) { | |
200 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; | |
201 rdata->surfaces_count = 2; | |
202 rdata->surface_visible_idx = 0; | |
203 rdata->surface_render_idx = 1; | |
204 } else { | |
205 if ((flags & SDL_RENDERER_PRESENTFLIP3) == | |
206 SDL_RENDERER_PRESENTFLIP3) { | |
207 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; | |
208 rdata->surfaces_count = 3; | |
209 rdata->surface_visible_idx = 0; | |
210 rdata->surface_render_idx = 1; | |
211 } else { | |
212 renderer->info.flags |= | |
213 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY; | |
214 rdata->surfaces_count = 1; | |
215 rdata->surface_visible_idx = 0; | |
216 rdata->surface_render_idx = 0; | |
217 } | |
218 } | |
219 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
220 |
3139 | 221 /* Create layer surfaces, which could be visible */ |
222 for (it = 0; it < rdata->surfaces_count; it++) { | |
223 /* TODO: add palette creation */ | |
224 | |
225 /* Create displayable surfaces */ | |
226 status = | |
227 gf_surface_create_layer(&rdata->surface[it], &didata->layer, 1, 0, | |
228 didata->current_mode.w, | |
229 didata->current_mode.h, | |
230 qnxgf_sdl_to_gf_pixelformat(didata-> | |
231 current_mode. | |
232 format), NULL, | |
233 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
|
234 |
3139 | 235 if (status != GF_ERR_OK) { |
236 /* Free already allocated surfaces */ | |
237 for (jt = it - 1; jt > 0; jt--) { | |
238 gf_surface_free(rdata->surface[jt]); | |
239 rdata->surface[jt] = NULL; | |
240 } | |
241 SDL_free(rdata); | |
242 SDL_free(renderer); | |
243 if (status == GF_ERR_MEM) { | |
244 SDL_SetError("unsufficient free video memory"); | |
245 } else { | |
246 SDL_SetError("error during displayable surface creation"); | |
247 } | |
248 return NULL; | |
249 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
250 |
3139 | 251 /* Get detailed information about allocated surface */ |
252 gf_surface_get_info(rdata->surface[it], &rdata->surface_info[it]); | |
253 } | |
254 | |
255 return renderer; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
256 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
257 |
3139 | 258 void |
259 gf_addrenderdriver(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
260 { |
3139 | 261 uint32_t it; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
262 |
3139 | 263 for (it = 0; it < _this->num_displays; it++) { |
264 SDL_AddRenderDriver(it, &gf_renderdriver); | |
265 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
266 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
267 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
268 /****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
269 /* SDL render interface */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
270 /****************************************************************************/ |
3139 | 271 static int |
272 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
|
273 { |
3139 | 274 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
|
275 |
3139 | 276 /* 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
|
277 |
3139 | 278 /* 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
|
279 |
3139 | 280 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
281 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
282 |
3139 | 283 static int |
284 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
|
285 { |
3139 | 286 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
287 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(rdata->window); | |
288 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
|
289 |
3139 | 290 /* 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
|
291 // 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
|
292 |
3139 | 293 /* 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
|
294 // 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
|
295 |
3139 | 296 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
297 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
298 |
3139 | 299 static int |
300 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
|
301 { |
3139 | 302 SDL_RenderData *renderdata = (SDL_RenderData *) renderer->driverdata; |
303 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | |
304 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); | |
305 SDL_TextureData *tdata = NULL; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
306 |
3139 | 307 /* Allocate texture driver data */ |
308 tdata = (SDL_TextureData *) SDL_calloc(1, sizeof(SDL_TextureData)); | |
309 if (tdata == NULL) { | |
310 SDL_OutOfMemory(); | |
311 return -1; | |
312 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
313 |
3139 | 314 /* Set texture driver data */ |
315 texture->driverdata = tdata; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
316 |
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 |
3139 | 319 static int |
320 gf_querytexturepixels(SDL_Renderer * renderer, SDL_Texture * texture, | |
321 void **pixels, int *pitch) | |
322 { | |
323 } | |
324 | |
325 static int | |
326 gf_settexturepalette(SDL_Renderer * renderer, SDL_Texture * texture, | |
327 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
|
328 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
329 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
330 |
3139 | 331 static int |
332 gf_gettexturepalette(SDL_Renderer * renderer, SDL_Texture * texture, | |
333 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
|
334 { |
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 |
3139 | 337 static int |
338 gf_settexturecolormod(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
|
339 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
340 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
341 |
3139 | 342 static int |
343 gf_settexturealphamod(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
|
344 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
345 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
346 |
3139 | 347 static int |
348 gf_settextureblendmode(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
|
349 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
350 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
351 |
3139 | 352 static int |
353 gf_settexturescalemode(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
|
354 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
355 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
356 |
3139 | 357 static int |
358 gf_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
359 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
|
360 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
361 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
362 |
3139 | 363 static int |
364 gf_locktexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
365 const SDL_Rect * rect, int markDirty, void **pixels, | |
366 int *pitch) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
367 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
368 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
369 |
3139 | 370 static void |
371 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
|
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_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects, | |
377 const SDL_Rect * rects) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
378 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
379 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
380 |
3139 | 381 static int |
382 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
|
383 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
384 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
385 |
3139 | 386 static int |
387 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
|
388 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
389 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
390 |
3139 | 391 static int |
392 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
|
393 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
394 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
395 |
3139 | 396 static int |
397 gf_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture, | |
398 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
|
399 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
400 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
401 |
3139 | 402 static void |
403 gf_renderpresent(SDL_Renderer * renderer) | |
404 { | |
405 } | |
406 | |
407 static void | |
408 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
|
409 { |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
410 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
411 |
3139 | 412 static void |
413 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
|
414 { |
3139 | 415 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
416 uint32_t it; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
417 |
3139 | 418 for (it = 0; it < rdata->surfaces_count; it++) { |
419 if (rdata->surface[it] != NULL) { | |
420 gf_surface_free(rdata->surface[it]); | |
421 } | |
422 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
423 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
424 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
425 /* vi: set ts=4 sw=4 expandtab: */ |