From 551691f42a67ba1f1d9608e92109aacca714435a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 8 Apr 2018 21:19:57 +0200 Subject: [PATCH] - made FTexture::GetPixels and FTexture::GetColumn non-pure-virtual. With the software renderer not being used for 2D anymore it would be quite annoying if every texture class had to implement these. If done properly, the SW renderer should actually be forced to dynamic_cast any texture to a FWorldTexture before using this stuff, but that'd be some pointless overhead better saved. --- src/gl/scene/gl_swscene.cpp | 6 ++---- src/textures/texture.cpp | 27 ++++++++++++++++----------- src/textures/textures.h | 6 ++---- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/gl/scene/gl_swscene.cpp b/src/gl/scene/gl_swscene.cpp index b0cf14fd5..2015ed4d2 100644 --- a/src/gl/scene/gl_swscene.cpp +++ b/src/gl/scene/gl_swscene.cpp @@ -45,9 +45,7 @@ float BaseBlendA; -// using FDummyTexture as base because that implements the required software renderer functions. - -class FSWPaletteTexture : public FDummyTexture +class FSWPaletteTexture : public FTexture { public: FSWPaletteTexture() @@ -68,7 +66,7 @@ public: } }; -class FSWSceneTexture : public FDummyTexture +class FSWSceneTexture : public FTexture { public: FHardwareTexture *hwtex; diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 3fc7c9a5c..ac72a8027 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -1453,6 +1453,22 @@ bool FTexture::GetTranslucency() return !!bTranslucent; } +//=========================================================================== +// +// empty stubs to be overloaded by child classes. +// +//=========================================================================== + +const uint8_t *FTexture::GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out) +{ + return nullptr; +} + +const uint8_t *FTexture::GetPixels(FRenderStyle style) +{ + return nullptr; +} + //=========================================================================== // // Dummy texture for the 0-entry. @@ -1476,17 +1492,6 @@ void FDummyTexture::SetSize (int width, int height) CalcBitSize (); } -// These only get called from the texture precacher which discards the result. -const uint8_t *FDummyTexture::GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out) -{ - return nullptr; -} - -const uint8_t *FDummyTexture::GetPixels(FRenderStyle style) -{ - return nullptr; -} - //========================================================================== // // Debug stuff diff --git a/src/textures/textures.h b/src/textures/textures.h index ec6b3f7f6..bfb675d6e 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -286,13 +286,13 @@ public: }; // Returns a single column of the texture - virtual const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out) = 0; + virtual const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out); // Returns a single column of the texture, in BGRA8 format virtual const uint32_t *GetColumnBgra(unsigned int column, const Span **spans_out); // Returns the whole texture, stored in column-major order - virtual const uint8_t *GetPixels(FRenderStyle style) = 0; + virtual const uint8_t *GetPixels(FRenderStyle style); // Returns the whole texture, stored in column-major order, in BGRA8 format virtual const uint32_t *GetPixelsBgra(); @@ -712,8 +712,6 @@ class FDummyTexture : public FTexture { public: FDummyTexture (); - const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out) override; - const uint8_t *GetPixels(FRenderStyle style) override; void SetSize (int width, int height); };