Mercurial > sdl-ios-xcode
comparison src/video/dummy/SDL_nullrender.c @ 3536:0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
SDL_DrawPoints()
SDL_BlendPoints()
SDL_BlendLines()
SDL_DrawLines()
SDL_FillRects()
SDL_BlendRects()
SDL_RenderPoints()
SDL_RenderLines()
SDL_RenderRects()
Renamed SDL_RenderFill() to SDL_RenderRect()
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 09 Dec 2009 15:56:56 +0000 |
parents | a65f7b3a2524 |
children | f638ded38b8a |
comparison
equal
deleted
inserted
replaced
3535:b403f790df65 | 3536:0267b8b1595c |
---|---|
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_RenderPoint(SDL_Renderer * renderer, int x, int y); | 34 static int SDL_DUMMY_RenderPoints(SDL_Renderer * renderer, |
35 static int SDL_DUMMY_RenderLine(SDL_Renderer * renderer, int x1, int y1, | 35 const SDL_Point * points, int count); |
36 int x2, int y2); | 36 static int SDL_DUMMY_RenderLines(SDL_Renderer * renderer, |
37 static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer, | 37 const SDL_Point * points, int count); |
38 const SDL_Rect * rect); | 38 static int SDL_DUMMY_RenderRects(SDL_Renderer * renderer, |
39 const SDL_Rect ** rects, int count); | |
39 static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, | 40 static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, |
40 SDL_Texture * texture, | 41 SDL_Texture * texture, |
41 const SDL_Rect * srcrect, | 42 const SDL_Rect * srcrect, |
42 const SDL_Rect * dstrect); | 43 const SDL_Rect * dstrect); |
43 static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, | 44 static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, |
97 SDL_OutOfMemory(); | 98 SDL_OutOfMemory(); |
98 return NULL; | 99 return NULL; |
99 } | 100 } |
100 SDL_zerop(data); | 101 SDL_zerop(data); |
101 | 102 |
102 renderer->RenderPoint = SDL_DUMMY_RenderPoint; | 103 renderer->RenderPoints = SDL_DUMMY_RenderPoints; |
103 renderer->RenderLine = SDL_DUMMY_RenderLine; | 104 renderer->RenderLines = SDL_DUMMY_RenderLines; |
104 renderer->RenderFill = SDL_DUMMY_RenderFill; | 105 renderer->RenderRects = SDL_DUMMY_RenderRects; |
105 renderer->RenderCopy = SDL_DUMMY_RenderCopy; | 106 renderer->RenderCopy = SDL_DUMMY_RenderCopy; |
106 renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels; | 107 renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels; |
107 renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels; | 108 renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels; |
108 renderer->RenderPresent = SDL_DUMMY_RenderPresent; | 109 renderer->RenderPresent = SDL_DUMMY_RenderPresent; |
109 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer; | 110 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer; |
137 | 138 |
138 return renderer; | 139 return renderer; |
139 } | 140 } |
140 | 141 |
141 static int | 142 static int |
142 SDL_DUMMY_RenderPoint(SDL_Renderer * renderer, int x, int y) | 143 SDL_DUMMY_RenderPoints(SDL_Renderer * renderer, |
144 const SDL_Point * points, int count) | |
143 { | 145 { |
144 SDL_DUMMY_RenderData *data = | 146 SDL_DUMMY_RenderData *data = |
145 (SDL_DUMMY_RenderData *) renderer->driverdata; | 147 (SDL_DUMMY_RenderData *) renderer->driverdata; |
146 SDL_Surface *target = data->screens[data->current_screen]; | 148 SDL_Surface *target = data->screens[data->current_screen]; |
147 int status; | |
148 | 149 |
149 if (renderer->blendMode == SDL_BLENDMODE_NONE || | 150 if (renderer->blendMode == SDL_BLENDMODE_NONE || |
150 renderer->blendMode == SDL_BLENDMODE_MASK) { | 151 renderer->blendMode == SDL_BLENDMODE_MASK) { |
151 Uint32 color = | 152 Uint32 color = SDL_MapRGBA(target->format, |
152 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b, | 153 renderer->r, renderer->g, renderer->b, |
153 renderer->a); | 154 renderer->a); |
154 | 155 |
155 status = SDL_DrawPoint(target, x, y, color); | 156 return SDL_DrawPoints(target, points, count, color); |
156 } else { | 157 } else { |
157 status = | 158 return SDL_BlendPoints(target, points, count, renderer->blendMode, |
158 SDL_BlendPoint(target, x, y, renderer->blendMode, renderer->r, | 159 renderer->r, renderer->g, renderer->b, |
159 renderer->g, renderer->b, renderer->a); | 160 renderer->a); |
160 } | 161 } |
161 return status; | 162 } |
162 } | 163 |
163 | 164 static int |
164 static int | 165 SDL_DUMMY_RenderLines(SDL_Renderer * renderer, |
165 SDL_DUMMY_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) | 166 const SDL_Point * points, int count) |
166 { | 167 { |
167 SDL_DUMMY_RenderData *data = | 168 SDL_DUMMY_RenderData *data = |
168 (SDL_DUMMY_RenderData *) renderer->driverdata; | 169 (SDL_DUMMY_RenderData *) renderer->driverdata; |
169 SDL_Surface *target = data->screens[data->current_screen]; | 170 SDL_Surface *target = data->screens[data->current_screen]; |
170 int status; | |
171 | 171 |
172 if (renderer->blendMode == SDL_BLENDMODE_NONE || | 172 if (renderer->blendMode == SDL_BLENDMODE_NONE || |
173 renderer->blendMode == SDL_BLENDMODE_MASK) { | 173 renderer->blendMode == SDL_BLENDMODE_MASK) { |
174 Uint32 color = | 174 Uint32 color = SDL_MapRGBA(target->format, |
175 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b, | 175 renderer->r, renderer->g, renderer->b, |
176 renderer->a); | 176 renderer->a); |
177 | 177 |
178 status = SDL_DrawLine(target, x1, y1, x2, y2, color); | 178 return SDL_DrawLines(target, points, count, color); |
179 } else { | 179 } else { |
180 status = | 180 return SDL_BlendLines(target, points, count, renderer->blendMode, |
181 SDL_BlendLine(target, x1, y1, x2, y2, renderer->blendMode, | 181 renderer->r, renderer->g, renderer->b, |
182 renderer->r, renderer->g, renderer->b, renderer->a); | 182 renderer->a); |
183 } | 183 } |
184 return status; | 184 } |
185 } | 185 |
186 | 186 static int |
187 static int | 187 SDL_DUMMY_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
188 SDL_DUMMY_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) | 188 int count) |
189 { | 189 { |
190 SDL_DUMMY_RenderData *data = | 190 SDL_DUMMY_RenderData *data = |
191 (SDL_DUMMY_RenderData *) renderer->driverdata; | 191 (SDL_DUMMY_RenderData *) renderer->driverdata; |
192 SDL_Surface *target = data->screens[data->current_screen]; | 192 SDL_Surface *target = data->screens[data->current_screen]; |
193 SDL_Rect real_rect = *rect; | 193 |
194 int status; | 194 if (renderer->blendMode == SDL_BLENDMODE_NONE || |
195 | 195 renderer->blendMode == SDL_BLENDMODE_MASK) { |
196 if (renderer->blendMode == SDL_BLENDMODE_NONE) { | 196 Uint32 color = SDL_MapRGBA(target->format, |
197 Uint32 color = | 197 renderer->r, renderer->g, renderer->b, |
198 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b, | 198 renderer->a); |
199 renderer->a); | 199 |
200 | 200 return SDL_FillRects(target, rects, count, color); |
201 status = SDL_FillRect(target, &real_rect, color); | 201 } else { |
202 } else { | 202 return SDL_BlendRects(target, rects, count, |
203 status = | 203 renderer->blendMode, |
204 SDL_BlendRect(target, &real_rect, renderer->blendMode, | 204 renderer->r, renderer->g, renderer->b, |
205 renderer->r, renderer->g, renderer->b, renderer->a); | 205 renderer->a); |
206 } | 206 } |
207 return status; | |
208 } | 207 } |
209 | 208 |
210 static int | 209 static int |
211 SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, | 210 SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
212 const SDL_Rect * srcrect, const SDL_Rect * dstrect) | 211 const SDL_Rect * srcrect, const SDL_Rect * dstrect) |