Remove legacy proto helper functions

Flag: EXEMPT (removing old flags)
Bug: 330785038
Test: presubmit
Change-Id: I2ced9157bf9aa3541b16cde5495131e82387772a
diff --git a/services/surfaceflinger/Android.bp b/services/surfaceflinger/Android.bp
index a37433c..c2a9880 100644
--- a/services/surfaceflinger/Android.bp
+++ b/services/surfaceflinger/Android.bp
@@ -47,6 +47,7 @@
         "libtimestats_deps",
         "libsurfaceflinger_common_deps",
         "surfaceflinger_defaults",
+        "libsurfaceflinger_proto_deps",
     ],
     cflags: [
         "-DLOG_TAG=\"SurfaceFlinger\"",
@@ -93,7 +94,6 @@
         "libcompositionengine",
         "libframetimeline",
         "libgui_aidl_static",
-        "liblayers_proto",
         "libperfetto_client_experimental",
         "librenderengine",
         "libscheduler",
diff --git a/services/surfaceflinger/CompositionEngine/Android.bp b/services/surfaceflinger/CompositionEngine/Android.bp
index 7fa58df..b826466 100644
--- a/services/surfaceflinger/CompositionEngine/Android.bp
+++ b/services/surfaceflinger/CompositionEngine/Android.bp
@@ -17,6 +17,7 @@
         "librenderengine_deps",
         "libtimestats_deps",
         "surfaceflinger_defaults",
+        "libsurfaceflinger_proto_deps",
     ],
     cflags: [
         "-DLOG_TAG=\"CompositionEngine\"",
@@ -41,7 +42,6 @@
         "libutils",
     ],
     static_libs: [
-        "liblayers_proto",
         "libmath",
         "librenderengine",
         "libtimestats",
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 1d35730..f12d685 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -73,7 +73,7 @@
 #include <gui/Surface.h>
 #include <gui/SurfaceComposerClient.h>
 #include <hidl/ServiceManagement.h>
-#include <layerproto/LayerProtoParser.h>
+#include <layerproto/LayerProtoHeader.h>
 #include <linux/sched/types.h>
 #include <log/log.h>
 #include <private/android_filesystem_config.h>
diff --git a/services/surfaceflinger/layerproto/Android.bp b/services/surfaceflinger/layerproto/Android.bp
index f77b137..0a69a72 100644
--- a/services/surfaceflinger/layerproto/Android.bp
+++ b/services/surfaceflinger/layerproto/Android.bp
@@ -8,14 +8,9 @@
     default_team: "trendy_team_android_core_graphics_stack",
 }
 
