• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <future>
21 #include <memory>
22 #include <mutex>
23 #include <optional>
24 #include <thread>
25 #include <unordered_map>
26 
27 namespace wayland {
28 
29 class Surface;
30 
31 class Surfaces {
32  public:
33   Surfaces() = default;
34   virtual ~Surfaces() = default;
35 
36   Surfaces(const Surfaces& rhs) = delete;
37   Surfaces& operator=(const Surfaces& rhs) = delete;
38 
39   Surfaces(Surfaces&& rhs) = delete;
40   Surfaces& operator=(Surfaces&& rhs) = delete;
41 
42   using FrameCallback =
43       std::function<void(std::uint32_t /*display_number*/,      //
44                          std::uint32_t /*frame_width*/,         //
45                          std::uint32_t /*frame_height*/,        //
46                          std::uint32_t /*frame_stride_bytes*/,  //
47                          std::uint8_t* /*frame_bytes*/)>;
48 
49   void SetFrameCallback(FrameCallback callback);
50 
51  private:
52   friend class Surface;
53   void HandleSurfaceFrame(std::uint32_t display_number,      //
54                           std::uint32_t frame_width,         //
55                           std::uint32_t frame_height,        //
56                           std::uint32_t frame_stride_bytes,  //
57                           std::uint8_t* frame_bytes);
58 
59   std::mutex callback_mutex_;
60   std::optional<FrameCallback> callback_;
61 };
62 
63 }  // namespace wayland
64