# HG changeset patch # User Mike Gorchak # Date 1255347901 0 # Node ID fff074de967553897f03e84905eb840a4d4a7f6a # Parent 45d7f0f70b2736b36decc25dd7218ba686f689a3 Photon SDL renderer almost finished, the double/tripple buffering is left only. diff -r 45d7f0f70b27 -r fff074de9675 src/video/photon/SDL_photon.c --- a/src/video/photon/SDL_photon.c Mon Oct 12 09:42:50 2009 +0000 +++ b/src/video/photon/SDL_photon.c Mon Oct 12 11:45:01 2009 +0000 @@ -431,11 +431,11 @@ didata->mode_2dcaps=0; if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND) { - didata->mode_2dcaps|=SDL_VIDEO_CAP_ALPHA_BLEND; + didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND; } if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_SCALED_BLIT)==PgVM_MODE_CAP2_SCALED_BLIT) { - didata->mode_2dcaps|=SDL_VIDEO_CAP_SCALED_BLIT; + didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_SCALED_BLIT; } } @@ -765,11 +765,11 @@ didata->mode_2dcaps=0; if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND) { - didata->mode_2dcaps|=SDL_VIDEO_CAP_ALPHA_BLEND; + didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND; } if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_SCALED_BLIT)==PgVM_MODE_CAP2_SCALED_BLIT) { - didata->mode_2dcaps|=SDL_VIDEO_CAP_SCALED_BLIT; + didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_SCALED_BLIT; } return 0; diff -r 45d7f0f70b27 -r fff074de9675 src/video/photon/SDL_photon.h --- a/src/video/photon/SDL_photon.h Mon Oct 12 09:42:50 2009 +0000 +++ b/src/video/photon/SDL_photon.h Mon Oct 12 11:45:01 2009 +0000 @@ -68,8 +68,8 @@ #define SDL_VIDEO_PHOTON_EVENT_SIZE 8192 /* Current video mode graphics capabilities */ -#define SDL_VIDEO_CAP_ALPHA_BLEND 0x00000001 -#define SDL_VIDEO_CAP_SCALED_BLIT 0x00000002 +#define SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND 0x00000001 +#define SDL_VIDEO_PHOTON_CAP_SCALED_BLIT 0x00000002 typedef struct SDL_DisplayData { diff -r 45d7f0f70b27 -r fff074de9675 src/video/photon/SDL_photon_render.c --- a/src/video/photon/SDL_photon_render.c Mon Oct 12 09:42:50 2009 +0000 +++ b/src/video/photon/SDL_photon_render.c Mon Oct 12 11:45:01 2009 +0000 @@ -92,9 +92,9 @@ SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED), - (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | - SDL_TEXTUREMODULATE_ALPHA), - (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND), + (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA), + (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | + SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_FAST), 10, @@ -232,7 +232,7 @@ if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN) { renderer->info.scale_modes=SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW; - if ((didata->mode_2dcaps & SDL_VIDEO_CAP_SCALED_BLIT)==SDL_VIDEO_CAP_SCALED_BLIT) + if ((didata->mode_2dcaps & SDL_VIDEO_PHOTON_CAP_SCALED_BLIT)==SDL_VIDEO_PHOTON_CAP_SCALED_BLIT) { /* This video mode supports hardware scaling */ renderer->info.scale_modes|=SDL_TEXTURESCALEMODE_FAST; @@ -763,6 +763,7 @@ return -1; } + SDL_Unsupported(); return -1; } @@ -786,21 +787,37 @@ return -1; } + SDL_Unsupported(); return -1; } static int photon_settexturecolormod(SDL_Renderer * renderer, SDL_Texture * texture) { - /* TODO */ + SDL_Unsupported(); return -1; } static int photon_settexturealphamod(SDL_Renderer * renderer, SDL_Texture * texture) { - /* TODO */ - return -1; + SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; + + /* Check, if it is not initialized */ + if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) + { + SDL_SetError("Photon: can't set texture blend mode for OpenGL ES window"); + return -1; + } + + /* Check if current renderer instance supports alpha modulation */ + if ((renderer->info.mod_modes & SDL_TEXTUREMODULATE_ALPHA)!=SDL_TEXTUREMODULATE_ALPHA) + { + SDL_Unsupported(); + return -1; + } + + return 0; } static int @@ -820,9 +837,9 @@ case SDL_BLENDMODE_NONE: case SDL_BLENDMODE_MASK: case SDL_BLENDMODE_BLEND: - return 0; case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_MOD: + return 0; default: SDL_Unsupported(); texture->blendMode = SDL_BLENDMODE_NONE; @@ -873,6 +890,7 @@ return -1; } + SDL_Unsupported(); return -1; } @@ -990,6 +1008,8 @@ photon_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects, const SDL_Rect * rects) { + SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; + /* Check, if it is not initialized */ if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) { @@ -1029,6 +1049,7 @@ photon_setdrawblendmode(SDL_Renderer * renderer) { /* TODO */ + SDL_Unsupported(); return -1; } @@ -1137,11 +1158,27 @@ { case SDL_BLENDMODE_MASK: /* Enable and set chroma key */ + PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); PgChromaOnCx(rdata->gc); - PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); break; case SDL_BLENDMODE_BLEND: - /* TODO */ + /* Enable and set chroma key and alpha blending */ + PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); + PgChromaOnCx(rdata->gc); + PgSetAlphaCx(rdata->gc, Pg_ALPHA_OP_SRC_GLOBAL | Pg_BLEND_SRC_As | Pg_BLEND_DST_1mAs, NULL, NULL, texture->a, 0); + PgAlphaOnCx(rdata->gc); + break; + case SDL_BLENDMODE_ADD: + /* Enable and set chroma key and alpha blending */ + PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); + PgChromaOnCx(rdata->gc); + PgSetAlphaCx(rdata->gc, Pg_ALPHA_OP_SRC_GLOBAL | Pg_BLEND_SRC_As | Pg_BLEND_DST_1, NULL, NULL, texture->a, 0); + PgAlphaOnCx(rdata->gc); + break; + case SDL_BLENDMODE_MOD: + /* Enable and set alpha blending */ + PgSetAlphaCx(rdata->gc, Pg_BLEND_SRC_0 | Pg_BLEND_DST_S, NULL, NULL, 0, 0); + PgAlphaOnCx(rdata->gc); break; case SDL_BLENDMODE_NONE: default: @@ -1213,7 +1250,18 @@ PgChromaOffCx(rdata->gc); break; case SDL_BLENDMODE_BLEND: - /* TODO */ + /* Disable chroma key and alpha blending */ + PgChromaOffCx(rdata->gc); + PgAlphaOffCx(rdata->gc); + break; + case SDL_BLENDMODE_ADD: + /* Disable chroma key and alpha blending */ + PgChromaOffCx(rdata->gc); + PgAlphaOffCx(rdata->gc); + break; + case SDL_BLENDMODE_MOD: + /* Disable chroma key and alpha blending */ + PgAlphaOffCx(rdata->gc); break; case SDL_BLENDMODE_NONE: default: