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