vulkan: refactor DebugReportCallbackList

Simplify DebugReportCallbackList to be a thread-safe list with three
methods:

 - AddCallback adds a node to the list
 - RemoveCallback removes a node from the list
 - Message invokes each of the nodes on the list

Add some static methods for Node* and VkDebugReportCallbackEXT
conversions.

Bug: 28120066
Change-Id: I109c6eff368cacb37508e2549dbd0b5dfa23bcb3
diff --git a/vulkan/libvulkan/debug_report.h b/vulkan/libvulkan/debug_report.h
index 72b1887..7a03d4a 100644
--- a/vulkan/libvulkan/debug_report.h
+++ b/vulkan/libvulkan/debug_report.h
@@ -30,6 +30,10 @@
 // clang-format on
 
 class DebugReportCallbackList {
+   private:
+    // forward declaration
+    struct Node;
+
    public:
     DebugReportCallbackList()
         : head_{nullptr, 0, nullptr, nullptr, VK_NULL_HANDLE} {}
@@ -37,14 +41,11 @@
     DebugReportCallbackList& operator=(const DebugReportCallbackList&) = delete;
     ~DebugReportCallbackList() = default;
 
-    VkResult CreateCallback(
-        VkInstance instance,
-        const VkDebugReportCallbackCreateInfoEXT* create_info,
-        const VkAllocationCallbacks* allocator,
-        VkDebugReportCallbackEXT* callback);
-    void DestroyCallback(VkInstance instance,
-                         VkDebugReportCallbackEXT callback,
-                         const VkAllocationCallbacks* allocator);
+    Node* AddCallback(const VkDebugReportCallbackCreateInfoEXT& info,
+                      VkDebugReportCallbackEXT driver_handle,
+                      const VkAllocationCallbacks& allocator);
+    void RemoveCallback(Node* node, const VkAllocationCallbacks& allocator);
+
     void Message(VkDebugReportFlagsEXT flags,
                  VkDebugReportObjectTypeEXT object_type,
                  uint64_t object,
@@ -53,13 +54,27 @@
                  const char* layer_prefix,
                  const char* message);
 
+    static Node* FromHandle(VkDebugReportCallbackEXT handle) {
+        return reinterpret_cast<Node*>(uintptr_t(handle));
+    }
+
+    static VkDebugReportCallbackEXT GetHandle(const Node* node) {
+        return VkDebugReportCallbackEXT(reinterpret_cast<uintptr_t>(node));
+    }
+
+    static VkDebugReportCallbackEXT GetDriverHandle(const Node* node) {
+        return node->driver_handle;
+    }
+
    private:
     struct Node {
         Node* next;
+
         VkDebugReportFlagsEXT flags;
         PFN_vkDebugReportCallbackEXT callback;
-        void* data;
-        VkDebugReportCallbackEXT driver_callback;
+        void* user_data;
+
+        VkDebugReportCallbackEXT driver_handle;
     };
 
     // TODO(jessehall): replace with std::shared_mutex when available in libc++