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 | |
Vishnu Nair | 59f6d2d | 2022-10-05 16:59:56 -0700 | [diff] [blame] | 18 | #include <gui/fake/BufferData.h> |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 19 | #include <layerproto/TransactionProto.h> |
| 20 | #include <utils/RefBase.h> |
Vishnu Nair | 8175062 | 2023-03-08 15:02:06 -0800 | [diff] [blame^] | 21 | #include "Display/DisplayMap.h" |
| 22 | #include "FrontEnd/DisplayInfo.h" |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 23 | |
Vishnu Nair | 8175062 | 2023-03-08 15:02:06 -0800 | [diff] [blame^] | 24 | #include "FrontEnd/LayerCreationArgs.h" |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 25 | #include "TransactionState.h" |
| 26 | |
| 27 | namespace android::surfaceflinger { |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 28 | |
Vishnu Nair | 8175062 | 2023-03-08 15:02:06 -0800 | [diff] [blame^] | 29 | struct TracingLayerState : ResolvedComposerState { |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 30 | bool hasSidebandStream; |
Vishnu Nair | 8175062 | 2023-03-08 15:02:06 -0800 | [diff] [blame^] | 31 | LayerCreationArgs args; |
Vishnu Nair | 68dee2b | 2021-11-08 18:52:12 -0800 | [diff] [blame] | 32 | }; |
| 33 | |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 34 | class TransactionProtoParser { |
| 35 | public: |
| 36 | // Utility class to map handles to ids and buffers to buffer properties without pulling |
| 37 | // in SurfaceFlinger dependencies. |
| 38 | class FlingerDataMapper { |
| 39 | public: |
| 40 | virtual ~FlingerDataMapper() = default; |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 41 | virtual sp<IBinder> getDisplayHandle(int32_t /* displayId */) const { return nullptr; } |
| 42 | virtual int32_t getDisplayId(const sp<IBinder>& /* displayHandle */) const { return -1; } |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | TransactionProtoParser(std::unique_ptr<FlingerDataMapper> provider) |
| 46 | : mMapper(std::move(provider)) {} |
| 47 | |
| 48 | proto::TransactionState toProto(const TransactionState&); |
Vishnu Nair | 8175062 | 2023-03-08 15:02:06 -0800 | [diff] [blame^] | 49 | proto::TransactionState toProto(const std::map<uint32_t /* layerId */, TracingLayerState>&); |
| 50 | proto::LayerCreationArgs toProto(const LayerCreationArgs& args); |
| 51 | proto::LayerState toProto(const ResolvedComposerState&); |
| 52 | proto::DisplayInfo toProto(const frontend::DisplayInfo&, uint32_t layerStack); |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 53 | |
| 54 | TransactionState fromProto(const proto::TransactionState&); |
| 55 | void mergeFromProto(const proto::LayerState&, TracingLayerState& outState); |
Vishnu Nair | 8175062 | 2023-03-08 15:02:06 -0800 | [diff] [blame^] | 56 | void fromProto(const proto::LayerCreationArgs&, LayerCreationArgs& outArgs); |
Robert Carr | a63d52a | 2022-03-03 08:03:37 -0800 | [diff] [blame] | 57 | std::unique_ptr<FlingerDataMapper> mMapper; |
Vishnu Nair | 8175062 | 2023-03-08 15:02:06 -0800 | [diff] [blame^] | 58 | frontend::DisplayInfo fromProto(const proto::DisplayInfo&); |
| 59 | void fromProto(const google::protobuf::RepeatedPtrField<proto::DisplayInfo>&, |
| 60 | display::DisplayMap<ui::LayerStack, frontend::DisplayInfo> outDisplayInfos); |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 61 | |
| 62 | private: |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 63 | proto::DisplayState toProto(const DisplayState&); |
Vishnu Nair | 8175062 | 2023-03-08 15:02:06 -0800 | [diff] [blame^] | 64 | void fromProto(const proto::LayerState&, ResolvedComposerState& out); |
Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 65 | DisplayState fromProto(const proto::DisplayState&); |
| 66 | |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame] | 67 | }; |
| 68 | |
Greg Kaiser | 2c90985 | 2021-12-07 09:45:29 -0800 | [diff] [blame] | 69 | } // namespace android::surfaceflinger |