Cleaning up the serialization change.
Renaming the define to be more in line with what it does and removing the host stub header file.

Change-Id: Ibd3a0a6a398c7f81cc661f71e4478707fe1679ed
diff --git a/Android.mk b/Android.mk
index 2d0b6c4..25c8beb 100644
--- a/Android.mk
+++ b/Android.mk
@@ -132,7 +132,7 @@
 
 # Now build a host version for serialization
 include $(CLEAR_VARS)
-LOCAL_CFLAGS += -DANDROID_RS_BUILD_FOR_HOST
+LOCAL_CFLAGS += -DANDROID_RS_SERIALIZE
 
 LOCAL_SRC_FILES:= \
 	rsAllocation.cpp \
diff --git a/RenderScript.h b/RenderScript.h
index 882a0b0..bb5e4aa 100644
--- a/RenderScript.h
+++ b/RenderScript.h
@@ -365,7 +365,7 @@
 RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype,
                                                RsAllocationMipmapControl mips,
                                                const void *data, uint32_t usages);
-#ifdef ANDROID_RS_BUILD_FOR_HOST
+#ifdef ANDROID_RS_SERIALIZE
 #define NO_RS_FUNCS
 #endif
 
diff --git a/rsAdapter.cpp b/rsAdapter.cpp
index 8d363fd..6e8ca70 100644
--- a/rsAdapter.cpp
+++ b/rsAdapter.cpp
@@ -15,11 +15,7 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
-#else
-#include "rsContextHostStub.h"
-#endif
 
 using namespace android;
 using namespace android::renderscript;
diff --git a/rsAllocation.cpp b/rsAllocation.cpp
index 2839b76..54dcbcb 100644
--- a/rsAllocation.cpp
+++ b/rsAllocation.cpp
@@ -13,15 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef ANDROID_RS_BUILD_FOR_HOST
-#include "rsContext.h"
 
+#include "rsContext.h"
+#ifndef ANDROID_RS_SERIALIZE
 #include <GLES/gl.h>
 #include <GLES2/gl2.h>
 #include <GLES/glext.h>
-#else
-#include "rsContextHostStub.h"
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 
 static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va);
 
