More header untangling.

Change-Id: I090943775cbda8d9515cdb484957f6b05d5b1799
diff --git a/driver/rsdGL.cpp b/driver/rsdGL.cpp
index 63bf7cc..fae602c 100644
--- a/driver/rsdGL.cpp
+++ b/driver/rsdGL.cpp
@@ -37,6 +37,7 @@
 
 #include <malloc.h>
 #include "rsContext.h"
+#include "rsDevice.h"
 #include "rsdShaderCache.h"
 #include "rsdVertexArray.h"
 #include "rsdFrameBufferObj.h"
diff --git a/rs.h b/rs.h
index fbcaf4a..825b9b8 100644
--- a/rs.h
+++ b/rs.h
@@ -20,10 +20,6 @@
 #include <stdint.h>
 #include <sys/types.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include "rsDefines.h"
 
 //
@@ -61,10 +57,6 @@
 
 #include "rsgApiFuncDecl.h"
 
-#ifdef __cplusplus
-};
-#endif
-
 #endif // RENDER_SCRIPT_H
 
 
diff --git a/rsAdapter.cpp b/rsAdapter.cpp
index 177fb60..41811ae 100644
--- a/rsAdapter.cpp
+++ b/rsAdapter.cpp
@@ -16,6 +16,7 @@
  */
 
 #include "rsContext.h"
+#include "rsAdapter.h"
 
 using namespace android;
 using namespace android::renderscript;
diff --git a/rsAllocation.cpp b/rsAllocation.cpp
index 83c88fd..a404c49 100644
--- a/rsAllocation.cpp
+++ b/rsAllocation.cpp
@@ -15,6 +15,8 @@
  */
 
 #include "rsContext.h"
+#include "rsAllocation.h"
+#include "rsAdapter.h"
 #include "rs_hal.h"
 
 #include "system/window.h"
diff --git a/rsAnimation.h b/rsAnimation.h
index bff8d6f..526a081 100644
--- a/rsAnimation.h
+++ b/rsAnimation.h
@@ -19,7 +19,7 @@
 
 #include "rsUtils.h"
 #include "rsObjectBase.h"
