From bec5d39ca89366155ef6f9d935538978a4bb799a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Dec 2016 18:58:39 +0100 Subject: [PATCH] ColoredSpan and FogBoundary drawers --- src/r_draw_pal.cpp | 24 ++++++++++++++++++++++-- src/r_draw_pal.h | 14 +++++++++++++- src/r_plane.cpp | 5 ----- src/r_plane.h | 5 ----- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index fa4b7df1d9..6eeba9ec75 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -2275,12 +2275,19 @@ namespace swrenderer ///////////////////////////////////////////////////////////////////////// - DrawColoredSpanPalCommand::DrawColoredSpanPalCommand(int y, int x1, int x2) + DrawColoredSpanPalCommand::DrawColoredSpanPalCommand(int y, int x1, int x2) : y(y), x1(x1), x2(x2) { + using namespace drawerargs; + color = ds_color; + destorg = dc_destorg; } void DrawColoredSpanPalCommand::Execute(DrawerThread *thread) { + if (thread->line_skipped_by_thread(y)) + return; + + memset(ylookup[y] + x1 + destorg, color, x2 - x1 + 1); } ///////////////////////////////////////////////////////////////////////// @@ -2325,11 +2332,24 @@ namespace swrenderer ///////////////////////////////////////////////////////////////////////// - DrawFogBoundaryLinePalCommand::DrawFogBoundaryLinePalCommand(int y, int y2, int x1) + DrawFogBoundaryLinePalCommand::DrawFogBoundaryLinePalCommand(int y, int x1, int x2) : y(y), x1(x1), x2(x2) { + using namespace drawerargs; + _colormap = dc_colormap; + _destorg = dc_destorg; } void DrawFogBoundaryLinePalCommand::Execute(DrawerThread *thread) { + if (thread->line_skipped_by_thread(y)) + return; + + const uint8_t *colormap = _colormap; + uint8_t *dest = ylookup[y] + _destorg; + int x = x1; + do + { + dest[x] = colormap[dest[x]]; + } while (++x <= x2); } } diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index ba9a953c3d..6fe775568d 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -188,6 +188,13 @@ namespace swrenderer DrawColoredSpanPalCommand(int y, int x1, int x2); void Execute(DrawerThread *thread) override; FString DebugInfo() override { return "DrawColoredSpanPalCommand"; } + + private: + int y; + int x1; + int x2; + int color; + uint8_t *destorg; }; class DrawSlabPalCommand : public PalSpanCommand @@ -211,8 +218,13 @@ namespace swrenderer class DrawFogBoundaryLinePalCommand : public PalSpanCommand { public: - DrawFogBoundaryLinePalCommand(int y, int y2, int x1); + DrawFogBoundaryLinePalCommand(int y, int x1, int x2); void Execute(DrawerThread *thread) override; + + private: + int y, x1, x2; + const uint8_t *_colormap; + uint8_t *_destorg; }; class RtInitColsPalCommand : public DrawerCommand diff --git a/src/r_plane.cpp b/src/r_plane.cpp index c6c7d6d2f0..3b026b293d 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -522,11 +522,6 @@ void R_MapTiltedPlane (int y, int x1) // //========================================================================== -void R_MapColoredPlane_C (int y, int x1) -{ - memset (ylookup[y] + x1 + dc_destorg, ds_color, spanend[y] - x1 + 1); -} - void R_MapColoredPlane(int y, int x1) { R_DrawColoredSpan(y, x1, spanend[y]); diff --git a/src/r_plane.h b/src/r_plane.h index 9141411af3..3a067b527e 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -96,11 +96,6 @@ void R_DrawNormalPlane (visplane_t *pl, double xscale, double yscale, fixed_t al void R_DrawTiltedPlane (visplane_t *pl, double xscale, double yscale, fixed_t alpha, bool additive, bool masked); void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1)); -void R_MapTiltedPlane_C(int y, int x1); -void R_MapTiltedPlane_rgba(int y, int x); -void R_MapColoredPlane_C(int y, int x1); -void R_MapColoredPlane_rgba(int y, int x1); - visplane_t *R_FindPlane ( const secplane_t &height, FTextureID picnum,