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; |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 28 | uint32_t flags = 0; |
| 29 | int32_t parentId = -1; |
| 30 | int32_t mirrorFromId = -1; |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | struct TracingLayerState : layer_state_t { |
| 34 | uint64_t bufferId; |
| 35 | uint32_t bufferHeight; |
| 36 | uint32_t bufferWidth; |
Vishnu Nair | d37343b | 2022-01-12 16:18:56 -0800 | [diff] [blame^] | 37 | int32_t pixelFormat; |
| 38 | uint64_t bufferUsage; |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 39 | bool hasSidebandStream; |
| 40 | int32_t parentId; |
| 41 | int32_t relativeParentId; |
| 42 | int32_t inputCropId; |
Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 43 | TracingLayerCreationArgs args; |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 44 | }; |
| 45 | |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 46 | class TransactionProtoParser { |
| 47 | public: |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 48 | typedef std::function<sp<IBinder>(int32_t)> LayerIdToHandleFn; |
| 49 | typedef std::function<sp<IBinder>(int32_t)> DisplayIdToHandleFn; |
| 50 | typedef std::function<int32_t(const sp<IBinder>&)> LayerHandleToIdFn; |
| 51 | typedef std::function<int32_t(const sp<IBinder>&)> DisplayHandleToIdFn; |
| 52 | |
| 53 | static proto::TransactionState toProto(const TransactionState&, LayerHandleToIdFn getLayerIdFn, |
| 54 | DisplayHandleToIdFn getDisplayIdFn); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 55 | static proto::TransactionState toProto( |
Greg Kaiser | 2c90985 | 2021-12-07 09:45:29 -0800 | [diff] [blame] | 56 | const std::map<int32_t /* layerId */, TracingLayerState>&); |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 57 | |
| 58 | static proto::LayerCreationArgs toProto(const TracingLayerCreationArgs& args); |
| 59 | |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 60 | static TransactionState fromProto(const proto::TransactionState&, |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 61 | LayerIdToHandleFn getLayerHandleFn, |
| 62 | DisplayIdToHandleFn getDisplayHandleFn); |
| 63 | static void fromProto(const proto::LayerState&, LayerIdToHandleFn getLayerHandleFn, |
| 64 | TracingLayerState& outState); |
| 65 | static void fromProto(const proto::LayerCreationArgs&, TracingLayerCreationArgs& outArgs); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 66 | |
| 67 | private: |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 68 | static proto::LayerState toProto(const layer_state_t&, LayerHandleToIdFn getLayerId); |
| 69 | static proto::DisplayState toProto(const DisplayState&, DisplayHandleToIdFn getDisplayId); |
| 70 | static void fromProto(const proto::LayerState&, LayerIdToHandleFn getLayerHandle, |
| 71 | layer_state_t& out); |
| 72 | static DisplayState fromProto(const proto::DisplayState&, DisplayIdToHandleFn getDisplayHandle); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
Greg Kaiser | 2c90985 | 2021-12-07 09:45:29 -0800 | [diff] [blame] | 75 | } // namespace android::surfaceflinger |