Cleanup diff with compat.

Change-Id: Ieedcdec03ccb05cac68cbebbd398e07cb885f4d3
diff --git a/driver/rsdAllocation.cpp b/driver/rsdAllocation.cpp
index 090c376..25a3d55 100644
--- a/driver/rsdAllocation.cpp
+++ b/driver/rsdAllocation.cpp
@@ -17,25 +17,28 @@
 
 #include "rsdCore.h"
 #include "rsdAllocation.h"
-#include "rsdFrameBufferObj.h"
 
 #include "rsAllocation.h"
 
 #include "system/window.h"
-#include "hardware/gralloc.h"
 #include "ui/Rect.h"
 #include "ui/GraphicBufferMapper.h"
+
+#ifndef RS_COMPATIBILITY_LIB
+#include "rsdFrameBufferObj.h"
 #include "gui/GLConsumer.h"
+#include "hardware/gralloc.h"
 
 #include <GLES/gl.h>
 #include <GLES2/gl2.h>
 #include <GLES/glext.h>
+#endif
 
 using namespace android;
 using namespace android::renderscript;
 
 
-
+#ifndef RS_COMPATIBILITY_LIB
 const static GLenum gFaceOrder[] = {
     GL_TEXTURE_CUBE_MAP_POSITIVE_X,
     GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
@@ -45,7 +48,6 @@
     GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
 };
 
-
 GLenum rsdTypeToGLType(RsDataType t) {
     switch (t) {
     case RS_TYPE_UNSIGNED_5_6_5:    return GL_UNSIGNED_SHORT_5_6_5;
@@ -75,6 +77,7 @@
     }
     return 0;
 }
+#endif
 
 uint8_t *GetOffsetPtr(const android::renderscript::Allocation *alloc,
                       uint32_t xoff, uint32_t yoff, uint32_t lod,
@@ -90,6 +93,7 @@
 static void Update2DTexture(const Context *rsc, const Allocation *alloc, const void *ptr,
                             uint32_t xoff, uint32_t yoff, uint32_t lod,
                             RsAllocationCubemapFace face, uint32_t w, uint32_t h) {
+#ifndef RS_COMPATIBILITY_LIB
     DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
 
     rsAssert(drv->textureID);
@@ -100,9 +104,11 @@
         t = gFaceOrder[face];
     }
     RSD_CALL_GL(glTexSubImage2D, t, lod, xoff, yoff, w, h, drv->glFormat, drv->glType, ptr);
+#endif
 }
 
 
+#ifndef RS_COMPATIBILITY_LIB
 static void Upload2DTexture(const Context *rsc, const Allocation *alloc, bool isFirstUpload) {
     DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
 
@@ -143,8 +149,10 @@
     }
     rsdGLCheckError(rsc, "Upload2DTexture");
 }
+#endif
 
 static void UploadToTexture(const Context *rsc, const Allocation *alloc) {
+#ifndef RS_COMPATIBILITY_LIB
     DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
 
     if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_IO_INPUT) {
@@ -178,9 +186,11 @@
         }
     }
     rsdGLCheckError(rsc, "UploadToTexture");
+#endif
 }
 
 static void AllocateRenderTarget(const Context *rsc, const Allocation *alloc) {
+#ifndef RS_COMPATIBILITY_LIB
     DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
 
     if (!drv->glFormat) {
@@ -201,9 +211,11 @@
                               alloc->mHal.state.dimensionX, alloc->mHal.state.dimensionY);
     }
     rsdGLCheckError(rsc, "AllocateRenderTarget");
+#endif
 }
 
 static void UploadToBufferObject(const Context *rsc, const Allocation *alloc) {
+#ifndef RS_COMPATIBILITY_LIB
     DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
 
     rsAssert(!alloc->mHal.state.type->getDimY());
@@ -224,6 +236,7 @@
                  alloc->mHal.drvState.lod[0].mallocPtr, GL_DYNAMIC_DRAW);
     RSD_CALL_GL(glBindBuffer, drv->glTarget, 0);
     rsdGLCheckError(rsc, "UploadToBufferObject");
+#endif
 }
 
 static size_t AllocationBuildPointerTable(const Context *rsc, const Allocation *alloc,
@@ -326,8 +339,13 @@
         }
     }
 
+#ifndef RS_COMPATIBILITY_LIB
     drv->glType = rsdTypeToGLType(alloc->mHal.state.type->getElement()->getComponent().getType());
     drv->glFormat = rsdKindToGLFormat(alloc->mHal.state.type->getElement()->getComponent().getKind());
+#else
+    drv->glType = 0;
+    drv->glFormat = 0;
+#endif
 
     if (alloc->mHal.state.usageFlags & ~RS_ALLOCATION_USAGE_SCRIPT) {
         drv->uploadDeferred = true;
@@ -342,6 +360,7 @@
 void rsdAllocationDestroy(const Context *rsc, Allocation *alloc) {
     DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
 
+#ifndef RS_COMPATIBILITY_LIB
     if (drv->bufferID) {
         // Causes a SW crash....
         //ALOGV(" mBufferID %i", mBufferID);
@@ -356,6 +375,7 @@
         RSD_CALL_GL(glDeleteRenderbuffers, 1, &drv->renderTargetID);
         drv->renderTargetID = 0;
     }
+#endif
 
     if (alloc->mHal.drvState.lod[0].mallocPtr) {
         // don't free user-allocated ptrs
@@ -364,10 +384,14 @@
         }
         alloc->mHal.drvState.lod[0].mallocPtr = NULL;
     }
+
+#ifndef RS_COMPATIBILITY_LIB
     if (drv->readBackFBO != NULL) {
         delete drv->readBackFBO;
         drv->readBackFBO = NULL;
     }
+#endif
+
     free(drv);
     alloc->mHal.drv = NULL;
 }
