Add convenient Type creator, alignment define, and fix USAGE_SHARED issue.

Change-Id: Ib344ed27feee95c9eddf4f58468ef3e29fdfabab
diff --git a/cpp/Allocation.cpp b/cpp/Allocation.cpp
index d6dfa94..9f3ce20 100644
--- a/cpp/Allocation.cpp
+++ b/cpp/Allocation.cpp
@@ -46,7 +46,8 @@
                    RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS |
                    RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET |
                    RS_ALLOCATION_USAGE_IO_INPUT |
-                   RS_ALLOCATION_USAGE_IO_OUTPUT)) != 0) {
+                   RS_ALLOCATION_USAGE_IO_OUTPUT |
+                   RS_ALLOCATION_USAGE_SHARED)) != 0) {
         ALOGE("Unknown usage specified.");
     }
 
diff --git a/cpp/Type.cpp b/cpp/Type.cpp
index b2dfa23..0b473c4 100644
--- a/cpp/Type.cpp
+++ b/cpp/Type.cpp
@@ -94,6 +94,22 @@
     */
 }
 
+sp<const Type> Type::create(sp<RS> rs, sp<const Element> e, uint32_t dimX, uint32_t dimY, uint32_t dimZ) {
+    void * id = rsTypeCreate(rs->getContext(), e->getID(), dimX, dimY, dimZ, false, false, 0);
+    Type *t = new Type(id, rs);
+
+    t->mElement = e;
+    t->mDimX = dimX;
+    t->mDimY = dimY;
+    t->mDimZ = dimZ;
+    t->mDimMipmaps = false;
+    t->mDimFaces = false;
+
+    t->calcElementCount();
+
+    return t;
+}
+
 Type::Builder::Builder(sp<RS> rs, sp<const Element> e) {
     mRS = rs;
     mElement = e;
diff --git a/cpp/rsCppStructs.h b/cpp/rsCppStructs.h
index 46eb336..f5bfd0c 100644
--- a/cpp/rsCppStructs.h
+++ b/cpp/rsCppStructs.h
@@ -23,6 +23,10 @@
 
 #include <rs.h>
 
+// Every row in an RS allocation is guaranteed to be aligned by this amount
+// Every row in a user-backed allocation must be aligned by this amount
+#define RS_CPU_ALLOCATION_ALIGNMENT 16
+
 namespace android {
 namespace RSC {
 
@@ -541,6 +545,7 @@
 
     Type(void *id, sp<RS> rs);
 
+    static sp<const Type> create(sp<RS> rs, sp<const Element> e, uint32_t dimX, uint32_t dimY, uint32_t dimZ);
 
     class Builder {
     protected: