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;
60 uint32_t FilterFlags = 0u;
64 Shared::GraphicFlip flip = Shared::kFlip_None,
PBitmap surface =
nullptr, uint32_t filter_flags = 0)
67 , Transform(transform)
70 , FilterFlags(filter_flags) {
101 bool IsModeSet()
const override;
102 bool IsNativeSizeValid()
const override;
103 bool IsRenderFrameValid()
const override;
105 Size GetNativeSize()
const override;
106 Rect GetRenderDestination()
const override;
108 bool SetVsync(
bool enabled)
override;
109 bool GetVsync()
const override;
112 Shared::GraphicFlip flip = Shared::kFlip_None,
PBitmap surface =
nullptr,
113 uint32_t filter_flags = 0)
override;
114 void EndSpriteBatch()
override;
115 void ClearDrawLists()
override;
117 void SetCallbackForPolling(GFXDRV_CLIENTCALLBACK callback)
override {
118 _pollingCallback = callback;
120 void SetCallbackToDrawScreen(GFXDRV_CLIENTCALLBACK callback, GFXDRV_CLIENTCALLBACK post_callback)
override {
121 _drawScreenCallback = callback;
122 _drawPostScreenCallback = post_callback;
124 void SetCallbackOnInit(GFXDRV_CLIENTCALLBACKINITGFX callback)
override {
125 _initGfxCallback = callback;
127 void SetCallbackOnSpriteEvt(GFXDRV_CLIENTCALLBACKEVT callback)
override {
128 _spriteEvtCallback = callback;
133 static const uintptr_t DRAWENTRY_STAGECALLBACK = 0x0;
134 static const uintptr_t DRAWENTRY_FADE = 0x1;
135 static const uintptr_t DRAWENTRY_TINT = 0x2;
138 virtual void OnInit();
141 virtual void OnUnInit();
147 virtual void OnModeReleased();
149 virtual void OnSetRenderFrame(
const Rect &dst_rect);
151 virtual void OnSetFilter();
155 virtual bool SetVsyncImpl(
bool vsync,
bool &vsync_res) {
return false; }
158 virtual void InitSpriteBatch(
size_t index,
const SpriteBatchDesc &desc) = 0;
160 virtual size_t GetLastDrawEntryIndex() = 0;
162 virtual void ResetAllBatches() = 0;
164 void OnScalingChanged();
174 bool _capsVsync =
false;
177 GFXDRV_CLIENTCALLBACK _pollingCallback;
178 GFXDRV_CLIENTCALLBACK _drawScreenCallback;
179 GFXDRV_CLIENTCALLBACK _drawPostScreenCallback;
180 GFXDRV_CLIENTCALLBACKEVT _spriteEvtCallback;
181 GFXDRV_CLIENTCALLBACKINITGFX _initGfxCallback;
184 SpriteBatchDescs _spriteBatchDesc;
189 size_t _actSpriteBatch;
192 uint32_t _rendSpriteBatch;
201 int GetWidth()
const override {
204 int GetHeight()
const override {
207 int GetColorDepth()
const override {
211 return _width == other->GetWidth() && _height == other->GetHeight() && _colDepth == other->GetColorDepth();
214 int _width = 0, _height = 0;
216 bool _hasAlpha =
false;
217 bool _opaque =
false;
228 uint32_t ID = UINT32_MAX;
229 bool RenderTarget =
false;
238 int width = 0, height = 0;
240 int allocWidth = 0, allocHeight = 0;
252 bool RequiresFullRedrawEachFrame()
override {
return true; }
253 bool HasAcceleratedTransform()
override {
return true; }
257 bool UsesMemoryBackBuffer()
override {
return false; }
259 Bitmap *GetMemoryBackBuffer()
override;
260 void SetMemoryBackBuffer(
Bitmap *backBuffer)
override;
261 Bitmap *GetStageBackBuffer(
bool mark_dirty)
override;
262 void SetStageBackBuffer(
Bitmap *backBuffer)
override;
271 void ClearSharedDDB(uint32_t sprite_id)
override;
273 void UpdateSharedDDB(uint32_t sprite_id,
Bitmap *bitmap,
bool has_alpha,
bool opaque)
override;
277 void SetStageScreen(
const Size &sz,
int x = 0,
int y = 0)
override;
281 virtual TextureData *CreateTextureData(
int width,
int height,
bool opaque,
bool as_render_target =
false) = 0;
283 virtual void UpdateTextureData(
TextureData *txdata,
Bitmap *bmp,
bool has_alpha,
bool opaque) = 0;
286 int width,
int height,
int color_depth,
bool opaque) = 0;
295 void SetStageScreen(
size_t index,
const Size &sz,
int x = 0,
int y = 0);
297 Bitmap *GetStageScreenRaw(
size_t index);
302 void DestroyAllStageScreens();
314 void DestroyFxPool();
317 void BitmapToVideoMem(
const Bitmap *bitmap,
const bool has_alpha,
const TextureTile *tile,
318 uint8_t *dst_ptr,
const int dst_pitch,
const bool usingLinearFiltering);
321 uint8_t *dst_ptr,
const int dst_pitch);
332 int _vmem_a_shift_32;
333 int _vmem_r_shift_32;
334 int _vmem_g_shift_32;
335 int _vmem_b_shift_32;
350 bool _stageScreenDirty;
364 template<
typename T,
bool HasAlpha>
365 void BitmapToVideoMemImpl(
const Bitmap *bitmap,
const TextureTile *tile, uint8_t *dst_ptr,
const int dst_pitch);
368 void BitmapToVideoMemOpaqueImpl(
const Bitmap *bitmap,
const TextureTile *tile, uint8_t *dst_ptr,
const int dst_pitch);
370 template<
typename T,
bool HasAlpha>
371 void BitmapToVideoMemLinearImpl(
const Bitmap *bitmap,
const TextureTile *tile, uint8_t *dst_ptr,
const int dst_pitch);
380 struct TextureCacheItem {
383 TextureCacheItem() =
default;
385 : Data(data), Res(res) {}
Definition: achievements_tables.h:27
Definition: allegro_bitmap.h:44
Definition: gfx_driver_base.h:247
Definition: gfx_driver_base.h:199
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:219
Definition: geometry.h:148
Definition: gfx_defines.h:33
Definition: gfx_driver_base.h:227
Definition: gfx_driver_base.h:97
Definition: gfx_driver_base.h:236
Definition: graphics_driver.h:85
Definition: gfx_driver_base.h:78