Blitter: Change some informational virtual functions to member values

pull/590/head
Jonathan G Rennison 10 months ago
parent 46f5fb9f25
commit c4e8b919f8

@ -18,7 +18,11 @@
/** Base for all 32bpp blitters. */
class Blitter_32bppBase : public Blitter {
public:
uint8 GetScreenDepth() override { return 32; }
Blitter_32bppBase()
{
this->SetScreenDepth(32);
}
void *MoveTo(void *video, int x, int y) override;
void SetPixel(void *video, int x, int y, uint8 colour) override;
void SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) override;

@ -15,7 +15,11 @@
/** Base for all 8bpp blitters. */
class Blitter_8bppBase : public Blitter {
public:
uint8 GetScreenDepth() override { return 8; }
Blitter_8bppBase()
{
this->SetScreenDepth(8);
}
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
void *MoveTo(void *video, int x, int y) override;
void SetPixel(void *video, int x, int y, uint8 colour) override;

@ -44,6 +44,15 @@ DECLARE_ENUM_AS_BIT_SET(BlitterSpriteFlags);
* How all blitters should look like. Extend this class to make your own.
*/
class Blitter : public SpriteEncoder {
uint8 screen_depth = 0;
protected:
void SetScreenDepth(uint8 depth)
{
this->screen_depth = depth;
this->SetIs32BppSupported(depth > 8);
}
public:
/** Parameters related to blitting. */
struct BlitterParams {
@ -75,11 +84,9 @@ public:
* Get the screen depth this blitter works for.
* This is either: 8, 16, 24 or 32.
*/
virtual uint8 GetScreenDepth() = 0;
bool Is32BppSupported() override
inline uint8 GetScreenDepth() const
{
return this->GetScreenDepth() > 8;
return this->screen_depth;
}
/**

@ -15,7 +15,11 @@
/** Blitter that does nothing. */
class Blitter_Null : public Blitter {
public:
uint8 GetScreenDepth() override { return 0; }
Blitter_Null()
{
this->SetScreenDepth(0);
}
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override {};
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override {};
Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;

@ -83,6 +83,7 @@ public:
/** Interface for something that can encode a sprite. */
class SpriteEncoder {
bool supports_missing_zoom_levels = false;
bool supports_32bpp = false;
protected:
inline void SetSupportsMissingZoomLevels(bool supported)
@ -90,6 +91,11 @@ protected:
this->supports_missing_zoom_levels = supported;
}
inline void SetIs32BppSupported(bool supported)
{
this->supports_32bpp = supported;
}
public:
virtual ~SpriteEncoder() = default;
@ -102,7 +108,10 @@ public:
/**
* Can the sprite encoder make use of RGBA sprites?
*/
virtual bool Is32BppSupported() = 0;
inline bool Is32BppSupported() const
{
return this->supports_32bpp;
}
/**
* Convert a sprite from the loader to our own format.

@ -490,6 +490,7 @@ void SetupDebugOutput()
*/
OpenGLBackend::OpenGLBackend() : cursor_cache(MAX_CACHED_CURSORS)
{
this->SetIs32BppSupported(true);
}
/**

@ -107,7 +107,6 @@ public:
/* SpriteEncoder */
bool Is32BppSupported() override { return true; }
uint GetSpriteAlignment() override { return 1u << (ZOOM_LVL_SPR_COUNT - 1); }
Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
};

Loading…
Cancel
Save