Mercurial > sdl-ios-xcode
comparison src/video/dummy/SDL_nullrender.c @ 2888:32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 20 Dec 2008 13:14:28 +0000 |
parents | 9dde605c7540 |
children | 133601e3b255 |
comparison
equal
deleted
inserted
replaced
2887:f8c0c5ef6d54 | 2888:32e8bbba1e94 |
---|---|
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_SetDrawColor(SDL_Renderer * renderer); | 34 static int SDL_DUMMY_SetDrawColor(SDL_Renderer * renderer); |
35 static int SDL_DUMMY_SetDrawBlendMode(SDL_Renderer * renderer); | |
36 static int SDL_DUMMY_RenderLine(SDL_Renderer * renderer, int x1, int y1, | |
37 int x2, int y2); | |
35 static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer, | 38 static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer, |
36 const SDL_Rect * rect); | 39 const SDL_Rect * rect); |
37 static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, | 40 static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, |
38 SDL_Texture * texture, | 41 SDL_Texture * texture, |
39 const SDL_Rect * srcrect, | 42 const SDL_Rect * srcrect, |
88 return NULL; | 91 return NULL; |
89 } | 92 } |
90 SDL_zerop(data); | 93 SDL_zerop(data); |
91 | 94 |
92 renderer->SetDrawColor = SDL_DUMMY_SetDrawColor; | 95 renderer->SetDrawColor = SDL_DUMMY_SetDrawColor; |
96 renderer->SetDrawBlendMode = SDL_DUMMY_SetDrawBlendMode; | |
97 renderer->RenderLine = SDL_DUMMY_RenderLine; | |
93 renderer->RenderFill = SDL_DUMMY_RenderFill; | 98 renderer->RenderFill = SDL_DUMMY_RenderFill; |
94 renderer->RenderCopy = SDL_DUMMY_RenderCopy; | 99 renderer->RenderCopy = SDL_DUMMY_RenderCopy; |
95 renderer->RenderPresent = SDL_DUMMY_RenderPresent; | 100 renderer->RenderPresent = SDL_DUMMY_RenderPresent; |
96 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer; | 101 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer; |
97 renderer->info.name = SDL_DUMMY_RenderDriver.info.name; | 102 renderer->info.name = SDL_DUMMY_RenderDriver.info.name; |
130 { | 135 { |
131 return 0; | 136 return 0; |
132 } | 137 } |
133 | 138 |
134 static int | 139 static int |
140 SDL_DUMMY_SetDrawBlendMode(SDL_Renderer * renderer) | |
141 { | |
142 return 0; | |
143 } | |
144 | |
145 static int | |
146 SDL_DUMMY_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) | |
147 { | |
148 SDL_DUMMY_RenderData *data = | |
149 (SDL_DUMMY_RenderData *) renderer->driverdata; | |
150 SDL_Surface *target = data->screens[data->current_screen]; | |
151 int status; | |
152 | |
153 if (renderer->blendMode == SDL_BLENDMODE_NONE) { | |
154 Uint32 color = | |
155 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b, | |
156 renderer->a); | |
157 | |
158 status = SDL_DrawLine(target, x1, y1, x2, y2, color); | |
159 } else { | |
160 status = | |
161 SDL_BlendLine(target, x1, y1, x2, y2, renderer->blendMode, | |
162 renderer->r, renderer->g, renderer->b, renderer->a); | |
163 } | |
164 return status; | |
165 } | |
166 | |
167 static int | |
135 SDL_DUMMY_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) | 168 SDL_DUMMY_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) |
136 { | 169 { |
137 SDL_DUMMY_RenderData *data = | 170 SDL_DUMMY_RenderData *data = |
138 (SDL_DUMMY_RenderData *) renderer->driverdata; | 171 (SDL_DUMMY_RenderData *) renderer->driverdata; |
139 SDL_Surface *target = data->screens[data->current_screen]; | 172 SDL_Surface *target = data->screens[data->current_screen]; |
140 Uint32 color; | |
141 SDL_Rect real_rect = *rect; | 173 SDL_Rect real_rect = *rect; |
142 | 174 int status; |
143 color = SDL_MapRGBA(target->format, | 175 |
144 renderer->r, renderer->g, renderer->b, renderer->a); | 176 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
145 | 177 Uint32 color = |
146 return SDL_FillRect(target, &real_rect, color); | 178 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b, |
179 renderer->a); | |
180 | |
181 status = SDL_FillRect(target, &real_rect, color); | |
182 } else { | |
183 status = | |
184 SDL_BlendRect(target, &real_rect, renderer->blendMode, | |
185 renderer->r, renderer->g, renderer->b, renderer->a); | |
186 } | |
187 return status; | |
147 } | 188 } |
148 | 189 |
149 static int | 190 static int |
150 SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, | 191 SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
151 const SDL_Rect * srcrect, const SDL_Rect * dstrect) | 192 const SDL_Rect * srcrect, const SDL_Rect * dstrect) |