Mercurial > sdl-ios-xcode
annotate src/video/ps3/SDL_ps3render.c @ 3142:c146645a770e gsoc2009_ps3
Roughly working framebuffer.
author | Martin Lowinski <martin@goldtopf.org> |
---|---|
date | Thu, 04 Jun 2009 07:02:15 +0000 |
parents | 3df74541339b |
children | 8fdabaa064c3 |
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 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
29 #include "SDL_ps3video.h" |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
30 #include "spulibs/spu_common.h" |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
31 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
32 #include <fcntl.h> |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
33 #include <stdlib.h> |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
34 #include <sys/ioctl.h> |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
35 #include <linux/kd.h> |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
36 #include <linux/fb.h> |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
37 #include <sys/mman.h> |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
38 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
39 #include <asm/ps3fb.h> |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
40 |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
41 /* Debugging |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
42 * 0: No debug messages |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
43 * 1: Video debug messages |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
44 * 2: SPE debug messages |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
45 * 3: Memory adresses |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
46 */ |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
47 #define DEBUG_LEVEL 2 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
48 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
49 #ifdef DEBUG_LEVEL |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
50 #define deprintf( level, fmt, args... ) \ |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
51 do \ |
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 if ( (unsigned)(level) <= DEBUG_LEVEL ) \ |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
54 { \ |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
55 fprintf( stdout, fmt, ##args ); \ |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
56 fflush( stdout ); \ |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
57 } \ |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
58 } while ( 0 ) |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
59 #else |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
60 #define deprintf( level, fmt, args... ) |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
61 #endif |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
62 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
63 /* SDL surface based renderer implementation */ |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
64 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
65 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
|
66 Uint32 flags); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
67 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
|
68 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
|
69 int x2, int y2); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
70 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
|
71 const SDL_Rect * rect); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
72 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
|
73 SDL_Texture * texture, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
74 const SDL_Rect * srcrect, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
75 const SDL_Rect * dstrect); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
76 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
|
77 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
|
78 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
79 /* Texture */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
80 static int PS3_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
81 static void PS3_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
82 |
3141
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_RenderDriver SDL_PS3_RenderDriver = { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
85 SDL_PS3_CreateRenderer, |
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 "ps3", |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
88 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTVSYNC | |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
89 SDL_RENDERER_PRESENTFLIP2) |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
90 /* (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
91 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
92 SDL_RENDERER_PRESENTDISCARD) */, |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
93 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
94 }; |
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 typedef struct |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
97 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
98 int current_screen; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
99 SDL_Surface *screens[3]; |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
100 SDL_VideoDisplay *display; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
101 uint8_t *center[2]; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
102 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
103 /* width of input (bounded by writeable width) */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
104 unsigned int bounded_width; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
105 /* height of input (bounded by writeable height) */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
106 unsigned int bounded_height; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
107 /* offset from the left side (used for centering) */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
108 unsigned int offset_left; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
109 /* offset from the upper side (used for centering) */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
110 unsigned int offset_top; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
111 /* width of screen which is writeable */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
112 unsigned int wr_width; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
113 /* width of screen which is writeable */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
114 unsigned int wr_height; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
115 /* size of a screen line: width * bpp/8 */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
116 unsigned int line_length; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
117 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
118 /* Use two buffers in fb? res < 720p */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
119 unsigned int double_buffering; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
120 } SDL_PS3_RenderData; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
121 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
122 typedef struct |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
123 { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
124 void *pixels; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
125 int pitch; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
126 int bpp; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
127 } PS3_TextureData; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
128 |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
129 SDL_Renderer * |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
130 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
|
131 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
132 deprintf(1, "SDL_PS3_CreateRenderer()\n"); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
133 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
134 SDL_DisplayMode *displayMode = &display->current_mode; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
135 SDL_Renderer *renderer; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
136 SDL_PS3_RenderData *data; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
137 int i, n; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
138 int bpp; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
139 Uint32 Rmask, Gmask, Bmask, Amask; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
140 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
141 if (!SDL_PixelFormatEnumToMasks |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
142 (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
|
143 SDL_SetError("Unknown display format"); |
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 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
147 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
|
148 if (!renderer) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
149 SDL_OutOfMemory(); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
150 return NULL; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
151 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
152 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
153 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
|
154 if (!data) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
155 SDL_PS3_DestroyRenderer(renderer); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
156 SDL_OutOfMemory(); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
157 return NULL; |
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 SDL_zerop(data); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
160 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
161 renderer->CreateTexture = PS3_CreateTexture; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
162 renderer->DestroyTexture = PS3_DestroyTexture; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
163 renderer->RenderPoint = SDL_PS3_RenderPoint; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
164 renderer->RenderLine = SDL_PS3_RenderLine; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
165 renderer->RenderFill = SDL_PS3_RenderFill; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
166 renderer->RenderCopy = SDL_PS3_RenderCopy; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
167 renderer->RenderPresent = SDL_PS3_RenderPresent; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
168 renderer->DestroyRenderer = SDL_PS3_DestroyRenderer; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
169 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
|
170 renderer->info.flags = 0; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
171 renderer->window = window->id; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
172 renderer->driverdata = data; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
173 Setup_SoftwareRenderer(renderer); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
174 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
175 data->double_buffering = 0; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
176 |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
177 if (flags & SDL_RENDERER_PRESENTFLIP2) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
178 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
179 n = 2; |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
180 data->double_buffering = 1; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
181 } else { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
182 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
183 n = 1; |
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 for (i = 0; i < n; ++i) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
186 data->screens[i] = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
187 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
|
188 Bmask, Amask); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
189 if (!data->screens[i]) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
190 SDL_PS3_DestroyRenderer(renderer); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
191 return NULL; |
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 /* Allocate aligned memory for pixels */ |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
194 SDL_free(data->screens[i]->pixels); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
195 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
|
196 if (!data->screens[i]->pixels) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
197 SDL_FreeSurface(data->screens[i]); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
198 SDL_OutOfMemory(); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
199 return NULL; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
200 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
201 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
|
202 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
|
203 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
204 data->current_screen = 0; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
205 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
206 return renderer; |
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 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
209 static int |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
210 PS3_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
211 deprintf(1, "PS3_CreateTexture()\n"); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
212 PS3_TextureData *data; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
213 data = (PS3_TextureData *) SDL_calloc(1, sizeof(*data)); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
214 if (!data) { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
215 SDL_OutOfMemory(); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
216 return -1; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
217 } |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
218 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
219 data->pitch = (texture->w * SDL_BYTESPERPIXEL(texture->format)); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
220 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
221 data->pixels = NULL; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
222 data->pixels = (void *)memalign(16, texture->h * data->pitch); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
223 if (!data->pixels) { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
224 PS3_DestroyTexture(renderer, texture); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
225 SDL_OutOfMemory(); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
226 return -1; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
227 } |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
228 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
229 texture->driverdata = data; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
230 return 0; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
231 } |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
232 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
233 static void |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
234 PS3_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
235 { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
236 PS3_TextureData *data = (PS3_TextureData *) texture->driverdata; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
237 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
238 if (!data) { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
239 return; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
240 } |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
241 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
242 free(data->pixels); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
243 } |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
244 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
245 static int |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
246 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
|
247 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
248 SDL_PS3_RenderData *data = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
249 (SDL_PS3_RenderData *) renderer->driverdata; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
250 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
|
251 int status; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
252 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
253 if (renderer->blendMode == SDL_BLENDMODE_NONE || |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
254 renderer->blendMode == SDL_BLENDMODE_MASK) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
255 Uint32 color = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
256 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
|
257 renderer->a); |
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 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
|
260 } else { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
261 status = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
262 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
|
263 renderer->g, renderer->b, renderer->a); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
264 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
265 return status; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
266 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
267 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
268 static int |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
269 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
|
270 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
271 SDL_PS3_RenderData *data = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
272 (SDL_PS3_RenderData *) renderer->driverdata; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
273 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
|
274 int status; |
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 if (renderer->blendMode == SDL_BLENDMODE_NONE || |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
277 renderer->blendMode == SDL_BLENDMODE_MASK) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
278 Uint32 color = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
279 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
|
280 renderer->a); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
281 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
282 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
|
283 } else { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
284 status = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
285 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
|
286 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
|
287 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
288 return status; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
289 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
290 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
291 static int |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
292 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
|
293 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
294 deprintf(1, "SDL_PS3_RenderFill()\n"); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
295 SDL_PS3_RenderData *data = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
296 (SDL_PS3_RenderData *) renderer->driverdata; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
297 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
|
298 SDL_Rect real_rect = *rect; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
299 int status; |
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 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
302 Uint32 color = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
303 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
|
304 renderer->a); |
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 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
|
307 } else { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
308 status = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
309 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
|
310 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
|
311 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
312 return status; |
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 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
315 static int |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
316 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
|
317 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
|
318 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
319 deprintf(1, "SDL_PS3_RenderCopy()\n"); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
320 SDL_PS3_RenderData *data = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
321 (SDL_PS3_RenderData *) renderer->driverdata; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
322 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
|
323 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
324 PS3_TextureData *txdata = (PS3_TextureData *) texture->driverdata; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
325 SDL_VideoData *devdata = display->device->driverdata; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
326 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
327 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
328 deprintf(1, "SDL_ISPIXELFORMAT_FOURCC = true\n"); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
329 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
|
330 void *pixels = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
331 (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
|
332 dstrect->x * target->format->BytesPerPixel; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
333 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
|
334 srcrect, display->current_mode.format, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
335 dstrect->w, dstrect->h, pixels, |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
336 target->pitch); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
337 } else { |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
338 deprintf(1, "SDL_ISPIXELFORMAT_FOURCC = false\n"); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
339 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
|
340 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
|
341 SDL_Rect real_srcrect = *srcrect; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
342 SDL_Rect real_dstrect = *dstrect; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
343 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
344 /* For testing */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
345 int width = 1280; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
346 int height = 720; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
347 void *pixels = (void *)memalign(16, height * data->screens[0]->pitch); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
348 SDL_memset(pixels, 0x42, height * data->screens[0]->pitch); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
349 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
350 /* Get screeninfo */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
351 struct fb_fix_screeninfo fb_finfo; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
352 if (ioctl(devdata->fbdev, FBIOGET_FSCREENINFO, &fb_finfo)) { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
353 SDL_SetError("[PS3] Can't get fixed screeninfo"); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
354 return -1; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
355 } |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
356 struct fb_var_screeninfo fb_vinfo; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
357 if (ioctl(devdata->fbdev, FBIOGET_VSCREENINFO, &fb_vinfo)) { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
358 SDL_SetError("[PS3] Can't get VSCREENINFO"); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
359 return -1; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
360 } |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
361 /* 16 and 15 bpp is reported as 16 bpp */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
362 txdata->bpp = fb_vinfo.bits_per_pixel; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
363 if (txdata->bpp == 16) |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
364 txdata->bpp = fb_vinfo.red.length + fb_vinfo.green.length + fb_vinfo.blue.length; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
365 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
366 /* Adjust centering */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
367 data->bounded_width = width < fb_vinfo.xres ? width : fb_vinfo.xres; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
368 data->bounded_height = height < fb_vinfo.yres ? height : fb_vinfo.yres; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
369 data->offset_left = (fb_vinfo.xres - data->bounded_width) >> 1; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
370 data->offset_top = (fb_vinfo.yres - data->bounded_height) >> 1; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
371 data->center[0] = devdata->frame_buffer + data->offset_left * txdata->bpp/8 + |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
372 data->offset_top * fb_finfo.line_length; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
373 data->center[1] = data->center[0] + fb_vinfo.yres * fb_finfo.line_length; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
374 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
375 /* Set SPU parms for copying the surface to framebuffer */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
376 devdata->fb_parms->data = (unsigned char *)pixels; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
377 devdata->fb_parms->center = data->center[data->current_screen]; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
378 devdata->fb_parms->out_line_stride = fb_finfo.line_length; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
379 devdata->fb_parms->in_line_stride = surface->w * txdata->bpp / 8; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
380 devdata->fb_parms->bounded_input_height = data->bounded_height; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
381 devdata->fb_parms->bounded_input_width = data->bounded_width; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
382 devdata->fb_parms->fb_pixel_size = txdata->bpp / 8; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
383 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
384 deprintf(3, "[PS3->SPU] fb_thread_data->argp = 0x%x\n", devdata->fb_thread_data->argp); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
385 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
386 /* Copying.. */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
387 SPE_SendMsg(devdata->fb_thread_data, SPU_START); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
388 SPE_SendMsg(devdata->fb_thread_data, (unsigned int)devdata->fb_thread_data->argp); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
389 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
390 SPE_WaitForMsg(devdata->fb_thread_data, SPU_FIN); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
391 free(pixels); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
392 |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
393 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
|
394 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
395 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
396 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
397 static void |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
398 SDL_PS3_RenderPresent(SDL_Renderer * renderer) |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
399 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
400 deprintf(1, "SDL_PS3_RenderPresent()\n"); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
401 static int frame_number; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
402 SDL_PS3_RenderData *data = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
403 (SDL_PS3_RenderData *) renderer->driverdata; |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
404 SDL_Window *window = SDL_GetWindowFromID(renderer->window); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
405 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
406 SDL_VideoData *devdata = display->device->driverdata; |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
407 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
408 /* Send the data to the display */ |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
409 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
|
410 char file[128]; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
411 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
|
412 renderer->window, ++frame_number); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
413 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
|
414 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
415 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
416 /* Wait for vsync */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
417 if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
418 unsigned long crt = 0; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
419 deprintf(1, "[PS3] Wait for vsync\n"); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
420 ioctl(devdata->fbdev, FBIO_WAITFORVSYNC, &crt); |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
421 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
422 |
3142
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
423 /* Page flip */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
424 deprintf(1, "[PS3] Page flip to buffer #%u 0x%x\n", data->current_screen, data->center[data->current_screen]); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
425 ioctl(devdata->fbdev, PS3FB_IOCTL_FSEL, (unsigned long)&data->current_screen); |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
426 |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
427 /* Update the flipping chain, if any */ |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
428 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2 && data->double_buffering) { |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
429 data->current_screen = (data->current_screen + 1) % 2; |
c146645a770e
Roughly working framebuffer.
Martin Lowinski <martin@goldtopf.org>
parents:
3141
diff
changeset
|
430 } |
3141
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
431 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
432 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
433 static void |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
434 SDL_PS3_DestroyRenderer(SDL_Renderer * renderer) |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
435 { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
436 deprintf(1, "SDL_PS3_DestroyRenderer()\n"); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
437 SDL_PS3_RenderData *data = |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
438 (SDL_PS3_RenderData *) renderer->driverdata; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
439 int i; |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
440 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
441 if (data) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
442 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
|
443 if (data->screens[i]) { |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
444 SDL_FreeSurface(data->screens[i]); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
445 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
446 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
447 SDL_free(data); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
448 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
449 SDL_free(renderer); |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
450 } |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
451 |
3df74541339b
Added ps3 video driver based on the dummy driver.
Martin Lowinski <martin@goldtopf.org>
parents:
diff
changeset
|
452 /* vi: set ts=4 sw=4 expandtab: */ |