Remove DisplayList's dependency on SkAutoTMalloc (#38359)

SkAutoTMalloc is not a public Skia API
diff --git a/display_list/display_list.cc b/display_list/display_list.cc
index d808f20..9268ed3 100644
--- a/display_list/display_list.cc
+++ b/display_list/display_list.cc
@@ -25,7 +25,7 @@
       bounds_({0, 0, 0, 0}),
       can_apply_group_opacity_(true) {}
 
-DisplayList::DisplayList(uint8_t* ptr,
+DisplayList::DisplayList(DisplayListStorage&& storage,
                          size_t byte_count,
                          unsigned int op_count,
                          size_t nested_byte_count,
@@ -33,7 +33,7 @@
                          const SkRect& bounds,
                          bool can_apply_group_opacity,
                          sk_sp<const DlRTree> rtree)
-    : storage_(ptr),
+    : storage_(std::move(storage)),
       byte_count_(byte_count),
       op_count_(op_count),
       nested_byte_count_(nested_byte_count),
diff --git a/display_list/display_list.h b/display_list/display_list.h
index 87c67d9..a20f93f 100644
--- a/display_list/display_list.h
+++ b/display_list/display_list.h
@@ -215,6 +215,26 @@
   };
 };
 
+// Manages a buffer allocated with malloc.
+class DisplayListStorage {
+ public:
+  DisplayListStorage() = default;
+  DisplayListStorage(DisplayListStorage&&) = default;
+
+  uint8_t* get() const { return ptr_.get(); }
+
+  void realloc(size_t count) {
+    ptr_.reset(static_cast<uint8_t*>(std::realloc(ptr_.release(), count)));
+    FML_CHECK(ptr_);
+  }
+
+ private:
+  struct FreeDeleter {
+    void operator()(uint8_t* p) { std::free(p); }
+  };
+  std::unique_ptr<uint8_t, FreeDeleter> ptr_;
+};
+
 // The base class that contains a sequence of rendering operations
 // for dispatch to a Dispatcher. These objects must be instantiated
 // through an instance of DisplayListBuilder::build().
@@ -263,7 +283,7 @@
   static void DisposeOps(uint8_t* ptr, uint8_t* end);
 
  private:
-  DisplayList(uint8_t* ptr,
+  DisplayList(DisplayListStorage&& ptr,
               size_t byte_count,
               unsigned int op_count,
               size_t nested_byte_count,
@@ -272,10 +292,7 @@
               bool can_apply_group_opacity,
               sk_sp<const DlRTree> rtree);
 
-  struct SkFreeDeleter {
-    void operator()(uint8_t* p) { sk_free(p); }
-  };
-  std::unique_ptr<uint8_t, SkFreeDeleter> storage_;
+  DisplayListStorage storage_;
   size_t byte_count_;
   unsigned int op_count_;
 
diff --git a/display_list/display_list_builder.cc b/display_list/display_list_builder.cc
index 2e0c7bc..14289a3 100644
--- a/display_list/display_list_builder.cc
+++ b/display_list/display_list_builder.cc
@@ -61,7 +61,7 @@
   nested_bytes_ = nested_op_count_ = 0;
   storage_.realloc(bytes);
   bool compatible = layer_stack_.back().is_group_opacity_compatible();
-  return sk_sp<DisplayList>(new DisplayList(storage_.release(), bytes, count,
+  return sk_sp<DisplayList>(new DisplayList(std::move(storage_), bytes, count,
                                             nested_bytes, nested_count,
                                             bounds(), compatible, rtree()));
 }
diff --git a/display_list/display_list_builder.h b/display_list/display_list_builder.h
index b16e8b3..94a784f 100644
--- a/display_list/display_list_builder.h
+++ b/display_list/display_list_builder.h
@@ -362,7 +362,7 @@
  private:
   void checkForDeferredSave();
 
-  SkAutoTMalloc<uint8_t> storage_;
+  DisplayListStorage storage_;
   size_t used_ = 0;
   size_t allocated_ = 0;
   int op_count_ = 0;