Fix clear() operation for rsScriptC.

- This removes a memory leak where some elements were not getting tracked
  properly (and then triggering an assert when a context is destroyed).
- Convert ScriptCState to use a tracked object reference for mScript.
- Add a missing clear to FontState.
- Clean up synchronization in RSTest so that our graphics context outlives
  any subtest context.

Change-Id: I0d5768c4d2f8810dd1ae2f68b1edd7e150f382fd
diff --git a/libs/rs/rsScriptC.h b/libs/rs/rsScriptC.h
index 9d09b0b..7ec80aa 100644
--- a/libs/rs/rsScriptC.h
+++ b/libs/rs/rsScriptC.h
@@ -79,14 +79,16 @@
     ScriptCState();
     ~ScriptCState();
 
-    ScriptC *mScript;
+    ObjectBaseRef<ScriptC> mScript;
 
     ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS];
     //String8 mSlotNames[MAX_SCRIPT_BANKS];
     bool mSlotWritable[MAX_SCRIPT_BANKS];
     //String8 mInvokableNames[MAX_SCRIPT_BANKS];
 
-    void clear();
+    void init(Context *rsc);
+
+    void clear(Context *rsc);
     void runCompiler(Context *rsc, ScriptC *s);
 
     struct SymbolTable_t {