@@ -400,6 +424,7 @@
 }
 
 static void rsdAllocationSyncFromFBO(const Context *rsc, const Allocation *alloc) {
+#ifndef RS_COMPATIBILITY_LIB
     if (!alloc->getIsScript()) {
         return; // nothing to sync
     }
@@ -428,6 +453,7 @@
 
     // Revert framebuffer to its original
     lastFbo->setActive(rsc);
+#endif
 }
 
 
@@ -472,11 +498,16 @@
 }
 
 int32_t rsdAllocationInitSurfaceTexture(const Context *rsc, const Allocation *alloc) {
+#ifndef RS_COMPATIBILITY_LIB
     DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
     UploadToTexture(rsc, alloc);
     return drv->textureID;
+#else
+    return 0;
+#endif
 }
 
+#ifndef RS_COMPATIBILITY_LIB
 static bool IoGetBuffer(const Context *rsc, Allocation *alloc, ANativeWindow *nw) {
     DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
 
@@ -499,8 +530,10 @@
 
     return true;
 }
+#endif
 
 void rsdAllocationSetSurfaceTexture(const Context *rsc, Allocation *alloc, ANativeWindow *nw) {
+#ifndef RS_COMPATIBILITY_LIB
     DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
 
     //ALOGE("rsdAllocationSetSurfaceTexture %p  %p", alloc, nw);
@@ -551,9 +584,11 @@
 
         IoGetBuffer(rsc, alloc, nw);
     }
+#endif
 }
 
 void rsdAllocationIoSend(const Context *rsc, Allocation *alloc) {
+#ifndef RS_COMPATIBILITY_LIB
     DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
     ANativeWindow *nw = alloc->mHal.state.wndSurface;
 
@@ -574,11 +609,14 @@
 
         IoGetBuffer(rsc, alloc, nw);
     }
+#endif
 }
 
 void rsdAllocationIoReceive(const Context *rsc, Allocation *alloc) {
+#ifndef RS_COMPATIBILITY_LIB
     DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
     alloc->mHal.state.surfaceTexture->updateTexImage();
+#endif
 }
 
 
diff --git a/driver/rsdAllocation.h b/driver/rsdAllocation.h
index 5f916d1..d506dc4 100644
--- a/driver/rsdAllocation.h
+++ b/driver/rsdAllocation.h
@@ -42,9 +42,15 @@
     // Is this a legal structure to be used as an FBO render target
     uint32_t renderTargetID;
 
+#ifndef RS_COMPATIBILITY_LIB
     GLenum glTarget;
     GLenum glType;
     GLenum glFormat;
+#else
+    int glTarget;
+    int glType;
+    int glFormat;
+#endif
 
     bool uploadDeferred;
 
@@ -53,8 +59,10 @@
     ANativeWindowBuffer *wndBuffer;
 };
 
+#ifndef RS_COMPATIBILITY_LIB
 GLenum rsdTypeToGLType(RsDataType t);
 GLenum rsdKindToGLFormat(RsDataKind k);
+#endif
 
 
 bool rsdAllocationInit(const android::renderscript::Context *rsc,
diff --git a/driver/rsdCore.h b/driver/rsdCore.h
index 0a46460..8b6ebf7 100644
--- a/driver/rsdCore.h
+++ b/driver/rsdCore.h
@@ -24,10 +24,13 @@
 #include "rsMutex.h"
 #include "rsSignal.h"
 
+#ifndef RS_COMPATIBILITY_LIB
 #include "rsdGL.h"
+#endif
 
 typedef void (* InvokeFunc_t)(void);
 typedef void (* ForEachFunc_t)(void);
+typedef int (* RootFunc_t)(void);
 typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
 
 typedef struct ScriptTLSStructRec {
@@ -43,7 +46,9 @@
     ScriptTLSStruct mTlsStruct;
     android::renderscript::RsdCpuReference *mCpuRef;
 
+#ifndef RS_COMPATIBILITY_LIB
     RsdGL gl;
+#endif
 } RsdHal;
 
 void rsdLaunchThreads(android::renderscript::Context *rsc, WorkerCallback_t cbk, void *data);
diff --git a/driver/rsdSampler.cpp b/driver/rsdSampler.cpp
index af48c61..96b27d4 100644
--- a/driver/rsdSampler.cpp
+++ b/driver/rsdSampler.cpp
@@ -20,12 +20,14 @@
 
 #include "rsContext.h"
 #include "rsSampler.h"
+
+#ifndef RS_COMPATIBILITY_LIB
 #include "rsProgramVertex.h"
 #include "rsProgramFragment.h"
 
 #include <GLES/gl.h>
 #include <GLES/glext.h>
-
+#endif
 
 using namespace android;
 using namespace android::renderscript;