Optimize FBO drawing with regions.
This optimization is currently disabled until Launcher is
modified to take advantage of it. The optimization can be
enabled by turning on RENDER_LAYERS_AS_REGIONS in the
OpenGLRenderer.h file.

Change-Id: I2fdf59d0f4dc690a3d7f712173ab8db3848b27b1
diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h
index 2da1950..9f78063 100644
--- a/libs/hwui/Snapshot.h
+++ b/libs/hwui/Snapshot.h
@@ -14,16 +14,16 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_UI_SNAPSHOT_H
-#define ANDROID_UI_SNAPSHOT_H
+#ifndef ANDROID_HWUI_SNAPSHOT_H
+#define ANDROID_HWUI_SNAPSHOT_H
 
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
 #include <utils/RefBase.h>
+#include <ui/Region.h>
 
 #include <SkCanvas.h>
-#include <SkRegion.h>
 
 #include "Layer.h"
 #include "Matrix.h"
@@ -46,6 +46,7 @@
     Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0), invisible(false) {
         transform = &mTransformRoot;
         clipRect = &mClipRectRoot;
+        region = NULL;
     }
 
     /**
@@ -75,6 +76,13 @@
         } else {
             flags |= Snapshot::kFlagDirtyLocalClip;
         }
+
+        if (s->flags & Snapshot::kFlagFboTarget) {
+            flags |= Snapshot::kFlagFboTarget;
+            region = s->region;
+        } else {
+            region = NULL;
+        }
     }
 
     /**
@@ -105,6 +113,11 @@
          * Indicates that this snapshot has changed the ortho matrix.
          */
         kFlagDirtyOrtho = 0x10,
+        /**
+         * Indicates that this snapshot or an ancestor snapshot is
+         * an FBO layer.
+         */
+        kFlagFboTarget = 0x20
     };
 
     /**
@@ -243,6 +256,11 @@
      */
     Rect* clipRect;
 
+    /**
+     * The ancestor layer's dirty region..
+     */
+    Region* region;
+
 private:
     mat4 mTransformRoot;
     Rect mClipRectRoot;
@@ -253,4 +271,4 @@
 }; // namespace uirenderer
 }; // namespace android
 
-#endif // ANDROID_UI_SNAPSHOT_H
+#endif // ANDROID_HWUI_SNAPSHOT_H