chaviw | 1d04428 | 2017-09-27 12:19:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | |
| 17 | #include <layerproto/LayerProtoHeader.h> |
| 18 | |
Vishnu Nair | 9245d3b | 2019-03-22 13:38:56 -0700 | [diff] [blame] | 19 | #include <Layer.h> |
chaviw | 98318de | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 20 | #include <gui/WindowInfo.h> |
Peiyong Lin | efefaac | 2018-08-17 12:27:51 -0700 | [diff] [blame] | 21 | #include <math/vec4.h> |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame^] | 22 | #include <ui/BlurRegion.h> |
chaviw | 1d04428 | 2017-09-27 12:19:28 -0700 | [diff] [blame] | 23 | #include <ui/GraphicBuffer.h> |
| 24 | #include <ui/Rect.h> |
| 25 | #include <ui/Region.h> |
Peiyong Lin | efefaac | 2018-08-17 12:27:51 -0700 | [diff] [blame] | 26 | #include <ui/Transform.h> |
chaviw | 1d04428 | 2017-09-27 12:19:28 -0700 | [diff] [blame] | 27 | |
| 28 | namespace android { |
| 29 | namespace surfaceflinger { |
| 30 | class LayerProtoHelper { |
| 31 | public: |
Nataniel Borges | 797b0e4 | 2019-02-15 14:11:58 -0800 | [diff] [blame] | 32 | static void writePositionToProto(const float x, const float y, |
| 33 | std::function<PositionProto*()> getPositionProto); |
| 34 | static void writeSizeToProto(const uint32_t w, const uint32_t h, |
| 35 | std::function<SizeProto*()> getSizeProto); |
| 36 | static void writeToProto(const Rect& rect, std::function<RectProto*()> getRectProto); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame^] | 37 | static void writeToProto(const Rect& rect, RectProto* rectProto); |
| 38 | static void readFromProto(const RectProto& proto, Rect& outRect); |
Nataniel Borges | 797b0e4 | 2019-02-15 14:11:58 -0800 | [diff] [blame] | 39 | static void writeToProto(const FloatRect& rect, |
| 40 | std::function<FloatRectProto*()> getFloatRectProto); |
| 41 | static void writeToProto(const Region& region, std::function<RegionProto*()> getRegionProto); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame^] | 42 | static void writeToProto(const Region& region, RegionProto* regionProto); |
| 43 | static void readFromProto(const RegionProto& regionProto, Region& outRegion); |
Nataniel Borges | 797b0e4 | 2019-02-15 14:11:58 -0800 | [diff] [blame] | 44 | static void writeToProto(const half4 color, std::function<ColorProto*()> getColorProto); |
chaviw | 0a39899 | 2021-08-13 10:13:01 -0500 | [diff] [blame] | 45 | // This writeToProto for transform is incorrect, but due to backwards compatibility, we can't |
| 46 | // update Layers to use it. Use writeTransformToProto for any new transform proto data. |
| 47 | static void writeToProtoDeprecated(const ui::Transform& transform, |
| 48 | TransformProto* transformProto); |
| 49 | static void writeTransformToProto(const ui::Transform& transform, |
| 50 | TransformProto* transformProto); |
Nataniel Borges | 797b0e4 | 2019-02-15 14:11:58 -0800 | [diff] [blame] | 51 | static void writeToProto(const sp<GraphicBuffer>& buffer, |
| 52 | std::function<ActiveBufferProto*()> getActiveBufferProto); |
chaviw | 98318de | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 53 | static void writeToProto(const gui::WindowInfo& inputInfo, |
Vishnu Nair | 9245d3b | 2019-03-22 13:38:56 -0700 | [diff] [blame] | 54 | const wp<Layer>& touchableRegionBounds, |
| 55 | std::function<InputWindowInfoProto*()> getInputWindowInfoProto); |
chaviw | ddeae26 | 2020-01-06 10:31:23 -0800 | [diff] [blame] | 56 | static void writeToProto(const mat4 matrix, ColorTransformProto* colorTransformProto); |
Vishnu Nair | 6b59115 | 2021-10-08 11:45:14 -0700 | [diff] [blame^] | 57 | static void readFromProto(const ColorTransformProto& colorTransformProto, mat4& matrix); |
| 58 | static void writeToProto(const android::BlurRegion region, BlurRegion*); |
| 59 | static void readFromProto(const BlurRegion& proto, android::BlurRegion& outRegion); |
chaviw | 1d04428 | 2017-09-27 12:19:28 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | } // namespace surfaceflinger |
Yiwei Zhang | 7124ad3 | 2018-02-21 13:02:45 -0800 | [diff] [blame] | 63 | } // namespace android |