Improve logging code to dump more detaild rs object info.  Fix bug with predefined elements not being recreated for contexts after one was destroyed. Add stricter type enforcement.
diff --git a/java/Film/src/com/android/film/FilmRS.java b/java/Film/src/com/android/film/FilmRS.java
index cee827b..b5b6723 100644
--- a/java/Film/src/com/android/film/FilmRS.java
+++ b/java/Film/src/com/android/film/FilmRS.java
@@ -152,9 +152,9 @@
         mBufferIDs = new int[13];
         mImages = new Allocation[13];
         mAllocIDs = Allocation.createSized(mRS,
-            Element.USER_FLOAT, mBufferIDs.length);
+            Element.USER_F32(mRS), mBufferIDs.length);
 
-        Element ie = Element.RGB_565;
+        Element ie = Element.RGB_565(mRS);
         mImages[0] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p01, ie, true);
         mImages[1] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p02, ie, true);
         mImages[2] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p03, ie, true);
@@ -195,7 +195,7 @@
     {
         mBufferState = new int[10];
         mAllocState = Allocation.createSized(mRS,
-            Element.USER_FLOAT, mBufferState.length);
+            Element.USER_F32(mRS), mBufferState.length);
         mBufferState[STATE_LAST_FOCUS] = -1;
         mAllocState.data(mBufferState);
     }
@@ -238,12 +238,12 @@
 
 
         mAllocOffsets = Allocation.createSized(mRS,
-            Element.USER_I32, mFSM.mTriangleOffsets.length);
+            Element.USER_I32(mRS), mFSM.mTriangleOffsets.length);
         mAllocOffsets.data(mFSM.mTriangleOffsets);
         mScriptStrip.bindAllocation(mAllocOffsets, 4);
 
         mAllocOffsetsTex = Allocation.createSized(mRS,
-            Element.USER_FLOAT, mFSM.mTriangleOffsetsTex.length);
+            Element.USER_F32(mRS), mFSM.mTriangleOffsetsTex.length);
         mAllocOffsetsTex.data(mFSM.mTriangleOffsetsTex);
         mScriptStrip.bindAllocation(mAllocOffsetsTex, 5);
 
diff --git a/java/Rollo/src/com/android/rollo/RolloRS.java b/java/Rollo/src/com/android/rollo/RolloRS.java
index ba74b58..ff89bc3 100644
--- a/java/Rollo/src/com/android/rollo/RolloRS.java
+++ b/java/Rollo/src/com/android/rollo/RolloRS.java
@@ -182,7 +182,7 @@
 
         mAllocScratchBuf = new int[32];
         mAllocScratch = Allocation.createSized(mRS,
-            Element.USER_I32, mAllocScratchBuf.length);
+            Element.USER_I32(mRS), mAllocScratchBuf.length);
         mAllocScratch.data(mAllocScratchBuf);
 
         Log.e("rs", "Done loading named");
@@ -193,14 +193,14 @@
             mIcons = new Allocation[29];
             mAllocIconIDBuf = new int[mIcons.length];
             mAllocIconID = Allocation.createSized(mRS,
-                Element.USER_I32, mAllocIconIDBuf.length);
+                Element.USER_I32(mRS), mAllocIconIDBuf.length);
 
             mLabels = new Allocation[29];
             mAllocLabelIDBuf = new int[mLabels.length];
             mAllocLabelID = Allocation.createSized(mRS,
-                Element.USER_I32, mLabels.length);
+                Element.USER_I32(mRS), mLabels.length);
 
-            Element ie8888 = Element.RGBA_8888;
+            Element ie8888 = Element.RGBA_8888(mRS);
 
             mIcons[0] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.browser, ie8888, true);
             mIcons[1] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.market, ie8888, true);
@@ -284,7 +284,7 @@
         p.setTextSize(20);
         p.setColor(0xffffffff);
         c.drawText(t, 2, 26, p);
-        return Allocation.createFromBitmap(mRS, b, Element.RGBA_8888, true);
+        return Allocation.createFromBitmap(mRS, b, Element.RGBA_8888(mRS), true);
     }
 
 
@@ -298,7 +298,7 @@
 
         mAllocStateBuf = new int[] {0, 0, 0, 8, 0, 0, -1, 0, mAllocIconIDBuf.length, 0, 0};
         mAllocState = Allocation.createSized(mRS,
-            Element.USER_I32, mAllocStateBuf.length);
+            Element.USER_I32(mRS), mAllocStateBuf.length);
         mScript.bindAllocation(mAllocState, 0);
         mScript.bindAllocation(mAllocIconID, 1);
         mScript.bindAllocation(mAllocScratch, 2);
diff --git a/rsAllocation.cpp b/rsAllocation.cpp
index 8ee6e5a..8ac9c26 100644
--- a/rsAllocation.cpp
+++ b/rsAllocation.cpp
@@ -141,6 +141,7 @@
 
     if (size != sizeBytes) {
         LOGE("Allocation::subData called with mismatched size expected %i, got %i", size, sizeBytes);
+        mType->dumpLOGV("type info");
         return;
     }
     memcpy(ptr, data, size);
diff --git a/rsComponent.cpp b/rsComponent.cpp
index 42e2e4f..de074c8 100644
--- a/rsComponent.cpp
+++ b/rsComponent.cpp
@@ -102,4 +102,9 @@
     return 0;
 }
 
+void Component::dumpLOGV(const char *prefix) const
+{
+    ObjectBase::dumpLOGV(prefix);
+    LOGV("%s   component: %i %i %i %i", prefix, mType, mKind, mIsNormalized, mBits);
+}
 
diff --git a/rsComponent.h b/rsComponent.h
index 290cd57..5366cc4 100644
--- a/rsComponent.h
+++ b/rsComponent.h
@@ -56,6 +56,7 @@
     const char * getCType() const;
 
     const char * getComponentName() const {return mName.string();}
+    virtual void dumpLOGV(const char *prefix) const;
 
 protected:
 
diff --git a/rsElement.cpp b/rsElement.cpp
index a00fb52..67e4f14 100644
--- a/rsElement.cpp
+++ b/rsElement.cpp
@@ -55,6 +55,8 @@
     rsAssert(!mComponents[idx].get());
     rsAssert(idx < mComponentCount);
     mComponents[idx].set(c);
+
+// Fixme: This should probably not be here
     c->incUserRef();
 }
 
@@ -179,6 +181,17 @@
 }
 
 
+void Element::dumpLOGV(const char *prefix) const
+{
+    ObjectBase::dumpLOGV(prefix);
+    LOGV("%s   Element: components %i,  size %i", prefix, mComponentCount, getSizeBytes());
+    for (uint32_t ct = 0; ct < mComponentCount; ct++) {
+        char buf[1024];
+        sprintf(buf, "%s component %i: ", prefix, ct);
+        mComponents[ct]->dumpLOGV(buf);
+    }
+}
+
 ElementState::ElementState()
 {
 }
@@ -201,6 +214,9 @@
 void rsi_ElementAdd(Context *rsc, RsDataKind dk, RsDataType dt, bool isNormalized, size_t bits, const char *name)
 {
     ElementState * sec = &rsc->mStateElement;
+
+    rsAssert(bits > 0);
+
     Component *c = new Component(rsc,
                                  static_cast<Component::DataKind>(dk),
                                  static_cast<Component::DataType>(dt),
@@ -215,6 +231,8 @@
     ElementState * sec = &rsc->mStateElement;
     Element *se = new Element(rsc, sec->mComponentBuildList.size());
 
+    rsAssert(se->getComponentCount() > 0);
+
     for (size_t ct = 0; ct < se->getComponentCount(); ct++) {
         se->setComponent(ct, sec->mComponentBuildList[ct]);
     }
diff --git a/rsElement.h b/rsElement.h
index 82da441..b41c552 100644
--- a/rsElement.h
+++ b/rsElement.h
@@ -51,6 +51,9 @@
     uint32_t getComponentCount() const {return mComponentCount;}
     Component * getComponent(uint32_t idx) const {return mComponents[idx].get();}
 
+
+    void dumpLOGV(const char *prefix) const;
+
 protected:
     // deallocate any components that are part of this element.
     void clear();
diff --git a/rsObjectBase.cpp b/rsObjectBase.cpp
index 720e8fc..0008ea4 100644
--- a/rsObjectBase.cpp
+++ b/rsObjectBase.cpp
@@ -41,7 +41,7 @@
     remove();
 }
 
-void ObjectBase::dumpObj(const char *op) const
+void ObjectBase::dumpLOGV(const char *op) const
 {
     if (mName) {
         LOGV("%s RSobj %p, name %s, refs %i,%i  from %s,%i links %p,%p,%p",
@@ -79,7 +79,7 @@
 {
     if (!(mSysRefCount | mUserRefCount)) {
         if (mRSC && mRSC->props.mLogObjects) {
-            dumpObj("checkDelete");
+            dumpLOGV("checkDelete");
         }
         delete this;
         return true;
@@ -188,7 +188,7 @@
         LOGV("Objects remaining.");
         o = rsc->mObjHead;
         while (o) {
-            o->dumpObj("  ");
+            o->dumpLOGV("  ");
             o = o->mNext;
         }
     }
diff --git a/rsObjectBase.h b/rsObjectBase.h
index ea5e37c..dc85ac7 100644
--- a/rsObjectBase.h
+++ b/rsObjectBase.h
@@ -50,7 +50,7 @@
 
     static void zeroAllUserRef(Context *rsc);
 
-    void dumpObj(const char *op) const;
+    virtual void dumpLOGV(const char *prefix) const;
 
 protected:
     const char *mAllocFile;
diff --git a/rsType.cpp b/rsType.cpp
index 5ce9ca2..ddaa2f0 100644
--- a/rsType.cpp
+++ b/rsType.cpp
@@ -302,6 +302,16 @@
 }
 
 
+void Type::dumpLOGV(const char *prefix) const
+{
+    char buf[1024];
+    ObjectBase::dumpLOGV(prefix);
+    LOGV("%s   Type: x=%i y=%i z=%i mip=%i face=%i", prefix, mDimX, mDimY, mDimZ, mDimLOD, mFaces);
+    sprintf(buf, "%s element: ", prefix);
+    mElement->dumpLOGV(buf);
+}
+
+
 //////////////////////////////////////////////////
 //
 namespace android {
diff --git a/rsType.h b/rsType.h
index 116f1c7..2c43405 100644
--- a/rsType.h
+++ b/rsType.h
@@ -69,6 +69,7 @@
 
     void enableGLVertexBuffer() const;
 
+    void dumpLOGV(const char *prefix) const;
 
 protected:
     struct LOD {