Android-cuttlefish cvd tool
wayland_server.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <atomic>
20#include <cstdint>
21#include <functional>
22#include <future>
23#include <memory>
24#include <string>
25#include <thread>
26
29
30namespace wayland {
31
32namespace internal {
33struct WaylandServerState;
34} // namespace internal
35
36// A Wayland compositing server that provides an interface for receiving frame
37// updates from a connected client.
39 public:
40 // Creates a Wayland compositing server. If specified, uses the given
41 // socket file descriptor to connect with clients. If provided, this
42 // server will close the file descriptor upon exit.
43 WaylandServer(int wayland_socket_fd = -1,
44 bool wayland_frames_are_rgba = true);
45 virtual ~WaylandServer();
46
47 WaylandServer(const WaylandServer& rhs) = delete;
48 WaylandServer& operator=(const WaylandServer& rhs) = delete;
49
52
53 // Registers the callback that will be run whenever a new frame is
54 // available.
56
58
59 private:
60 void ServerLoop(int wayland_socket_fd, bool wayland_frames_are_rgba);
61
62 bool server_ready_ = false;
64 std::condition_variable server_ready_cv_;
65
66 std::thread server_thread_;
67 std::unique_ptr<internal::WaylandServerState> server_state_;
68};
69
70} // namespace wayland
std::function< void(std::uint32_t, std::uint32_t, std::uint32_t, std::uint32_t, std::uint32_t, std::uint8_t *)> FrameCallback
Definition: wayland_surfaces.h:50
Definition: wayland_server.h:38
WaylandServer & operator=(WaylandServer &&rhs)=delete
void SetFrameCallback(Surfaces::FrameCallback callback)
Definition: wayland_server.cpp:102
std::condition_variable server_ready_cv_
Definition: wayland_server.h:64
void SetDisplayEventCallback(DisplayEventCallback callback)
Definition: wayland_server.cpp:106
WaylandServer(int wayland_socket_fd=-1, bool wayland_frames_are_rgba=true)
Definition: wayland_server.cpp:44
bool server_ready_
Definition: wayland_server.h:62
void ServerLoop(int wayland_socket_fd, bool wayland_frames_are_rgba)
Definition: wayland_server.cpp:60
WaylandServer & operator=(const WaylandServer &rhs)=delete
virtual ~WaylandServer()
Definition: wayland_server.cpp:55
std::mutex server_ready_mutex_
Definition: wayland_server.h:63
std::thread server_thread_
Definition: wayland_server.h:66
WaylandServer(const WaylandServer &rhs)=delete
std::unique_ptr< internal::WaylandServerState > server_state_
Definition: wayland_server.h:67
WaylandServer(WaylandServer &&rhs)=delete
Definition: socket.h:155
Definition: wayland_compositor.cpp:27
std::function< void(const DisplayEvent &)> DisplayEventCallback
Definition: wayland_server_callbacks.h:34