Android-cuttlefish cvd tool
wayland_surfaces.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 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 <stdint.h>
20
21#include <future>
22#include <memory>
23#include <mutex>
24#include <optional>
25#include <thread>
26#include <unordered_map>
27
29
30namespace wayland {
31
32class Surface;
33
34class Surfaces {
35 public:
36 Surfaces() = default;
37 virtual ~Surfaces() = default;
38
39 Surfaces(const Surfaces& rhs) = delete;
40 Surfaces& operator=(const Surfaces& rhs) = delete;
41
42 Surfaces(Surfaces&& rhs) = delete;
43 Surfaces& operator=(Surfaces&& rhs) = delete;
44
45 void SetFrameCallback(FrameCallback callback);
46
48
49 void SetFramesAreRGBA(bool frames_are_rgba);
50
51 private:
52 friend class Surface;
53 void HandleSurfaceFrame(uint32_t display_number, //
54 uint32_t frame_width, //
55 uint32_t frame_height, //
56 uint32_t frame_fourcc_format, //
57 uint32_t frame_stride_bytes, //
58 uint8_t* frame_bytes);
59
60 void HandleSurfaceCreated(uint32_t display_number, uint32_t display_width,
61 uint32_t display_height);
62
63 void HandleSurfaceDestroyed(uint32_t display_number);
64
65 std::mutex callback_mutex_;
66 std::optional<FrameCallback> callback_;
67 std::optional<DisplayEventCallback> event_callback_;
68 // If true, report that the received frames are RGBA regardless
69 // of the format reported by the wayland client.
70 bool frames_are_rgba_ = false;
71};
72
73} // namespace wayland
Definition: wayland_surface.h:31
Definition: wayland_surfaces.h:34
Surfaces()=default
std::optional< FrameCallback > callback_
Definition: wayland_surfaces.h:66
Surfaces(Surfaces &&rhs)=delete
void SetFramesAreRGBA(bool frames_are_rgba)
Definition: wayland_surfaces.cpp:40
virtual ~Surfaces()=default
bool frames_are_rgba_
Definition: wayland_surfaces.h:70
void SetDisplayEventCallback(DisplayEventCallback callback)
Definition: wayland_surfaces.cpp:35
std::mutex callback_mutex_
Definition: wayland_surfaces.h:65
Surfaces(const Surfaces &rhs)=delete
void HandleSurfaceDestroyed(uint32_t display_number)
Definition: wayland_surfaces.cpp:76
void SetFrameCallback(FrameCallback callback)
Definition: wayland_surfaces.cpp:30
void HandleSurfaceFrame(uint32_t display_number, uint32_t frame_width, uint32_t frame_height, uint32_t frame_fourcc_format, uint32_t frame_stride_bytes, uint8_t *frame_bytes)
Definition: wayland_surfaces.cpp:44
Surfaces & operator=(const Surfaces &rhs)=delete
Surfaces & operator=(Surfaces &&rhs)=delete
void HandleSurfaceCreated(uint32_t display_number, uint32_t display_width, uint32_t display_height)
Definition: wayland_surfaces.cpp:61
std::optional< DisplayEventCallback > event_callback_
Definition: wayland_surfaces.h:67
Definition: wayland_compositor.cpp:26
std::function< void(const DisplayEvent &)> DisplayEventCallback
Definition: wayland_server_callbacks.h:35
std::function< void(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint8_t *)> FrameCallback
Definition: wayland_server_callbacks.h:43