-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathdisplay.cpp
More file actions
123 lines (102 loc) · 3.05 KB
/
display.cpp
File metadata and controls
123 lines (102 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// lv-tool - Libvisual commandline tool
//
// Copyright (C) 2012-2013 Libvisual team
// 2004-2006 Dennis Smit
//
// Authors: Daniel Hiepler <daniel@niftylight.de>
// Chong Kai Xiong <kaixiong@codeleft.sg>
// Dennis Smit <ds@nerds-incorporated.org>
//
// This file is part of lv-tool.
//
// lv-tool is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// lv-tool is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with lv-tool. If not, see <http://www.gnu.org/licenses/>.
#include "display.hpp"
#include "display_driver_factory.hpp"
#include <libvisual/libvisual.h>
#include <utility>
#include <stdexcept>
#include <string>
class Display::Impl
{
public:
std::unique_ptr<DisplayDriver> driver;
Impl (std::unique_ptr<DisplayDriver> driver_)
: driver {std::move (driver_)}
{}
~Impl ()
{}
};
Display::Display (std::string const& driver_name)
: m_impl {new Impl {DisplayDriverFactory::instance().make (driver_name, *this)}}
{
if (!m_impl->driver) {
throw std::runtime_error ("Failed to load display driver '" + driver_name + "'. Valid driver set? (\"--driver\" parameter)");
}
}
Display::~Display ()
{
}
LV::VideoPtr Display::get_video () const
{
return m_impl->driver->get_video ();
}
LV::VideoPtr Display::create (VisVideoDepth depth,
VisVideoAttrOptions const* vidoptions,
unsigned int width,
unsigned int height,
bool resizable)
{
visual_log (VISUAL_LOG_INFO, "Attempting to create display (%dx%d %s)",
width, height, visual_video_depth_name (depth));
return m_impl->driver->create (depth, vidoptions, width, height, resizable);
}
void Display::close ()
{
visual_log (VISUAL_LOG_INFO, "Closing display");
m_impl->driver->close ();
}
void Display::set_title(std::string const& title)
{
m_impl->driver->set_title(title);
}
void Display::lock ()
{
m_impl->driver->lock ();
}
void Display::unlock ()
{
m_impl->driver->unlock ();
}
void Display::update_all ()
{
LV::VideoPtr video = get_video ();
LV::Rect rect (video->get_width (), video->get_height ());
m_impl->driver->update_rect (rect);
}
void Display::update_rect (LV::Rect const& rect)
{
m_impl->driver->update_rect (rect);
}
bool Display::is_fullscreen () const
{
return m_impl->driver->is_fullscreen ();
}
void Display::set_fullscreen (bool fullscreen, bool autoscale)
{
m_impl->driver->set_fullscreen (fullscreen, autoscale);
}
void Display::drain_events (VisEventQueue& eventqueue)
{
m_impl->driver->drain_events (eventqueue);
}