Don't blend transparent pixels when rendering layers.

With this change, the rendere keeps track of what regions are rendered into
and generates a mesh that matches these regions exactly. The mesh is used
to composite the layer on screen.

Change-Id: I1f342576b9134fb29caff7fb8f4c1da179fe956d
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 56be134..7387b92 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -133,19 +133,24 @@
     virtual void composeLayer(sp<Snapshot> current, sp<Snapshot> previous);
 
     /**
-     * Mark the layer as dirty at the specified coordinates. The coordinates
-     * are transformed with the supplied matrix.
+     * Marks the specified region as dirty at the specified bounds.
      */
-    virtual void dirtyLayer(const float left, const float top,
-            const float right, const float bottom, const mat4 transform);
+    void dirtyLayerUnchecked(Rect& bounds, Region* region);
 
     /**
-     * Mark the layer as dirty at the specified coordinates.
+     * Returns the current snapshot.
      */
-    virtual void dirtyLayer(const float left, const float top,
-            const float right, const float bottom);
+    sp<Snapshot> getSnapshot() {
+        return mSnapshot;
+    }
 
-    void dirtyLayerUnchecked(Rect& bounds, Region* region);
+    virtual Region* getRegion() {
+        return mSnapshot->region;
+    }
+
+    virtual bool hasLayer() {
+        return (mSnapshot->flags & Snapshot::kFlagFboTarget) && mSnapshot->region;
+    }
 
 private:
     /**
@@ -225,6 +230,19 @@
     void clearLayerRegions();
 
     /**
+     * Mark the layer as dirty at the specified coordinates. The coordinates
+     * are transformed with the supplied matrix.
+     */
+    void dirtyLayer(const float left, const float top,
+            const float right, const float bottom, const mat4 transform);
+
+    /**
+     * Mark the layer as dirty at the specified coordinates.
+     */
+    void dirtyLayer(const float left, const float top,
+            const float right, const float bottom);
+
+    /**
      * Draws a colored rectangle with the specified color. The specified coordinates
      * are transformed by the current snapshot's transform matrix.
      *