~alan-griffiths/miral/debug

« back to all changes in this revision

Viewing changes to miral-qt/src/platforms/mirserver/screen.h

  • Committer: Gerry Boland
  • Date: 2016-06-01 22:06:51 UTC
  • mto: This revision was merged to the branch mainline in revision 178.
  • Revision ID: gerry.boland@canonical.com-20160601220651-ge508tffql4e7u7c
Import QtMir code into miral-qt subdirectory. Disabled by default, use -DMIRAL_ENABLE_QT=1 to build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013-2016 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it under
 
5
 * the terms of the GNU Lesser General Public License version 3, as published by
 
6
 * the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
 
9
 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
 
10
 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
 * Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#ifndef SCREEN_H
 
18
#define SCREEN_H
 
19
 
 
20
// Qt
 
21
#include <QObject>
 
22
#include <QTimer>
 
23
#include <QtDBus/QDBusInterface>
 
24
#include <qpa/qplatformscreen.h>
 
25
 
 
26
// Mir
 
27
#include <mir/graphics/display_configuration.h>
 
28
 
 
29
// local
 
30
#include "cursor.h"
 
31
#include "screenwindow.h"
 
32
 
 
33
class QOrientationSensor;
 
34
namespace mir {
 
35
    namespace graphics { class DisplayBuffer; class DisplaySyncGroup; }
 
36
    namespace renderer { namespace gl { class RenderTarget; }}
 
37
}
 
38
 
 
39
class Screen : public QObject, public QPlatformScreen
 
40
{
 
41
    Q_OBJECT
 
42
public:
 
43
    Screen(const mir::graphics::DisplayConfigurationOutput &);
 
44
    ~Screen();
 
45
 
 
46
    // QPlatformScreen methods.
 
47
    QRect geometry() const override { return m_geometry; }
 
48
    int depth() const override { return m_depth; }
 
49
    QImage::Format format() const override { return m_format; }
 
50
    qreal devicePixelRatio() const override { return m_devicePixelRatio; }
 
51
    QSizeF physicalSize() const override { return m_physicalSize; }
 
52
    qreal refreshRate() const override { return m_refreshRate; }
 
53
    Qt::ScreenOrientation nativeOrientation() const override { return m_nativeOrientation; }
 
54
    Qt::ScreenOrientation orientation() const override { return m_currentOrientation; }
 
55
    QPlatformCursor *cursor() const override;
 
56
    QString name() const override;
 
57
 
 
58
    float scale() const { return m_scale; }
 
59
    MirFormFactor formFactor() const { return m_formFactor; }
 
60
    MirPowerMode powerMode() const { return m_powerMode; }
 
61
    mir::graphics::DisplayConfigurationOutputId outputId() const { return m_outputId; }
 
62
    mir::graphics::DisplayConfigurationOutputType outputType() const { return m_type; }
 
63
    std::vector<MirPixelFormat> pixelFormats() const { return m_pixelFormats; }
 
64
    std::vector<mir::graphics::DisplayConfigurationMode> modes() const { return m_modes; }
 
65
    uint32_t currentModeIndex() const { return m_currentModeIndex; }
 
66
    uint32_t preferredModeIndex() const { return m_preferredModeIndex; }
 
67
 
 
68
    ScreenWindow* window() const;
 
69
 
 
70
    // QObject methods.
 
71
    void customEvent(QEvent* event) override;
 
72
 
 
73
    // To make it testable
 
74
    static bool skipDBusRegistration;
 
75
    bool orientationSensorEnabled();
 
76
 
 
77
public Q_SLOTS:
 
78
   void onDisplayPowerStateChanged(int, int);
 
79
   void onOrientationReadingChanged();
 
80
 
 
81
protected:
 
82
    void setWindow(ScreenWindow *window);
 
83
 
 
84
    void setMirDisplayConfiguration(const mir::graphics::DisplayConfigurationOutput &, bool notify = true);
 
85
    void setMirDisplayBuffer(mir::graphics::DisplayBuffer *, mir::graphics::DisplaySyncGroup *);
 
86
    void swapBuffers();
 
87
    void makeCurrent();
 
88
    void doneCurrent();
 
89
 
 
90
private:
 
91
    void toggleSensors(const bool enable) const;
 
92
    bool internalDisplay() const;
 
93
 
 
94
    QRect m_geometry;
 
95
    int m_depth;
 
96
    QImage::Format m_format;
 
97
    qreal m_devicePixelRatio;
 
98
    QSizeF m_physicalSize;
 
99
    qreal m_refreshRate;
 
100
    float m_scale;
 
101
    MirFormFactor m_formFactor;
 
102
    std::vector<MirPixelFormat> m_pixelFormats;
 
103
    std::vector<mir::graphics::DisplayConfigurationMode> m_modes;
 
104
    uint32_t m_currentModeIndex;
 
105
    uint32_t m_preferredModeIndex;
 
106
 
 
107
    mir::renderer::gl::RenderTarget *m_renderTarget;
 
108
    mir::graphics::DisplaySyncGroup *m_displayGroup;
 
109
    mir::graphics::DisplayConfigurationOutputId m_outputId;
 
110
    mir::graphics::DisplayConfigurationCardId m_cardId;
 
111
    mir::graphics::DisplayConfigurationOutputType m_type;
 
112
    MirPowerMode m_powerMode;
 
113
 
 
114
    Qt::ScreenOrientation m_nativeOrientation;
 
115
    Qt::ScreenOrientation m_currentOrientation;
 
116
    QOrientationSensor *m_orientationSensor;
 
117
 
 
118
    ScreenWindow *m_screenWindow;
 
119
    QDBusInterface *m_unityScreen;
 
120
 
 
121
    qtmir::Cursor m_cursor;
 
122
 
 
123
    friend class ScreensModel;
 
124
    friend class ScreenWindow;
 
125
};
 
126
 
 
127
#endif // SCREEN_H