All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404083
This commit is contained in:
parent
c6540a326c
commit
0ce7835ad6
3 changed files with 160 additions and 63 deletions
|
@ -106,7 +106,7 @@
|
|||
|
||||
#define PHOTON_SCANCODE_PRNSCR 0x54 /* only key pressed event, no release */
|
||||
#define PHOTON_SCANCODE_SCROLLLOCK 0x46
|
||||
#if 0 /* pause doesn't generates a scancode */
|
||||
#if 0 /* pause doesn't generates a scancode */
|
||||
#define PHOTON_SCANCODE_PAUSE 0x??
|
||||
#endif
|
||||
#define PHOTON_SCANCODE_INSERT 0x52
|
||||
|
|
|
@ -270,7 +270,7 @@ photon_addrenderdriver(_THIS)
|
|||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* Render helper functions */
|
||||
/* Renderer helper functions */
|
||||
/****************************************************************************/
|
||||
|
||||
static int _photon_recreate_surfaces(SDL_Renderer * renderer)
|
||||
|
@ -577,6 +577,100 @@ int _photon_update_rectangles(SDL_Renderer* renderer, PhRect_t* rect)
|
|||
}
|
||||
}
|
||||
|
||||
int _photon_set_blending(SDL_Renderer* renderer, uint32_t blendmode, uint32_t globalalpha, uint32_t blendsource)
|
||||
{
|
||||
SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
|
||||
|
||||
/* Switch on requested graphics context modifiers */
|
||||
switch (blendmode)
|
||||
{
|
||||
case SDL_BLENDMODE_MASK:
|
||||
/* Enable and set chroma key */
|
||||
if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
|
||||
{
|
||||
PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
|
||||
PgChromaOnCx(rdata->gc);
|
||||
}
|
||||
break;
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
/* Enable and set chroma key and alpha blending */
|
||||
if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
|
||||
{
|
||||
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, globalalpha, 0);
|
||||
PgAlphaOnCx(rdata->gc);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
/* Enable and set chroma key and alpha blending */
|
||||
if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
|
||||
{
|
||||
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, globalalpha, 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:
|
||||
/* Do nothing */
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _photon_reset_blending(SDL_Renderer* renderer, uint32_t blendmode, uint32_t blendsource)
|
||||
{
|
||||
SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
|
||||
|
||||
/* Switch off graphics context modifiers */
|
||||
switch (blendmode)
|
||||
{
|
||||
case SDL_BLENDMODE_MASK:
|
||||
/* Disable chroma key */
|
||||
if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
|
||||
{
|
||||
PgChromaOffCx(rdata->gc);
|
||||
}
|
||||
break;
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
/* Disable chroma key and alpha blending */
|
||||
if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
|
||||
{
|
||||
PgChromaOffCx(rdata->gc);
|
||||
}
|
||||
PgAlphaOffCx(rdata->gc);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
/* Disable chroma key and alpha blending */
|
||||
if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
|
||||
{
|
||||
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:
|
||||
/* Do nothing */
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* SDL render interface */
|
||||
/****************************************************************************/
|
||||
|
@ -1069,9 +1163,30 @@ photon_setdrawcolor(SDL_Renderer * renderer)
|
|||
static int
|
||||
photon_setdrawblendmode(SDL_Renderer * renderer)
|
||||
{
|
||||
/* TODO */
|
||||
SDL_Unsupported();
|
||||
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;
|
||||
}
|
||||
|
||||
switch (renderer->blendMode)
|
||||
{
|
||||
case SDL_BLENDMODE_NONE:
|
||||
case SDL_BLENDMODE_MASK:
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
case SDL_BLENDMODE_ADD:
|
||||
case SDL_BLENDMODE_MOD:
|
||||
return 0;
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
renderer->blendMode = SDL_BLENDMODE_NONE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1086,6 +1201,9 @@ photon_renderpoint(SDL_Renderer * renderer, int x, int y)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* Enable blending, if requested */
|
||||
_photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND);
|
||||
|
||||
switch (rdata->surfaces_type)
|
||||
{
|
||||
case SDL_PHOTON_SURFTYPE_OFFSCREEN:
|
||||
|
@ -1099,6 +1217,9 @@ photon_renderpoint(SDL_Renderer * renderer, int x, int y)
|
|||
break;
|
||||
}
|
||||
|
||||
/* Disable blending, if it was enabled */
|
||||
_photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1114,6 +1235,9 @@ photon_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* Enable blending, if requested */
|
||||
_photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND);
|
||||
|
||||
switch (rdata->surfaces_type)
|
||||
{
|
||||
case SDL_PHOTON_SURFTYPE_OFFSCREEN:
|
||||
|
@ -1127,6 +1251,9 @@ photon_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
|
|||
break;
|
||||
}
|
||||
|
||||
/* Disable blending, if it was enabled */
|
||||
_photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1142,6 +1269,9 @@ photon_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* Enable blending, if requested */
|
||||
_photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND);
|
||||
|
||||
switch (rdata->surfaces_type)
|
||||
{
|
||||
case SDL_PHOTON_SURFTYPE_OFFSCREEN:
|
||||
|
@ -1154,6 +1284,11 @@ photon_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Disable blending, if it was enabled */
|
||||
_photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1174,38 +1309,7 @@ photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* Switch on requested graphics context modifiers */
|
||||
switch(texture->blendMode)
|
||||
{
|
||||
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);
|
||||
break;
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
/* 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:
|
||||
/* Do nothing */
|
||||
break;
|
||||
}
|
||||
_photon_set_blending(renderer, texture->blendMode, texture->a, SDL_PHOTON_TEXTURE_BLEND);
|
||||
|
||||
/* Set source blit area */
|
||||
src_rect.ul.x = srcrect->x;
|
||||
|
@ -1263,32 +1367,7 @@ photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
break;
|
||||
}
|
||||
|
||||
/* Switch off graphics context modifiers */
|
||||
switch(texture->blendMode)
|
||||
{
|
||||
case SDL_BLENDMODE_MASK:
|
||||
/* Disable chroma key */
|
||||
PgChromaOffCx(rdata->gc);
|
||||
break;
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
/* 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:
|
||||
/* Do nothing */
|
||||
break;
|
||||
}
|
||||
_photon_reset_blending(renderer, texture->blendMode, SDL_PHOTON_TEXTURE_BLEND);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1352,6 +1431,20 @@ photon_renderpresent(SDL_Renderer * renderer)
|
|||
/* finish blit */
|
||||
PgFFlush(Ph_DONE_DRAW);
|
||||
PgWaitHWIdle();
|
||||
|
||||
/* Check if we are using double buffering */
|
||||
if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2)
|
||||
{
|
||||
rdata->surface_visible_idx=rdata->surface_render_idx;
|
||||
rdata->surface_render_idx=(rdata->surface_render_idx + 1) % 2;
|
||||
}
|
||||
|
||||
/* Check if we are using triple buffering */
|
||||
if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) == SDL_RENDERER_PRESENTFLIP3)
|
||||
{
|
||||
rdata->surface_visible_idx=rdata->surface_render_idx;
|
||||
rdata->surface_render_idx=(rdata->surface_render_idx + 1) % 3;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
#define SDL_PHOTON_SURFTYPE_OFFSCREEN 0x00000001
|
||||
#define SDL_PHOTON_SURFTYPE_PHIMAGE 0x00000002
|
||||
|
||||
#define SDL_PHOTON_UNKNOWN_BLEND 0x00000000
|
||||
#define SDL_PHOTON_DRAW_BLEND 0x00000001
|
||||
#define SDL_PHOTON_TEXTURE_BLEND 0x00000002
|
||||
|
||||
typedef struct SDL_RenderData
|
||||
{
|
||||
SDL_bool enable_vsync; /* VSYNC flip synchronization enable */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue