comparison src/video/photon/SDL_photon_render.c @ 5141:da10636e5eca

Making the API simpler, scaling is always defined as linear interpolation and should be supported as much as possible on all renderers.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 31 Jan 2011 22:44:43 -0800
parents aa8888658021
children e743b9c3f6d6
comparison
equal deleted inserted replaced
5140:e594f07297a9 5141:da10636e5eca
102 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD | 102 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
103 SDL_RENDERER_ACCELERATED), 103 SDL_RENDERER_ACCELERATED),
104 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA), 104 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA),
105 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | 105 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND |
106 SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), 106 SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
107 (SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW | SDL_SCALEMODE_FAST),
108 10, 107 10,
109 {SDL_PIXELFORMAT_INDEX8, 108 {SDL_PIXELFORMAT_INDEX8,
110 SDL_PIXELFORMAT_RGB555, 109 SDL_PIXELFORMAT_RGB555,
111 SDL_PIXELFORMAT_RGB565, 110 SDL_PIXELFORMAT_RGB565,
112 SDL_PIXELFORMAT_RGB24, 111 SDL_PIXELFORMAT_RGB24,
151 renderer->SetTexturePalette = photon_settexturepalette; 150 renderer->SetTexturePalette = photon_settexturepalette;
152 renderer->GetTexturePalette = photon_gettexturepalette; 151 renderer->GetTexturePalette = photon_gettexturepalette;
153 renderer->SetTextureAlphaMod = photon_settexturealphamod; 152 renderer->SetTextureAlphaMod = photon_settexturealphamod;
154 renderer->SetTextureColorMod = photon_settexturecolormod; 153 renderer->SetTextureColorMod = photon_settexturecolormod;
155 renderer->SetTextureBlendMode = photon_settextureblendmode; 154 renderer->SetTextureBlendMode = photon_settextureblendmode;
156 renderer->SetTextureScaleMode = photon_settexturescalemode;
157 renderer->UpdateTexture = photon_updatetexture; 155 renderer->UpdateTexture = photon_updatetexture;
158 renderer->LockTexture = photon_locktexture; 156 renderer->LockTexture = photon_locktexture;
159 renderer->UnlockTexture = photon_unlocktexture; 157 renderer->UnlockTexture = photon_unlocktexture;
160 renderer->DirtyTexture = photon_dirtytexture; 158 renderer->DirtyTexture = photon_dirtytexture;
161 renderer->SetDrawColor = photon_setdrawcolor; 159 renderer->SetDrawColor = photon_setdrawcolor;
248 renderer->info.texture_formats[0]=didata->current_mode.format; 246 renderer->info.texture_formats[0]=didata->current_mode.format;
249 247
250 /* Initialize surfaces */ 248 /* Initialize surfaces */
251 _photon_recreate_surfaces(renderer); 249 _photon_recreate_surfaces(renderer);
252 250
253 /* Set current scale blitting capabilities */
254 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN)
255 {
256 renderer->info.scale_modes=SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW;
257 if ((didata->mode_2dcaps & SDL_VIDEO_PHOTON_CAP_SCALED_BLIT)==SDL_VIDEO_PHOTON_CAP_SCALED_BLIT)
258 {
259 /* This video mode supports hardware scaling */
260 renderer->info.scale_modes|=SDL_SCALEMODE_FAST;
261 }
262 }
263 else
264 {
265 /* PhImage blit functions do not support scaling */
266 renderer->info.scale_modes=SDL_SCALEMODE_NONE;
267 }
268
269 return renderer; 251 return renderer;
270 } 252 }
271 253
272 void 254 void
273 photon_addrenderdriver(_THIS) 255 photon_addrenderdriver(_THIS)
975 return -1; 957 return -1;
976 } 958 }
977 } 959 }
978 960
979 static int 961 static int
980 photon_settexturescalemode(SDL_Renderer * renderer, SDL_Texture * texture)
981 {
982 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
983
984 switch (texture->scaleMode)
985 {
986 case SDL_SCALEMODE_NONE:
987 return 0;
988 case SDL_SCALEMODE_FAST:
989 if ((renderer->info.scale_modes & SDL_SCALEMODE_FAST)==SDL_SCALEMODE_FAST)
990 {
991 return 0;
992 }
993 else
994 {
995 SDL_Unsupported();
996 texture->scaleMode = SDL_SCALEMODE_FAST;
997 return -1;
998 }
999 break;
1000 case SDL_SCALEMODE_SLOW:
1001 if ((renderer->info.scale_modes & SDL_SCALEMODE_SLOW)==SDL_SCALEMODE_SLOW)
1002 {
1003 return 0;
1004 }
1005 else
1006 {
1007 SDL_Unsupported();
1008 texture->scaleMode = SDL_SCALEMODE_SLOW;
1009 return -1;
1010 }
1011 break;
1012 case SDL_SCALEMODE_BEST:
1013 SDL_Unsupported();
1014 texture->scaleMode = SDL_SCALEMODE_SLOW;
1015 return -1;
1016 default:
1017 SDL_Unsupported();
1018 texture->scaleMode = SDL_SCALEMODE_NONE;
1019 return -1;
1020 }
1021
1022 SDL_Unsupported();
1023 return -1;
1024 }
1025
1026 static int
1027 photon_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture, 962 photon_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture,
1028 const SDL_Rect * rect, const void *pixels, int pitch) 963 const SDL_Rect * rect, const void *pixels, int pitch)
1029 { 964 {
1030 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; 965 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
1031 SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; 966 SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata;