Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 23 | namespace android::surfaceflinger { |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 24 | |
| 25 | struct TracingLayerCreationArgs { |
| 26 | int32_t layerId; |
| 27 | std::string name; |
| 28 | uint32_t flags; |
| 29 | int32_t parentId; |
| 30 | }; |
| 31 | |
| 32 | struct 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 Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 44 | class TransactionProtoParser { |
| 45 | public: |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 46 | 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 Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 53 | static proto::TransactionState toProto( |
Greg Kaiser | 2c90985 | 2021-12-07 09:45:29 -0800 | [diff] [blame^] | 54 | const std::map<int32_t /* layerId */, TracingLayerState>&); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 55 | |
| 56 | static proto::LayerCreationArgs toProto(const TracingLayerCreationArgs& args); |
| 57 | |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 58 | static TransactionState fromProto(const proto::TransactionState&, |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 59 | 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 Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 64 | |
| 65 | private: |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 66 | 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 Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
Greg Kaiser | 2c90985 | 2021-12-07 09:45:29 -0800 | [diff] [blame^] | 73 | } // namespace android::surfaceflinger |