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 #include <renderengine/ExternalTexture.h> 19 20 #include <Layer.h> 21 #include <gui/WindowInfo.h> 22 #include <math/vec4.h> 23 #include <ui/BlurRegion.h> 24 #include <ui/GraphicBuffer.h> 25 #include <ui/Rect.h> 26 #include <ui/Region.h> 27 #include <ui/Transform.h> 28 29 namespace android { 30 namespace surfaceflinger { 31 class LayerProtoHelper { 32 public: 33 static void writePositionToProto(const float x, const float y, 34 std::function<PositionProto*()> getPositionProto); 35 static void writeSizeToProto(const uint32_t w, const uint32_t h, 36 std::function<SizeProto*()> getSizeProto); 37 static void writeToProto(const Rect& rect, std::function<RectProto*()> getRectProto); 38 static void writeToProto(const Rect& rect, RectProto* rectProto); 39 static void readFromProto(const RectProto& proto, Rect& outRect); 40 static void writeToProto(const FloatRect& rect, 41 std::function<FloatRectProto*()> getFloatRectProto); 42 static void writeToProto(const Region& region, std::function<RegionProto*()> getRegionProto); 43 static void writeToProto(const Region& region, RegionProto* regionProto); 44 static void readFromProto(const RegionProto& regionProto, Region& outRegion); 45 static void writeToProto(const half4 color, std::function<ColorProto*()> getColorProto); 46 // This writeToProto for transform is incorrect, but due to backwards compatibility, we can't 47 // update Layers to use it. Use writeTransformToProto for any new transform proto data. 48 static void writeToProtoDeprecated(const ui::Transform& transform, 49 TransformProto* transformProto); 50 static void writeTransformToProto(const ui::Transform& transform, 51 TransformProto* transformProto); 52 static void writeToProto(const renderengine::ExternalTexture& buffer, 53 std::function<ActiveBufferProto*()> getActiveBufferProto); 54 static void writeToProto(const gui::WindowInfo& inputInfo, 55 const wp<Layer>& touchableRegionBounds, 56 std::function<InputWindowInfoProto*()> getInputWindowInfoProto); 57 static void writeToProto(const mat4 matrix, ColorTransformProto* colorTransformProto); 58 static void readFromProto(const ColorTransformProto& colorTransformProto, mat4& matrix); 59 static void writeToProto(const android::BlurRegion region, BlurRegion*); 60 static void readFromProto(const BlurRegion& proto, android::BlurRegion& outRegion); 61 }; 62 63 } // namespace surfaceflinger 64 } // namespace android 65