Merge "Remove dead code"
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index e03f5fa..0872032 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -907,10 +907,6 @@
                 animator.getAnimatorNativePtr());
     }
 
-    public void serializeDisplayListTree() {
-        nSerializeDisplayListTree(mNativeProxy);
-    }
-
     public static int copySurfaceInto(Surface surface, Rect srcRect, Bitmap bitmap) {
         if (srcRect == null) {
             // Empty rect means entire surface
@@ -1202,8 +1198,6 @@
     private static native void nStopDrawing(long nativeProxy);
     private static native void nNotifyFramePending(long nativeProxy);
 
-    private static native void nSerializeDisplayListTree(long nativeProxy);
-
     private static native void nDumpProfileInfo(long nativeProxy, FileDescriptor fd,
             @DumpFlags int dumpFlags);
 
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 9231277..70054717 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -2961,9 +2961,6 @@
      */
     void outputDisplayList(View view) {
         view.mRenderNode.output();
-        if (mAttachInfo.mThreadedRenderer != null) {
-            mAttachInfo.mThreadedRenderer.serializeDisplayListTree();
-        }
     }
 
     /**
diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp
index 7481f1c..a73939c 100644
--- a/core/jni/android_view_ThreadedRenderer.cpp
+++ b/core/jni/android_view_ThreadedRenderer.cpp
@@ -813,12 +813,6 @@
     proxy->notifyFramePending();
 }
 
-static void android_view_ThreadedRenderer_serializeDisplayListTree(JNIEnv* env, jobject clazz,
-        jlong proxyPtr) {
-    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
-    proxy->serializeDisplayListTree();
-}
-
 static void android_view_ThreadedRenderer_dumpProfileInfo(JNIEnv* env, jobject clazz,
         jlong proxyPtr, jobject javaFileDescriptor, jint dumpFlags) {
     RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
@@ -1081,7 +1075,6 @@
     { "nFence", "(J)V", (void*) android_view_ThreadedRenderer_fence },
     { "nStopDrawing", "(J)V", (void*) android_view_ThreadedRenderer_stopDrawing },
     { "nNotifyFramePending", "(J)V", (void*) android_view_ThreadedRenderer_notifyFramePending },
-    { "nSerializeDisplayListTree", "(J)V", (void*) android_view_ThreadedRenderer_serializeDisplayListTree },
     { "nDumpProfileInfo", "(JLjava/io/FileDescriptor;I)V", (void*) android_view_ThreadedRenderer_dumpProfileInfo },
     { "setupShadersDiskCache", "(Ljava/lang/String;Ljava/lang/String;)V",
                 (void*) android_view_ThreadedRenderer_setupShadersDiskCache },
diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp
index 592a6e6..de4eaf5 100644
--- a/libs/hwui/Android.bp
+++ b/libs/hwui/Android.bp
@@ -269,13 +269,8 @@
         "TextureCache.cpp",
         "VectorDrawable.cpp",
         "VkLayer.cpp",
-        "protos/hwui.proto",
     ],
 
-    proto: {
-        export_proto_headers: true,
-    },
-
     export_include_dirs: ["."],
     export_shared_lib_headers: ["libRScpp"],
 }
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index d93a757..5ac330b 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -29,9 +29,6 @@
 #include "utils/StringUtils.h"
 #include "utils/TraceUtils.h"
 
-#include "protos/ProtoHelpers.h"
-#include "protos/hwui.pb.h"
-
 #include <SkPathOps.h>
 #include <algorithm>
 #include <sstream>
@@ -101,77 +98,6 @@
     output << std::endl;
 }
 
-void RenderNode::copyTo(proto::RenderNode* pnode) {
-    pnode->set_id(static_cast<uint64_t>(reinterpret_cast<uintptr_t>(this)));
-    pnode->set_name(mName.string(), mName.length());
-
-    proto::RenderProperties* pprops = pnode->mutable_properties();
-    pprops->set_left(properties().getLeft());
-    pprops->set_top(properties().getTop());
-    pprops->set_right(properties().getRight());
-    pprops->set_bottom(properties().getBottom());
-    pprops->set_clip_flags(properties().getClippingFlags());
-    pprops->set_alpha(properties().getAlpha());
-    pprops->set_translation_x(properties().getTranslationX());
-    pprops->set_translation_y(properties().getTranslationY());
-    pprops->set_translation_z(properties().getTranslationZ());
-    pprops->set_elevation(properties().getElevation());
-    pprops->set_rotation(properties().getRotation());
-    pprops->set_rotation_x(properties().getRotationX());
-    pprops->set_rotation_y(properties().getRotationY());
-    pprops->set_scale_x(properties().getScaleX());
-    pprops->set_scale_y(properties().getScaleY());
-    pprops->set_pivot_x(properties().getPivotX());
-    pprops->set_pivot_y(properties().getPivotY());
-    pprops->set_has_overlapping_rendering(properties().getHasOverlappingRendering());
-    pprops->set_pivot_explicitly_set(properties().isPivotExplicitlySet());
-    pprops->set_project_backwards(properties().getProjectBackwards());
-    pprops->set_projection_receiver(properties().isProjectionReceiver());
-    set(pprops->mutable_clip_bounds(), properties().getClipBounds());
-
-    const Outline& outline = properties().getOutline();
-    if (outline.getType() != Outline::Type::None) {
-        proto::Outline* poutline = pprops->mutable_outline();
-        poutline->clear_path();
-        if (outline.getType() == Outline::Type::Empty) {
-            poutline->set_type(proto::Outline_Type_Empty);
-        } else if (outline.getType() == Outline::Type::ConvexPath) {
-            poutline->set_type(proto::Outline_Type_ConvexPath);
-            if (const SkPath* path = outline.getPath()) {
-                set(poutline->mutable_path(), *path);
-            }
-        } else if (outline.getType() == Outline::Type::RoundRect) {
-            poutline->set_type(proto::Outline_Type_RoundRect);
-        } else {
-            ALOGW("Uknown outline type! %d", static_cast<int>(outline.getType()));
-            poutline->set_type(proto::Outline_Type_None);
-        }
-        poutline->set_should_clip(outline.getShouldClip());
-        poutline->set_alpha(outline.getAlpha());
-        poutline->set_radius(outline.getRadius());
-        set(poutline->mutable_bounds(), outline.getBounds());
-    } else {
-        pprops->clear_outline();
-    }
-
-    const RevealClip& revealClip = properties().getRevealClip();
-    if (revealClip.willClip()) {
-        proto::RevealClip* prevealClip = pprops->mutable_reveal_clip();
-        prevealClip->set_x(revealClip.getX());
-        prevealClip->set_y(revealClip.getY());
-        prevealClip->set_radius(revealClip.getRadius());
-    } else {
-        pprops->clear_reveal_clip();
-    }
-
-    pnode->clear_children();
-    if (mDisplayList) {
-        for (auto&& child : mDisplayList->getChildren()) {
-            child->renderNode->copyTo(pnode->add_children());
-        }
-    }
-}
-
 int RenderNode::getDebugSize() {
     int size = sizeof(RenderNode);
     if (mStagingDisplayList) {
diff --git a/libs/hwui/RenderNode.h b/libs/hwui/RenderNode.h
index 1469a15..1e0d4e2 100644
--- a/libs/hwui/RenderNode.h
+++ b/libs/hwui/RenderNode.h
@@ -108,7 +108,6 @@
 
     ANDROID_API void output();
     ANDROID_API int getDebugSize();
-    void copyTo(proto::RenderNode* node);
 
     bool isRenderable() const { return mDisplayList && !mDisplayList->isEmpty(); }
 
diff --git a/libs/hwui/protos/ProtoHelpers.h b/libs/hwui/protos/ProtoHelpers.h
deleted file mode 100644
index 833c77f..0000000
--- a/libs/hwui/protos/ProtoHelpers.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-#ifndef PROTOHELPERS_H
-#define PROTOHELPERS_H
-
-#include "Rect.h"
-#include "protos/hwui.pb.h"
-
-namespace android {
-namespace uirenderer {
-
-void set(proto::RectF* dest, const Rect& src) {
-    dest->set_left(src.left);
-    dest->set_top(src.top);
-    dest->set_right(src.right);
-    dest->set_bottom(src.bottom);
-}
-
-void set(std::string* dest, const SkPath& src) {
-    size_t size = src.writeToMemory(nullptr);
-    dest->resize(size);
-    src.writeToMemory(&*dest->begin());
-}
-
-}  // namespace uirenderer
-}  // namespace android
-
-#endif  // PROTOHELPERS_H
diff --git a/libs/hwui/protos/hwui.proto b/libs/hwui/protos/hwui.proto
deleted file mode 100644
index dcff80a..0000000
--- a/libs/hwui/protos/hwui.proto
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-syntax = "proto2";
-
-package android.uirenderer.proto;
-
-option optimize_for = LITE_RUNTIME;
-
-message RenderNode {
-    required uint64 id = 1;
-    required string name = 2;
-    required RenderProperties properties = 3;
-    optional DisplayList display_list = 4;
-    repeated RenderNode children = 5;
-};
-
-message RenderProperties {
-    required int32 left = 1;
-    required int32 right = 2;
-    required int32 top = 3;
-    required int32 bottom = 4;
-    required int32 clip_flags = 5;
-    required float alpha = 6;
-    required float translation_x = 7;
-    required float translation_y = 8;
-    required float translation_z = 9;
-    required float elevation = 10;
-    required float rotation = 11;
-    required float rotation_x = 12;
-    required float rotation_y = 13;
-    required float scale_x = 14;
-    required float scale_y = 15;
-    required float pivot_x = 16;
-    required float pivot_y = 17;
-    required bool has_overlapping_rendering = 18;
-    required bool pivot_explicitly_set = 19;
-    required bool project_backwards = 20;
-    required bool projection_receiver = 21;
-    required RectF clip_bounds = 22;
-    optional Outline outline = 23;
-    optional RevealClip reveal_clip = 24;
-};
-
-message RectF {
-    required float left = 1;
-    required float right = 2;
-    required float top = 3;
-    required float bottom = 4;
-}
-
-message Outline {
-    required bool should_clip = 1;
-    enum Type {
-        None = 0;
-        Empty = 1;
-        ConvexPath = 2;
-        RoundRect = 3;
-    }
-    required Type type = 2;
-    required RectF bounds = 3;
-    required float radius = 4;
-    required float alpha = 5;
-    optional bytes path = 6;
-}
-
-message RevealClip {
-    required float x = 1;
-    required float y = 2;
-    required float radius = 3;
-}
-
-message DisplayList {
-    optional int32 projection_receive_index = 1;
-    repeated DrawOp draw_ops = 2;
-}
-
-message DrawOp {
-    oneof drawop {
-        DrawOp_RenderNode render_node = 1;
-    }
-}
-
-message DrawOp_RenderNode {
-    optional RenderNode node = 1;
-}
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 609d26c..d983200 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -30,14 +30,12 @@
 #include "pipeline/skia/SkiaOpenGLPipeline.h"
 #include "pipeline/skia/SkiaPipeline.h"
 #include "pipeline/skia/SkiaVulkanPipeline.h"
-#include "protos/hwui.pb.h"
 #include "renderstate/RenderState.h"
 #include "renderstate/Stencil.h"
 #include "utils/GLUtils.h"
 #include "utils/TimeUtils.h"
 
 #include <cutils/properties.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
 #include <private/hwui/DrawGlInfo.h>
 #include <strings.h>
 
@@ -50,8 +48,6 @@
 #define TRIM_MEMORY_COMPLETE 80
 #define TRIM_MEMORY_UI_HIDDEN 20
 
-#define ENABLE_RENDERNODE_SERIALIZATION false
-
 #define LOG_FRAMETIME_MMA 0
 
 #if LOG_FRAMETIME_MMA
@@ -637,39 +633,6 @@
     mJankTracker.setDescription(JankTrackerType::Window, std::move(name));
 }
 
-void CanvasContext::serializeDisplayListTree() {
-#if ENABLE_RENDERNODE_SERIALIZATION
-    using namespace google::protobuf::io;
-    char package[128];
-    // Check whether tracing is enabled for this process.
-    FILE* file = fopen("/proc/self/cmdline", "r");
-    if (file) {
-        if (!fgets(package, 128, file)) {
-            ALOGE("Error reading cmdline: %s (%d)", strerror(errno), errno);
-            fclose(file);
-            return;
-        }
-        fclose(file);
-    } else {
-        ALOGE("Error opening /proc/self/cmdline: %s (%d)", strerror(errno), errno);
-        return;
-    }
-    char path[1024];
-    snprintf(path, 1024, "/data/data/%s/cache/rendertree_dump", package);
-    int fd = open(path, O_CREAT | O_WRONLY, S_IRWXU | S_IRGRP | S_IROTH);
-    if (fd == -1) {
-        ALOGD("Failed to open '%s'", path);
-        return;
-    }
-    proto::RenderNode tree;
-    // TODO: Streaming writes?
-    mRootRenderNode->copyTo(&tree);
-    std::string data = tree.SerializeAsString();
-    write(fd, data.c_str(), data.length());
-    close(fd);
-#endif
-}
-
 void CanvasContext::waitOnFences() {
     if (mFrameFences.size()) {
         ATRACE_CALL();
diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h
index 8aaa8c1..930498af3 100644
--- a/libs/hwui/renderthread/CanvasContext.h
+++ b/libs/hwui/renderthread/CanvasContext.h
@@ -155,8 +155,6 @@
 
     void setName(const std::string&& name);
 
-    void serializeDisplayListTree();
-
     void addRenderNode(RenderNode* node, bool placeFront);
     void removeRenderNode(RenderNode* node);
 
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index 00645d6..a1a2bad 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -274,10 +274,6 @@
     mDrawFrameTask.setFrameCallback(std::move(callback));
 }
 
-void RenderProxy::serializeDisplayListTree() {
-    mRenderThread.queue().post([=]() { mContext->serializeDisplayListTree(); });
-}
-
 void RenderProxy::addFrameMetricsObserver(FrameMetricsObserver* observerPtr) {
     mRenderThread.queue().post([ this, observer = sp{observerPtr} ]() {
         mContext->addFrameMetricsObserver(observer.get());
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index bd5c9a9..ca20755 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -109,8 +109,6 @@
     ANDROID_API static void setProcessStatsBuffer(int fd);
     ANDROID_API int getRenderThreadTid();
 
-    ANDROID_API void serializeDisplayListTree();
-
     ANDROID_API void addRenderNode(RenderNode* node, bool placeFront);
     ANDROID_API void removeRenderNode(RenderNode* node);
     ANDROID_API void drawRenderNode(RenderNode* node);
diff --git a/libs/hwui/tests/macrobench/main.cpp b/libs/hwui/tests/macrobench/main.cpp
index 4cb5cfd..072719b 100644
--- a/libs/hwui/tests/macrobench/main.cpp
+++ b/libs/hwui/tests/macrobench/main.cpp
@@ -19,7 +19,6 @@
 
 #include "Properties.h"
 #include "hwui/Typeface.h"
-#include "protos/hwui.pb.h"
 
 #include <benchmark/benchmark.h>
 #include <getopt.h>