Mir
stream.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by:
17  * Kevin DuBois <kevin.dubois@canonical.com>
18  */
19 
20 #ifndef MIR_COMPOSITOR_STREAM_H_
21 #define MIR_COMPOSITOR_STREAM_H_
22 
26 #include "mir/geometry/size.h"
27 #include "multi_monitor_arbiter.h"
28 #include <mutex>
29 #include <memory>
30 
31 namespace mir
32 {
33 namespace frontend { class ClientBuffers; }
34 namespace compositor
35 {
36 class Schedule;
37 class Stream : public BufferStream
38 {
39 public:
40  Stream(std::unique_ptr<frontend::ClientBuffers>, geometry::Size sz, MirPixelFormat format);
41 
42  void swap_buffers(
43  graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete) override;
44  void with_most_recent_buffer_do(std::function<void(graphics::Buffer&)> const& exec) override;
45  MirPixelFormat pixel_format() const override;
46  void add_observer(std::shared_ptr<scene::SurfaceObserver> const& observer) override;
47  void remove_observer(std::weak_ptr<scene::SurfaceObserver> const& observer) override;
48  std::shared_ptr<graphics::Buffer>
49  lock_compositor_buffer(void const* user_id) override;
50  geometry::Size stream_size() override;
51  void resize(geometry::Size const& size) override;
52  void allow_framedropping(bool) override;
53  void force_requests_to_complete() override;
54  int buffers_ready_for_compositor(void const* user_id) const override;
55  void drop_old_buffers() override;
56  bool has_submitted_buffer() const override;
58  void remove_buffer(graphics::BufferID) override;
59  void with_buffer(graphics::BufferID id, std::function<void(graphics::Buffer&)> const& fn) override;
60  void set_scale(float scale) override;
61 
62 private:
63  enum class ScheduleMode;
64  void transition_schedule(std::shared_ptr<Schedule>&& new_schedule, std::lock_guard<std::mutex> const&);
65 
66  std::mutex mutable mutex;
67  ScheduleMode schedule_mode;
68  std::shared_ptr<Schedule> schedule;
69  std::shared_ptr<frontend::ClientBuffers> buffers;
70  std::shared_ptr<MultiMonitorArbiter> arbiter;
72  MirPixelFormat const pf;
73  bool first_frame_posted;
74 
75  scene::SurfaceObservers observers;
76 };
77 }
78 }
79 
80 #endif /* MIR_COMPOSITOR_STREAM_H_ */
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
void force_requests_to_complete() override
Definition: stream.cpp:133
void with_most_recent_buffer_do(std::function< void(graphics::Buffer &)> const &exec) override
Definition: stream.cpp:64
ScheduleMode
Definition: stream.cpp:33
bool has_submitted_buffer() const override
Definition: stream.cpp:156
int buffers_ready_for_compositor(void const *user_id) const override
Definition: stream.cpp:138
Definition: buffer_stream.h:40
Stream(std::unique_ptr< frontend::ClientBuffers >, geometry::Size sz, MirPixelFormat format)
Definition: stream.cpp:38
Definition: stream.h:37
void drop_old_buffers() override
Definition: stream.cpp:146
std::shared_ptr< graphics::Buffer > lock_compositor_buffer(void const *user_id) override
Definition: stream.cpp:87
void add_observer(std::shared_ptr< scene::SurfaceObserver > const &observer) override
Definition: stream.cpp:76
void remove_buffer(graphics::BufferID) override
Definition: stream.cpp:167
MirPixelFormat
32-bit pixel formats (8888): The order of components in the enum matches the order of the components ...
Definition: common.h:134
void remove_observer(std::weak_ptr< scene::SurfaceObserver > const &observer) override
Definition: stream.cpp:81
void allow_framedropping(bool) override
Definition: stream.cpp:106
Definition: surface_observers.h:30
void set_scale(float scale) override
Definition: stream.cpp:178
MirPixelFormat pixel_format() const override
Definition: stream.cpp:71
Buffer creation properties.
Definition: buffer_properties.h:48
void with_buffer(graphics::BufferID id, std::function< void(graphics::Buffer &)> const &fn) override
Definition: stream.cpp:172
Definition: buffer.h:44
geometry::Size stream_size() override
Definition: stream.cpp:93
void resize(geometry::Size const &size) override
Definition: stream.cpp:99
int const size
Definition: make_socket_rpc_channel.cpp:51
graphics::BufferID allocate_buffer(graphics::BufferProperties const &) override
Definition: stream.cpp:162
void swap_buffers(graphics::Buffer *old_buffer, std::function< void(graphics::Buffer *new_buffer)> complete) override
Definition: stream.cpp:50

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015