AGS: Engine: renderers support creating DDB as a render target

Partially from upstream 4c8218e9ca4da7403ff14e45c57584517d2abc2f
This commit is contained in:
Walter Agazzi 2023-03-01 21:07:59 +01:00 committed by Thierry Crozat
parent af16689b2b
commit b828199c25
4 changed files with 15 additions and 2 deletions

View File

@ -251,6 +251,10 @@ IDriverDependantBitmap *ScummVMRendererGraphicsDriver::CreateDDBFromBitmap(Bitma
return new ALSoftwareBitmap(bitmap, opaque, hasAlpha);
}
IDriverDependantBitmap *ScummVMRendererGraphicsDriver::CreateRenderTargetDDB(int width, int height, int color_depth, bool opaque) {
return new ALSoftwareBitmap(width, height, color_depth, opaque);
}
void ScummVMRendererGraphicsDriver::UpdateDDBFromBitmap(IDriverDependantBitmap *bitmapToUpdate, Bitmap *bitmap, bool hasAlpha) {
ALSoftwareBitmap *alSwBmp = (ALSoftwareBitmap *)bitmapToUpdate;
alSwBmp->_bmp = bitmap;

View File

@ -176,6 +176,7 @@ public:
int GetCompatibleBitmapFormat(int color_depth) override;
IDriverDependantBitmap *CreateDDB(int width, int height, int color_depth, bool opaque) override;
IDriverDependantBitmap *CreateDDBFromBitmap(Bitmap *bitmap, bool hasAlpha, bool opaque) override;
IDriverDependantBitmap *CreateRenderTargetDDB(int width, int height, int color_depth, bool opaque) override;
void UpdateDDBFromBitmap(IDriverDependantBitmap *ddb, Bitmap *bitmap, bool hasAlpha) override;
void DestroyDDB(IDriverDependantBitmap *ddb) override;

View File

@ -223,7 +223,9 @@ public:
void SetMemoryBackBuffer(Bitmap *backBuffer) override;
Bitmap *GetStageBackBuffer(bool mark_dirty) override;
bool GetStageMatrixes(RenderMatrixes &rm) override;
// Creates new texture using given parameters
IDriverDependantBitmap *CreateDDB(int width, int height, int color_depth, bool opaque) override = 0;
// Creates new texture and copy bitmap contents over
IDriverDependantBitmap *CreateDDBFromBitmap(Bitmap *bitmap, bool hasAlpha, bool opaque = false) override;
// Get shared texture from cache, or create from bitmap and assign ID
IDriverDependantBitmap *GetSharedDDB(uint32_t sprite_id, Bitmap *bitmap, bool hasAlpha, bool opaque) override;
@ -235,7 +237,7 @@ public:
protected:
// Create texture data with the given parameters
virtual TextureData *CreateTextureData(int width, int height, bool opaque) = 0;
virtual TextureData *CreateTextureData(int width, int height, bool opaque, bool as_render_target = false) = 0;
// Update texture data from the given bitmap
virtual void UpdateTextureData(TextureData *txdata, Bitmap *bmp, bool opaque, bool hasAlpha) = 0;
// Create DDB using preexisting texture data

View File

@ -133,11 +133,17 @@ public:
// Gets closest recommended bitmap format (currently - only color depth) for the given original format.
// Engine needs to have game bitmaps brought to the certain range of formats, easing conversion into the video bitmaps.
virtual int GetCompatibleBitmapFormat(int color_depth) = 0;
// Creates a "raw" DDB, without pixel initialization
virtual IDriverDependantBitmap *CreateDDB(int width, int height, int color_depth, bool opaque = false) = 0;
// Creates DDB, initializes from the given bitmap
// Creates DDB, initializes from the given bitmap.
virtual IDriverDependantBitmap *CreateDDBFromBitmap(Shared::Bitmap *bitmap, bool hasAlpha, bool opaque = false) = 0;
// Creates DDB intended to be used as a render target (allow render other DDBs on it).
virtual IDriverDependantBitmap *CreateRenderTargetDDB(int width, int height, int color_depth, bool opaque = false) = 0;
// Updates DBB using the given bitmap; bitmap must have same size and format
// as the one that this DDB was initialized with.
virtual void UpdateDDBFromBitmap(IDriverDependantBitmap *bitmapToUpdate, Shared::Bitmap *bitmap, bool hasAlpha) = 0;
// Destroy the DDB.
virtual void DestroyDDB(IDriverDependantBitmap *bitmap) = 0;
// Get shared texture from cache, or create from bitmap and assign ID