-cc_library {
-    name: "liblayers_proto",
+cc_defaults {
+    name: "libsurfaceflinger_proto_deps",
     export_include_dirs: ["include"],
-
-    srcs: [
-        "LayerProtoParser.cpp",
-    ],
-
     static_libs: [
         "libperfetto_client_experimental",
     ],
@@ -31,24 +26,15 @@
     ],
 
     shared_libs: [
-        "android.hardware.graphics.common@1.1",
-        "libgui",
-        "libui",
         "libprotobuf-cpp-lite",
-        "libbase",
     ],
 
-    cppflags: [
-        "-Werror",
-        "-Wno-unused-parameter",
-        "-Wno-format",
-        "-Wno-c++98-compat-pedantic",
-        "-Wno-float-conversion",
-        "-Wno-disabled-macro-expansion",
-        "-Wno-float-equal",
-        "-Wno-sign-conversion",
-        "-Wno-padded",
-        "-Wno-old-style-cast",
-        "-Wno-undef",
+    header_libs: [
+        "libsurfaceflinger_proto_headers",
     ],
 }
+
+cc_library_headers {
+    name: "libsurfaceflinger_proto_headers",
+    export_include_dirs: ["include"],
+}
diff --git a/services/surfaceflinger/layerproto/LayerProtoParser.cpp b/services/surfaceflinger/layerproto/LayerProtoParser.cpp
deleted file mode 100644
index c3d0a40..0000000
--- a/services/surfaceflinger/layerproto/LayerProtoParser.cpp
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <android-base/stringprintf.h>
-#include <layerproto/LayerProtoParser.h>
-#include <ui/DebugUtils.h>
-
-using android::base::StringAppendF;
-using android::base::StringPrintf;
-
-namespace android {
-namespace surfaceflinger {
-
-bool sortLayers(LayerProtoParser::Layer* lhs, const LayerProtoParser::Layer* rhs) {
-    uint32_t ls = lhs->layerStack;
-    uint32_t rs = rhs->layerStack;
-    if (ls != rs) return ls < rs;
-
-    int32_t lz = lhs->z;
-    int32_t rz = rhs->z;
-    if (lz != rz) {
-        return lz < rz;
-    }
-
-    return lhs->id < rhs->id;
-}
-
-LayerProtoParser::LayerTree LayerProtoParser::generateLayerTree(
-        const perfetto::protos::LayersProto& layersProto) {
-    LayerTree layerTree;
-    layerTree.allLayers = generateLayerList(layersProto);
-
-    // find and sort the top-level layers
-    for (Layer& layer : layerTree.allLayers) {
-        if (layer.parent == nullptr) {
-            layerTree.topLevelLayers.push_back(&layer);
-        }
-    }
-    std::sort(layerTree.topLevelLayers.begin(), layerTree.topLevelLayers.end(), sortLayers);
-
-    return layerTree;
-}
-
-std::vector<LayerProtoParser::Layer> LayerProtoParser::generateLayerList(
-        const perfetto::protos::LayersProto& layersProto) {
-    std::vector<Layer> layerList;
-    std::unordered_map<int32_t, Layer*> layerMap;
-
-    // build the layer list and the layer map
-    layerList.reserve(layersProto.layers_size());
-    layerMap.reserve(layersProto.layers_size());
-    for (int i = 0; i < layersProto.layers_size(); i++) {
-        layerList.emplace_back(generateLayer(layersProto.layers(i)));
-        // this works because layerList never changes capacity
-        layerMap[layerList.back().id] = &layerList.back();
-    }
-
-    // fix up children and relatives
-    for (int i = 0; i < layersProto.layers_size(); i++) {
-        updateChildrenAndRelative(layersProto.layers(i), layerMap);
-    }
-
-    return layerList;
-}
-
-LayerProtoParser::Layer LayerProtoParser::generateLayer(
-        const perfetto::protos::LayerProto& layerProto) {
-    Layer layer;
-    layer.id = layerProto.id();
-    layer.name = layerProto.name();
-    layer.type = layerProto.type();
-    layer.transparentRegion = generateRegion(layerProto.transparent_region());
-    layer.visibleRegion = generateRegion(layerProto.visible_region());
-    layer.damageRegion = generateRegion(layerProto.damage_region());
-    layer.layerStack = layerProto.layer_stack();
-    layer.z = layerProto.z();
-    layer.position = {layerProto.position().x(), layerProto.position().y()};
-    layer.requestedPosition = {layerProto.requested_position().x(),
-                                layerProto.requested_position().y()};
-    layer.size = {layerProto.size().w(), layerProto.size().h()};
-    layer.crop = generateRect(layerProto.crop());
-    layer.isOpaque = layerProto.is_opaque();
-    layer.invalidate = layerProto.invalidate();
-    layer.dataspace = layerProto.dataspace();
-    layer.pixelFormat = layerProto.pixel_format();
-    layer.color = {layerProto.color().r(), layerProto.color().g(), layerProto.color().b(),
-                    layerProto.color().a()};
-    layer.requestedColor = {layerProto.requested_color().r(), layerProto.requested_color().g(),
-                             layerProto.requested_color().b(), layerProto.requested_color().a()};
-    layer.flags = layerProto.flags();
-    layer.transform = generateTransform(layerProto.transform());
-    layer.requestedTransform = generateTransform(layerProto.requested_transform());
-    layer.activeBuffer = generateActiveBuffer(layerProto.active_buffer());
-    layer.bufferTransform = generateTransform(layerProto.buffer_transform());
-    layer.queuedFrames = layerProto.queued_frames();
-    layer.refreshPending = layerProto.refresh_pending();
-    layer.isProtected = layerProto.is_protected();
-    layer.isTrustedOverlay = layerProto.is_trusted_overlay();
-    layer.cornerRadius = layerProto.corner_radius();
-    layer.backgroundBlurRadius = layerProto.background_blur_radius();
-    for (const auto& entry : layerProto.metadata()) {
-        const std::string& dataStr = entry.second;
-        std::vector<uint8_t>& outData = layer.metadata.mMap[entry.first];
-        outData.resize(dataStr.size());
-        memcpy(outData.data(), dataStr.data(), dataStr.size());
-    }
-    layer.cornerRadiusCrop = generateFloatRect(layerProto.corner_radius_crop());
-    layer.shadowRadius = layerProto.shadow_radius();
-    layer.ownerUid = layerProto.owner_uid();
-    return layer;
-}
-
-LayerProtoParser::Region LayerProtoParser::generateRegion(
-        const perfetto::protos::RegionProto& regionProto) {
-    LayerProtoParser::Region region;
-    for (int i = 0; i < regionProto.rect_size(); i++) {
-        const perfetto::protos::RectProto& rectProto = regionProto.rect(i);
-        region.rects.push_back(generateRect(rectProto));
-    }
-
-    return region;
-}
-
-LayerProtoParser::Rect LayerProtoParser::generateRect(
-        const perfetto::protos::RectProto& rectProto) {
-    LayerProtoParser::Rect rect;
-    rect.left = rectProto.left();
-    rect.top = rectProto.top();
-    rect.right = rectProto.right();
-    rect.bottom = rectProto.bottom();
-
-    return rect;
-}
-
-LayerProtoParser::FloatRect LayerProtoParser::generateFloatRect(
-        const perfetto::protos::FloatRectProto& rectProto) {
-    LayerProtoParser::FloatRect rect;
-    rect.left = rectProto.left();
-    rect.top = rectProto.top();
-    rect.right = rectProto.right();
-    rect.bottom = rectProto.bottom();
-
-    return rect;
-}
-
-LayerProtoParser::Transform LayerProtoParser::generateTransform(
-        const perfetto::protos::TransformProto& transformProto) {
-    LayerProtoParser::Transform transform;
-    transform.dsdx = transformProto.dsdx();
-    transform.dtdx = transformProto.dtdx();
-    transform.dsdy = transformProto.dsdy();
-    transform.dtdy = transformProto.dtdy();
-
-    return transform;
-}
-
-LayerProtoParser::ActiveBuffer LayerProtoParser::generateActiveBuffer(
-        const perfetto::protos::ActiveBufferProto& activeBufferProto) {
-    LayerProtoParser::ActiveBuffer activeBuffer;
-    activeBuffer.width = activeBufferProto.width();
-    activeBuffer.height = activeBufferProto.height();
-    activeBuffer.stride = activeBufferProto.stride();
-    activeBuffer.format = activeBufferProto.format();
-
-    return activeBuffer;
-}
-
-void LayerProtoParser::updateChildrenAndRelative(const perfetto::protos::LayerProto& layerProto,
-                                                 std::unordered_map<int32_t, Layer*>& layerMap) {
-    auto currLayer = layerMap[layerProto.id()];
-
-    for (int i = 0; i < layerProto.children_size(); i++) {
-        if (layerMap.count(layerProto.children(i)) > 0) {
-            currLayer->children.push_back(layerMap[layerProto.children(i)]);
-        }
-    }
-
-    for (int i = 0; i < layerProto.relatives_size(); i++) {
-        if (layerMap.count(layerProto.relatives(i)) > 0) {
-            currLayer->relatives.push_back(layerMap[layerProto.relatives(i)]);
-        }
-    }
-
-    if (layerProto.has_parent()) {
-        if (layerMap.count(layerProto.parent()) > 0) {
-            currLayer->parent = layerMap[layerProto.parent()];
-        }
-    }
-
-    if (layerProto.has_z_order_relative_of()) {
-        if (layerMap.count(layerProto.z_order_relative_of()) > 0) {
-            currLayer->zOrderRelativeOf = layerMap[layerProto.z_order_relative_of()];
-        }
-    }
-}
-
-std::string LayerProtoParser::layerTreeToString(const LayerTree& layerTree) {
-    std::string result;
-    for (const LayerProtoParser::Layer* layer : layerTree.topLevelLayers) {
-        if (layer->zOrderRelativeOf != nullptr) {
-            continue;
-        }
-        result.append(layerToString(layer));
-    }
-
-    return result;
-}
-
-std::string LayerProtoParser::layerToString(const LayerProtoParser::Layer* layer) {
-    std::string result;
-
-    std::vector<Layer*> traverse(layer->relatives);
-    for (LayerProtoParser::Layer* child : layer->children) {
-        if (child->zOrderRelativeOf != nullptr) {
-            continue;
-        }
-
-        traverse.push_back(child);
-    }
-
-    std::sort(traverse.begin(), traverse.end(), sortLayers);
-
-    size_t i = 0;
-    for (; i < traverse.size(); i++) {
-        auto& relative = traverse[i];
-        if (relative->z >= 0) {
-            break;
-        }
-        result.append(layerToString(relative));
-    }
-    result.append(layer->to_string());
-    result.append("\n");
-    for (; i < traverse.size(); i++) {
-        auto& relative = traverse[i];
-        result.append(layerToString(relative));
-    }
-
-    return result;
-}
-
-std::string LayerProtoParser::ActiveBuffer::to_string() const {
-    return StringPrintf("[%4ux%4u:%4u,%s]", width, height, stride,
-                        decodePixelFormat(format).c_str());
-}
-
-std::string LayerProtoParser::Transform::to_string() const {
-    return StringPrintf("[%.2f, %.2f][%.2f, %.2f]", static_cast<double>(dsdx),
-                        static_cast<double>(dtdx), static_cast<double>(dsdy),
-                        static_cast<double>(dtdy));
-}
-
-std::string LayerProtoParser::Rect::to_string() const {
-    return StringPrintf("[%3d, %3d, %3d, %3d]", left, top, right, bottom);
-}
-
-std::string LayerProtoParser::FloatRect::to_string() const {
-    return StringPrintf("[%.2f, %.2f, %.2f, %.2f]", left, top, right, bottom);
-}
-
-std::string LayerProtoParser::Region::to_string(const char* what) const {
-    std::string result =
-            StringPrintf("  Region %s (this=%lx count=%d)\n", what, static_cast<unsigned long>(id),
-                         static_cast<int>(rects.size()));
-
-    for (auto& rect : rects) {
-        StringAppendF(&result, "    %s\n", rect.to_string().c_str());
-    }
-
-    return result;
-}
-
-std::string LayerProtoParser::Layer::to_string() const {
-    std::string result;
-    StringAppendF(&result, "+ %s (%s) uid=%d\n", type.c_str(), name.c_str(), ownerUid);
-    result.append(transparentRegion.to_string("TransparentRegion").c_str());
-    result.append(visibleRegion.to_string("VisibleRegion").c_str());
-    result.append(damageRegion.to_string("SurfaceDamageRegion").c_str());
-
-    StringAppendF(&result, "      layerStack=%4d, z=%9d, pos=(%g,%g), size=(%4d,%4d), ", layerStack,
-                  z, static_cast<double>(position.x), static_cast<double>(position.y), size.x,
-                  size.y);
-
-    StringAppendF(&result, "crop=%s, ", crop.to_string().c_str());
-    StringAppendF(&result, "cornerRadius=%f, ", cornerRadius);
-    StringAppendF(&result, "isProtected=%1d, ", isProtected);
-    StringAppendF(&result, "isTrustedOverlay=%1d, ", isTrustedOverlay);
-    StringAppendF(&result, "isOpaque=%1d, invalidate=%1d, ", isOpaque, invalidate);
-    StringAppendF(&result, "dataspace=%s, ", dataspace.c_str());
-    StringAppendF(&result, "defaultPixelFormat=%s, ", pixelFormat.c_str());
-    StringAppendF(&result, "backgroundBlurRadius=%1d, ", backgroundBlurRadius);
-    StringAppendF(&result, "color=(%.3f,%.3f,%.3f,%.3f), flags=0x%08x, ",
-                  static_cast<double>(color.r), static_cast<double>(color.g),
-                  static_cast<double>(color.b), static_cast<double>(color.a), flags);
-    StringAppendF(&result, "tr=%s", transform.to_string().c_str());
-    result.append("\n");
-    StringAppendF(&result, "      parent=%s\n", parent == nullptr ? "none" : parent->name.c_str());
-    StringAppendF(&result, "      zOrderRelativeOf=%s\n",
-                  zOrderRelativeOf == nullptr ? "none" : zOrderRelativeOf->name.c_str());
-    StringAppendF(&result, "      activeBuffer=%s,", activeBuffer.to_string().c_str());
-    StringAppendF(&result, " tr=%s", bufferTransform.to_string().c_str());
-    StringAppendF(&result, " queued-frames=%d", queuedFrames);
-    StringAppendF(&result, " metadata={");
-    bool first = true;
-    for (const auto& entry : metadata.mMap) {
-        if (!first) result.append(", ");
-        first = false;
-        result.append(metadata.itemToString(entry.first, ":"));
-    }
-    result.append("},");
-    StringAppendF(&result, " cornerRadiusCrop=%s, ", cornerRadiusCrop.to_string().c_str());
-    StringAppendF(&result, " shadowRadius=%.3f, ", shadowRadius);
-    return result;
-}
-
-} // namespace surfaceflinger
-} // namespace android
diff --git a/services/surfaceflinger/layerproto/include/layerproto/LayerProtoParser.h b/services/surfaceflinger/layerproto/include/layerproto/LayerProtoParser.h
deleted file mode 100644
index 79c3982..0000000
--- a/services/surfaceflinger/layerproto/include/layerproto/LayerProtoParser.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <layerproto/LayerProtoHeader.h>
-
-#include <gui/LayerMetadata.h>
-#include <math/vec4.h>
-
-#include <memory>
-#include <unordered_map>
-#include <vector>
-
-using android::gui::LayerMetadata;
-
-namespace android {
-namespace surfaceflinger {
-
-class LayerProtoParser {
-public:
-    class ActiveBuffer {
-    public:
-        uint32_t width;
-        uint32_t height;
-        uint32_t stride;
-        int32_t format;
-
-        std::string to_string() const;
-    };
-
-    class Transform {
-    public:
-        float dsdx;
-        float dtdx;
-        float dsdy;
-        float dtdy;
-
-        std::string to_string() const;
-    };
-
-    class Rect {
-    public:
-        int32_t left;
-        int32_t top;
-        int32_t right;
-        int32_t bottom;
-
-        std::string to_string() const;
-    };
-
-    class FloatRect {
-    public:
-        float left;
-        float top;
-        float right;
-        float bottom;
-
-        std::string to_string() const;
-    };
-
-    class Region {
-    public:
-        uint64_t id;
-        std::vector<Rect> rects;
-
-        std::string to_string(const char* what) const;
-    };
-
-    class Layer {
-    public:
-        int32_t id;
-        std::string name;
-        std::vector<Layer*> children;
-        std::vector<Layer*> relatives;
-        std::string type;
-        LayerProtoParser::Region transparentRegion;
-        LayerProtoParser::Region visibleRegion;
-        LayerProtoParser::Region damageRegion;
-        uint32_t layerStack;
-        int32_t z;
-        float2 position;
-        float2 requestedPosition;
-        int2 size;
-        LayerProtoParser::Rect crop;
-        bool isOpaque;
-        bool invalidate;
-        std::string dataspace;
-        std::string pixelFormat;
-        half4 color;
-        half4 requestedColor;
-        uint32_t flags;
-        Transform transform;
-        Transform requestedTransform;
-        Layer* parent = 0;
-        Layer* zOrderRelativeOf = 0;
-        LayerProtoParser::ActiveBuffer activeBuffer;
-        Transform bufferTransform;
-        int32_t queuedFrames;
-        bool refreshPending;
-        bool isProtected;
-        bool isTrustedOverlay;
-        float cornerRadius;
-        int backgroundBlurRadius;
-        LayerMetadata metadata;
-        LayerProtoParser::FloatRect cornerRadiusCrop;
-        float shadowRadius;
-        uid_t ownerUid;
-
-        std::string to_string() const;
-    };
-
-    class LayerTree {
-    public:
-        // all layers in LayersProto and in the original order
-        std::vector<Layer> allLayers;
-
-        // pointers to top-level layers in allLayers
-        std::vector<Layer*> topLevelLayers;
-    };
-
-    static LayerTree generateLayerTree(const perfetto::protos::LayersProto& layersProto);
-    static std::string layerTreeToString(const LayerTree& layerTree);
-
-private:
-    static std::vector<Layer> generateLayerList(const perfetto::protos::LayersProto& layersProto);
-    static LayerProtoParser::Layer generateLayer(const perfetto::protos::LayerProto& layerProto);
-    static LayerProtoParser::Region generateRegion(
-            const perfetto::protos::RegionProto& regionProto);
-    static LayerProtoParser::Rect generateRect(const perfetto::protos::RectProto& rectProto);
-    static LayerProtoParser::FloatRect generateFloatRect(
-            const perfetto::protos::FloatRectProto& rectProto);
-    static LayerProtoParser::Transform generateTransform(
-            const perfetto::protos::TransformProto& transformProto);
-    static LayerProtoParser::ActiveBuffer generateActiveBuffer(
-            const perfetto::protos::ActiveBufferProto& activeBufferProto);
-    static void updateChildrenAndRelative(const perfetto::protos::LayerProto& layerProto,
-                                          std::unordered_map<int32_t, Layer*>& layerMap);
-
-    static std::string layerToString(const LayerProtoParser::Layer* layer);
-};
-
-} // namespace surfaceflinger
-} // namespace android
diff --git a/services/surfaceflinger/tests/Android.bp b/services/surfaceflinger/tests/Android.bp
index 38fc977..4d5c0fd 100644
--- a/services/surfaceflinger/tests/Android.bp
+++ b/services/surfaceflinger/tests/Android.bp
@@ -28,6 +28,7 @@
         "android.hardware.graphics.common-ndk_shared",
         "surfaceflinger_defaults",
         "libsurfaceflinger_common_test_deps",
+        "libsurfaceflinger_proto_deps",
     ],
     test_suites: ["device-tests"],
     srcs: [
@@ -58,14 +59,12 @@
         "ScreenCapture_test.cpp",
         "SetFrameRate_test.cpp",
         "SetGeometry_test.cpp",
-        "Stress_test.cpp",
         "TextureFiltering_test.cpp",
         "VirtualDisplay_test.cpp",
         "WindowInfosListener_test.cpp",
     ],
     data: ["SurfaceFlinger_test.filter"],
     static_libs: [
-        "liblayers_proto",
         "android.hardware.graphics.composer@2.1",
         "libsurfaceflinger_common",
     ],