@@ -78,7 +76,7 @@
         mPtr = NULL;
     }
     freeScriptMemory();
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     if (mBufferID) {
         // Causes a SW crash....
         //LOGV(" mBufferID %i", mBufferID);
@@ -89,7 +87,7 @@
         glDeleteTextures(1, &mTextureID);
         mTextureID = 0;
     }
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 }
 
 void Allocation::setCpuWritable(bool) {
@@ -114,7 +112,7 @@
 }
 
 uint32_t Allocation::getGLTarget() const {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     if (getIsTexture()) {
         if (mType->getDimFaces()) {
             return GL_TEXTURE_CUBE_MAP;
@@ -125,7 +123,7 @@
     if (getIsBufferObject()) {
         return GL_ARRAY_BUFFER;
     }
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
     return 0;
 }
 
@@ -156,7 +154,7 @@
 }
 
 void Allocation::uploadToTexture(const Context *rsc) {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     mUsageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE;
     GLenum type = mType->getElement()->getComponent().getGLType();
     GLenum format = mType->getElement()->getComponent().getGLFormat();
@@ -193,10 +191,10 @@
     }
 
     rsc->checkError("Allocation::uploadToTexture");
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 }
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
 const static GLenum gFaceOrder[] = {
     GL_TEXTURE_CUBE_MAP_POSITIVE_X,
     GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
@@ -205,12 +203,12 @@
     GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
     GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
 };
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 
 void Allocation::update2DTexture(const void *ptr, uint32_t xoff, uint32_t yoff,
                                  uint32_t lod, RsAllocationCubemapFace face,
                                  uint32_t w, uint32_t h) {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     GLenum type = mType->getElement()->getComponent().getGLType();
     GLenum format = mType->getElement()->getComponent().getGLFormat();
     GLenum target = (GLenum)getGLTarget();
@@ -222,11 +220,11 @@
         t = gFaceOrder[face];
     }
     glTexSubImage2D(t, lod, xoff, yoff, w, h, format, type, ptr);
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 }
 
 void Allocation::upload2DTexture(bool isFirstUpload) {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     GLenum type = mType->getElement()->getComponent().getGLType();
     GLenum format = mType->getElement()->getComponent().getGLFormat();
 
@@ -264,7 +262,7 @@
     if (mMipmapControl == RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE) {
         glGenerateMipmap(target);
     }
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 }
 
 void Allocation::deferedUploadToBufferObject(const Context *rsc) {
@@ -273,7 +271,7 @@
 }
 
 void Allocation::uploadToBufferObject(const Context *rsc) {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     rsAssert(!mType->getDimY());
     rsAssert(!mType->getDimZ());
 
@@ -292,7 +290,7 @@
     glBufferData(target, mType->getSizeBytes(), getPtr(), GL_DYNAMIC_DRAW);
     glBindBuffer(target, 0);
     rsc->checkError("Allocation::uploadToBufferObject");
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 }
 
 void Allocation::uploadCheck(Context *rsc) {
@@ -450,13 +448,13 @@
 }
 
 void Allocation::addProgramToDirty(const Program *p) {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     mToDirtyList.push(p);
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 }
 
 void Allocation::removeProgramToDirty(const Program *p) {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     for (size_t ct=0; ct < mToDirtyList.size(); ct++) {
         if (mToDirtyList[ct] == p) {
             mToDirtyList.removeAt(ct);
@@ -464,7 +462,7 @@
         }
     }
     rsAssert(0);
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 }
 
 void Allocation::dumpLOGV(const char *prefix) const {
@@ -539,11 +537,11 @@
 }
 
 void Allocation::sendDirty() const {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     for (size_t ct=0; ct < mToDirtyList.size(); ct++) {
         mToDirtyList[ct]->forceDirty();
     }
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 }
 
 void Allocation::incRefs(const void *ptr, size_t ct, size_t startOff) const {
@@ -602,7 +600,7 @@
 
 /////////////////
 //
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
 
 namespace android {
 namespace renderscript {
@@ -848,4 +846,4 @@
     return texAlloc;
 }
 
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
diff --git a/rsAnimation.cpp b/rsAnimation.cpp
index 6abda3c..48b4f02 100644
--- a/rsAnimation.cpp
+++ b/rsAnimation.cpp
@@ -14,12 +14,7 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
-#else
-#include "rsContextHostStub.h"
-#endif //ANDROID_RS_BUILD_FOR_HOST
-
 #include "rsAnimation.h"
 
 
diff --git a/rsComponent.cpp b/rsComponent.cpp
index cb3caf8..4c4987a 100644
--- a/rsComponent.cpp
+++ b/rsComponent.cpp
@@ -16,7 +16,7 @@
 
 #include "rsComponent.h"
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
 #include <GLES/gl.h>
 #endif
 
@@ -181,7 +181,7 @@
 }
 
 uint32_t Component::getGLType() const {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     switch (mType) {
     case RS_TYPE_UNSIGNED_5_6_5:    return GL_UNSIGNED_SHORT_5_6_5;
     case RS_TYPE_UNSIGNED_5_5_5_1:  return GL_UNSIGNED_SHORT_5_5_5_1;
@@ -195,12 +195,12 @@
     case RS_TYPE_SIGNED_16:     return GL_SHORT;
     default:    break;
     }
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
     return 0;
 }
 
 uint32_t Component::getGLFormat() const {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     switch (mKind) {
     case RS_KIND_PIXEL_L: return GL_LUMINANCE;
     case RS_KIND_PIXEL_A: return GL_ALPHA;
@@ -209,7 +209,7 @@
     case RS_KIND_PIXEL_RGBA: return GL_RGBA;
     default: break;
     }
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
     return 0;
 }
 
diff --git a/rsContext.h b/rsContext.h
index 9f94f26..c5e32a6 100644
--- a/rsContext.h
+++ b/rsContext.h
@@ -18,16 +18,16 @@
 #define ANDROID_RS_CONTEXT_H
 
 #include "rsUtils.h"
-#include "rsMutex.h"
-
-#include "rsThreadIO.h"
 #include "rsType.h"
-#include "rsMatrix.h"
 #include "rsAllocation.h"
 #include "rsMesh.h"
+
+#ifndef ANDROID_RS_SERIALIZE
+#include "rsMutex.h"
+#include "rsThreadIO.h"
+#include "rsMatrix.h"
 #include "rsDevice.h"
 #include "rsScriptC.h"
-#include "rsAllocation.h"
 #include "rsAdapter.h"
 #include "rsSampler.h"
 #include "rsFont.h"
@@ -42,6 +42,7 @@
 #include "rsLocklessFifo.h"
 
 #include <ui/egl/android_natives.h>
+#endif // ANDROID_RS_SERIALIZE
 
 // ---------------------------------------------------------------------------
 namespace android {
@@ -66,6 +67,8 @@
 #define CHECK_OBJ_OR_NULL(o)
 #endif
 
+#ifndef ANDROID_RS_SERIALIZE
+
 class Context {
 public:
     static Context * createContext(Device *, const RsSurfaceConfig *sc);
@@ -321,6 +324,39 @@
     uint32_t mAverageFPS;
 };
 
-}
-}
+#else
+
+class Context {
+public:
+    Context() {
+        mObjHead = NULL;
+    }
+    ~Context() {
+        ObjectBase::zeroAllUserRef(this);
+    }
+
+    ElementState mStateElement;
+    TypeState mStateType;
+
+    struct {
+        bool mLogTimes;
+        bool mLogScripts;
+        bool mLogObjects;
+        bool mLogShaders;
+        bool mLogShadersAttr;
+        bool mLogShadersUniforms;
+        bool mLogVisual;
+    } props;
+
+    void setError(RsError e, const char *msg = NULL) {  }
+
+    mutable const ObjectBase * mObjHead;
+
+protected:
+
+};
+#endif //ANDROID_RS_SERIALIZE
+
+} // renderscript
+} // android
 #endif
