28 #ifndef AGS_ENGINE_GFX_GFX_DRIVER_BASE_H 29 #define AGS_ENGINE_GFX_GFX_DRIVER_BASE_H 31 #include "common/std/memory.h" 32 #include "common/std/map.h" 33 #include "common/std/vector.h" 34 #include "ags/engine/gfx/ddb.h" 35 #include "ags/shared/gfx/gfx_def.h" 36 #include "ags/engine/gfx/graphics_driver.h" 37 #include "ags/shared/util/scaling.h" 44 using Shared::PlaneScaling;
48 uint32_t Parent = UINT32_MAX;
55 Shared::GraphicFlip Flip = Shared::kFlip_None;
61 Shared::GraphicFlip flip = Shared::kFlip_None,
PBitmap surface =
nullptr)
64 , Transform(transform)
97 bool IsModeSet()
const override;
98 bool IsNativeSizeValid()
const override;
99 bool IsRenderFrameValid()
const override;
101 Size GetNativeSize()
const override;
102 Rect GetRenderDestination()
const override;
104 bool SetVsync(
bool enabled)
override;
105 bool GetVsync()
const override;
108 Shared::GraphicFlip flip = Shared::kFlip_None,
PBitmap surface =
nullptr)
override;
109 void EndSpriteBatch()
override;
110 void ClearDrawLists()
override;
112 void SetCallbackForPolling(GFXDRV_CLIENTCALLBACK callback)
override {
113 _pollingCallback = callback;
115 void SetCallbackToDrawScreen(GFXDRV_CLIENTCALLBACK callback, GFXDRV_CLIENTCALLBACK post_callback)
override {
116 _drawScreenCallback = callback;
117 _drawPostScreenCallback = post_callback;
119 void SetCallbackOnInit(GFXDRV_CLIENTCALLBACKINITGFX callback)
override {
120 _initGfxCallback = callback;
122 void SetCallbackOnSpriteEvt(GFXDRV_CLIENTCALLBACKEVT callback)
override {
123 _spriteEvtCallback = callback;
128 static const intptr_t DRAWENTRY_STAGECALLBACK = 0x0;
129 static const intptr_t DRAWENTRY_FADE = 0x1;
130 static const intptr_t DRAWENTRY_TINT = 0x2;
133 virtual void OnInit();
136 virtual void OnUnInit();
142 virtual void OnModeReleased();
144 virtual void OnSetRenderFrame(
const Rect &dst_rect);
146 virtual void OnSetFilter();
150 virtual bool SetVsyncImpl(
bool vsync,
bool &vsync_res) {
return false; }
153 virtual void InitSpriteBatch(
size_t index,
const SpriteBatchDesc &desc) = 0;
155 virtual size_t GetLastDrawEntryIndex() = 0;
157 virtual void ResetAllBatches() = 0;
159 void OnScalingChanged();
169 bool _capsVsync =
false;
172 GFXDRV_CLIENTCALLBACK _pollingCallback;
173 GFXDRV_CLIENTCALLBACK _drawScreenCallback;
174 GFXDRV_CLIENTCALLBACK _drawPostScreenCallback;
175 GFXDRV_CLIENTCALLBACKEVT _spriteEvtCallback;
176 GFXDRV_CLIENTCALLBACKINITGFX _initGfxCallback;
179 SpriteBatchDescs _spriteBatchDesc;
184 size_t _actSpriteBatch;
187 uint32_t _rendSpriteBatch;
196 int GetWidth()
const override {
199 int GetHeight()
const override {
202 int GetColorDepth()
const override {
206 int _width = 0, _height = 0;
208 bool _hasAlpha =
false;
209 bool _opaque =
false;
220 uint32_t ID = UINT32_MAX;
221 bool RenderTarget =
false;
230 int width = 0, height = 0;
242 bool UsesMemoryBackBuffer()
override;
243 Bitmap *GetMemoryBackBuffer()
override;
244 void SetMemoryBackBuffer(
Bitmap *backBuffer)
override;
245 Bitmap *GetStageBackBuffer(
bool mark_dirty)
override;
246 void SetStageBackBuffer(
Bitmap *backBuffer)
override;
255 void ClearSharedDDB(uint32_t sprite_id)
override;
257 void UpdateSharedDDB(uint32_t sprite_id,
Bitmap *bitmap,
bool hasAlpha,
bool opaque)
override;
261 void SetStageScreen(
const Size &sz,
int x = 0,
int y = 0)
override;
265 virtual TextureData *CreateTextureData(
int width,
int height,
bool opaque,
bool as_render_target =
false) = 0;
267 virtual void UpdateTextureData(
TextureData *txdata,
Bitmap *bmp,
bool opaque,
bool hasAlpha) = 0;
270 int width,
int height,
int color_depth,
bool opaque) = 0;
279 void SetStageScreen(
size_t index,
const Size &sz,
int x = 0,
int y = 0);
281 Bitmap *GetStageScreenRaw(
size_t index);
286 void DestroyAllStageScreens();
298 void DestroyFxPool();
301 void BitmapToVideoMem(
const Bitmap *bitmap,
const bool has_alpha,
const TextureTile *tile,
302 char *dst_ptr,
const int dst_pitch,
const bool usingLinearFiltering);
304 void BitmapToVideoMemOpaque(
const Bitmap *bitmap,
const bool has_alpha,
const TextureTile *tile,
305 char *dst_ptr,
const int dst_pitch);
316 int _vmem_a_shift_32;
317 int _vmem_r_shift_32;
318 int _vmem_g_shift_32;
319 int _vmem_b_shift_32;
334 bool _stageScreenDirty;
354 struct TextureCacheItem {
357 TextureCacheItem() =
default;
359 : Data(data), Res(res) {}
Definition: achievements_tables.h:27
Definition: allegro_bitmap.h:44
Definition: gfx_driver_base.h:237
Definition: gfx_driver_base.h:194
Definition: gfx_defines.h:60
Definition: viewport.h:128
Definition: gfx_driver_base.h:47
Definition: graphics_driver.h:98
Definition: surface.h:329
Definition: scaling.h:108
Definition: geometry.h:215
Definition: geometry.h:144
Definition: gfx_defines.h:33
Definition: gfx_driver_base.h:219
Definition: gfx_driver_base.h:93
Definition: gfx_driver_base.h:228
Definition: graphics_driver.h:85
Definition: gfx_driver_base.h:74