Tag HardwareRenderers with a name to help debugging

The name of the renderer is the same as the window it belongs to.

Change-Id: Ie9adc0a1978afa026923ea41f5540eda6ba65a92
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index 69c81c8..1c4d05f 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -215,7 +215,7 @@
     bool disableScissor();
     void setScissorEnabled(bool enabled);
 
-    void startTiling(GLuint x, GLuint y, GLuint width, GLuint height, bool preserve);
+    void startTiling(GLuint x, GLuint y, GLuint width, GLuint height, bool discard);
     void endTiling();
 
     /**
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 9f0a38b..6a05789 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -142,6 +142,18 @@
 // Setup
 ///////////////////////////////////////////////////////////////////////////////
 
+void OpenGLRenderer::setName(const char* name) {
+    if (name) {
+        mName.setTo(name);
+    } else {
+        mName.clear();
+    }
+}
+
+const char* OpenGLRenderer::getName() const {
+    return mName.string();
+}
+
 bool OpenGLRenderer::isDeferred() {
     return false;
 }
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 594580e..750b3d2 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -64,6 +64,19 @@
     virtual ~OpenGLRenderer();
 
     /**
+     * Sets the name of this renderer. The name is optional and
+     * empty by default. If the pointer is null the name is set
+     * to the empty string.
+     */
+    ANDROID_API void setName(const char* name);
+
+    /**
+     * Returns the name of this renderer as UTF8 string.
+     * The returned pointer is never null.
+     */
+    ANDROID_API const char* getName() const;
+
+    /**
      * Read externally defined properties to control the behavior
      * of the renderer.
      */
@@ -904,6 +917,9 @@
     // No-ops start/endTiling when set
     bool mSuppressTiling;
 
+    // Optional name of the renderer
+    String8 mName;
+
     friend class DisplayListRenderer;
 
 }; // class OpenGLRenderer