comparison src/video/SDL_renderer_sw.c @ 1970:db3ba6c0d0df

Allow the render context to do necessary work when the video mode changes.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 06 Aug 2006 04:39:13 +0000
parents a788656ca29a
children 5432b63cc919
comparison
equal deleted inserted replaced
1969:5d3724f64f2b 1970:db3ba6c0d0df
29 29
30 30
31 /* SDL surface based renderer implementation */ 31 /* SDL surface based renderer implementation */
32 32
33 static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags); 33 static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags);
34 static int SW_ActivateRenderer(SDL_Renderer * renderer);
35 static int SW_DisplayModeChanged(SDL_Renderer * renderer);
34 static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); 36 static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
35 static int SW_QueryTexturePixels(SDL_Renderer * renderer, 37 static int SW_QueryTexturePixels(SDL_Renderer * renderer,
36 SDL_Texture * texture, void **pixels, 38 SDL_Texture * texture, void **pixels,
37 int *pitch); 39 int *pitch);
38 static int SW_SetTexturePalette(SDL_Renderer * renderer, 40 static int SW_SetTexturePalette(SDL_Renderer * renderer,
177 if (!data) { 179 if (!data) {
178 SW_DestroyRenderer(renderer); 180 SW_DestroyRenderer(renderer);
179 SDL_OutOfMemory(); 181 SDL_OutOfMemory();
180 return NULL; 182 return NULL;
181 } 183 }
182 184 renderer->ActivateRenderer = SW_ActivateRenderer;
185 renderer->DisplayModeChanged = SW_DisplayModeChanged;
183 renderer->CreateTexture = SW_CreateTexture; 186 renderer->CreateTexture = SW_CreateTexture;
184 renderer->QueryTexturePixels = SW_QueryTexturePixels; 187 renderer->QueryTexturePixels = SW_QueryTexturePixels;
185 renderer->SetTexturePalette = SW_SetTexturePalette; 188 renderer->SetTexturePalette = SW_SetTexturePalette;
186 renderer->GetTexturePalette = SW_GetTexturePalette; 189 renderer->GetTexturePalette = SW_GetTexturePalette;
187 renderer->UpdateTexture = SW_UpdateTexture; 190 renderer->UpdateTexture = SW_UpdateTexture;
268 271
269 return renderer; 272 return renderer;
270 } 273 }
271 274
272 static int 275 static int
276 SW_ActivateRenderer(SDL_Renderer * renderer)
277 {
278 SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
279
280 if (data->renderer && data->renderer->ActivateRenderer) {
281 if (data->renderer->ActivateRenderer(data->renderer) < 0) {
282 return -1;
283 }
284 }
285 return 0;
286 }
287
288 static int
289 SW_DisplayModeChanged(SDL_Renderer * renderer)
290 {
291 SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
292
293 if (data->renderer && data->renderer->DisplayModeChanged) {
294 if (data->renderer->DisplayModeChanged(data->renderer) < 0) {
295 return -1;
296 }
297 }
298 return 0;
299 }
300
301 static int
273 SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) 302 SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
274 { 303 {
275 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { 304 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
276 texture->driverdata = SDL_SW_CreateYUVTexture(texture); 305 texture->driverdata = SDL_SW_CreateYUVTexture(texture);
277 } else { 306 } else {