Add display name and id to traces

On a multi-display device, it is helpful to know which display
particular methods are called for. Add information to traces specifying
the name and id of the display. The device still needs to specify
different names for displays (see b/254851304), but the traces will now
show the id, which is helpful until the device is updated, at which
point the names will be immediately helpful.

Output:
- Store a string that combines the readable name and the DisplayId. This
  saves allocation costs for the various places where we add this info
  to the trace.
- Print the name and id in present and postFramebuffer. Although
  postFramebuffer is called by present, future CLs will move it to a
  separate thread, and this allows tracking which call applies to which
  display.
DisplaySettings:
- Add a field with the display name and id. This allows SkiaRenderEngine
  to print them as well.
SkiaRenderEngine:
- Print the name and id in drawLayersInternal
- Replace the outdated text for the function name referring to the class
  as "SkiaGL" with a simple call to __func__.
Display:
- Print the name and id in chooseClientCompositionStrategy, which may
  also run in another thread.

Bug: 241285473
Test: manual; look at traces
Change-Id: I3081c4e4a7b5874139af6b5dd74a6a8ab0ad8cf7
diff --git a/libs/renderengine/include/renderengine/DisplaySettings.h b/libs/renderengine/include/renderengine/DisplaySettings.h
index 25fe9f2..8d7c13c 100644
--- a/libs/renderengine/include/renderengine/DisplaySettings.h
+++ b/libs/renderengine/include/renderengine/DisplaySettings.h
@@ -23,17 +23,24 @@
 #include <math/mat4.h>
 #include <renderengine/PrintMatrix.h>
 #include <renderengine/BorderRenderInfo.h>
+#include <ui/DisplayId.h>
 #include <ui/GraphicTypes.h>
 #include <ui/Rect.h>
 #include <ui/Region.h>
 #include <ui/Transform.h>
 
+#include <optional>
+
 namespace android {
 namespace renderengine {
 
 // DisplaySettings contains the settings that are applicable when drawing all
 // layers for a given display.
 struct DisplaySettings {
+    // A string containing the name of the display, along with its id, if it has
+    // one.
+    std::string namePlusId;
+
     // Rectangle describing the physical display. We will project from the
     // logical clip onto this rectangle.
     Rect physicalDisplay = Rect::INVALID_RECT;
@@ -85,8 +92,8 @@
 };
 
 static inline bool operator==(const DisplaySettings& lhs, const DisplaySettings& rhs) {
-    return lhs.physicalDisplay == rhs.physicalDisplay && lhs.clip == rhs.clip &&
-            lhs.maxLuminance == rhs.maxLuminance &&
+    return lhs.namePlusId == rhs.namePlusId && lhs.physicalDisplay == rhs.physicalDisplay &&
+            lhs.clip == rhs.clip && lhs.maxLuminance == rhs.maxLuminance &&
             lhs.currentLuminanceNits == rhs.currentLuminanceNits &&
             lhs.outputDataspace == rhs.outputDataspace &&
             lhs.colorTransform == rhs.colorTransform &&
@@ -121,6 +128,7 @@
 
 static inline void PrintTo(const DisplaySettings& settings, ::std::ostream* os) {
     *os << "DisplaySettings {";
+    *os << "\n    .display = " << settings.namePlusId;
     *os << "\n    .physicalDisplay = ";
     PrintTo(settings.physicalDisplay, os);
     *os << "\n    .clip = ";
diff --git a/libs/renderengine/skia/SkiaRenderEngine.cpp b/libs/renderengine/skia/SkiaRenderEngine.cpp
index b9aa5ac..fca6c0e 100644
--- a/libs/renderengine/skia/SkiaRenderEngine.cpp
+++ b/libs/renderengine/skia/SkiaRenderEngine.cpp
@@ -636,7 +636,7 @@
         const DisplaySettings& display, const std::vector<LayerSettings>& layers,
         const std::shared_ptr<ExternalTexture>& buffer, const bool /*useFramebufferCache*/,
         base::unique_fd&& bufferFence) {
-    ATRACE_NAME("SkiaGL::drawLayersInternal");
+    ATRACE_FORMAT("%s for %s", __func__, display.namePlusId.c_str());
 
     std::lock_guard<std::mutex> lock(mRenderingMutex);