Making sure we can build libRS on the host for serialization.

Change-Id: If0a5d77b20c0e1e2d124fa0737643a5dd1d4409a
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index c598f03..2839b76c 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -21,12 +21,7 @@
 #include <GLES/glext.h>
 #else
 #include "rsContextHostStub.h"
-
-#include <OpenGL/gl.h>
-#include <OpenGl/glext.h>
-#endif
-
-#include "utils/StopWatch.h"
+#endif //ANDROID_RS_BUILD_FOR_HOST
 
 static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va);
 
@@ -83,7 +78,7 @@
         mPtr = NULL;
     }
     freeScriptMemory();
-
+#ifndef ANDROID_RS_BUILD_FOR_HOST
     if (mBufferID) {
         // Causes a SW crash....
         //LOGV(" mBufferID %i", mBufferID);
@@ -94,6 +89,7 @@
         glDeleteTextures(1, &mTextureID);
         mTextureID = 0;
     }
+#endif //ANDROID_RS_BUILD_FOR_HOST
 }
 
 void Allocation::setCpuWritable(bool) {
@@ -118,6 +114,7 @@
 }
 
 uint32_t Allocation::getGLTarget() const {
+#ifndef ANDROID_RS_BUILD_FOR_HOST
     if (getIsTexture()) {
         if (mType->getDimFaces()) {
             return GL_TEXTURE_CUBE_MAP;
@@ -128,6 +125,7 @@
     if (getIsBufferObject()) {
         return GL_ARRAY_BUFFER;
     }
+#endif //ANDROID_RS_BUILD_FOR_HOST
     return 0;
 }
 
@@ -158,7 +156,7 @@
 }
 
 void Allocation::uploadToTexture(const Context *rsc) {
-
+#ifndef ANDROID_RS_BUILD_FOR_HOST
     mUsageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE;
     GLenum type = mType->getElement()->getComponent().getGLType();
     GLenum format = mType->getElement()->getComponent().getGLFormat();
@@ -195,8 +193,10 @@
     }
 
     rsc->checkError("Allocation::uploadToTexture");
+#endif //ANDROID_RS_BUILD_FOR_HOST
 }
 
+#ifndef ANDROID_RS_BUILD_FOR_HOST
 const static GLenum gFaceOrder[] = {
     GL_TEXTURE_CUBE_MAP_POSITIVE_X,
     GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
@@ -205,10 +205,12 @@
     GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
     GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
 };
+#endif //ANDROID_RS_BUILD_FOR_HOST
 
 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
     GLenum type = mType->getElement()->getComponent().getGLType();
     GLenum format = mType->getElement()->getComponent().getGLFormat();
     GLenum target = (GLenum)getGLTarget();
@@ -220,9 +222,11 @@
         t = gFaceOrder[face];
     }
     glTexSubImage2D(t, lod, xoff, yoff, w, h, format, type, ptr);
+#endif //ANDROID_RS_BUILD_FOR_HOST
 }
 
 void Allocation::upload2DTexture(bool isFirstUpload) {
+#ifndef ANDROID_RS_BUILD_FOR_HOST
     GLenum type = mType->getElement()->getComponent().getGLType();
     GLenum format = mType->getElement()->getComponent().getGLFormat();
 
@@ -258,10 +262,9 @@
     }
 
     if (mMipmapControl == RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE) {
-#ifndef ANDROID_RS_BUILD_FOR_HOST
         glGenerateMipmap(target);
-#endif //ANDROID_RS_BUILD_FOR_HOST
     }
+#endif //ANDROID_RS_BUILD_FOR_HOST
 }
 
 void Allocation::deferedUploadToBufferObject(const Context *rsc) {
@@ -270,6 +273,7 @@
 }
 
 void Allocation::uploadToBufferObject(const Context *rsc) {
+#ifndef ANDROID_RS_BUILD_FOR_HOST
     rsAssert(!mType->getDimY());
     rsAssert(!mType->getDimZ());
 
@@ -288,6 +292,7 @@
     glBufferData(target, mType->getSizeBytes(), getPtr(), GL_DYNAMIC_DRAW);
     glBindBuffer(target, 0);
     rsc->checkError("Allocation::uploadToBufferObject");
+#endif //ANDROID_RS_BUILD_FOR_HOST
 }
 
 void Allocation::uploadCheck(Context *rsc) {
@@ -386,7 +391,7 @@
     ptr += mType->getElement()->getFieldOffsetBytes(cIdx);
 
     if (sizeBytes != e->getSizeBytes()) {
-        LOGE("Error Allocation::subElementData data size %i does not match field size %i.", sizeBytes, e->getSizeBytes());
+        LOGE("Error Allocation::subElementData data size %i does not match field size %zu.", sizeBytes, e->getSizeBytes());
         rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size.");
         return;
     }
@@ -429,7 +434,7 @@
     ptr += mType->getElement()->getFieldOffsetBytes(cIdx);
 
     if (sizeBytes != e->getSizeBytes()) {
-        LOGE("Error Allocation::subElementData data size %i does not match field size %i.", sizeBytes, e->getSizeBytes());
+        LOGE("Error Allocation::subElementData data size %i does not match field size %zu.", sizeBytes, e->getSizeBytes());
         rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size.");
         return;
     }
@@ -445,10 +450,13 @@
 }
 
 void Allocation::addProgramToDirty(const Program *p) {
+#ifndef ANDROID_RS_BUILD_FOR_HOST
     mToDirtyList.push(p);
+#endif //ANDROID_RS_BUILD_FOR_HOST
 }
 
 void Allocation::removeProgramToDirty(const Program *p) {
+#ifndef ANDROID_RS_BUILD_FOR_HOST
     for (size_t ct=0; ct < mToDirtyList.size(); ct++) {
         if (mToDirtyList[ct] == p) {
             mToDirtyList.removeAt(ct);
@@ -456,6 +464,7 @@
         }
     }
     rsAssert(0);
+#endif //ANDROID_RS_BUILD_FOR_HOST
 }
 
 void Allocation::dumpLOGV(const char *prefix) const {
@@ -530,9 +539,11 @@
 }
 
 void Allocation::sendDirty() const {
+#ifndef ANDROID_RS_BUILD_FOR_HOST
     for (size_t ct=0; ct < mToDirtyList.size(); ct++) {
         mToDirtyList[ct]->forceDirty();
     }
+#endif //ANDROID_RS_BUILD_FOR_HOST
 }
 
 void Allocation::incRefs(const void *ptr, size_t ct, size_t startOff) const {
@@ -591,7 +602,7 @@
 
 /////////////////
 //
-
+#ifndef ANDROID_RS_BUILD_FOR_HOST
 
 namespace android {
 namespace renderscript {
@@ -674,8 +685,6 @@
     }
 }
 
-#ifndef ANDROID_RS_BUILD_FOR_HOST
-
 void rsi_AllocationSyncAll(Context *rsc, RsAllocation va, RsAllocationUsageType src) {
     Allocation *a = static_cast<Allocation *>(va);
     a->syncAll(rsc, src);
@@ -739,8 +748,6 @@
     a->resize2D(rsc, dimX, dimY);
 }
 
-#endif //ANDROID_RS_BUILD_FOR_HOST
-
 }
 }
 
@@ -840,3 +847,5 @@
     texAlloc->deferedUploadToTexture(rsc);
     return texAlloc;
 }
+
+#endif //ANDROID_RS_BUILD_FOR_HOST