blob: 7ad0ca3a930f10a58dbd1c0c439338869972d017 [file] [log] [blame]
Cody Schuffelen134ff032019-11-22 00:25:32 -08001#pragma once
2/*
3 * Copyright (C) 2017 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#include "common/vsoc/shm/base.h"
19#include "common/vsoc/shm/lock.h"
20
21// Memory layout for screen region
22
23namespace vsoc {
24namespace layout {
25
26namespace screen {
27struct TimeSpec {
28 static constexpr size_t layout_size = 16;
29
30 int64_t ts_sec;
31 uint32_t ts_nsec;
32 // Host and guest compilers are giving the structure different sizes without
33 // this field.
34 uint32_t reserved;
35};
36ASSERT_SHM_COMPATIBLE(TimeSpec);
37
38struct CompositionStats {
39 static constexpr size_t layout_size = 4 + 2 * 2 + 5 * TimeSpec::layout_size;
40
41 uint32_t num_prepare_calls;
42 uint16_t num_layers;
43 uint16_t num_hwcomposited_layers;
44 TimeSpec last_vsync;
45 TimeSpec prepare_start;
46 TimeSpec prepare_end;
47 TimeSpec set_start;
48 TimeSpec set_end;
49};
50ASSERT_SHM_COMPATIBLE(CompositionStats);
51
52struct ScreenLayout : public RegionLayout {
53 static constexpr size_t layout_size = 24 + CompositionStats::layout_size;
54 static const char* region_name;
55 // Display properties
56 uint32_t x_res;
57 uint32_t y_res;
58 uint16_t dpi;
59 uint16_t refresh_rate_hz;
60
61 // Protects access to the frame offset, sequential number and stats.
62 // See the region implementation for more details.
63 SpinLock bcast_lock;
64 // The frame sequential number
65 std::atomic<uint32_t> seq_num;
66 // The index of the buffer containing the current frame.
67 int32_t buffer_index;
68 CompositionStats stats;
69 uint8_t buffer[0];
70};
71ASSERT_SHM_COMPATIBLE(ScreenLayout);
72
73} // namespace screen
74
75} // namespace layout
76} // namespace vsoc