Add support for transformations.

This change adds partial support for the following transforms:
- scale()
- translate()
- rotate()
- setMatrix()
- getMatrix()

The transform is stored in a snapshot and saved/restored as needed.
The transform is currently not applied to the clip rect and is not
mapped to the vertex shader.

Change-Id: Id48993453311200804149917d0c126a4d0471226
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 8a541fc..595768c 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -17,24 +17,36 @@
 #ifndef ANDROID_OPENGL_RENDERER_H
 #define ANDROID_OPENGL_RENDERER_H
 
+#include <SkMatrix.h>
 #include <SkXfermode.h>
 
 #include <utils/RefBase.h>
 
+#include "Matrix.h"
 #include "Rect.h"
 
 namespace android {
 
+///////////////////////////////////////////////////////////////////////////////
+// Support
+///////////////////////////////////////////////////////////////////////////////
+
 class Snapshot: public LightRefBase<Snapshot> {
 public:
-	Snapshot() { }
+	Snapshot() {
+	}
 
-	Snapshot(const sp<Snapshot> s): clipRect(s->clipRect), flags(0), previous(s) { }
+	Snapshot(const sp<Snapshot> s): transform(s->transform), clipRect(s->clipRect),
+				flags(0), previous(s) {
+	}
 
 	enum Flags {
 		kFlagClipSet = 0x1,
 	};
 
+	// Local transformations
+	mat4 transform;
+
 	// Clipping rectangle at the time of this snapshot
 	Rect clipRect;
 
@@ -45,6 +57,10 @@
 	sp<Snapshot> previous;
 }; // struct Snapshot
 
+///////////////////////////////////////////////////////////////////////////////
+// Renderer
+///////////////////////////////////////////////////////////////////////////////
+
 class OpenGLRenderer {
 public:
     OpenGLRenderer();
@@ -58,6 +74,14 @@
     void restore();
     void restoreToCount(int saveCount);
 
+    void translate(float dx, float dy);
+    void rotate(float degrees);
+    void scale(float sx, float sy);
+
+    void setMatrix(SkMatrix* matrix);
+    void getMatrix(SkMatrix* matrix);
+    void concatMatrix(SkMatrix* matrix);
+
     bool clipRect(float left, float top, float right, float bottom);
 
     void drawColor(int color, SkXfermode::Mode mode);
@@ -76,6 +100,8 @@
 
     // Number of saved states
     int mSaveCount;
+    // Base state
+    Snapshot mFirstSnapshot;
     // Current state
     sp<Snapshot> mSnapshot;
 }; // class OpenGLRenderer