diff --git a/rsContextHostStub.h b/rsContextHostStub.h
deleted file mode 100644
index 7e8ec39..0000000
--- a/rsContextHostStub.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_CONTEXT_HOST_STUB_H
-#define ANDROID_RS_CONTEXT_HOST_STUB_H
-
-#include "rsUtils.h"
-#include "rsType.h"
-#include "rsAllocation.h"
-#include "rsMesh.h"
-#include "rsAllocation.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-#define CHECK_OBJ(o)
-#define CHECK_OBJ_OR_NULL(o)
-
-class Device;
-
-class Context {
-public:
-    Context(Device *, bool isGraphics, bool useDepth) {
-        mObjHead = NULL;
-    }
-    ~Context() {
-    }
-
-    //StructuredAllocationContext mStateAllocation;
-    ElementState mStateElement;
-    TypeState mStateType;
-    RsSurfaceConfig mUserSurfaceConfig;
-
-    //bool setupCheck();
-
-
-    uint32_t getWidth() const {return 0;}
-    uint32_t getHeight() const {return 0;}
-
-    // Timers
-    enum Timers {
-        RS_TIMER_IDLE,
-        RS_TIMER_INTERNAL,
-        RS_TIMER_SCRIPT,
-        RS_TIMER_CLEAR_SWAP,
-        _RS_TIMER_TOTAL
-    };
-
-    void timerSet(Timers) { }
-
-    bool checkVersion1_1() const {return false; }
-    bool checkVersion2_0() const {return false; }
-
-    struct {
-        bool mLogTimes;
-        bool mLogScripts;
-        bool mLogObjects;
-        bool mLogShaders;
-        bool mLogShadersAttr;
-        bool mLogShadersUniforms;
-        bool mLogVisual;
-    } props;
-
-    void dumpDebug() const {    }
-    void checkError(const char *) const {  };
-    void setError(RsError e, const char *msg = NULL) {  }
-
-    mutable const ObjectBase * mObjHead;
-
-    bool ext_OES_texture_npot() const {return mGL.OES_texture_npot;}
-    bool ext_GL_NV_texture_npot_2D_mipmap() const {return mGL.GL_NV_texture_npot_2D_mipmap;}
-    float ext_texture_max_aniso() const {return mGL.EXT_texture_max_aniso; }
-    uint32_t getMaxFragmentTextures() const {return mGL.mMaxFragmentTextureImageUnits;}
-    uint32_t getMaxFragmentUniformVectors() const {return mGL.mMaxFragmentUniformVectors;}
-    uint32_t getMaxVertexUniformVectors() const {return mGL.mMaxVertexUniformVectors;}
-    uint32_t getMaxVertexAttributes() const {return mGL.mMaxVertexAttribs;}
-
-protected:
-
-    struct {
-        const uint8_t * mVendor;
-        const uint8_t * mRenderer;
-        const uint8_t * mVersion;
-        const uint8_t * mExtensions;
-
-        uint32_t mMajorVersion;
-        uint32_t mMinorVersion;
-
-        int32_t mMaxVaryingVectors;
-        int32_t mMaxTextureImageUnits;
-
-        int32_t mMaxFragmentTextureImageUnits;
-        int32_t mMaxFragmentUniformVectors;
-
-        int32_t mMaxVertexAttribs;
-        int32_t mMaxVertexUniformVectors;
-        int32_t mMaxVertexTextureUnits;
-
-        bool OES_texture_npot;
-        bool GL_NV_texture_npot_2D_mipmap;
-        float EXT_texture_max_aniso;
-    } mGL;
-
-};
-
-}
-}
-#endif
-
diff --git a/rsDevice.cpp b/rsDevice.cpp
index dd96445..d7d03f6 100644
--- a/rsDevice.cpp
+++ b/rsDevice.cpp
@@ -15,11 +15,7 @@
  */
 
 #include "rsDevice.h"
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
-#else
-#include "rsContextHostStub.h"
-#endif
 
 using namespace android;
 using namespace android::renderscript;
