Drawing functions take their color as a Color argument, instead of as separate r, g, and b arguments.

This paves the way for using draw operations with an alpha channel.



git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3369 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Meep-Eep
2009-11-29 19:54:51 +00:00
parent b67323f0b4
commit 85a10c006c
10 changed files with 111 additions and 122 deletions
+1 -1
View File
@@ -303,7 +303,7 @@ FixContextFontEffect (void)
RECT r = { {0, 0}, {w, h} }; RECT r = { {0, 0}, {w, h} };
Color color = _get_context_fg_color (); Color color = _get_context_fg_color ();
TFB_DrawImage_Rect (&r, color.r, color.g, color.b, img); TFB_DrawImage_Rect (&r, color, img);
} }
_pCurContext->FontBacking = img; _pCurContext->FontBacking = img;
+2 -2
View File
@@ -254,7 +254,7 @@ RotateFrame (FRAME Frame, int angle_deg)
void void
SetFrameTransparentColor (FRAME Frame, Color color) SetFrameTransparentColor (FRAME Frame, Color color)
{ {
TFB_DrawCanvas_SetTransparentColor (Frame->image->NormalImg, TFB_DrawCanvas_SetTransparentColor (Frame->image->NormalImg, color,
color.r, color.g, color.b, FALSE); FALSE);
} }
+4 -4
View File
@@ -46,14 +46,14 @@ enum
typedef struct tfb_dc_line typedef struct tfb_dc_line
{ {
int x1, y1, x2, y2; int x1, y1, x2, y2;
int r, g, b; Color color;
SCREEN destBuffer; SCREEN destBuffer;
} TFB_DrawCommand_Line; } TFB_DrawCommand_Line;
typedef struct tfb_dc_rect typedef struct tfb_dc_rect
{ {
RECT rect; RECT rect;
int r, g, b; Color color;
SCREEN destBuffer; SCREEN destBuffer;
} TFB_DrawCommand_Rect; } TFB_DrawCommand_Rect;
@@ -70,7 +70,7 @@ typedef struct tfb_dc_filledimg
{ {
TFB_Image *image; TFB_Image *image;
int x, y; int x, y;
int r, g, b; Color color;
SCREEN destBuffer; SCREEN destBuffer;
int scale; int scale;
} TFB_DrawCommand_FilledImage; } TFB_DrawCommand_FilledImage;
@@ -104,7 +104,7 @@ typedef struct tfb_dc_scissor
typedef struct tfb_dc_setpal typedef struct tfb_dc_setpal
{ {
int index; int index;
int r, g, b; Color color;
} TFB_DrawCommand_SetPalette; } TFB_DrawCommand_SetPalette;
typedef struct tfb_dc_setmip typedef struct tfb_dc_setmip
+55 -45
View File
@@ -42,40 +42,42 @@ TFB_DrawCanvas_Initialize (void)
} }
void void
TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TFB_Canvas target) TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, Color color,
TFB_Canvas target)
{ {
Uint32 color; Uint32 sdlColor;
PutPixelFn screen_plot; PutPixelFn screen_plot;
screen_plot = putpixel_for (target); screen_plot = putpixel_for (target);
color = SDL_MapRGB (((NativeCanvas) target)->format, r, g, b); sdlColor = SDL_MapRGB (((NativeCanvas) target)->format,
color.r, color.g, color.b);
SDL_LockSurface ((NativeCanvas) target); SDL_LockSurface ((NativeCanvas) target);
line (x1, y1, x2, y2, color, screen_plot, (NativeCanvas) target); line (x1, y1, x2, y2, sdlColor, screen_plot, (NativeCanvas) target);
SDL_UnlockSurface ((NativeCanvas) target); SDL_UnlockSurface ((NativeCanvas) target);
} }
void void
TFB_DrawCanvas_Rect (RECT *rect, int r, int g, int b, TFB_Canvas target) TFB_DrawCanvas_Rect (RECT *rect, Color color, TFB_Canvas target)
{ {
SDL_Surface *dst = target; SDL_Surface *dst = target;
SDL_PixelFormat *fmt = dst->format; SDL_PixelFormat *fmt = dst->format;
Uint32 color; Uint32 sdlColor;
SDL_Rect sr; SDL_Rect sr;
sr.x = rect->corner.x; sr.x = rect->corner.x;
sr.y = rect->corner.y; sr.y = rect->corner.y;
sr.w = rect->extent.width; sr.w = rect->extent.width;
sr.h = rect->extent.height; sr.h = rect->extent.height;
color = SDL_MapRGB (fmt, r, g, b); sdlColor = SDL_MapRGB (fmt, color.r, color.g, color.b);
if (fmt->Amask && (dst->flags & SDL_SRCCOLORKEY)) if (fmt->Amask && (dst->flags & SDL_SRCCOLORKEY))
{ // special case -- alpha surface with colorkey { // special case -- alpha surface with colorkey
// colorkey rects are transparent // colorkey rects are transparent
if ((color & ~fmt->Amask) == (fmt->colorkey & ~fmt->Amask)) if ((sdlColor & ~fmt->Amask) == (fmt->colorkey & ~fmt->Amask))
color &= ~fmt->Amask; // make transparent sdlColor &= ~fmt->Amask; // make transparent
} }
SDL_FillRect (dst, &sr, color); SDL_FillRect (dst, &sr, sdlColor);
} }
void void
@@ -88,7 +90,8 @@ TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale,
if (img == 0) if (img == 0)
{ {
log_add (log_Warning, "ERROR: TFB_DrawCanvas_Image passed null image ptr"); log_add (log_Warning,
"ERROR: TFB_DrawCanvas_Image passed null image ptr");
return; return;
} }
@@ -240,7 +243,8 @@ TFB_DrawCanvas_Fill (TFB_Canvas source, int width, int height,
} }
void void
TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, TFB_Canvas target) TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale,
Color color, TFB_Canvas target)
{ {
SDL_Rect srcRect, targetRect, *pSrcRect; SDL_Rect srcRect, targetRect, *pSrcRect;
SDL_Surface *surf; SDL_Surface *surf;
@@ -249,7 +253,8 @@ TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int
if (img == 0) if (img == 0)
{ {
log_add (log_Warning, "ERROR: TFB_DrawCanvas_FilledImage passed null image ptr"); log_add (log_Warning,
"ERROR: TFB_DrawCanvas_FilledImage passed null image ptr");
return; return;
} }
@@ -306,9 +311,9 @@ TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
pal[i].r = r; pal[i].r = color.r;
pal[i].g = g; pal[i].g = color.g;
pal[i].b = b; pal[i].b = color.b;
} }
SDL_SetColors (surf, pal, 0, 256); SDL_SetColors (surf, pal, 0, 256);
// reflect the change in *actual* image palette // reflect the change in *actual* image palette
@@ -338,19 +343,19 @@ TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int
} }
if (force_fill || if (force_fill ||
img->last_fill.r != r || img->last_fill.r != color.r ||
img->last_fill.g != g || img->last_fill.g != color.g ||
img->last_fill.b != b) img->last_fill.b != color.b)
{ // image or fillcolor changed - regenerate { // image or fillcolor changed - regenerate
TFB_DrawCanvas_Fill (surf, surf->w, surf->h, TFB_DrawCanvas_Fill (surf, surf->w, surf->h, SDL_MapRGBA (
SDL_MapRGBA (newfill->format, r, g, b, 0), newfill); newfill->format, color.r, color.g, color.b, 0), newfill);
// important to keep alpha=0 in fillcolor // important to keep alpha=0 in fillcolor
// -- we process alpha ourselves // -- we process alpha ourselves
// cache filled image if possible // cache filled image if possible
img->last_fill.r = r; img->last_fill.r = color.r;
img->last_fill.g = g; img->last_fill.g = color.g;
img->last_fill.b = b; img->last_fill.b = color.b;
} }
img->FilledImg = newfill; img->FilledImg = newfill;
@@ -687,7 +692,8 @@ TFB_DrawCanvas_SetTransparentIndex (TFB_Canvas canvas, int index, BOOLEAN rleacc
} }
void void
TFB_DrawCanvas_CopyTransparencyInfo (TFB_Canvas src_canvas, TFB_Canvas dst_canvas) TFB_DrawCanvas_CopyTransparencyInfo (TFB_Canvas src_canvas,
TFB_Canvas dst_canvas)
{ {
SDL_Surface* src = (SDL_Surface*)src_canvas; SDL_Surface* src = (SDL_Surface*)src_canvas;
@@ -699,14 +705,14 @@ TFB_DrawCanvas_CopyTransparencyInfo (TFB_Canvas src_canvas, TFB_Canvas dst_canva
} }
else else
{ {
int r, g, b; Color color;
if (TFB_DrawCanvas_GetTransparentColor (src_canvas, &r, &g, &b)) if (TFB_DrawCanvas_GetTransparentColor (src_canvas, &color))
TFB_DrawCanvas_SetTransparentColor (dst_canvas, r, g, b, FALSE); TFB_DrawCanvas_SetTransparentColor (dst_canvas, color, FALSE);
} }
} }
BOOLEAN BOOLEAN
TFB_DrawCanvas_GetTransparentColor (TFB_Canvas canvas, int *r, int *g, int *b) TFB_DrawCanvas_GetTransparentColor (TFB_Canvas canvas, Color *color)
{ {
if (!TFB_DrawCanvas_IsPaletted (canvas) if (!TFB_DrawCanvas_IsPaletted (canvas)
&& (((SDL_Surface *)canvas)->flags & SDL_SRCCOLORKEY) ) && (((SDL_Surface *)canvas)->flags & SDL_SRCCOLORKEY) )
@@ -714,24 +720,26 @@ TFB_DrawCanvas_GetTransparentColor (TFB_Canvas canvas, int *r, int *g, int *b)
Uint8 ur, ug, ub; Uint8 ur, ug, ub;
int colorkey = ((SDL_Surface *)canvas)->format->colorkey; int colorkey = ((SDL_Surface *)canvas)->format->colorkey;
SDL_GetRGB (colorkey, ((SDL_Surface *)canvas)->format, &ur, &ug, &ub); SDL_GetRGB (colorkey, ((SDL_Surface *)canvas)->format, &ur, &ug, &ub);
*r = ur; color->r = ur;
*g = ug; color->g = ug;
*b = ub; color->b = ub;
color->a = 0xff;
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
void void
TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, int r, int g, int b, TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, Color color,
BOOLEAN rleaccel) BOOLEAN rleaccel)
{ {
Uint32 color; Uint32 sdlColor;
int flags = SDL_SRCCOLORKEY; int flags = SDL_SRCCOLORKEY;
if (rleaccel) if (rleaccel)
flags |= SDL_RLEACCEL; flags |= SDL_RLEACCEL;
color = SDL_MapRGBA (((SDL_Surface *)canvas)->format, r, g, b, 0); sdlColor = SDL_MapRGBA (((SDL_Surface *)canvas)->format,
SDL_SetColorKey ((SDL_Surface *)canvas, flags, color); color.r, color.g, color.b, 0);
SDL_SetColorKey ((SDL_Surface *)canvas, flags, sdlColor);
if (!TFB_DrawCanvas_IsPaletted (canvas)) if (!TFB_DrawCanvas_IsPaletted (canvas))
{ {
@@ -1591,7 +1599,7 @@ TFB_DrawCanvas_GetLine (TFB_Canvas canvas, int line)
} }
void void
TFB_DrawCanvas_GetPixel (TFB_Canvas canvas, int x, int y, int *r, int *g, int *b) TFB_DrawCanvas_GetPixel (TFB_Canvas canvas, int x, int y, Color *color)
{ {
SDL_Surface* surf = (SDL_Surface *)canvas; SDL_Surface* surf = (SDL_Surface *)canvas;
Uint8 ur, ug, ub; Uint8 ur, ug, ub;
@@ -1601,18 +1609,19 @@ TFB_DrawCanvas_GetPixel (TFB_Canvas canvas, int x, int y, int *r, int *g, int *b
getpixel = getpixel_for(surf); getpixel = getpixel_for(surf);
pixel = (*getpixel)(surf, x, y); pixel = (*getpixel)(surf, x, y);
SDL_GetRGB (pixel, surf->format, &ur, &ug, &ub); SDL_GetRGB (pixel, surf->format, &ur, &ug, &ub);
*r = ur; color->r = ur;
*g = ug; color->g = ug;
*b = ub; color->b = ub;
} }
void void
TFB_DrawCanvas_Rotate (TFB_Canvas src_canvas, TFB_Canvas dst_canvas, int angle, EXTENT size) TFB_DrawCanvas_Rotate (TFB_Canvas src_canvas, TFB_Canvas dst_canvas,
int angle, EXTENT size)
{ {
SDL_Surface *src = (SDL_Surface *)src_canvas; SDL_Surface *src = (SDL_Surface *)src_canvas;
SDL_Surface *dst = (SDL_Surface *)dst_canvas; SDL_Surface *dst = (SDL_Surface *)dst_canvas;
int ret; int ret;
int r, g, b; Color color;
if (size.width > dst->w || size.height > dst->h) if (size.width > dst->w || size.height > dst->h)
{ {
@@ -1623,11 +1632,12 @@ TFB_DrawCanvas_Rotate (TFB_Canvas src_canvas, TFB_Canvas dst_canvas, int angle,
return; return;
} }
if (TFB_DrawCanvas_GetTransparentColor (src, &r, &g, &b)) if (TFB_DrawCanvas_GetTransparentColor (src, &color))
{ {
TFB_DrawCanvas_SetTransparentColor (dst, r, g, b, FALSE); TFB_DrawCanvas_SetTransparentColor (dst, color, FALSE);
/* fill destination with transparent color before rotating */ /* fill destination with transparent color before rotating */
SDL_FillRect(dst, NULL, SDL_MapRGBA (dst->format, r, g, b, 0)); SDL_FillRect(dst, NULL, SDL_MapRGBA (dst->format,
color.r, color.g, color.b, 0));
} }
ret = rotateSurface (src, dst, angle, 0); ret = rotateSurface (src, dst, angle, 0);
+2 -1
View File
@@ -150,7 +150,8 @@ PutPixelFn putpixel_for(SDL_Surface *surface)
* Adapted from Paul Heckbert's implementation of Bresenham's algorithm, * Adapted from Paul Heckbert's implementation of Bresenham's algorithm,
* 3 Sep 85; taken from Graphics Gems I */ * 3 Sep 85; taken from Graphics Gems I */
void line(int x1, int y1, int x2, int y2, Uint32 color, PutPixelFn plot, SDL_Surface *surface) void line(int x1, int y1, int x2, int y2, Uint32 color, PutPixelFn plot,
SDL_Surface *surface)
{ {
int d, x, y, ax, ay, sx, sy, dx, dy; int d, x, y, ax, ay, sx, sy, dx, dy;
SDL_Rect r; SDL_Rect r;
+3 -5
View File
@@ -724,8 +724,7 @@ TFB_FlushGraphics (void) // Only call from main thread!!
TFB_DrawCanvas_FilledImage (DC.data.filledimage.image, TFB_DrawCanvas_FilledImage (DC.data.filledimage.image,
DC.data.filledimage.x, DC.data.filledimage.y, DC.data.filledimage.x, DC.data.filledimage.y,
DC.data.filledimage.scale, DC.data.filledimage.r, DC.data.filledimage.scale, DC.data.filledimage.color,
DC.data.filledimage.g, DC.data.filledimage.b,
SDL_Screens[DC.data.filledimage.destBuffer]); SDL_Screens[DC.data.filledimage.destBuffer]);
if (DC.data.filledimage.destBuffer == 0) if (DC.data.filledimage.destBuffer == 0)
@@ -778,7 +777,7 @@ TFB_FlushGraphics (void) // Only call from main thread!!
} }
TFB_DrawCanvas_Line (DC.data.line.x1, DC.data.line.y1, TFB_DrawCanvas_Line (DC.data.line.x1, DC.data.line.y1,
DC.data.line.x2, DC.data.line.y2, DC.data.line.x2, DC.data.line.y2,
DC.data.line.r, DC.data.line.g, DC.data.line.b, DC.data.line.color,
SDL_Screens[DC.data.line.destBuffer]); SDL_Screens[DC.data.line.destBuffer]);
break; break;
} }
@@ -786,8 +785,7 @@ TFB_FlushGraphics (void) // Only call from main thread!!
{ {
if (DC.data.rect.destBuffer == 0) if (DC.data.rect.destBuffer == 0)
TFB_BBox_RegisterRect (&DC.data.rect.rect); TFB_BBox_RegisterRect (&DC.data.rect.rect);
TFB_DrawCanvas_Rect (&DC.data.rect.rect, DC.data.rect.r, TFB_DrawCanvas_Rect (&DC.data.rect.rect, DC.data.rect.color,
DC.data.rect.g, DC.data.rect.b,
SDL_Screens[DC.data.rect.destBuffer]); SDL_Screens[DC.data.rect.destBuffer]);
break; break;
+12 -19
View File
@@ -24,8 +24,7 @@
static const HOT_SPOT NullHs = {0, 0}; static const HOT_SPOT NullHs = {0, 0};
void void
TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, Color color, SCREEN dest)
SCREEN dest)
{ {
TFB_DrawCommand DC; TFB_DrawCommand DC;
@@ -34,16 +33,14 @@ TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, int r, int g, int b,
DC.data.line.y1 = y1; DC.data.line.y1 = y1;
DC.data.line.x2 = x2; DC.data.line.x2 = x2;
DC.data.line.y2 = y2; DC.data.line.y2 = y2;
DC.data.line.r = r; DC.data.line.color = color;
DC.data.line.g = g;
DC.data.line.b = b;
DC.data.line.destBuffer = dest; DC.data.line.destBuffer = dest;
TFB_EnqueueDrawCommand (&DC); TFB_EnqueueDrawCommand (&DC);
} }
void void
TFB_DrawScreen_Rect (RECT *rect, int r, int g, int b, SCREEN dest) TFB_DrawScreen_Rect (RECT *rect, Color color, SCREEN dest)
{ {
RECT locRect; RECT locRect;
TFB_DrawCommand DC; TFB_DrawCommand DC;
@@ -58,9 +55,7 @@ TFB_DrawScreen_Rect (RECT *rect, int r, int g, int b, SCREEN dest)
DC.Type = TFB_DRAWCOMMANDTYPE_RECTANGLE; DC.Type = TFB_DRAWCOMMANDTYPE_RECTANGLE;
DC.data.rect.rect = *rect; DC.data.rect.rect = *rect;
DC.data.rect.r = r; DC.data.rect.color = color;
DC.data.rect.g = g;
DC.data.rect.b = b;
DC.data.rect.destBuffer = dest; DC.data.rect.destBuffer = dest;
TFB_EnqueueDrawCommand (&DC); TFB_EnqueueDrawCommand (&DC);
@@ -85,7 +80,7 @@ TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale,
void void
TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale,
int r, int g, int b, SCREEN dest) Color color, SCREEN dest)
{ {
TFB_DrawCommand DC; TFB_DrawCommand DC;
@@ -94,9 +89,7 @@ TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale,
DC.data.filledimage.x = x; DC.data.filledimage.x = x;
DC.data.filledimage.y = y; DC.data.filledimage.y = y;
DC.data.filledimage.scale = (scale == GSCALE_IDENTITY) ? 0 : scale; DC.data.filledimage.scale = (scale == GSCALE_IDENTITY) ? 0 : scale;
DC.data.filledimage.r = r; DC.data.filledimage.color = color;
DC.data.filledimage.g = g;
DC.data.filledimage.b = b;
DC.data.filledimage.destBuffer = dest; DC.data.filledimage.destBuffer = dest;
TFB_EnqueueDrawCommand (&DC); TFB_EnqueueDrawCommand (&DC);
@@ -240,20 +233,20 @@ TFB_DrawScreen_Callback (void (*callback) (void *arg), void *arg)
} }
void void
TFB_DrawImage_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TFB_DrawImage_Line (int x1, int y1, int x2, int y2, Color color,
TFB_Image *dest) TFB_Image *dest)
{ {
LockMutex (dest->mutex); LockMutex (dest->mutex);
TFB_DrawCanvas_Line (x1, y1, x2, y2, r, g, b, dest->NormalImg); TFB_DrawCanvas_Line (x1, y1, x2, y2, color, dest->NormalImg);
dest->dirty = TRUE; dest->dirty = TRUE;
UnlockMutex (dest->mutex); UnlockMutex (dest->mutex);
} }
void void
TFB_DrawImage_Rect (RECT *rect, int r, int g, int b, TFB_Image *image) TFB_DrawImage_Rect (RECT *rect, Color color, TFB_Image *image)
{ {
LockMutex (image->mutex); LockMutex (image->mutex);
TFB_DrawCanvas_Rect (rect, r, g, b, image->NormalImg); TFB_DrawCanvas_Rect (rect, color, image->NormalImg);
image->dirty = TRUE; image->dirty = TRUE;
UnlockMutex (image->mutex); UnlockMutex (image->mutex);
} }
@@ -270,10 +263,10 @@ TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale,
void void
TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale,
int r, int g, int b, TFB_Image *target) Color color, TFB_Image *target)
{ {
LockMutex (target->mutex); LockMutex (target->mutex);
TFB_DrawCanvas_FilledImage (img, x, y, scale, r, g, b, target->NormalImg); TFB_DrawCanvas_FilledImage (img, x, y, scale, color, target->NormalImg);
target->dirty = TRUE; target->dirty = TRUE;
UnlockMutex (target->mutex); UnlockMutex (target->mutex);
} }
+12 -13
View File
@@ -79,14 +79,14 @@ typedef struct tfb_pixelformat
// Drawing commands // Drawing commands
void TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, int r, int g, int b, void TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, Color color,
SCREEN dest); SCREEN dest);
void TFB_DrawScreen_Rect (RECT *rect, int r, int g, int b, SCREEN dest); void TFB_DrawScreen_Rect (RECT *rect, Color color, SCREEN dest);
void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale,
TFB_ColorMap *cmap, SCREEN dest); TFB_ColorMap *cmap, SCREEN dest);
void TFB_DrawScreen_Copy (RECT *r, SCREEN src, SCREEN dest); void TFB_DrawScreen_Copy (RECT *r, SCREEN src, SCREEN dest);
void TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, void TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale,
int r, int g, int b, SCREEN dest); Color color, SCREEN dest);
void TFB_DrawScreen_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, void TFB_DrawScreen_FontChar (TFB_Char *, TFB_Image *backing, int x, int y,
SCREEN dest); SCREEN dest);
@@ -107,13 +107,13 @@ void TFB_DrawImage_SetMipmap (TFB_Image *img, TFB_Image *mmimg, int hotx,
void TFB_DrawImage_Delete (TFB_Image *image); void TFB_DrawImage_Delete (TFB_Image *image);
void TFB_DrawImage_FixScaling (TFB_Image *image, int target, int type); void TFB_DrawImage_FixScaling (TFB_Image *image, int target, int type);
void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, int r, int g, int b, void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, Color color,
TFB_Image *dest); TFB_Image *dest);
void TFB_DrawImage_Rect (RECT *rect, int r, int g, int b, TFB_Image *image); void TFB_DrawImage_Rect (RECT *rect, Color color, TFB_Image *image);
void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale,
TFB_ColorMap *cmap, TFB_Image *target); TFB_ColorMap *cmap, TFB_Image *target);
void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale,
int r, int g, int b, TFB_Image *target); Color color, TFB_Image *target);
void TFB_DrawImage_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, void TFB_DrawImage_FontChar (TFB_Char *, TFB_Image *backing, int x, int y,
TFB_Image *target); TFB_Image *target);
@@ -143,13 +143,13 @@ void TFB_DrawCanvas_GetExtent (TFB_Canvas canvas, EXTENT *size);
void TFB_DrawCanvas_Delete (TFB_Canvas canvas); void TFB_DrawCanvas_Delete (TFB_Canvas canvas);
void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, int r, int g, int b, void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, Color color,
TFB_Canvas dest); TFB_Canvas dest);
void TFB_DrawCanvas_Rect (RECT *rect, int r, int g, int b, TFB_Canvas image); void TFB_DrawCanvas_Rect (RECT *rect, Color color, TFB_Canvas image);
void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale,
TFB_ColorMap *cmap, TFB_Canvas target); TFB_ColorMap *cmap, TFB_Canvas target);
void TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, void TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale,
int r, int g, int b, TFB_Canvas target); Color color, TFB_Canvas target);
void TFB_DrawCanvas_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, void TFB_DrawCanvas_FontChar (TFB_Char *, TFB_Image *backing, int x, int y,
TFB_Canvas target); TFB_Canvas target);
@@ -159,9 +159,9 @@ int TFB_DrawCanvas_GetTransparentIndex (TFB_Canvas canvas);
void TFB_DrawCanvas_SetTransparentIndex (TFB_Canvas canvas, int i, void TFB_DrawCanvas_SetTransparentIndex (TFB_Canvas canvas, int i,
BOOLEAN rleaccel); BOOLEAN rleaccel);
BOOLEAN TFB_DrawCanvas_GetTransparentColor (TFB_Canvas canvas, BOOLEAN TFB_DrawCanvas_GetTransparentColor (TFB_Canvas canvas,
int *r, int *g, int *b); Color *color);
void TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, void TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas,
int r, int g, int b, BOOLEAN rleaccel); Color color, BOOLEAN rleaccel);
void TFB_DrawCanvas_CopyTransparencyInfo (TFB_Canvas src, TFB_Canvas dst); void TFB_DrawCanvas_CopyTransparencyInfo (TFB_Canvas src, TFB_Canvas dst);
void TFB_DrawCanvas_Initialize (void); void TFB_DrawCanvas_Initialize (void);
void TFB_DrawCanvas_Lock (TFB_Canvas canvas); void TFB_DrawCanvas_Lock (TFB_Canvas canvas);
@@ -169,8 +169,7 @@ void TFB_DrawCanvas_Unlock (TFB_Canvas canvas);
void TFB_DrawCanvas_GetScreenFormat (TFB_PixelFormat *fmt); void TFB_DrawCanvas_GetScreenFormat (TFB_PixelFormat *fmt);
int TFB_DrawCanvas_GetStride (TFB_Canvas canvas); int TFB_DrawCanvas_GetStride (TFB_Canvas canvas);
void *TFB_DrawCanvas_GetLine (TFB_Canvas canvas, int line); void *TFB_DrawCanvas_GetLine (TFB_Canvas canvas, int line);
void TFB_DrawCanvas_GetPixel (TFB_Canvas canvas, int x, int y, void TFB_DrawCanvas_GetPixel (TFB_Canvas canvas, int x, int y, Color *color);
int *r, int *g, int *b);
TFB_Canvas TFB_GetScreenCanvas (SCREEN screen); TFB_Canvas TFB_GetScreenCanvas (SCREEN screen);
+12 -27
View File
@@ -38,10 +38,9 @@ TFB_Prim_Point (POINT *p, Color color)
r.extent.width = r.extent.height = 1; r.extent.width = r.extent.height = 1;
if (_CurFramePtr->Type == SCREEN_DRAWABLE) if (_CurFramePtr->Type == SCREEN_DRAWABLE)
TFB_DrawScreen_Rect (&r, color.r, color.g, color.b, TFB_SCREEN_MAIN); TFB_DrawScreen_Rect (&r, color, TFB_SCREEN_MAIN);
else else
TFB_DrawImage_Rect (&r, color.r, color.g, color.b, TFB_DrawImage_Rect (&r, color, _CurFramePtr->image);
_CurFramePtr->image);
} }
void void
@@ -87,18 +86,14 @@ TFB_Prim_FillRect (RECT *r, Color color)
+ (GSCALE_IDENTITY >> 1)) / GSCALE_IDENTITY; + (GSCALE_IDENTITY >> 1)) / GSCALE_IDENTITY;
rect.extent.height = (rect.extent.height * gscale rect.extent.height = (rect.extent.height * gscale
+ (GSCALE_IDENTITY >> 1)) / GSCALE_IDENTITY; + (GSCALE_IDENTITY >> 1)) / GSCALE_IDENTITY;
rect.corner.x += (r->extent.width - rect.corner.x += (r->extent.width - rect.extent.width) >> 1;
rect.extent.width) >> 1; rect.corner.y += (r->extent.height - rect.extent.height) >> 1;
rect.corner.y += (r->extent.height -
rect.extent.height) >> 1;
} }
if (_CurFramePtr->Type == SCREEN_DRAWABLE) if (_CurFramePtr->Type == SCREEN_DRAWABLE)
TFB_DrawScreen_Rect (&rect, color.r, color.g, color.b, TFB_DrawScreen_Rect (&rect, color, TFB_SCREEN_MAIN);
TFB_SCREEN_MAIN);
else else
TFB_DrawImage_Rect (&rect, color.r, color.g, color.b, TFB_DrawImage_Rect (&rect, color, _CurFramePtr->image);
_CurFramePtr->image);
} }
void void
@@ -112,11 +107,9 @@ TFB_Prim_Line (LINE *line, Color color)
y2=line->second.y - _CurFramePtr->HotSpot.y; y2=line->second.y - _CurFramePtr->HotSpot.y;
if (_CurFramePtr->Type == SCREEN_DRAWABLE) if (_CurFramePtr->Type == SCREEN_DRAWABLE)
TFB_DrawScreen_Line (x1, y1, x2, y2, color.r, color.g, color.b, TFB_DrawScreen_Line (x1, y1, x2, y2, color, TFB_SCREEN_MAIN);
TFB_SCREEN_MAIN);
else else
TFB_DrawImage_Line (x1, y1, x2, y2, color.r, color.g, color.b, TFB_DrawImage_Line (x1, y1, x2, y2, color, _CurFramePtr->image);
_CurFramePtr->image);
} }
void void
@@ -174,7 +167,6 @@ TFB_Prim_StampFill (STAMP *stmp, Color color)
int x, y; int x, y;
FRAME SrcFramePtr; FRAME SrcFramePtr;
TFB_Image *img; TFB_Image *img;
int r, g, b;
int gscale; int gscale;
SrcFramePtr = stmp->frame; SrcFramePtr = stmp->frame;
@@ -199,20 +191,15 @@ TFB_Prim_StampFill (STAMP *stmp, Color color)
x = stmp->origin.x - _CurFramePtr->HotSpot.x; x = stmp->origin.x - _CurFramePtr->HotSpot.x;
y = stmp->origin.y - _CurFramePtr->HotSpot.y; y = stmp->origin.y - _CurFramePtr->HotSpot.y;
r = color.r;
g = color.g;
b = color.b;
UnlockMutex (img->mutex); UnlockMutex (img->mutex);
if (_CurFramePtr->Type == SCREEN_DRAWABLE) if (_CurFramePtr->Type == SCREEN_DRAWABLE)
{ {
TFB_DrawScreen_FilledImage (img, x, y, gscale, r, g, b, TFB_DrawScreen_FilledImage (img, x, y, gscale, color, TFB_SCREEN_MAIN);
TFB_SCREEN_MAIN);
} }
else else
{ {
TFB_DrawImage_FilledImage (img, x, y, gscale, r, g, b, TFB_DrawImage_FilledImage (img, x, y, gscale, color,
_CurFramePtr->image); _CurFramePtr->image);
} }
} }
@@ -227,13 +214,11 @@ TFB_Prim_FontChar (POINT *origin, TFB_Char *fontChar, TFB_Image *backing)
if (_CurFramePtr->Type == SCREEN_DRAWABLE) if (_CurFramePtr->Type == SCREEN_DRAWABLE)
{ {
TFB_DrawScreen_FontChar (fontChar, backing, x, y, TFB_DrawScreen_FontChar (fontChar, backing, x, y, TFB_SCREEN_MAIN);
TFB_SCREEN_MAIN);
} }
else else
{ {
TFB_DrawImage_FontChar (fontChar, backing, x, y, TFB_DrawImage_FontChar (fontChar, backing, x, y, _CurFramePtr->image);
_CurFramePtr->image);
} }
} }
+7 -4
View File
@@ -94,18 +94,21 @@ DrawOscilloscope (void)
TFB_DrawImage_Image (scope_bg, 0, 0, 0, NULL, scope_surf); TFB_DrawImage_Image (scope_bg, 0, 0, 0, NULL, scope_surf);
if (GraphForegroundStream (scope_data, RADAR_WIDTH - 2, RADAR_HEIGHT - 2)) if (GraphForegroundStream (scope_data, RADAR_WIDTH - 2, RADAR_HEIGHT - 2))
{ {
int i, r, g, b; int i;
Color color;
TFB_DrawCanvas_GetPixel (scope_bg->NormalImg, TFB_DrawCanvas_GetPixel (scope_bg->NormalImg,
scope_bg->extent.width / 2, scope_bg->extent.height / 2, scope_bg->extent.width / 2, scope_bg->extent.height / 2,
&r, &g, &b); &color);
for (i = 0; i < RADAR_WIDTH - 3; ++i) for (i = 0; i < RADAR_WIDTH - 3; ++i)
TFB_DrawImage_Line (i + 1, scope_data[i] + 1, i + 2, TFB_DrawImage_Line (i + 1, scope_data[i] + 1, i + 2,
scope_data[i + 1] + 1, r, g, b, scope_surf); scope_data[i + 1] + 1, color, scope_surf);
} }
TFB_DrawImage_Image (scope_surf, 0, 0, 0, NULL, scope_frame->image); TFB_DrawImage_Image (scope_surf, 0, 0, 0, NULL, scope_frame->image);
s.frame = scope_frame; s.frame = scope_frame;
s.origin.x = s.origin.y = 0; s.origin.x = 0;
s.origin.y = 0;
DrawStamp (&s); DrawStamp (&s);
} }