@@ -121,7 +120,6 @@
         "libEGL",
         "libGLESv2",
         "libgui",
-        "liblayers_proto",
         "liblog",
         "libprotobuf-cpp-full",
         "libui",
diff --git a/services/surfaceflinger/tests/Stress_test.cpp b/services/surfaceflinger/tests/Stress_test.cpp
deleted file mode 100644
index b30df5e..0000000
--- a/services/surfaceflinger/tests/Stress_test.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// TODO(b/129481165): remove the #pragma below and fix conversion issues
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wconversion"
-
-#include <gtest/gtest.h>
-
-#include <gui/SurfaceComposerClient.h>
-
-#include <utils/String8.h>
-
-#include <thread>
-#include <functional>
-#include <layerproto/LayerProtoParser.h>
-
-namespace android {
-
-TEST(SurfaceFlingerStress, create_and_destroy) {
-    auto do_stress = []() {
-        sp<SurfaceComposerClient> client = sp<SurfaceComposerClient>::make();
-        ASSERT_EQ(NO_ERROR, client->initCheck());
-        for (int j = 0; j < 1000; j++) {
-            auto surf = client->createSurface(String8("t"), 100, 100,
-                    PIXEL_FORMAT_RGBA_8888, 0);
-            ASSERT_TRUE(surf != nullptr);
-            surf.clear();
-        }
-    };
-
-    std::vector<std::thread> threads;
-    for (int i = 0; i < 10; i++) {
-        threads.push_back(std::thread(do_stress));
-    }
-    for (auto& thread : threads) {
-        thread.join();
-    }
-}
-
-perfetto::protos::LayersProto generateLayerProto() {
-    perfetto::protos::LayersProto layersProto;
-    std::array<perfetto::protos::LayerProto*, 10> layers = {};
-    for (size_t i = 0; i < layers.size(); ++i) {
-        layers[i] = layersProto.add_layers();
-        layers[i]->set_id(i);
-    }
-
-    layers[0]->add_children(1);
-    layers[1]->set_parent(0);
-    layers[0]->add_children(2);
-    layers[2]->set_parent(0);
-    layers[0]->add_children(3);
-    layers[3]->set_parent(0);
-    layers[2]->add_children(4);
-    layers[4]->set_parent(2);
-    layers[3]->add_children(5);
-    layers[5]->set_parent(3);
-    layers[5]->add_children(6);
-    layers[6]->set_parent(5);
-    layers[5]->add_children(7);
-    layers[7]->set_parent(5);
-    layers[6]->add_children(8);
-    layers[8]->set_parent(6);
-
-    layers[4]->set_z_order_relative_of(3);
-    layers[3]->add_relatives(4);
-    layers[8]->set_z_order_relative_of(9);
-    layers[9]->add_relatives(8);
-    layers[3]->set_z_order_relative_of(1);
-    layers[1]->add_relatives(3);
-
-/* ----------------------------
- *       - 0 -      - 9 -
- *      /  |  \
- *     1   2   3(1)
- *         |    |
- *         4(3) 5
- *             / \
- *            6   7
- *            |
- *            8(9)
- * -------------------------- */
-
-    return layersProto;
-}
-
-TEST(LayerProtoStress, mem_info) {
-    std::string cmd = "dumpsys meminfo ";
-    cmd += std::to_string(getpid());
-    system(cmd.c_str());
-    for (int i = 0; i < 100000; i++) {
-        perfetto::protos::LayersProto layersProto = generateLayerProto();
-        auto layerTree = surfaceflinger::LayerProtoParser::generateLayerTree(layersProto);
-        surfaceflinger::LayerProtoParser::layerTreeToString(layerTree);
-    }
-    system(cmd.c_str());
-}
-
-}
-
-// TODO(b/129481165): remove the #pragma below and fix conversion issues
-#pragma clang diagnostic pop // ignored "-Wconversion"
diff --git a/services/surfaceflinger/tests/unittests/Android.bp b/services/surfaceflinger/tests/unittests/Android.bp
index 9ebef8c..215f49d 100644
--- a/services/surfaceflinger/tests/unittests/Android.bp
+++ b/services/surfaceflinger/tests/unittests/Android.bp
@@ -153,6 +153,7 @@
         "android.hardware.power-ndk_static",
         "librenderengine_deps",
         "libsurfaceflinger_common_test_deps",
+        "libsurfaceflinger_proto_deps",
     ],
     static_libs: [
         "android.hardware.common-V2-ndk",
@@ -171,7 +172,6 @@
         "libframetimeline",
         "libgmock",
         "libgui_mocks",
-        "liblayers_proto",
         "libperfetto_client_experimental",
         "librenderengine",
         "librenderengine_mocks",
diff --git a/services/surfaceflinger/tests/utils/ColorUtils.h b/services/surfaceflinger/tests/utils/ColorUtils.h
index 07916b6..253bad7 100644
--- a/services/surfaceflinger/tests/utils/ColorUtils.h
+++ b/services/surfaceflinger/tests/utils/ColorUtils.h
@@ -74,8 +74,8 @@
     static void applyMatrix(half3& color, const mat3& mat) {
         half3 ret = half3(0);
 
-        for (int i = 0; i < 3; i++) {
-            for (int j = 0; j < 3; j++) {
+        for (size_t i = 0; i < 3; i++) {
+            for (size_t j = 0; j < 3; j++) {
                 ret[i] = ret[i] + color[j] * mat[j][i];
             }
         }