diff --git a/rsElement.cpp b/rsElement.cpp
index 7c3b9e8..477cb61 100644
--- a/rsElement.cpp
+++ b/rsElement.cpp
@@ -15,11 +15,7 @@
  */
 
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
-#else
-#include "rsContextHostStub.h"
-#endif
 
 using namespace android;
 using namespace android::renderscript;
diff --git a/rsFileA3D.cpp b/rsFileA3D.cpp
index 97ce8c8..cd02c24 100644
--- a/rsFileA3D.cpp
+++ b/rsFileA3D.cpp
@@ -15,12 +15,7 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
-#else
-#include "rsContextHostStub.h"
-#endif
-
 #include "rsFileA3D.h"
 
 #include "rsMesh.h"
diff --git a/rsFont.cpp b/rsFont.cpp
index 7fdfbe0..8a5ab99 100644
--- a/rsFont.cpp
+++ b/rsFont.cpp
@@ -15,11 +15,7 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
-#else
-#include "rsContextHostStub.h"
-#endif
 
 #include "rsFont.h"
 #include "rsProgramFragment.h"
diff --git a/rsMesh.cpp b/rsMesh.cpp
index 8cf76e5..76fe62d 100644
--- a/rsMesh.cpp
+++ b/rsMesh.cpp
@@ -14,14 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
-
+#ifndef ANDROID_RS_SERIALIZE
 #include <GLES/gl.h>
 #include <GLES2/gl2.h>
 #include <GLES/glext.h>
-#else
-#include "rsContextHostStub.h"
 #endif
 
 using namespace android;
@@ -33,7 +30,7 @@
     mVertexBuffers = NULL;
     mVertexBufferCount = 0;
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     mAttribs = NULL;
     mAttribAllocationIndex = NULL;
 
@@ -53,7 +50,7 @@
         delete[] mPrimitives;
     }
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     if (mAttribs) {
         delete[] mAttribs;
         delete[] mAttribAllocationIndex;
@@ -134,7 +131,7 @@
         }
     }
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     mesh->updateGLPrimitives();
     mesh->initVertexAttribs();
     mesh->uploadAll(rsc);
@@ -142,7 +139,7 @@
     return mesh;
 }
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
 
 bool Mesh::isValidGLComponent(const Element *elem, uint32_t fieldIdx) {
     // Do not create attribs for padding
diff --git a/rsMesh.h b/rsMesh.h
index e44f90d..3e080e2 100644
--- a/rsMesh.h
+++ b/rsMesh.h
@@ -54,7 +54,7 @@
     virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_MESH; }
     static Mesh *createFromStream(Context *rsc, IStream *stream);
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
     void render(Context *) const;
     void renderPrimitive(Context *, uint32_t primIndex) const;
     void renderPrimitiveRange(Context *, uint32_t primIndex, uint32_t start, uint32_t len) const;
diff --git a/rsObjectBase.cpp b/rsObjectBase.cpp
index aec2f67..f428f94 100644
--- a/rsObjectBase.cpp
+++ b/rsObjectBase.cpp
@@ -15,13 +15,7 @@
  */
 
 #include "rsObjectBase.h"
-
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
-#else
-#include "rsContextHostStub.h"
-#endif
-
 
 using namespace android;
 using namespace android::renderscript;
diff --git a/rsProgram.cpp b/rsProgram.cpp
index 39b85e3..4ef05bf 100644
--- a/rsProgram.cpp
+++ b/rsProgram.cpp
@@ -14,15 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
+#ifndef ANDROID_RS_SERIALIZE
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
-#else
-#include "rsContextHostStub.h"
-#include <OpenGL/gl.h>
-#include <OpenGL/glext.h>
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 
 #include "rsProgram.h"
 
diff --git a/rsProgramFragment.cpp b/rsProgramFragment.cpp
index 22cd5d3..ff314b7 100644
--- a/rsProgramFragment.cpp
+++ b/rsProgramFragment.cpp
@@ -14,17 +14,13 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
+#ifndef ANDROID_RS_SERIALIZE
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
-#else
-#include "rsContextHostStub.h"
-#include <OpenGL/gl.h>
-#include <OpenGL/glext.h>
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 
 #include "rsProgramFragment.h"
 
