annotate src/video/fbcon-1.3/SDL_fbrender.c @ 3158:30f3b987fec3 gsoc2009_ps3

created env (fbcon-1.3) and added basic files
author Martin Lowinski <martin@goldtopf.org>
date Sat, 07 Nov 2009 11:35:19 +0000
parents
children 2632b7453516
rev   line source
3158
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
1 /*
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
4
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
9
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
13 Lesser General Public License for more details.
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
14
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
18
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
19 Sam Lantinga
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
20 slouken@libsdl.org
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
21 */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
22 #include "SDL_config.h"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
23
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
24 #include "SDL_video.h"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
25 #include "../SDL_sysvideo.h"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
26 #include "../SDL_yuv_sw_c.h"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
27 #include "../SDL_renderer_sw.h"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
28
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
29
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
30 /* SDL surface based renderer implementation */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
31
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
32 static SDL_Renderer *SDL_FB_CreateRenderer(SDL_Window * window,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
33 Uint32 flags);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
34 static int SDL_FB_RenderPoint(SDL_Renderer * renderer, int x, int y);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
35 static int SDL_FB_RenderLine(SDL_Renderer * renderer, int x1, int y1,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
36 int x2, int y2);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
37 static int SDL_FB_RenderFill(SDL_Renderer * renderer,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
38 const SDL_Rect * rect);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
39 static int SDL_FB_RenderCopy(SDL_Renderer * renderer,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
40 SDL_Texture * texture,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
41 const SDL_Rect * srcrect,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
42 const SDL_Rect * dstrect);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
43 static void SDL_FB_RenderPresent(SDL_Renderer * renderer);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
44 static void SDL_FB_DestroyRenderer(SDL_Renderer * renderer);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
45
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
46
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
47 SDL_RenderDriver SDL_FB_RenderDriver = {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
48 SDL_FB_CreateRenderer,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
49 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
50 "fbcon",
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
51 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
52 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
53 SDL_RENDERER_PRESENTDISCARD),
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
54 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
55 };
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
56
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
57 typedef struct
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
58 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
59 int current_screen;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
60 SDL_Surface *screens[3];
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
61 } SDL_FB_RenderData;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
62
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
63 SDL_Renderer *
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
64 SDL_FB_CreateRenderer(SDL_Window * window, Uint32 flags)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
65 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
66 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
67 SDL_DisplayMode *displayMode = &display->current_mode;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
68 SDL_Renderer *renderer;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
69 SDL_FB_RenderData *data;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
70 int i, n;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
71 int bpp;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
72 Uint32 Rmask, Gmask, Bmask, Amask;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
73
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
74 if (!SDL_PixelFormatEnumToMasks
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
75 (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
76 SDL_SetError("Unknown display format");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
77 return NULL;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
78 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
79
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
80 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
81 if (!renderer) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
82 SDL_OutOfMemory();
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
83 return NULL;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
84 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
85
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
86 data = (SDL_FB_RenderData *) SDL_malloc(sizeof(*data));
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
87 if (!data) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
88 SDL_FB_DestroyRenderer(renderer);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
89 SDL_OutOfMemory();
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
90 return NULL;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
91 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
92 SDL_zerop(data);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
93
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
94 renderer->RenderPoint = SDL_FB_RenderPoint;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
95 renderer->RenderLine = SDL_FB_RenderLine;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
96 renderer->RenderFill = SDL_FB_RenderFill;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
97 renderer->RenderCopy = SDL_FB_RenderCopy;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
98 renderer->RenderPresent = SDL_FB_RenderPresent;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
99 renderer->DestroyRenderer = SDL_FB_DestroyRenderer;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
100 renderer->info.name = SDL_FB_RenderDriver.info.name;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
101 renderer->info.flags = 0;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
102 renderer->window = window->id;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
103 renderer->driverdata = data;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
104 Setup_SoftwareRenderer(renderer);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
105
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
106 if (flags & SDL_RENDERER_PRESENTFLIP2) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
107 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
108 n = 2;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
109 } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
110 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
111 n = 3;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
112 } else {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
113 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
114 n = 1;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
115 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
116 for (i = 0; i < n; ++i) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
117 data->screens[i] =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
118 SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
119 Bmask, Amask);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
120 if (!data->screens[i]) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
121 SDL_FB_DestroyRenderer(renderer);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
122 return NULL;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
123 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
124 SDL_SetSurfacePalette(data->screens[i], display->palette);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
125 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
126 data->current_screen = 0;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
127
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
128 return renderer;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
129 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
130
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
131 static int
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
132 SDL_FB_RenderPoint(SDL_Renderer * renderer, int x, int y)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
133 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
134 SDL_FB_RenderData *data =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
135 (SDL_FB_RenderData *) renderer->driverdata;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
136 SDL_Surface *target = data->screens[data->current_screen];
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
137 int status;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
138
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
139 if (renderer->blendMode == SDL_BLENDMODE_NONE ||
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
140 renderer->blendMode == SDL_BLENDMODE_MASK) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
141 Uint32 color =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
142 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
143 renderer->a);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
144
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
145 status = SDL_DrawPoint(target, x, y, color);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
146 } else {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
147 status =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
148 SDL_BlendPoint(target, x, y, renderer->blendMode, renderer->r,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
149 renderer->g, renderer->b, renderer->a);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
150 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
151 return status;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
152 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
153
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
154 static int
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
155 SDL_FB_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
156 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
157 SDL_FB_RenderData *data =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
158 (SDL_FB_RenderData *) renderer->driverdata;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
159 SDL_Surface *target = data->screens[data->current_screen];
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
160 int status;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
161
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
162 if (renderer->blendMode == SDL_BLENDMODE_NONE ||
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
163 renderer->blendMode == SDL_BLENDMODE_MASK) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
164 Uint32 color =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
165 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
166 renderer->a);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
167
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
168 status = SDL_DrawLine(target, x1, y1, x2, y2, color);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
169 } else {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
170 status =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
171 SDL_BlendLine(target, x1, y1, x2, y2, renderer->blendMode,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
172 renderer->r, renderer->g, renderer->b, renderer->a);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
173 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
174 return status;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
175 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
176
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
177 static int
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
178 SDL_FB_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
179 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
180 SDL_FB_RenderData *data =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
181 (SDL_FB_RenderData *) renderer->driverdata;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
182 SDL_Surface *target = data->screens[data->current_screen];
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
183 SDL_Rect real_rect = *rect;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
184 int status;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
185
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
186 if (renderer->blendMode == SDL_BLENDMODE_NONE) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
187 Uint32 color =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
188 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
189 renderer->a);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
190
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
191 status = SDL_FillRect(target, &real_rect, color);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
192 } else {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
193 status =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
194 SDL_BlendRect(target, &real_rect, renderer->blendMode,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
195 renderer->r, renderer->g, renderer->b, renderer->a);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
196 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
197 return status;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
198 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
199
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
200 static int
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
201 SDL_FB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
202 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
203 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
204 SDL_FB_RenderData *data =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
205 (SDL_FB_RenderData *) renderer->driverdata;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
206 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
207 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
208
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
209 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
210 SDL_Surface *target = data->screens[data->current_screen];
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
211 void *pixels =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
212 (Uint8 *) target->pixels + dstrect->y * target->pitch +
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
213 dstrect->x * target->format->BytesPerPixel;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
214 return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
215 srcrect, display->current_mode.format,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
216 dstrect->w, dstrect->h, pixels,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
217 target->pitch);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
218 } else {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
219 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
220 SDL_Surface *target = data->screens[data->current_screen];
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
221 SDL_Rect real_srcrect = *srcrect;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
222 SDL_Rect real_dstrect = *dstrect;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
223
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
224 return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
225 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
226 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
227
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
228 static void
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
229 SDL_FB_RenderPresent(SDL_Renderer * renderer)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
230 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
231 static int frame_number;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
232 SDL_FB_RenderData *data =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
233 (SDL_FB_RenderData *) renderer->driverdata;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
234
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
235 /* Send the data to the display */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
236 if (SDL_getenv("SDL_VIDEO_FB_SAVE_FRAMES")) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
237 char file[128];
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
238 SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
239 renderer->window, ++frame_number);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
240 SDL_SaveBMP(data->screens[data->current_screen], file);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
241 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
242
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
243 /* Update the flipping chain, if any */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
244 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
245 data->current_screen = (data->current_screen + 1) % 2;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
246 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
247 data->current_screen = (data->current_screen + 1) % 3;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
248 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
249 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
250
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
251 static void
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
252 SDL_FB_DestroyRenderer(SDL_Renderer * renderer)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
253 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
254 SDL_FB_RenderData *data =
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
255 (SDL_FB_RenderData *) renderer->driverdata;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
256 int i;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
257
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
258 if (data) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
259 for (i = 0; i < SDL_arraysize(data->screens); ++i) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
260 if (data->screens[i]) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
261 SDL_FreeSurface(data->screens[i]);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
262 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
263 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
264 SDL_free(data);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
265 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
266 SDL_free(renderer);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
267 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
268
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
269 /* vi: set ts=4 sw=4 expandtab: */