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