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 
19 #include <Layer.h>
20 #include <input/InputWindow.h>
21 #include <math/vec4.h>
22 #include <ui/GraphicBuffer.h>
23 #include <ui/Rect.h>
24 #include <ui/Region.h>
25 #include <ui/Transform.h>
26 
27 namespace android {
28 namespace surfaceflinger {
29 class LayerProtoHelper {
30 public:
31     static void writePositionToProto(const float x, const float y,
32                                      std::function<PositionProto*()> getPositionProto);
33     static void writeSizeToProto(const uint32_t w, const uint32_t h,
34                                  std::function<SizeProto*()> getSizeProto);
35     static void writeToProto(const Rect& rect, std::function<RectProto*()> getRectProto);
36     static void writeToProto(const FloatRect& rect,
37                              std::function<FloatRectProto*()> getFloatRectProto);
38     static void writeToProto(const Region& region, std::function<RegionProto*()> getRegionProto);
39     static void writeToProto(const half4 color, std::function<ColorProto*()> getColorProto);
40     static void writeToProto(const ui::Transform& transform, TransformProto* transformProto);
41     static void writeToProto(const sp<GraphicBuffer>& buffer,
42                              std::function<ActiveBufferProto*()> getActiveBufferProto);
43     static void writeToProto(const InputWindowInfo& inputInfo,
44                              const wp<Layer>& touchableRegionBounds,
45                              std::function<InputWindowInfoProto*()> getInputWindowInfoProto);
46     static void writeToProto(const mat4 matrix, ColorTransformProto* colorTransformProto);
47 };
48 
49 } // namespace surfaceflinger
50 } // namespace android
51