annotate src/video/ps3/SDL_ps3render.c @ 3141:3df74541339b gsoc2009_ps3

Added ps3 video driver based on the dummy driver. Added spulib for copying to framebuffer. Added SPU managing functions. Added open/close and taking control of the framebuffer.
author Martin Lowinski <martin@goldtopf.org>
date Fri, 29 May 2009 09:50:21 +0000
parents
children c146645a770e
rev   line source
3141
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
1 /*
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
4
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
9
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
13 Lesser General Public License for more details.
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
14
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
18
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
19 Sam Lantinga
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
20 slouken@libsdl.org
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
21 */
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
22 #include "SDL_config.h"
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
23
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
24 #include "SDL_video.h"
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
25 #include "../SDL_sysvideo.h"
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
26 #include "../SDL_yuv_sw_c.h"
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
27 #include "../SDL_renderer_sw.h"
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
28
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
29 /* Debugging
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
30 * 0: No debug messages
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
31 * 1: Video debug messages
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
32 * 2: SPE debug messages
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
33 * 3: Memory adresses
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
34 */
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
35 #define DEBUG_LEVEL 2
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
36
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
37 #ifdef DEBUG_LEVEL
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
38 #define deprintf( level, fmt, args... ) \
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
39 do \
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
40 { \
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
41 if ( (unsigned)(level) <= DEBUG_LEVEL ) \
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
42 { \
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
43 fprintf( stdout, fmt, ##args ); \
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
44 fflush( stdout ); \
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
45 } \
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
46 } while ( 0 )
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
47 #else
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
48 #define deprintf( level, fmt, args... )
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
49 #endif
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
50
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
51 /* SDL surface based renderer implementation */
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
52
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
53 static SDL_Renderer *SDL_PS3_CreateRenderer(SDL_Window * window,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
54 Uint32 flags);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
55 static int SDL_PS3_RenderPoint(SDL_Renderer * renderer, int x, int y);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
56 static int SDL_PS3_RenderLine(SDL_Renderer * renderer, int x1, int y1,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
57 int x2, int y2);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
58 static int SDL_PS3_RenderFill(SDL_Renderer * renderer,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
59 const SDL_Rect * rect);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
60 static int SDL_PS3_RenderCopy(SDL_Renderer * renderer,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
61 SDL_Texture * texture,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
62 const SDL_Rect * srcrect,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
63 const SDL_Rect * dstrect);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
64 static void SDL_PS3_RenderPresent(SDL_Renderer * renderer);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
65 static void SDL_PS3_DestroyRenderer(SDL_Renderer * renderer);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
66
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
67
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
68 SDL_RenderDriver SDL_PS3_RenderDriver = {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
69 SDL_PS3_CreateRenderer,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
70 {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
71 "ps3",
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
72 (/*SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |*/
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
73 SDL_RENDERER_PRESENTFLIP2 /*| SDL_RENDERER_PRESENTFLIP3 |
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
74 SDL_RENDERER_PRESENTDISCARD*/),
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
75 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
76 };
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
77
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
78 typedef struct
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
79 {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
80 int current_screen;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
81 SDL_Surface *screens[3];
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
82 } SDL_PS3_RenderData;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
83
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
84 SDL_Renderer *
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
85 SDL_PS3_CreateRenderer(SDL_Window * window, Uint32 flags)
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
86 {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
87 deprintf(1, "SDL_PS3_CreateRenderer()\n");
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
88 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
89 SDL_DisplayMode *displayMode = &display->current_mode;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
90 SDL_Renderer *renderer;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
91 SDL_PS3_RenderData *data;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
92 int i, n;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
93 int bpp;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
94 Uint32 Rmask, Gmask, Bmask, Amask;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
95
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
96 if (!SDL_PixelFormatEnumToMasks
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
97 (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
98 SDL_SetError("Unknown display format");
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
99 return NULL;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
100 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
101
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
102 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
103 if (!renderer) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
104 SDL_OutOfMemory();
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
105 return NULL;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
106 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
107
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
108 data = (SDL_PS3_RenderData *) SDL_malloc(sizeof(*data));
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
109 if (!data) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
110 SDL_PS3_DestroyRenderer(renderer);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
111 SDL_OutOfMemory();
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
112 return NULL;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
113 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
114 SDL_zerop(data);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
115
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
116 renderer->RenderPoint = SDL_PS3_RenderPoint;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
117 renderer->RenderLine = SDL_PS3_RenderLine;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
118 renderer->RenderFill = SDL_PS3_RenderFill;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
119 renderer->RenderCopy = SDL_PS3_RenderCopy;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
120 renderer->RenderPresent = SDL_PS3_RenderPresent;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
121 renderer->DestroyRenderer = SDL_PS3_DestroyRenderer;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
122 renderer->info.name = SDL_PS3_RenderDriver.info.name;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
123 renderer->info.flags = 0;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
124 renderer->window = window->id;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
125 renderer->driverdata = data;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
126 Setup_SoftwareRenderer(renderer);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
127
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
128 if (flags & SDL_RENDERER_PRESENTFLIP2) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
129 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
130 n = 2;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
131 } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
132 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
133 n = 3;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
134 } else {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
135 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
136 n = 1;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
137 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
138 for (i = 0; i < n; ++i) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
139 data->screens[i] =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
140 SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
141 Bmask, Amask);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
142 if (!data->screens[i]) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
143 SDL_PS3_DestroyRenderer(renderer);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
144 return NULL;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
145 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
146 /* Allocate aligned memory for pixels */
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
147 SDL_free(data->screens[i]->pixels);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
148 data->screens[i]->pixels = (void *)memalign(16, data->screens[i]->h * data->screens[i]->pitch);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
149 if (!data->screens[i]->pixels) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
150 SDL_FreeSurface(data->screens[i]);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
151 SDL_OutOfMemory();
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
152 return NULL;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
153 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
154 SDL_memset(data->screens[i]->pixels, 0, data->screens[i]->h * data->screens[i]->pitch);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
155 SDL_SetSurfacePalette(data->screens[i], display->palette);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
156 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
157 data->current_screen = 0;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
158
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
159 return renderer;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
160 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
161
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
162 static int
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
163 SDL_PS3_RenderPoint(SDL_Renderer * renderer, int x, int y)
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
164 {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
165 SDL_PS3_RenderData *data =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
166 (SDL_PS3_RenderData *) renderer->driverdata;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
167 SDL_Surface *target = data->screens[data->current_screen];
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
168 int status;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
169
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
170 if (renderer->blendMode == SDL_BLENDMODE_NONE ||
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
171 renderer->blendMode == SDL_BLENDMODE_MASK) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
172 Uint32 color =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
173 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
174 renderer->a);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
175
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
176 status = SDL_DrawPoint(target, x, y, color);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
177 } else {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
178 status =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
179 SDL_BlendPoint(target, x, y, renderer->blendMode, renderer->r,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
180 renderer->g, renderer->b, renderer->a);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
181 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
182 return status;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
183 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
184
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
185 static int
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
186 SDL_PS3_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
187 {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
188 SDL_PS3_RenderData *data =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
189 (SDL_PS3_RenderData *) renderer->driverdata;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
190 SDL_Surface *target = data->screens[data->current_screen];
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
191 int status;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
192
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
193 if (renderer->blendMode == SDL_BLENDMODE_NONE ||
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
194 renderer->blendMode == SDL_BLENDMODE_MASK) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
195 Uint32 color =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
196 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
197 renderer->a);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
198
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
199 status = SDL_DrawLine(target, x1, y1, x2, y2, color);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
200 } else {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
201 status =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
202 SDL_BlendLine(target, x1, y1, x2, y2, renderer->blendMode,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
203 renderer->r, renderer->g, renderer->b, renderer->a);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
204 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
205 return status;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
206 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
207
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
208 static int
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
209 SDL_PS3_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
210 {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
211 deprintf(1, "SDL_PS3_RenderFill()\n");
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
212 SDL_PS3_RenderData *data =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
213 (SDL_PS3_RenderData *) renderer->driverdata;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
214 SDL_Surface *target = data->screens[data->current_screen];
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
215 SDL_Rect real_rect = *rect;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
216 int status;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
217
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
218 if (renderer->blendMode == SDL_BLENDMODE_NONE) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
219 Uint32 color =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
220 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
221 renderer->a);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
222
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
223 status = SDL_FillRect(target, &real_rect, color);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
224 } else {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
225 status =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
226 SDL_BlendRect(target, &real_rect, renderer->blendMode,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
227 renderer->r, renderer->g, renderer->b, renderer->a);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
228 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
229 return status;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
230 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
231
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
232 static int
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
233 SDL_PS3_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
234 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
235 {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
236 deprintf(1, "SDL_PS3_RenderCopy()\n");
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
237 SDL_PS3_RenderData *data =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
238 (SDL_PS3_RenderData *) renderer->driverdata;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
239 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
240 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
241
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
242 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
243 SDL_Surface *target = data->screens[data->current_screen];
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
244 void *pixels =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
245 (Uint8 *) target->pixels + dstrect->y * target->pitch +
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
246 dstrect->x * target->format->BytesPerPixel;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
247 return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
248 srcrect, display->current_mode.format,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
249 dstrect->w, dstrect->h, pixels,
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
250 target->pitch);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
251 } else {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
252 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
253 SDL_Surface *target = data->screens[data->current_screen];
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
254 SDL_Rect real_srcrect = *srcrect;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
255 SDL_Rect real_dstrect = *dstrect;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
256
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
257 return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
258 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
259 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
260
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
261 static void
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
262 SDL_PS3_RenderPresent(SDL_Renderer * renderer)
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
263 {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
264 deprintf(1, "SDL_PS3_RenderPresent()\n");
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
265 static int frame_number;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
266 SDL_PS3_RenderData *data =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
267 (SDL_PS3_RenderData *) renderer->driverdata;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
268
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
269 /* Send the data to the display */
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
270 if (SDL_getenv("SDL_VIDEO_PS3_SAVE_FRAMES")) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
271 char file[128];
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
272 SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
273 renderer->window, ++frame_number);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
274 SDL_SaveBMP(data->screens[data->current_screen], file);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
275 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
276
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
277 /* Update the flipping chain, if any */
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
278 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
279 data->current_screen = (data->current_screen + 1) % 2;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
280 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
281 data->current_screen = (data->current_screen + 1) % 3;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
282 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
283
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
284 /* How to access the framebuffer from here?
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
285 unsigned long crt = 0;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
286 unsigned int s_center_index = 0;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
287 unsigned int * s_center[2];
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
288 s_center[0] = frame_buffer;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
289 // Wait for vsync
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
290 deprintf(1, "[PS3] Wait for vsync\n");
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
291 ioctl(fbdev, FBIO_WAITFORVSYNC, &crt);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
292 // Page flip
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
293 deprintf(1, "[PS3] Page flip to buffer #%u 0x%x\n", s_center_index, s_center[s_center_index]);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
294 ioctl(fbdev, PS3FB_IOCTL_FSEL, (unsigned long)&s_center_index);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
295 */
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
296 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
297
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
298 static void
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
299 SDL_PS3_DestroyRenderer(SDL_Renderer * renderer)
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
300 {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
301 deprintf(1, "SDL_PS3_DestroyRenderer()\n");
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
302 SDL_PS3_RenderData *data =
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
303 (SDL_PS3_RenderData *) renderer->driverdata;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
304 int i;
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
305
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
306 if (data) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
307 for (i = 0; i < SDL_arraysize(data->screens); ++i) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
308 if (data->screens[i]) {
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
309 SDL_FreeSurface(data->screens[i]);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
310 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
311 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
312 SDL_free(data);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
313 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
314 SDL_free(renderer);
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
315 }
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
316
3df74541339b Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
317 /* vi: set ts=4 sw=4 expandtab: */