add matrix objects to the lua bindings, as well as a lua script to find the proportion of image draw commands with different kinds of matrices

git-svn-id: http://skia.googlecode.com/svn/trunk@9986 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp
index 04dfbb1..658b43b 100644
--- a/src/utils/SkLua.cpp
+++ b/src/utils/SkLua.cpp
@@ -128,6 +128,11 @@
     lua_setfield(L, -2, key);
 }
 
+static void setfield_boolean(lua_State* L, const char key[], bool value) {
+    lua_pushboolean(L, value);
+    lua_setfield(L, -2, key);
+}
+
 static void setfield_scalar(lua_State* L, const char key[], SkScalar value) {
     setfield_number(L, key, SkScalarToLua(value));
 }
@@ -648,6 +653,24 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
+static int lmatrix_getType(lua_State* L) {
+    SkMatrix::TypeMask mask = get_obj<SkMatrix>(L, 1)->getType();
+    
+    lua_newtable(L);
+    setfield_boolean(L, "translate",   SkToBool(mask & SkMatrix::kTranslate_Mask));
+    setfield_boolean(L, "scale",       SkToBool(mask & SkMatrix::kScale_Mask));
+    setfield_boolean(L, "affine",      SkToBool(mask & SkMatrix::kAffine_Mask));
+    setfield_boolean(L, "perspective", SkToBool(mask & SkMatrix::kPerspective_Mask));
+    return 1;
+}
+
+static const struct luaL_Reg gSkMatrix_Methods[] = {
+    { "getType", lmatrix_getType },
+    { NULL, NULL }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
 static int lpath_getBounds(lua_State* L) {
     SkLua(L).pushRect(get_obj<SkPath>(L, 1)->getBounds());
     return 1;
@@ -971,6 +994,7 @@
     REG_CLASS(L, SkPaint);
     REG_CLASS(L, SkRRect);
     REG_CLASS(L, SkTypeface);
+    REG_CLASS(L, SkMatrix);
 }
 
 extern "C" int luaopen_skia(lua_State* L);