From d8f805ddc92df236549b4e35d05790ea2a173941 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Dec 2016 18:31:26 +0100 Subject: [PATCH] Added DrawSlabPalCommand and rewrote the actual for loop so nobody can say it came from build.. --- src/r_draw_pal.cpp | 30 ++++++++++++++++++++++++++++++ src/r_draw_pal.h | 11 +++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index ab598957d..fa4b7df1d 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -2286,11 +2286,41 @@ namespace swrenderer ///////////////////////////////////////////////////////////////////////// DrawSlabPalCommand::DrawSlabPalCommand(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p, const uint8_t *colormap) + : _dx(dx), _v(v), _dy(dy), _vi(vi), _vptr(vptr), _p(p), _colormap(colormap) { + using namespace drawerargs; + _pitch = dc_pitch; + _start_y = static_cast((p - dc_destorg) / dc_pitch); } void DrawSlabPalCommand::Execute(DrawerThread *thread) { + int count = _dy; + uint8_t *dest = _p; + int pitch = _pitch; + int width = _dx; + const uint8_t *colormap = _colormap; + const uint8_t *source = _vptr; + fixed_t fracpos = _v; + fixed_t iscale = _vi; + + count = thread->count_for_thread(_start_y, count); + dest = thread->dest_for_thread(_start_y, pitch, dest); + fracpos += iscale * thread->skipped_by_thread(_start_y); + iscale *= thread->num_cores; + pitch *= thread->num_cores; + + while (count > 0) + { + uint8_t color = colormap[source[fracpos >> FRACBITS]]; + + for (int x = 0; x < width; x++) + dest[x] = color; + + dest += pitch; + fracpos += iscale; + count--; + } } ///////////////////////////////////////////////////////////////////////// diff --git a/src/r_draw_pal.h b/src/r_draw_pal.h index d9fb2d489..ba9a953c3 100644 --- a/src/r_draw_pal.h +++ b/src/r_draw_pal.h @@ -195,6 +195,17 @@ namespace swrenderer public: DrawSlabPalCommand(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p, const uint8_t *colormap); void Execute(DrawerThread *thread) override; + + private: + int _dx; + fixed_t _v; + int _dy; + fixed_t _vi; + const uint8_t *_vptr; + uint8_t *_p; + const uint8_t *_colormap; + int _pitch; + int _start_y; }; class DrawFogBoundaryLinePalCommand : public PalSpanCommand