Migrate planet scan tint to new drawing modes

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3477 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-12-27 07:23:28 +00:00
parent 24513c7b07
commit 8df76e7440
2 changed files with 28 additions and 32 deletions
+27 -31
View File
@@ -33,16 +33,6 @@
// It still doesn't look right though (it is too bright) // It still doesn't look right though (it is too bright)
#define USE_ADDITIVE_SCAN_BLIT #define USE_ADDITIVE_SCAN_BLIT
// XXX: these are currently defined in libs/graphics/sdl/3do_getbody.c
// they should be sorted out and cleaned up at some point
extern DWORD frame_mapRGBA (FRAME FramePtr, UBYTE r, UBYTE g,
UBYTE b, UBYTE a);
extern void fill_frame_rgb (FRAME FramePtr, DWORD color, int x0, int y0,
int x, int y);
extern void arith_frame_blit (FRAME srcFrame, const RECT *rsrc,
FRAME dstFrame, const RECT *rdst, int num, int denom);
static int rotFrameIndex; static int rotFrameIndex;
static int rotDirection; static int rotDirection;
static bool throbShield; static bool throbShield;
@@ -246,29 +236,35 @@ static void
renderTintFrame (Color tintColor) renderTintFrame (Color tintColor)
{ {
PLANET_ORBIT *Orbit = &pSolarSysState->Orbit; PLANET_ORBIT *Orbit = &pSolarSysState->Orbit;
DWORD pix; CONTEXT oldContext;
int denom; DrawMode mode, oldMode;
FRAME topoFrame = SetAbsFrameIndex (Orbit->TintFrame, 0); STAMP s;
FRAME tintFrame = SetAbsFrameIndex (Orbit->TintFrame, 1); RECT r;
// render a solid color frame we will use for tinting oldContext = SetContext (OffScreenContext);
#ifdef USE_ADDITIVE_SCAN_BLIT SetContextFGFrame (Orbit->TintFrame);
tintColor.r /= 2; SetContextClipRect (NULL);
tintColor.g /= 2; // get the rect of the whole context (or our frame really)
tintColor.b /= 2; GetContextClipRect (&r);
denom = -1;
#else // copy the topo frame to the tint frame
tintColor.a = 128; s.origin.x = 0;
denom = 0; s.origin.y = 0;
#endif s.frame = pSolarSysState->TopoFrame;
pix = frame_mapRGBA (tintFrame, tintColor.r, tintColor.g, tintColor.b, DrawStamp (&s);
tintColor.a);
fill_frame_rgb (tintFrame, pix, 0, 0, 0, 0);
// copy topoFrame
arith_frame_blit (pSolarSysState->TopoFrame, NULL, topoFrame, NULL, 0, 0);
// apply the tint // apply the tint
arith_frame_blit (tintFrame, NULL, topoFrame, NULL, 0, denom); #ifdef USE_ADDITIVE_SCAN_BLIT
mode = MAKE_DRAW_MODE (DRAW_ADDITIVE, DRAW_FACTOR_1 / 2);
#else
mode = MAKE_DRAW_MODE (DRAW_ALPHA, DRAW_FACTOR_1 / 2);
#endif
oldMode = SetContextDrawMode (mode);
SetContextForeGroundColor (tintColor);
DrawFilledRectangle (&r);
SetContextDrawMode (oldMode);
SetContext (oldContext);
} }
// tintColor.a is ignored // tintColor.a is ignored
@@ -289,7 +285,7 @@ DrawPlanet (int tintY, Color tintColor)
} }
else else
{ // apply different scan type tints { // apply different scan type tints
FRAME tintFrame = SetAbsFrameIndex (Orbit->TintFrame, 0); FRAME tintFrame = Orbit->TintFrame;
int height = GetFrameHeight (tintFrame); int height = GetFrameHeight (tintFrame);
if (!sameColor (tintColor, Orbit->TintColor)) if (!sameColor (tintColor, Orbit->TintColor))
+1 -1
View File
@@ -1296,7 +1296,7 @@ planet_orbit_init (void)
Orbit->SphereFrame = CaptureDrawable (CreateDrawable ( Orbit->SphereFrame = CaptureDrawable (CreateDrawable (
WANT_PIXMAP | WANT_ALPHA, DIAMETER, DIAMETER, 2)); WANT_PIXMAP | WANT_ALPHA, DIAMETER, DIAMETER, 2));
Orbit->TintFrame = CaptureDrawable (CreateDrawable ( Orbit->TintFrame = CaptureDrawable (CreateDrawable (
WANT_PIXMAP | WANT_ALPHA, MAP_WIDTH, MAP_HEIGHT, 2)); WANT_PIXMAP, MAP_WIDTH, MAP_HEIGHT, 1));
Orbit->ObjectFrame = 0; Orbit->ObjectFrame = 0;
Orbit->WorkFrame = 0; Orbit->WorkFrame = 0;
Orbit->lpTopoData = HCalloc (MAP_WIDTH * MAP_HEIGHT); Orbit->lpTopoData = HCalloc (MAP_WIDTH * MAP_HEIGHT);