blob: 6c1202f028c2259b77bc899f3ea7501d17e98ae7 [file] [log] [blame]
Vishnu Nair6b591152021-10-08 11:45:14 -07001/*
2 * Copyright (C) 2021 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#pragma once
17
18#include <layerproto/TransactionProto.h>
19#include <utils/RefBase.h>
20
21#include "TransactionState.h"
22
23namespace android::surfaceflinger {
Vishnu Nair68dee2b2021-11-08 18:52:12 -080024
25struct TracingLayerCreationArgs {
26 int32_t layerId;
27 std::string name;
28 uint32_t flags;
29 int32_t parentId;
30};
31
32struct TracingLayerState : layer_state_t {
33 uint64_t bufferId;
34 uint32_t bufferHeight;
35 uint32_t bufferWidth;
36 bool hasSidebandStream;
37 int32_t parentId;
38 int32_t relativeParentId;
39 int32_t inputCropId;
40 std::string name;
41 uint32_t layerCreationFlags;
42};
43
Vishnu Nair6b591152021-10-08 11:45:14 -070044class TransactionProtoParser {
45public:
Vishnu Nair68dee2b2021-11-08 18:52:12 -080046 typedef std::function<sp<IBinder>(int32_t)> LayerIdToHandleFn;
47 typedef std::function<sp<IBinder>(int32_t)> DisplayIdToHandleFn;
48 typedef std::function<int32_t(const sp<IBinder>&)> LayerHandleToIdFn;
49 typedef std::function<int32_t(const sp<IBinder>&)> DisplayHandleToIdFn;
50
51 static proto::TransactionState toProto(const TransactionState&, LayerHandleToIdFn getLayerIdFn,
52 DisplayHandleToIdFn getDisplayIdFn);
Vishnu Nair6b591152021-10-08 11:45:14 -070053 static proto::TransactionState toProto(
Greg Kaiser2c909852021-12-07 09:45:29 -080054 const std::map<int32_t /* layerId */, TracingLayerState>&);
Vishnu Nair68dee2b2021-11-08 18:52:12 -080055
56 static proto::LayerCreationArgs toProto(const TracingLayerCreationArgs& args);
57
Vishnu Nair6b591152021-10-08 11:45:14 -070058 static TransactionState fromProto(const proto::TransactionState&,
Vishnu Nair68dee2b2021-11-08 18:52:12 -080059 LayerIdToHandleFn getLayerHandleFn,
60 DisplayIdToHandleFn getDisplayHandleFn);
61 static void fromProto(const proto::LayerState&, LayerIdToHandleFn getLayerHandleFn,
62 TracingLayerState& outState);
63 static void fromProto(const proto::LayerCreationArgs&, TracingLayerCreationArgs& outArgs);
Vishnu Nair6b591152021-10-08 11:45:14 -070064
65private:
Vishnu Nair68dee2b2021-11-08 18:52:12 -080066 static proto::LayerState toProto(const layer_state_t&, LayerHandleToIdFn getLayerId);
67 static proto::DisplayState toProto(const DisplayState&, DisplayHandleToIdFn getDisplayId);
68 static void fromProto(const proto::LayerState&, LayerIdToHandleFn getLayerHandle,
69 layer_state_t& out);
70 static DisplayState fromProto(const proto::DisplayState&, DisplayIdToHandleFn getDisplayHandle);
Vishnu Nair6b591152021-10-08 11:45:14 -070071};
72
Greg Kaiser2c909852021-12-07 09:45:29 -080073} // namespace android::surfaceflinger