all repos — mgba @ 000b49e45b30ec9c856b7b2e8cf8baee21daa56d

mGBA Game Boy Advance Emulator

src/platform/qt/Display.h (view raw)

  1/* Copyright (c) 2013-2015 Jeffrey Pfau
  2 *
  3 * This Source Code Form is subject to the terms of the Mozilla Public
  4 * License, v. 2.0. If a copy of the MPL was not distributed with this
  5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6#pragma once
  7
  8#include <mgba-util/common.h>
  9
 10#include <memory>
 11
 12#include <QWidget>
 13
 14#include "MessagePainter.h"
 15
 16struct VDir;
 17struct VideoShader;
 18
 19namespace QGBA {
 20
 21class CoreController;
 22class VideoProxy;
 23
 24class Display : public QWidget {
 25Q_OBJECT
 26
 27public:
 28	enum class Driver {
 29		QT = 0,
 30#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
 31		OPENGL = 1,
 32#endif
 33#ifdef BUILD_GL
 34		OPENGL1 = 2,
 35#endif
 36	};
 37
 38	Display(QWidget* parent = nullptr);
 39
 40	static Display* create(QWidget* parent = nullptr);
 41	static void setDriver(Driver driver) { s_driver = driver; }
 42
 43	bool isAspectRatioLocked() const { return m_lockAspectRatio; }
 44	bool isIntegerScalingLocked() const { return m_lockIntegerScaling; }
 45	bool hasInterframeBlending() const { return m_interframeBlending; }
 46	bool isFiltered() const { return m_filter; }
 47	bool isShowOSD() const { return m_showOSD; }
 48
 49	virtual void startDrawing(std::shared_ptr<CoreController>) = 0;
 50	virtual bool isDrawing() const = 0;
 51	virtual bool supportsShaders() const = 0;
 52	virtual VideoShader* shaders() = 0;
 53	virtual int framebufferHandle() { return -1; }
 54	virtual void setVideoScale(int scale) {}
 55
 56	QSize viewportSize();
 57
 58	virtual void setVideoProxy(std::shared_ptr<VideoProxy> proxy) { m_videoProxy = proxy; }
 59	std::shared_ptr<VideoProxy> videoProxy() { return m_videoProxy; }
 60	
 61signals:
 62	void showCursor();
 63	void hideCursor();
 64
 65public slots:
 66	virtual void stopDrawing() = 0;
 67	virtual void pauseDrawing() = 0;
 68	virtual void unpauseDrawing() = 0;
 69	virtual void forceDraw() = 0;
 70	virtual void lockAspectRatio(bool lock);
 71	virtual void lockIntegerScaling(bool lock);
 72	virtual void interframeBlending(bool enable);
 73	virtual void showOSDMessages(bool enable);
 74	virtual void filter(bool filter);
 75	virtual void framePosted() = 0;
 76	virtual void setShaders(struct VDir*) = 0;
 77	virtual void clearShaders() = 0;
 78	virtual void resizeContext() = 0;
 79
 80	void showMessage(const QString& message);
 81
 82protected:
 83	virtual void resizeEvent(QResizeEvent*) override;
 84	virtual void mouseMoveEvent(QMouseEvent*) override;
 85
 86	MessagePainter* messagePainter() { return &m_messagePainter; }
 87
 88	void setSystemDimensions(int width, int height);
 89
 90private:
 91	static Driver s_driver;
 92	static const int MOUSE_DISAPPEAR_TIMER = 1000;
 93
 94	MessagePainter m_messagePainter;
 95	bool m_showOSD = true;
 96	bool m_lockAspectRatio = false;
 97	bool m_lockIntegerScaling = false;
 98	bool m_interframeBlending = false;
 99	bool m_filter = false;
100	QTimer m_mouseTimer;
101	int m_coreWidth;
102	int m_coreHeight;
103	std::shared_ptr<VideoProxy> m_videoProxy;
104};
105
106}