Mercurial > sdl-ios-xcode
comparison src/video/directfb/SDL_DirectFB_render.c @ 3040:62d4992e5a92
indent
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 14 Jan 2009 04:25:32 +0000 |
parents | c73a5f8a03d2 |
children | b8d313de8a65 |
comparison
equal
deleted
inserted
replaced
3039:829043b363d1 | 3040:62d4992e5a92 |
---|---|
180 | 180 |
181 static void | 181 static void |
182 SetBlendMode(DirectFB_RenderData * data, int blendMode, | 182 SetBlendMode(DirectFB_RenderData * data, int blendMode, |
183 DirectFB_TextureData * source) | 183 DirectFB_TextureData * source) |
184 { | 184 { |
185 SDL_DFB_WINDOWSURFACE(data->window); | 185 SDL_DFB_WINDOWSURFACE(data->window); |
186 | 186 |
187 //FIXME: check for format change | 187 //FIXME: check for format change |
188 if (1 || data->lastBlendMode != blendMode) { | 188 if (1 || data->lastBlendMode != blendMode) { |
189 switch (blendMode) { | 189 switch (blendMode) { |
190 case SDL_BLENDMODE_NONE: | 190 case SDL_BLENDMODE_NONE: |
191 /**< No blending */ | 191 /**< No blending */ |
192 data->blitFlags = DSBLIT_NOFX; | 192 data->blitFlags = DSBLIT_NOFX; |
196 break; | 196 break; |
197 case SDL_BLENDMODE_MASK: | 197 case SDL_BLENDMODE_MASK: |
198 data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; | 198 data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; |
199 data->drawFlags = DSDRAW_BLEND; | 199 data->drawFlags = DSDRAW_BLEND; |
200 destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA); | 200 destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA); |
201 destsurf->SetDstBlendFunction(destsurf, | 201 destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA); |
202 DSBF_INVSRCALPHA); | |
203 break; | 202 break; |
204 case SDL_BLENDMODE_BLEND: | 203 case SDL_BLENDMODE_BLEND: |
205 data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; | 204 data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; |
206 data->drawFlags = DSDRAW_BLEND; | 205 data->drawFlags = DSDRAW_BLEND; |
207 destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA); | 206 destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA); |
208 destsurf->SetDstBlendFunction(destsurf, | 207 destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA); |
209 DSBF_INVSRCALPHA); | |
210 break; | 208 break; |
211 case SDL_BLENDMODE_ADD: | 209 case SDL_BLENDMODE_ADD: |
212 data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; | 210 data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; |
213 data->drawFlags = DSDRAW_BLEND; | 211 data->drawFlags = DSDRAW_BLEND; |
214 // FIXME: SRCALPHA kills performance on radeon ... | 212 // FIXME: SRCALPHA kills performance on radeon ... |
215 // It will be cheaper to copy the surface to | 213 // It will be cheaper to copy the surface to |
216 // a temporay surface and premultiply | 214 // a temporay surface and premultiply |
217 if (source && TextureHasAlpha(source)) | 215 if (source && TextureHasAlpha(source)) |
218 destsurf->SetSrcBlendFunction(destsurf, | 216 destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA); |
219 DSBF_SRCALPHA); | |
220 else | 217 else |
221 destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE); | 218 destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE); |
222 destsurf->SetDstBlendFunction(destsurf, DSBF_ONE); | 219 destsurf->SetDstBlendFunction(destsurf, DSBF_ONE); |
223 break; | 220 break; |
224 case SDL_BLENDMODE_MOD: | 221 case SDL_BLENDMODE_MOD: |
322 data->flipflags |= DSFLIP_WAITFORSYNC; | 319 data->flipflags |= DSFLIP_WAITFORSYNC; |
323 renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; | 320 renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; |
324 } else | 321 } else |
325 data->flipflags |= DSFLIP_ONSYNC; | 322 data->flipflags |= DSFLIP_ONSYNC; |
326 | 323 |
327 SDL_DFB_CHECKERR(windata->surface->GetCapabilities(windata->surface, &scaps)); | 324 SDL_DFB_CHECKERR(windata->surface-> |
325 GetCapabilities(windata->surface, &scaps)); | |
328 if (scaps & DSCAPS_DOUBLE) | 326 if (scaps & DSCAPS_DOUBLE) |
329 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; | 327 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; |
330 else if (scaps & DSCAPS_TRIPLE) | 328 else if (scaps & DSCAPS_TRIPLE) |
331 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; | 329 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; |
332 else | 330 else |
797 static int | 795 static int |
798 PrepareDraw(SDL_Renderer * renderer) | 796 PrepareDraw(SDL_Renderer * renderer) |
799 { | 797 { |
800 DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; | 798 DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; |
801 SDL_DFB_WINDOWSURFACE(data->window); | 799 SDL_DFB_WINDOWSURFACE(data->window); |
802 | 800 |
803 DFBResult ret; | 801 DFBResult ret; |
804 Uint8 r, g, b, a; | 802 Uint8 r, g, b, a; |
805 | 803 |
806 r = renderer->r; | 804 r = renderer->r; |
807 g = renderer->g; | 805 g = renderer->g; |
808 b = renderer->b; | 806 b = renderer->b; |
809 a = renderer->a; | 807 a = renderer->a; |
810 | 808 |
811 SetBlendMode(data, renderer->blendMode, NULL); | 809 SetBlendMode(data, renderer->blendMode, NULL); |
812 SDL_DFB_CHECKERR(destsurf->SetDrawingFlags(destsurf, | 810 SDL_DFB_CHECKERR(destsurf->SetDrawingFlags(destsurf, data->drawFlags)); |
813 data->drawFlags)); | |
814 | 811 |
815 switch (renderer->blendMode) { | 812 switch (renderer->blendMode) { |
816 case SDL_BLENDMODE_NONE: | 813 case SDL_BLENDMODE_NONE: |
817 case SDL_BLENDMODE_MASK: | 814 case SDL_BLENDMODE_MASK: |
818 case SDL_BLENDMODE_BLEND: | 815 case SDL_BLENDMODE_BLEND: |
854 DFBResult ret; | 851 DFBResult ret; |
855 | 852 |
856 PrepareDraw(renderer); | 853 PrepareDraw(renderer); |
857 /* Use antialiasing when available */ | 854 /* Use antialiasing when available */ |
858 #if (DFB_VERSION_ATLEAST(1,2,0)) | 855 #if (DFB_VERSION_ATLEAST(1,2,0)) |
859 SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf, | 856 SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf, DSRO_ANTIALIAS)); |
860 DSRO_ANTIALIAS)); | |
861 #endif | 857 #endif |
862 SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, x1, y1, x2, y2)); | 858 SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, x1, y1, x2, y2)); |
863 return 0; | 859 return 0; |
864 error: | 860 error: |
865 return -1; | 861 return -1; |
872 SDL_DFB_WINDOWSURFACE(data->window); | 868 SDL_DFB_WINDOWSURFACE(data->window); |
873 DFBResult ret; | 869 DFBResult ret; |
874 | 870 |
875 PrepareDraw(renderer); | 871 PrepareDraw(renderer); |
876 SDL_DFB_CHECKERR(destsurf->FillRectangle(destsurf, rect->x, rect->y, | 872 SDL_DFB_CHECKERR(destsurf->FillRectangle(destsurf, rect->x, rect->y, |
877 rect->w, rect->h)); | 873 rect->w, rect->h)); |
878 | 874 |
879 return 0; | 875 return 0; |
880 error: | 876 error: |
881 return -1; | 877 return -1; |
882 } | 878 } |
936 } | 932 } |
937 | 933 |
938 SDLtoDFBRect(srcrect, &sr); | 934 SDLtoDFBRect(srcrect, &sr); |
939 SDLtoDFBRect(dstrect, &dr); | 935 SDLtoDFBRect(dstrect, &dr); |
940 | 936 |
941 SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF, 0xFF, 0xFF)); | 937 SDL_DFB_CHECKERR(destsurf-> |
942 if (texture->modMode & | 938 SetColor(destsurf, 0xFF, 0xFF, 0xFF, 0xFF)); |
943 (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA)) { | 939 if (texture-> |
940 modMode & (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA)) | |
941 { | |
944 if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) { | 942 if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) { |
945 alpha = texture->a; | 943 alpha = texture->a; |
946 SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF, | 944 SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF, |
947 0xFF, alpha)); | 945 0xFF, alpha)); |
948 } | 946 } |
949 if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { | 947 if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { |
950 | 948 |
951 SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, | 949 SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, |
952 texture->r, | 950 texture->r, |
953 texture->g, | 951 texture->g, |
954 texture->b, alpha)); | 952 texture->b, alpha)); |
955 flags |= DSBLIT_COLORIZE; | 953 flags |= DSBLIT_COLORIZE; |
956 } | 954 } |
957 if (alpha < 0xFF) | 955 if (alpha < 0xFF) |
958 flags |= DSBLIT_SRC_PREMULTCOLOR; | 956 flags |= DSBLIT_SRC_PREMULTCOLOR; |
959 } else | 957 } else |
960 SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF, | 958 SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF, |
961 0xFF, 0xFF)); | 959 0xFF, 0xFF)); |
962 | 960 |
963 SetBlendMode(data, texture->blendMode, texturedata); | 961 SetBlendMode(data, texture->blendMode, texturedata); |
964 | 962 |
965 SDL_DFB_CHECKERR(destsurf->SetBlittingFlags(destsurf, | 963 SDL_DFB_CHECKERR(destsurf->SetBlittingFlags(destsurf, |
966 data->blitFlags | 964 data->blitFlags | flags)); |
967 | flags)); | |
968 | 965 |
969 #if (DFB_VERSION_ATLEAST(1,2,0)) | 966 #if (DFB_VERSION_ATLEAST(1,2,0)) |
970 SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf, | 967 SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf, |
971 texturedata-> | 968 texturedata-> |
972 render_options)); | 969 render_options)); |
973 #endif | 970 #endif |
974 | 971 |
975 if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) { | 972 if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) { |
976 SDL_DFB_CHECKERR(destsurf->Blit(destsurf, | 973 SDL_DFB_CHECKERR(destsurf->Blit(destsurf, |
977 texturedata->surface, | 974 texturedata->surface, |
978 &sr, dr.x, dr.y)); | 975 &sr, dr.x, dr.y)); |
979 } else { | 976 } else { |
980 SDL_DFB_CHECKERR(destsurf->StretchBlit(destsurf, | 977 SDL_DFB_CHECKERR(destsurf->StretchBlit(destsurf, |
981 texturedata->surface, | 978 texturedata->surface, |
982 &sr, &dr)); | 979 &sr, &dr)); |
983 } | 980 } |
984 } | 981 } |
985 return 0; | 982 return 0; |
986 error: | 983 error: |
987 return -1; | 984 return -1; |
1033 | 1030 |
1034 static void | 1031 static void |
1035 DirectFB_DestroyRenderer(SDL_Renderer * renderer) | 1032 DirectFB_DestroyRenderer(SDL_Renderer * renderer) |
1036 { | 1033 { |
1037 DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; | 1034 DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; |
1038 | 1035 |
1039 if (data) { | 1036 if (data) { |
1040 SDL_free(data); | 1037 SDL_free(data); |
1041 } | 1038 } |
1042 SDL_free(renderer); | 1039 SDL_free(renderer); |
1043 } | 1040 } |