Generalize more common elements of graphics backends, isolate backend-specific parts

This commit is contained in:
Michael Martin
2019-08-17 20:56:25 -07:00
parent dd4c3e433e
commit 29fcff95c7
5 changed files with 19 additions and 11 deletions
+7 -2
View File
@@ -52,6 +52,7 @@ static BOOLEAN first_init = TRUE;
static void TFB_GL_Preprocess (int force_full_redraw, int transition_amount, int fade_amount);
static void TFB_GL_Postprocess (void);
static void TFB_GL_UploadTransitionScreen (void);
static void TFB_GL_Scaled_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect);
static void TFB_GL_Unscaled_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect);
static void TFB_GL_ColorLayer (Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_Rect *rect);
@@ -59,12 +60,14 @@ static void TFB_GL_ColorLayer (Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_Rect *rec
static TFB_GRAPHICS_BACKEND opengl_scaled_backend = {
TFB_GL_Preprocess,
TFB_GL_Postprocess,
TFB_GL_UploadTransitionScreen,
TFB_GL_Scaled_ScreenLayer,
TFB_GL_ColorLayer };
static TFB_GRAPHICS_BACKEND opengl_unscaled_backend = {
TFB_GL_Preprocess,
TFB_GL_Postprocess,
TFB_GL_UploadTransitionScreen,
TFB_GL_Unscaled_ScreenLayer,
TFB_GL_ColorLayer };
@@ -96,6 +99,7 @@ ReInit_Screen (SDL_Surface **screen, SDL_Surface *template, int w, int h)
static int
AttemptColorDepth (int flags, int width, int height, int bpp)
{
SDL_Surface *SDL_Video;
int videomode_flags;
ScreenColorDepth = bpp;
ScreenWidthActual = width;
@@ -298,7 +302,8 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height)
return 0;
}
void TFB_GL_UploadTransitionScreen (void)
static void
TFB_GL_UploadTransitionScreen (void)
{
GL_Screens[TFB_SCREEN_TRANSITION].updated.x = 0;
GL_Screens[TFB_SCREEN_TRANSITION].updated.y = 0;
@@ -307,7 +312,7 @@ void TFB_GL_UploadTransitionScreen (void)
GL_Screens[TFB_SCREEN_TRANSITION].dirty = TRUE;
}
void
static void
TFB_GL_ScanLines (void)
{
int y;
-1
View File
@@ -23,7 +23,6 @@
int TFB_GL_InitGraphics (int driver, int flags, int width, int height);
int TFB_GL_ConfigureVideo (int driver, int flags, int width, int height, int togglefullscreen);
void TFB_GL_UploadTransitionScreen (void);
#ifdef HAVE_OPENGL
#ifdef WIN32
+10
View File
@@ -20,6 +20,7 @@
#include "scalers.h"
#include "libs/log.h"
static SDL_Surface *SDL_Video = NULL;
static SDL_Surface *fade_color_surface = NULL;
static SDL_Surface *fade_temp = NULL;
static SDL_Surface *scaled_display = NULL;
@@ -32,18 +33,21 @@ static void TFB_Pure_Scaled_Preprocess (int force_full_redraw, int transition_am
static void TFB_Pure_Scaled_Postprocess (void);
static void TFB_Pure_Unscaled_Preprocess (int force_full_redraw, int transition_amount, int fade_amount);
static void TFB_Pure_Unscaled_Postprocess (void);
static void TFB_Pure_UploadTransitionScreen (void);
static void TFB_Pure_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect);
static void TFB_Pure_ColorLayer (Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_Rect *rect);
static TFB_GRAPHICS_BACKEND pure_scaled_backend = {
TFB_Pure_Scaled_Preprocess,
TFB_Pure_Scaled_Postprocess,
TFB_Pure_UploadTransitionScreen,
TFB_Pure_ScreenLayer,
TFB_Pure_ColorLayer };
static TFB_GRAPHICS_BACKEND pure_unscaled_backend = {
TFB_Pure_Unscaled_Preprocess,
TFB_Pure_Unscaled_Postprocess,
TFB_Pure_UploadTransitionScreen,
TFB_Pure_ScreenLayer,
TFB_Pure_ColorLayer };
@@ -402,6 +406,12 @@ TFB_Pure_Unscaled_Postprocess (void)
updated.w, updated.h);
}
static void
TFB_Pure_UploadTransitionScreen (void)
{
/* This is a no-op in SDL1 Pure mode */
}
static void
TFB_Pure_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect)
{
+1 -7
View File
@@ -35,7 +35,6 @@
#include "libs/vidlib.h"
#include SDL_INCLUDE(SDL_thread.h)
SDL_Surface *SDL_Video;
SDL_Surface *SDL_Screen;
SDL_Surface *TransitionScreen;
@@ -584,12 +583,7 @@ TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
void
TFB_UploadTransitionScreen (void)
{
#ifdef HAVE_OPENGL
if (GraphicsDriver == TFB_GFXDRIVER_SDL_OPENGL)
{
TFB_GL_UploadTransitionScreen ();
}
#endif
graphics_backend->uploadTransitionScreen ();
}
void
+1 -1
View File
@@ -30,13 +30,13 @@
typedef struct _tfb_graphics_backend {
void (*preprocess) (int force_redraw, int transition_amount, int fade_amount);
void (*postprocess) (void);
void (*uploadTransitionScreen) (void);
void (*screen) (SCREEN screen, Uint8 alpha, SDL_Rect *rect);
void (*color) (Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_Rect *rect);
} TFB_GRAPHICS_BACKEND;
extern TFB_GRAPHICS_BACKEND *graphics_backend;
extern SDL_Surface *SDL_Video;
extern SDL_Surface *SDL_Screen;
extern SDL_Surface *TransitionScreen;