output: add scheduleFrame reasons (#7)

This commit is contained in:
UjinT34 2024-07-07 19:05:05 +03:00 committed by GitHub
parent 946c756414
commit a473c5313d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 37 additions and 13 deletions

View file

@ -187,7 +187,7 @@ namespace Aquamarine {
virtual Hyprutils::Memory::CSharedPointer<IBackendImplementation> getBackend(); virtual Hyprutils::Memory::CSharedPointer<IBackendImplementation> getBackend();
virtual bool setCursor(Hyprutils::Memory::CSharedPointer<IBuffer> buffer, const Hyprutils::Math::Vector2D& hotspot); virtual bool setCursor(Hyprutils::Memory::CSharedPointer<IBuffer> buffer, const Hyprutils::Math::Vector2D& hotspot);
virtual void moveCursor(const Hyprutils::Math::Vector2D& coord); virtual void moveCursor(const Hyprutils::Math::Vector2D& coord);
virtual void scheduleFrame(); virtual void scheduleFrame(const scheduleFrameReason reason = AQ_SCHEDULE_UNKNOWN);
virtual void setCursorVisible(bool visible); virtual void setCursorVisible(bool visible);
virtual Hyprutils::Math::Vector2D cursorPlaneSize(); virtual Hyprutils::Math::Vector2D cursorPlaneSize();
virtual size_t getGammaSize(); virtual size_t getGammaSize();

View file

@ -15,7 +15,7 @@ namespace Aquamarine {
virtual bool commit(); virtual bool commit();
virtual bool test(); virtual bool test();
virtual Hyprutils::Memory::CSharedPointer<IBackendImplementation> getBackend(); virtual Hyprutils::Memory::CSharedPointer<IBackendImplementation> getBackend();
virtual void scheduleFrame(); virtual void scheduleFrame(const scheduleFrameReason reason = AQ_SCHEDULE_UNKNOWN);
virtual bool destroy(); virtual bool destroy();
Hyprutils::Memory::CWeakPointer<CHeadlessOutput> self; Hyprutils::Memory::CWeakPointer<CHeadlessOutput> self;

View file

@ -46,7 +46,7 @@ namespace Aquamarine {
virtual Hyprutils::Memory::CSharedPointer<IBackendImplementation> getBackend(); virtual Hyprutils::Memory::CSharedPointer<IBackendImplementation> getBackend();
virtual bool setCursor(Hyprutils::Memory::CSharedPointer<IBuffer> buffer, const Hyprutils::Math::Vector2D& hotspot); virtual bool setCursor(Hyprutils::Memory::CSharedPointer<IBuffer> buffer, const Hyprutils::Math::Vector2D& hotspot);
virtual void moveCursor(const Hyprutils::Math::Vector2D& coord); virtual void moveCursor(const Hyprutils::Math::Vector2D& coord);
virtual void scheduleFrame(); virtual void scheduleFrame(const scheduleFrameReason reason = AQ_SCHEDULE_UNKNOWN);
virtual Hyprutils::Math::Vector2D cursorPlaneSize(); virtual Hyprutils::Math::Vector2D cursorPlaneSize();
virtual bool destroy(); virtual bool destroy();

View file

@ -100,6 +100,19 @@ namespace Aquamarine {
; ;
} }
enum scheduleFrameReason : uint32_t {
AQ_SCHEDULE_UNKNOWN = 0,
AQ_SCHEDULE_NEW_CONNECTOR,
AQ_SCHEDULE_CURSOR_VISIBLE,
AQ_SCHEDULE_CURSOR_SHAPE,
AQ_SCHEDULE_CURSOR_MOVE,
AQ_SCHEDULE_CLIENT_UNKNOWN,
AQ_SCHEDULE_DAMAGE,
AQ_SCHEDULE_NEW_MONITOR,
AQ_SCHEDULE_RENDER_MONITOR,
AQ_SCHEDULE_NEEDS_FRAME,
};
virtual bool commit() = 0; virtual bool commit() = 0;
virtual bool test() = 0; virtual bool test() = 0;
virtual Hyprutils::Memory::CSharedPointer<IBackendImplementation> getBackend() = 0; virtual Hyprutils::Memory::CSharedPointer<IBackendImplementation> getBackend() = 0;
@ -108,7 +121,7 @@ namespace Aquamarine {
virtual void moveCursor(const Hyprutils::Math::Vector2D& coord); // includes the hotspot virtual void moveCursor(const Hyprutils::Math::Vector2D& coord); // includes the hotspot
virtual void setCursorVisible(bool visible); // moving the cursor will make it visible again without this util virtual void setCursorVisible(bool visible); // moving the cursor will make it visible again without this util
virtual Hyprutils::Math::Vector2D cursorPlaneSize(); // -1, -1 means no set size, 0, 0 means error virtual Hyprutils::Math::Vector2D cursorPlaneSize(); // -1, -1 means no set size, 0, 0 means error
virtual void scheduleFrame(); virtual void scheduleFrame(const scheduleFrameReason reason = AQ_SCHEDULE_UNKNOWN);
virtual size_t getGammaSize(); virtual size_t getGammaSize();
virtual bool destroy(); // not all backends allow this!!! virtual bool destroy(); // not all backends allow this!!!

View file

@ -3,6 +3,7 @@
#include <time.h> #include <time.h>
#include <sys/timerfd.h> #include <sys/timerfd.h>
#include <string.h> #include <string.h>
#include "Shared.hpp"
using namespace Aquamarine; using namespace Aquamarine;
using namespace Hyprutils::Memory; using namespace Hyprutils::Memory;
@ -53,7 +54,9 @@ Hyprutils::Memory::CSharedPointer<IBackendImplementation> Aquamarine::CHeadlessO
return backend.lock(); return backend.lock();
} }
void Aquamarine::CHeadlessOutput::scheduleFrame() { void Aquamarine::CHeadlessOutput::scheduleFrame(const scheduleFrameReason reason) {
TRACE(backend->backend->log(AQ_LOG_TRACE,
std::format("CHeadlessOutput::scheduleFrame: reason {}, needsFrame {}, frameScheduled {}", (uint32_t)reason, needsFrame, frameScheduled)));
// FIXME: limit fps to the committed framerate. // FIXME: limit fps to the committed framerate.
needsFrame = true; needsFrame = true;

View file

@ -723,7 +723,9 @@ Hyprutils::Math::Vector2D Aquamarine::CWaylandOutput::cursorPlaneSize() {
return {-1, -1}; // no limit return {-1, -1}; // no limit
} }
void Aquamarine::CWaylandOutput::scheduleFrame() { void Aquamarine::CWaylandOutput::scheduleFrame(const scheduleFrameReason reason) {
TRACE(backend->backend->log(AQ_LOG_TRACE,
std::format("CWaylandOutput::scheduleFrame: reason {}, needsFrame {}, frameScheduled {}", (uint32_t)reason, needsFrame, frameScheduled)));
needsFrame = true; needsFrame = true;
if (frameScheduled) if (frameScheduled)

View file

@ -1,3 +1,4 @@
#include "aquamarine/output/Output.hpp"
#include <aquamarine/backend/DRM.hpp> #include <aquamarine/backend/DRM.hpp>
#include <aquamarine/backend/drm/Legacy.hpp> #include <aquamarine/backend/drm/Legacy.hpp>
#include <aquamarine/backend/drm/Atomic.hpp> #include <aquamarine/backend/drm/Atomic.hpp>
@ -1065,7 +1066,7 @@ void Aquamarine::SDRMConnector::connect(drmModeConnector* connector) {
output->swapchain = CSwapchain::create(backend->backend->allocator, backend->self.lock()); output->swapchain = CSwapchain::create(backend->backend->allocator, backend->self.lock());
backend->backend->events.newOutput.emit(output); backend->backend->events.newOutput.emit(output);
output->scheduleFrame(); output->scheduleFrame(IOutput::AQ_SCHEDULE_NEW_CONNECTOR);
} }
void Aquamarine::SDRMConnector::disconnect() { void Aquamarine::SDRMConnector::disconnect() {
@ -1136,7 +1137,7 @@ bool Aquamarine::CDRMOutput::test() {
void Aquamarine::CDRMOutput::setCursorVisible(bool visible) { void Aquamarine::CDRMOutput::setCursorVisible(bool visible) {
cursorVisible = visible; cursorVisible = visible;
needsFrame = true; needsFrame = true;
scheduleFrame(); scheduleFrame(AQ_SCHEDULE_CURSOR_VISIBLE);
} }
bool Aquamarine::CDRMOutput::commitState(bool onlyTest) { bool Aquamarine::CDRMOutput::commitState(bool onlyTest) {
@ -1298,7 +1299,7 @@ bool Aquamarine::CDRMOutput::setCursor(SP<IBuffer> buffer, const Vector2D& hotsp
} }
needsFrame = true; needsFrame = true;
scheduleFrame(); scheduleFrame(AQ_SCHEDULE_CURSOR_SHAPE);
return true; return true;
} }
@ -1308,7 +1309,10 @@ void Aquamarine::CDRMOutput::moveCursor(const Vector2D& coord) {
backend->impl->moveCursor(connector); backend->impl->moveCursor(connector);
} }
void Aquamarine::CDRMOutput::scheduleFrame() { void Aquamarine::CDRMOutput::scheduleFrame(const scheduleFrameReason reason) {
TRACE(backend->backend->log(AQ_LOG_TRACE,
std::format("CDRMOutput::scheduleFrame: reason {}, needsFrame {}, isPageFlipPending {}, frameEventScheduled {}", (uint32_t)reason, needsFrame,
connector->isPageFlipPending, connector->frameEventScheduled)));
needsFrame = true; needsFrame = true;
if (connector->isPageFlipPending || connector->frameEventScheduled) if (connector->isPageFlipPending || connector->frameEventScheduled)

View file

@ -4,6 +4,7 @@
#include <xf86drmMode.h> #include <xf86drmMode.h>
#include <sys/mman.h> #include <sys/mman.h>
#include "Shared.hpp" #include "Shared.hpp"
#include "aquamarine/output/Output.hpp"
using namespace Aquamarine; using namespace Aquamarine;
using namespace Hyprutils::Memory; using namespace Hyprutils::Memory;
@ -323,7 +324,7 @@ bool Aquamarine::CDRMAtomicImpl::moveCursor(SP<SDRMConnector> connector) {
return true; return true;
connector->output->needsFrame = true; connector->output->needsFrame = true;
connector->output->scheduleFrame(); connector->output->scheduleFrame(IOutput::AQ_SCHEDULE_CURSOR_MOVE);
return true; return true;
} }

View file

@ -1,3 +1,4 @@
#include "aquamarine/output/Output.hpp"
#include <aquamarine/backend/drm/Legacy.hpp> #include <aquamarine/backend/drm/Legacy.hpp>
#include <cstring> #include <cstring>
#include <xf86drm.h> #include <xf86drm.h>
@ -18,7 +19,7 @@ bool Aquamarine::CDRMLegacyImpl::moveCursor(Hyprutils::Memory::CSharedPointer<SD
return true; return true;
connector->output->needsFrame = true; connector->output->needsFrame = true;
connector->output->scheduleFrame(); connector->output->scheduleFrame(IOutput::AQ_SCHEDULE_CURSOR_MOVE);
return true; return true;
} }

View file

@ -23,7 +23,7 @@ void Aquamarine::IOutput::setCursorVisible(bool visible) {
; ;
} }
void Aquamarine::IOutput::scheduleFrame() { void Aquamarine::IOutput::scheduleFrame(const scheduleFrameReason reason) {
; ;
} }