-
+#include "rsDefines.h"
 // ---------------------------------------------------------------------------
 namespace android {
 namespace renderscript {
diff --git a/rsContext.cpp b/rsContext.cpp
index 748b72a..1b51872 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -18,6 +18,7 @@
 #include "rsDevice.h"
 #include "rsContext.h"
 #include "rsThreadIO.h"
+#include "rsMesh.h"
 #include <ui/FramebufferNativeWindow.h>
 #include <gui/DisplayEventReceiver.h>
 
diff --git a/rsContext.h b/rsContext.h
index 05c799e..0f44267 100644
--- a/rsContext.h
+++ b/rsContext.h
@@ -18,18 +18,10 @@
 #define ANDROID_RS_CONTEXT_H
 
 #include "rsUtils.h"
-#include "rsType.h"
-#include "rsAllocation.h"
-#include "rsMesh.h"
-
 #include "rs_hal.h"
 
-#include "rsMutex.h"
 #include "rsThreadIO.h"
-#include "rsMatrix4x4.h"
-#include "rsDevice.h"
 #include "rsScriptC.h"
-#include "rsAdapter.h"
 #include "rsSampler.h"
 #include "rsFont.h"
 #include "rsPath.h"
@@ -39,13 +31,13 @@
 #include "rsProgramVertex.h"
 #include "rsFBOCache.h"
 
-#include "rsgApiStructs.h"
-
 // ---------------------------------------------------------------------------
 namespace android {
 
 namespace renderscript {
 
+class Device;
+
 #if 0
 #define CHECK_OBJ(o) { \
     GET_TLS(); \
diff --git a/rsFont.cpp b/rsFont.cpp
index 2bf9a75..1f53c79 100644
--- a/rsFont.cpp
+++ b/rsFont.cpp
@@ -19,6 +19,7 @@
 #include "rs.h"
 #include "rsFont.h"
 #include "rsProgramFragment.h"
+#include "rsMesh.h"
 #include <cutils/properties.h>
 
 #ifndef ANDROID_RS_SERIALIZE
diff --git a/rsMesh.cpp b/rsMesh.cpp
index f9dbc33..399a52b 100644
--- a/rsMesh.cpp
+++ b/rsMesh.cpp
@@ -15,6 +15,7 @@
  */
 
 #include "rsContext.h"
+#include "rsMesh.h"
 #include "rs.h"
 
 using namespace android;
diff --git a/rsPath.cpp b/rsPath.cpp
index c4f4978..055bb86 100644
--- a/rsPath.cpp
+++ b/rsPath.cpp
@@ -15,6 +15,7 @@
  */
 
 #include "rsContext.h"
+#include "rs.h"
 
 using namespace android;
 using namespace android::renderscript;
diff --git a/rsPath.h b/rsPath.h
index 7c05503..1abfc9a 100644
--- a/rsPath.h
+++ b/rsPath.h
@@ -18,7 +18,7 @@
 #define ANDROID_RS_PATH_H
 
 
-#include "rs.h"
+#include "rsObjectBase.h"
 
 // ---------------------------------------------------------------------------
 namespace android {
diff --git a/rsProgramVertex.cpp b/rsProgramVertex.cpp
index c8a53ea..23fcbe7 100644
--- a/rsProgramVertex.cpp
+++ b/rsProgramVertex.cpp
@@ -16,6 +16,7 @@
 
 #include "rsContext.h"
 #include "rsProgramVertex.h"
+#include "rsMatrix4x4.h"
 
 using namespace android;
 using namespace android::renderscript;
diff --git a/rsScriptC_Lib.cpp b/rsScriptC_Lib.cpp
index a5a0fae..749495d 100644
--- a/rsScriptC_Lib.cpp
+++ b/rsScriptC_Lib.cpp
@@ -19,6 +19,7 @@
 #include "rsMatrix4x4.h"
 #include "rsMatrix3x3.h"
 #include "rsMatrix2x2.h"
+#include "rsgApiStructs.h"
 
 #include "utils/Timers.h"
 
diff --git a/rsScriptC_LibGL.cpp b/rsScriptC_LibGL.cpp
index bda18fd..21b1c42 100644
--- a/rsScriptC_LibGL.cpp
+++ b/rsScriptC_LibGL.cpp
@@ -19,6 +19,8 @@
 #include "rsMatrix4x4.h"
 #include "rsMatrix3x3.h"
 #include "rsMatrix2x2.h"
+#include "rsMesh.h"
+#include "rsgApiStructs.h"
 
 #include "utils/Timers.h"
 #include "driver/rsdVertexArray.h"
diff --git a/rsThreadIO.cpp b/rsThreadIO.cpp
index 7182f53..8a0a5dc 100644
--- a/rsThreadIO.cpp
+++ b/rsThreadIO.cpp
@@ -15,8 +15,8 @@
  */
 
 #include "rsContext.h"
-
 #include "rsThreadIO.h"
+#include "rsgApiStructs.h"
 
 #include <unistd.h>
 #include <sys/types.h>
diff --git a/rsg_generator.c b/rsg_generator.c
index 99c305e..c0f82dc 100644
--- a/rsg_generator.c
+++ b/rsg_generator.c
@@ -187,7 +187,7 @@
     fprintf(f, "#include \"rsDevice.h\"\n");
     fprintf(f, "#include \"rsContext.h\"\n");
     fprintf(f, "#include \"rsThreadIO.h\"\n");
-    //fprintf(f, "#include \"rsgApiStructs.h\"\n");
+    fprintf(f, "#include \"rsgApiStructs.h\"\n");
     fprintf(f, "#include \"rsgApiFuncDecl.h\"\n");
     fprintf(f, "#include \"rsFifo.h\"\n");
     fprintf(f, "\n");
@@ -408,6 +408,7 @@
     fprintf(f, "#include \"rsDevice.h\"\n");
     fprintf(f, "#include \"rsContext.h\"\n");
     fprintf(f, "#include \"rsThreadIO.h\"\n");
+    fprintf(f, "#include \"rsgApiStructs.h\"\n");
     fprintf(f, "#include \"rsgApiFuncDecl.h\"\n");
     fprintf(f, "\n");
     fprintf(f, "namespace android {\n");