• 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 #include "host/libs/wayland/wayland_surfaces.h"
18 
19 #include <android-base/logging.h>
20 #include <wayland-server-protocol.h>
21 
22 #include "host/libs/wayland/wayland_surface.h"
23 
24 namespace wayland {
25 
SetFrameCallback(FrameCallback callback)26 void Surfaces::SetFrameCallback(FrameCallback callback) {
27   std::unique_lock<std::mutex> lock(callback_mutex_);
28   callback_.emplace(std::move(callback));
29 }
30 
HandleSurfaceFrame(std::uint32_t display_number,std::uint32_t frame_width,std::uint32_t frame_height,std::uint32_t frame_stride_bytes,std::uint8_t * frame_bytes)31 void Surfaces::HandleSurfaceFrame(std::uint32_t display_number,
32                                   std::uint32_t frame_width,
33                                   std::uint32_t frame_height,
34                                   std::uint32_t frame_stride_bytes,
35                                   std::uint8_t* frame_bytes) {
36   std::unique_lock<std::mutex> lock(callback_mutex_);
37   if (callback_) {
38     (callback_.value())(display_number, frame_width, frame_height,
39                         frame_stride_bytes, frame_bytes);
40   }
41 }
42 
43 }  // namespace wayland