mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-18 16:03:05 +00:00
AGS: Engine: for renderers, picked out SetVsync into base, add SetVsyncImpl
The base class will now take care of not applying vsync when not necessary, saving the new state, and anything else generic. SetVsyncImpl() virtual method will be overridden by each renderer to provide actual implementation. This also allows setting vsync to be forced internally. Partially from upstream 81aa25ab6af683f52ebf5a5054f59824fa8851fc
This commit is contained in:
parent
430758510e
commit
92f0189a0e
@ -222,19 +222,18 @@ bool ScummVMRendererGraphicsDriver::DoesSupportVsyncToggle() {
|
||||
return g_system->hasFeature(OSystem::kFeatureVSync);
|
||||
}
|
||||
|
||||
bool ScummVMRendererGraphicsDriver::SetVsync(bool enabled) {
|
||||
if (_mode.Vsync == enabled) {
|
||||
return _mode.Vsync;
|
||||
}
|
||||
|
||||
bool ScummVMRendererGraphicsDriver::SetVsyncImpl(bool enabled, bool &vsync_res) {
|
||||
if (g_system->hasFeature(OSystem::kFeatureVSync)) {
|
||||
g_system->beginGFXTransaction();
|
||||
g_system->setFeatureState(OSystem::kFeatureVSync, enabled);
|
||||
g_system->endGFXTransaction();
|
||||
|
||||
_mode.Vsync = g_system->getFeatureState(OSystem::kFeatureVSync);
|
||||
vsync_res = g_system->getFeatureState(OSystem::kFeatureVSync);
|
||||
if (!vsync_res)
|
||||
Debug::Printf(kDbgMsg_Error, "Renderer: SetVsync (%d) failed", enabled);
|
||||
return vsync_res;
|
||||
}
|
||||
return _mode.Vsync;
|
||||
return false;
|
||||
}
|
||||
|
||||
int ScummVMRendererGraphicsDriver::GetCompatibleBitmapFormat(int color_depth) {
|
||||
|
@ -214,7 +214,6 @@ public:
|
||||
void SetGamma(int newGamma) override;
|
||||
void UseSmoothScaling(bool /*enabled*/) override {}
|
||||
bool DoesSupportVsyncToggle() override;
|
||||
bool SetVsync(bool enabled) override;
|
||||
void RenderSpritesAtScreenResolution(bool /*enabled*/, int /*supersampling*/) override {}
|
||||
bool RequiresFullRedrawEachFrame() override {
|
||||
return false;
|
||||
@ -238,6 +237,7 @@ public:
|
||||
void SetGraphicsFilter(PSDLRenderFilter filter);
|
||||
|
||||
protected:
|
||||
bool SetVsyncImpl(bool vsync, bool &vsync_res) override;
|
||||
size_t GetLastDrawEntryIndex() override {
|
||||
return _spriteList.size();
|
||||
}
|
||||
|
@ -64,6 +64,18 @@ Rect GraphicsDriverBase::GetRenderDestination() const {
|
||||
return _dstRect;
|
||||
}
|
||||
|
||||
bool GraphicsDriverBase::SetVsync(bool enabled) {
|
||||
if (_mode.Vsync == enabled) {
|
||||
return _mode.Vsync;
|
||||
}
|
||||
|
||||
bool new_value;
|
||||
if (SetVsyncImpl(enabled, new_value)) {
|
||||
_mode.Vsync = new_value;
|
||||
}
|
||||
return _mode.Vsync;
|
||||
}
|
||||
|
||||
void GraphicsDriverBase::BeginSpriteBatch(const Rect &viewport, const SpriteTransform &transform,
|
||||
GraphicFlip flip, PBitmap surface) {
|
||||
_spriteBatchDesc.push_back(SpriteBatchDesc(_actSpriteBatch, viewport, transform, flip, surface));
|
||||
|
@ -101,6 +101,8 @@ public:
|
||||
Size GetNativeSize() const override;
|
||||
Rect GetRenderDestination() const override;
|
||||
|
||||
bool SetVsync(bool enabled) override;
|
||||
|
||||
void BeginSpriteBatch(const Rect &viewport, const SpriteTransform &transform,
|
||||
Shared::GraphicFlip flip = Shared::kFlip_None, PBitmap surface = nullptr) override;
|
||||
void EndSpriteBatch() override;
|
||||
@ -141,6 +143,11 @@ protected:
|
||||
virtual void OnSetRenderFrame(const Rect &dst_rect);
|
||||
// Called when the new filter is set
|
||||
virtual void OnSetFilter();
|
||||
|
||||
// Try changing vsync setting; fills new current mode in vsync_res,
|
||||
// returns whether the new setting was set successfully.
|
||||
virtual bool SetVsyncImpl(bool vsync, bool &vsync_res) { return false; }
|
||||
|
||||
// Initialize sprite batch and allocate necessary resources
|
||||
virtual void InitSpriteBatch(size_t index, const SpriteBatchDesc &desc) = 0;
|
||||
// Gets the index of a last draw entry (sprite)
|
||||
|
Loading…
x
Reference in New Issue
Block a user