Preparing libRS for for compilation on host.
Change-Id: I851add79831331c8a8b20dcccdb0817f8ad0c359
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 781c24f..60b39b0 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -190,14 +190,14 @@
{
LOG_API("nContextSetSurface, con(%p), width(%i), height(%i), surface(%p)", con, width, height, (Surface *)wnd);
- Surface * window = NULL;
+ ANativeWindow * window = NULL;
if (wnd == NULL) {
} else {
- window = (Surface*) android_Surface_getNativeWindow(_env, wnd).get();
+ window = android_Surface_getNativeWindow(_env, wnd).get();
}
- rsContextSetSurface(con, width, height, window, 1);
+ rsContextSetSurface(con, width, height, window);
}
static void
diff --git a/libs/rs/RenderScriptDefines.h b/libs/rs/RenderScriptDefines.h
index 308437d..ee9645c 100644
--- a/libs/rs/RenderScriptDefines.h
+++ b/libs/rs/RenderScriptDefines.h
@@ -50,6 +50,8 @@
typedef void * RsProgramStore;
typedef void * RsProgramRaster;
+typedef void * RsNativeWindow;
+
typedef void (* RsBitmapCallback_t)(void *);
typedef struct {
diff --git a/libs/rs/driver/rsdGL.cpp b/libs/rs/driver/rsdGL.cpp
index de9fb51..a70589b 100644
--- a/libs/rs/driver/rsdGL.cpp
+++ b/libs/rs/driver/rsdGL.cpp
@@ -300,7 +300,7 @@
}
-bool rsdGLSetSurface(const Context *rsc, uint32_t w, uint32_t h, ANativeWindow *sur) {
+bool rsdGLSetSurface(const Context *rsc, uint32_t w, uint32_t h, RsNativeWindow sur) {
RsdHal *dc = (RsdHal *)rsc->mHal.drv;
EGLBoolean ret;
@@ -319,7 +319,7 @@
dc->gl.height = 1;
}
- dc->gl.wndSurface = sur;
+ dc->gl.wndSurface = (ANativeWindow *)sur;
if (dc->gl.wndSurface != NULL) {
dc->gl.width = w;
dc->gl.height = h;
diff --git a/libs/rs/driver/rsdGL.h b/libs/rs/driver/rsdGL.h
index 90cbe04..01c8438 100644
--- a/libs/rs/driver/rsdGL.h
+++ b/libs/rs/driver/rsdGL.h
@@ -18,6 +18,7 @@
#define RSD_GL_H
#include <rs_hal.h>
+#include <EGL/egl.h>
class RsdShaderCache;
class RsdVertexArrayState;
@@ -74,7 +75,7 @@
bool rsdGLInit(const android::renderscript::Context *rsc);
void rsdGLShutdown(const android::renderscript::Context *rsc);
bool rsdGLSetSurface(const android::renderscript::Context *rsc,
- uint32_t w, uint32_t h, ANativeWindow *sur);
+ uint32_t w, uint32_t h, RsNativeWindow sur);
void rsdGLSwap(const android::renderscript::Context *rsc);
void rsdGLCheckError(const android::renderscript::Context *rsc,
const char *msg, bool isFatal = false);
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index 29de5f0..4c8b5db 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -140,7 +140,7 @@
ContextSetSurface {
param uint32_t width
param uint32_t height
- param ANativeWindow *sur
+ param RsNativeWindow sur
}
ContextDump {
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index a4e1b72..d3bd0d9 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -18,8 +18,6 @@
#include "rsContext.h"
#include "rsThreadIO.h"
#include <ui/FramebufferNativeWindow.h>
-#include <ui/PixelFormat.h>
-#include <ui/egl/android_natives.h>
#include <sys/types.h>
#include <sys/resource.h>
@@ -246,7 +244,7 @@
while (!rsc->mExit) {
mDraw |= rsc->mIO.playCoreCommands(rsc, !mDraw);
mDraw &= (rsc->mRootScript.get() != NULL);
- mDraw &= (rsc->mWndSurface != NULL);
+ mDraw &= rsc->mHasSurface;
uint32_t targetTime = 0;
if (mDraw && rsc->mIsGraphicsContext) {
@@ -371,7 +369,7 @@
return false;
}
- mWndSurface = NULL;
+ mHasSurface = false;
timerInit();
timerSet(RS_TIMER_INTERNAL);
@@ -406,7 +404,6 @@
mIO.shutdown();
int status = pthread_join(mThreadId, &res);
-
if (mHal.funcs.shutdownDriver) {
mHal.funcs.shutdownDriver(this);
}
@@ -421,11 +418,11 @@
LOGV("Context::~Context done");
}
-void Context::setSurface(uint32_t w, uint32_t h, ANativeWindow *sur) {
+void Context::setSurface(uint32_t w, uint32_t h, RsNativeWindow sur) {
rsAssert(mIsGraphicsContext);
mHal.funcs.setSurface(this, w, h, sur);
- mWndSurface = sur;
+ mHasSurface = sur != NULL;
mWidth = w;
mHeight = h;
@@ -617,7 +614,7 @@
rsc->resume();
}
-void rsi_ContextSetSurface(Context *rsc, uint32_t w, uint32_t h, ANativeWindow *sur, size_t sur_length) {
+void rsi_ContextSetSurface(Context *rsc, uint32_t w, uint32_t h, RsNativeWindow sur) {
rsc->setSurface(w, h, sur);
}
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index 6336210..be615a3 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -44,8 +44,6 @@
#endif // ANDROID_RS_SERIALIZE
-class ANativeWindow;
-
// ---------------------------------------------------------------------------
namespace android {
@@ -136,7 +134,7 @@
void pause();
void resume();
- void setSurface(uint32_t w, uint32_t h, ANativeWindow *sur);
+ void setSurface(uint32_t w, uint32_t h, RsNativeWindow sur);
void setPriority(int32_t p);
void destroyWorkerThreadResources();
@@ -244,7 +242,7 @@
static void * threadProc(void *);
static void * helperThreadProc(void *);
- ANativeWindow *mWndSurface;
+ bool mHasSurface;
Vector<ObjectBase *> mNames;
diff --git a/libs/rs/rsUtils.h b/libs/rs/rsUtils.h
index 3b60af5..3a6c85a 100644
--- a/libs/rs/rsUtils.h
+++ b/libs/rs/rsUtils.h
@@ -32,10 +32,6 @@
#include <time.h>
#include <cutils/atomic.h>
-#ifndef ANDROID_RS_SERIALIZE
-#include <EGL/egl.h>
-#endif
-
#include <math.h>
#include "RenderScript.h"
diff --git a/libs/rs/rs_hal.h b/libs/rs/rs_hal.h
index cfa4e74..9d8c906 100644
--- a/libs/rs/rs_hal.h
+++ b/libs/rs/rs_hal.h
@@ -47,7 +47,7 @@
typedef struct {
bool (*initGraphics)(const Context *);
void (*shutdownGraphics)(const Context *);
- bool (*setSurface)(const Context *, uint32_t w, uint32_t h, ANativeWindow *);
+ bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow);
void (*swap)(const Context *);
void (*shutdownDriver)(Context *);