comparison src/video/dummy/SDL_nullrender.c @ 3596:f638ded38b8a

Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color. Renamed SDL_RenderPoint() and SDL_RenderLine() to SDL_RenderDrawPoint() and SDL_RenderDrawLine(). Added API for rectangle drawing (as opposed to filling) Added placeholder API functions for circles and ellipses ... I'm not sure whether these will stay. Optimized software line drawing quite a bit. Added support for Wu's anti-aliased line drawing, currently disabled by default.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 23 Dec 2009 01:55:00 +0000
parents 0267b8b1595c
children 64ce267332c6
comparison
equal deleted inserted replaced
3595:b7c6828d4039 3596:f638ded38b8a
29 29
30 /* SDL surface based renderer implementation */ 30 /* SDL surface based renderer implementation */
31 31
32 static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window, 32 static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window,
33 Uint32 flags); 33 Uint32 flags);
34 static int SDL_DUMMY_RenderPoints(SDL_Renderer * renderer, 34 static int SDL_DUMMY_RenderDrawPoints(SDL_Renderer * renderer,
35 const SDL_Point * points, int count); 35 const SDL_Point * points, int count);
36 static int SDL_DUMMY_RenderLines(SDL_Renderer * renderer, 36 static int SDL_DUMMY_RenderDrawLines(SDL_Renderer * renderer,
37 const SDL_Point * points, int count); 37 const SDL_Point * points, int count);
38 static int SDL_DUMMY_RenderRects(SDL_Renderer * renderer, 38 static int SDL_DUMMY_RenderDrawRects(SDL_Renderer * renderer,
39 const SDL_Rect ** rects, int count); 39 const SDL_Rect ** rects, int count);
40 static int SDL_DUMMY_RenderFillRects(SDL_Renderer * renderer,
41 const SDL_Rect ** rects, int count);
40 static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, 42 static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer,
41 SDL_Texture * texture, 43 SDL_Texture * texture,
42 const SDL_Rect * srcrect, 44 const SDL_Rect * srcrect,
43 const SDL_Rect * dstrect); 45 const SDL_Rect * dstrect);
44 static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, 46 static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer,
98 SDL_OutOfMemory(); 100 SDL_OutOfMemory();
99 return NULL; 101 return NULL;
100 } 102 }
101 SDL_zerop(data); 103 SDL_zerop(data);
102 104
103 renderer->RenderPoints = SDL_DUMMY_RenderPoints; 105 renderer->RenderDrawPoints = SDL_DUMMY_RenderDrawPoints;
104 renderer->RenderLines = SDL_DUMMY_RenderLines; 106 renderer->RenderDrawLines = SDL_DUMMY_RenderDrawLines;
105 renderer->RenderRects = SDL_DUMMY_RenderRects; 107 renderer->RenderDrawRects = SDL_DUMMY_RenderDrawRects;
108 renderer->RenderFillRects = SDL_DUMMY_RenderFillRects;
106 renderer->RenderCopy = SDL_DUMMY_RenderCopy; 109 renderer->RenderCopy = SDL_DUMMY_RenderCopy;
107 renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels; 110 renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels;
108 renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels; 111 renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels;
109 renderer->RenderPresent = SDL_DUMMY_RenderPresent; 112 renderer->RenderPresent = SDL_DUMMY_RenderPresent;
110 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer; 113 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer;
138 141
139 return renderer; 142 return renderer;
140 } 143 }
141 144
142 static int 145 static int
143 SDL_DUMMY_RenderPoints(SDL_Renderer * renderer, 146 SDL_DUMMY_RenderDrawPoints(SDL_Renderer * renderer,
144 const SDL_Point * points, int count) 147 const SDL_Point * points, int count)
145 { 148 {
146 SDL_DUMMY_RenderData *data = 149 SDL_DUMMY_RenderData *data =
147 (SDL_DUMMY_RenderData *) renderer->driverdata; 150 (SDL_DUMMY_RenderData *) renderer->driverdata;
148 SDL_Surface *target = data->screens[data->current_screen]; 151 SDL_Surface *target = data->screens[data->current_screen];
149 152
160 renderer->a); 163 renderer->a);
161 } 164 }
162 } 165 }
163 166
164 static int 167 static int
165 SDL_DUMMY_RenderLines(SDL_Renderer * renderer, 168 SDL_DUMMY_RenderDrawLines(SDL_Renderer * renderer,
166 const SDL_Point * points, int count) 169 const SDL_Point * points, int count)
167 { 170 {
168 SDL_DUMMY_RenderData *data = 171 SDL_DUMMY_RenderData *data =
169 (SDL_DUMMY_RenderData *) renderer->driverdata; 172 (SDL_DUMMY_RenderData *) renderer->driverdata;
170 SDL_Surface *target = data->screens[data->current_screen]; 173 SDL_Surface *target = data->screens[data->current_screen];
171 174
182 renderer->a); 185 renderer->a);
183 } 186 }
184 } 187 }
185 188
186 static int 189 static int
187 SDL_DUMMY_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, 190 SDL_DUMMY_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
188 int count) 191 int count)
189 { 192 {
190 SDL_DUMMY_RenderData *data = 193 SDL_DUMMY_RenderData *data =
191 (SDL_DUMMY_RenderData *) renderer->driverdata; 194 (SDL_DUMMY_RenderData *) renderer->driverdata;
192 SDL_Surface *target = data->screens[data->current_screen]; 195 SDL_Surface *target = data->screens[data->current_screen];
193 196
195 renderer->blendMode == SDL_BLENDMODE_MASK) { 198 renderer->blendMode == SDL_BLENDMODE_MASK) {
196 Uint32 color = SDL_MapRGBA(target->format, 199 Uint32 color = SDL_MapRGBA(target->format,
197 renderer->r, renderer->g, renderer->b, 200 renderer->r, renderer->g, renderer->b,
198 renderer->a); 201 renderer->a);
199 202
200 return SDL_FillRects(target, rects, count, color); 203 return SDL_DrawRects(target, rects, count, color);
201 } else { 204 } else {
202 return SDL_BlendRects(target, rects, count, 205 return SDL_BlendRects(target, rects, count,
203 renderer->blendMode, 206 renderer->blendMode,
204 renderer->r, renderer->g, renderer->b, 207 renderer->r, renderer->g, renderer->b,
205 renderer->a); 208 renderer->a);
209 }
210 }
211
212 static int
213 SDL_DUMMY_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
214 int count)
215 {
216 SDL_DUMMY_RenderData *data =
217 (SDL_DUMMY_RenderData *) renderer->driverdata;
218 SDL_Surface *target = data->screens[data->current_screen];
219
220 if (renderer->blendMode == SDL_BLENDMODE_NONE ||
221 renderer->blendMode == SDL_BLENDMODE_MASK) {
222 Uint32 color = SDL_MapRGBA(target->format,
223 renderer->r, renderer->g, renderer->b,
224 renderer->a);
225
226 return SDL_FillRects(target, rects, count, color);
227 } else {
228 return SDL_BlendFillRects(target, rects, count,
229 renderer->blendMode,
230 renderer->r, renderer->g, renderer->b,
231 renderer->a);
206 } 232 }
207 } 233 }
208 234
209 static int 235 static int
210 SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 236 SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,