mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Blitter: Change some informational virtual functions to member values
This commit is contained in:
parent
46f5fb9f25
commit
c4e8b919f8
@ -18,7 +18,11 @@
|
|||||||
/** Base for all 32bpp blitters. */
|
/** Base for all 32bpp blitters. */
|
||||||
class Blitter_32bppBase : public Blitter {
|
class Blitter_32bppBase : public Blitter {
|
||||||
public:
|
public:
|
||||||
uint8 GetScreenDepth() override { return 32; }
|
Blitter_32bppBase()
|
||||||
|
{
|
||||||
|
this->SetScreenDepth(32);
|
||||||
|
}
|
||||||
|
|
||||||
void *MoveTo(void *video, int x, int y) override;
|
void *MoveTo(void *video, int x, int y) override;
|
||||||
void SetPixel(void *video, int x, int y, uint8 colour) 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;
|
void SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) override;
|
||||||
|
@ -15,7 +15,11 @@
|
|||||||
/** Base for all 8bpp blitters. */
|
/** Base for all 8bpp blitters. */
|
||||||
class Blitter_8bppBase : public Blitter {
|
class Blitter_8bppBase : public Blitter {
|
||||||
public:
|
public:
|
||||||
uint8 GetScreenDepth() override { return 8; }
|
Blitter_8bppBase()
|
||||||
|
{
|
||||||
|
this->SetScreenDepth(8);
|
||||||
|
}
|
||||||
|
|
||||||
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
|
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
|
||||||
void *MoveTo(void *video, int x, int y) override;
|
void *MoveTo(void *video, int x, int y) override;
|
||||||
void SetPixel(void *video, int x, int y, uint8 colour) 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.
|
* How all blitters should look like. Extend this class to make your own.
|
||||||
*/
|
*/
|
||||||
class Blitter : public SpriteEncoder {
|
class Blitter : public SpriteEncoder {
|
||||||
|
uint8 screen_depth = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void SetScreenDepth(uint8 depth)
|
||||||
|
{
|
||||||
|
this->screen_depth = depth;
|
||||||
|
this->SetIs32BppSupported(depth > 8);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Parameters related to blitting. */
|
/** Parameters related to blitting. */
|
||||||
struct BlitterParams {
|
struct BlitterParams {
|
||||||
@ -75,11 +84,9 @@ public:
|
|||||||
* Get the screen depth this blitter works for.
|
* Get the screen depth this blitter works for.
|
||||||
* This is either: 8, 16, 24 or 32.
|
* This is either: 8, 16, 24 or 32.
|
||||||
*/
|
*/
|
||||||
virtual uint8 GetScreenDepth() = 0;
|
inline uint8 GetScreenDepth() const
|
||||||
|
|
||||||
bool Is32BppSupported() override
|
|
||||||
{
|
{
|
||||||
return this->GetScreenDepth() > 8;
|
return this->screen_depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,7 +15,11 @@
|
|||||||
/** Blitter that does nothing. */
|
/** Blitter that does nothing. */
|
||||||
class Blitter_Null : public Blitter {
|
class Blitter_Null : public Blitter {
|
||||||
public:
|
public:
|
||||||
uint8 GetScreenDepth() override { return 0; }
|
Blitter_Null()
|
||||||
|
{
|
||||||
|
this->SetScreenDepth(0);
|
||||||
|
}
|
||||||
|
|
||||||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override {};
|
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override {};
|
||||||
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override {};
|
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override {};
|
||||||
Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
|
Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
|
||||||
|
@ -83,6 +83,7 @@ public:
|
|||||||
/** Interface for something that can encode a sprite. */
|
/** Interface for something that can encode a sprite. */
|
||||||
class SpriteEncoder {
|
class SpriteEncoder {
|
||||||
bool supports_missing_zoom_levels = false;
|
bool supports_missing_zoom_levels = false;
|
||||||
|
bool supports_32bpp = false;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline void SetSupportsMissingZoomLevels(bool supported)
|
inline void SetSupportsMissingZoomLevels(bool supported)
|
||||||
@ -90,6 +91,11 @@ protected:
|
|||||||
this->supports_missing_zoom_levels = supported;
|
this->supports_missing_zoom_levels = supported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void SetIs32BppSupported(bool supported)
|
||||||
|
{
|
||||||
|
this->supports_32bpp = supported;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~SpriteEncoder() = default;
|
virtual ~SpriteEncoder() = default;
|
||||||
@ -102,7 +108,10 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Can the sprite encoder make use of RGBA sprites?
|
* 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.
|
* Convert a sprite from the loader to our own format.
|
||||||
|
@ -490,6 +490,7 @@ void SetupDebugOutput()
|
|||||||
*/
|
*/
|
||||||
OpenGLBackend::OpenGLBackend() : cursor_cache(MAX_CACHED_CURSORS)
|
OpenGLBackend::OpenGLBackend() : cursor_cache(MAX_CACHED_CURSORS)
|
||||||
{
|
{
|
||||||
|
this->SetIs32BppSupported(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +107,6 @@ public:
|
|||||||
|
|
||||||
/* SpriteEncoder */
|
/* SpriteEncoder */
|
||||||
|
|
||||||
bool Is32BppSupported() override { return true; }
|
|
||||||
uint GetSpriteAlignment() override { return 1u << (ZOOM_LVL_SPR_COUNT - 1); }
|
uint GetSpriteAlignment() override { return 1u << (ZOOM_LVL_SPR_COUNT - 1); }
|
||||||
Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
|
Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user