DisplayRefreshMonitorManager.h [plain text]
#pragma once
#include "AnimationFrameRate.h"
#include "DisplayRefreshMonitor.h"
#include "PlatformScreen.h"
#include <wtf/NeverDestroyed.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
class DisplayRefreshMonitorManager {
friend class NeverDestroyed<DisplayRefreshMonitorManager>;
friend class DisplayRefreshMonitor;
public:
WEBCORE_EXPORT static DisplayRefreshMonitorManager& sharedManager();
void unregisterClient(DisplayRefreshMonitorClient&);
void setPreferredFramesPerSecond(DisplayRefreshMonitorClient&, FramesPerSecond);
bool scheduleAnimation(DisplayRefreshMonitorClient&);
void windowScreenDidChange(PlatformDisplayID, DisplayRefreshMonitorClient&);
WEBCORE_EXPORT void displayWasUpdated(PlatformDisplayID);
private:
DisplayRefreshMonitorManager() = default;
virtual ~DisplayRefreshMonitorManager();
void displayDidRefresh(DisplayRefreshMonitor&);
size_t findMonitorForDisplayID(PlatformDisplayID) const;
DisplayRefreshMonitor* monitorForDisplayID(PlatformDisplayID) const;
DisplayRefreshMonitor* monitorForClient(DisplayRefreshMonitorClient&);
struct DisplayRefreshMonitorWrapper {
DisplayRefreshMonitorWrapper(DisplayRefreshMonitorWrapper&&) = default;
~DisplayRefreshMonitorWrapper()
{
if (monitor)
monitor->stop();
}
RefPtr<DisplayRefreshMonitor> monitor;
};
Vector<DisplayRefreshMonitorWrapper> m_monitors;
};
}