diff --git a/rsProgramRaster.cpp b/rsProgramRaster.cpp
index f2b5b9a..ace1572 100644
--- a/rsProgramRaster.cpp
+++ b/rsProgramRaster.cpp
@@ -14,15 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
+#ifndef ANDROID_RS_SERIALIZE
 #include <GLES/gl.h>
 #include <GLES/glext.h>
-#else
-#include "rsContextHostStub.h"
-#include <OpenGL/gl.h>
-#include <OpenGl/glext.h>
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 
 #include "rsProgramRaster.h"
 
diff --git a/rsProgramStore.cpp b/rsProgramStore.cpp
index 72ac574..09b759d 100644
--- a/rsProgramStore.cpp
+++ b/rsProgramStore.cpp
@@ -14,15 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
+#ifndef ANDROID_RS_SERIALIZE
 #include <GLES/gl.h>
 #include <GLES/glext.h>
-#else
-#include "rsContextHostStub.h"
-#include <OpenGL/gl.h>
-#include <OpenGl/glext.h>
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 
 #include "rsProgramStore.h"
 
diff --git a/rsProgramVertex.cpp b/rsProgramVertex.cpp
index ad2beaf..403c2a6 100644
--- a/rsProgramVertex.cpp
+++ b/rsProgramVertex.cpp
@@ -14,17 +14,13 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
+#ifndef ANDROID_RS_SERIALIZE
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
-#else
-#include "rsContextHostStub.h"
-#include <OpenGL/gl.h>
-#include <OpenGL/glext.h>
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 
 #include "rsProgramVertex.h"
 
diff --git a/rsSampler.cpp b/rsSampler.cpp
index c80aecc..db2383a 100644
--- a/rsSampler.cpp
+++ b/rsSampler.cpp
@@ -14,15 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#include "rsContext.h"
+#ifndef ANDROID_RS_SERIALIZE
 #include <GLES/gl.h>
 #include <GLES/glext.h>
-#include "rsContext.h"
-#else
-#include "rsContextHostStub.h"
-#include <OpenGL/gl.h>
-#include <OpenGL/glext.h>
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 
 #include "rsSampler.h"
 
diff --git a/rsShaderCache.cpp b/rsShaderCache.cpp
index b958021..e8d89c2 100644
--- a/rsShaderCache.cpp
+++ b/rsShaderCache.cpp
@@ -14,14 +14,11 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
+#ifndef ANDROID_RS_SERIALIZE
 #include <GLES/gl.h>
 #include <GLES2/gl2.h>
-#else
-#include "rsContextHostStub.h"
-#include <OpenGL/gl.h>
-#endif //ANDROID_RS_BUILD_FOR_HOST
+#endif //ANDROID_RS_SERIALIZE
 
 using namespace android;
 using namespace android::renderscript;
diff --git a/rsStream.cpp b/rsStream.cpp
index 49ed567..b9df0cc 100644
--- a/rsStream.cpp
+++ b/rsStream.cpp
@@ -15,12 +15,7 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
-#else
-#include "rsContextHostStub.h"
-#endif
-
 #include "rsStream.h"
 
 using namespace android;
diff --git a/rsType.cpp b/rsType.cpp
index b94c2f8..cd2be94 100644
--- a/rsType.cpp
+++ b/rsType.cpp
@@ -14,11 +14,7 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
-#else
-#include "rsContextHostStub.h"
-#endif
 
 using namespace android;
 using namespace android::renderscript;
diff --git a/rsUtils.h b/rsUtils.h
index 0699b57..3b60af5 100644
--- a/rsUtils.h
+++ b/rsUtils.h
@@ -32,7 +32,7 @@
 #include <time.h>
 #include <cutils/atomic.h>
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
+#ifndef ANDROID_RS_SERIALIZE
 #include <EGL/egl.h>
 #endif
 
diff --git a/rsVertexArray.cpp b/rsVertexArray.cpp
index d9393fe..354ee89 100644
--- a/rsVertexArray.cpp
+++ b/rsVertexArray.cpp
@@ -14,13 +14,10 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
 #include "rsContext.h"
+#ifndef ANDROID_RS_SERIALIZE
 #include <GLES/gl.h>
 #include <GLES2/gl2.h>
-#else
-#include "rsContextHostStub.h"
-#include <OpenGL/gl.h>
 #endif
 
 using namespace android;