Add flags word to context initialization.
bug 10427951
Change-Id: If3b9337712bd16655de4a42ccf829bbcd9e01b6e
diff --git a/cpp/RenderScript.cpp b/cpp/RenderScript.cpp
index fb72738..3be195f 100644
--- a/cpp/RenderScript.cpp
+++ b/cpp/RenderScript.cpp
@@ -66,8 +66,8 @@
}
}
-bool RS::init(bool forceCpu, bool synchronous) {
- return RS::init(RS_VERSION, forceCpu, synchronous);
+bool RS::init(uint32_t flags) {
+ return RS::init(RS_VERSION, flags);
}
static bool loadSymbols(void* handle) {
@@ -412,7 +412,7 @@
ALOGE("%s init failed!", filename);
return false;
}
- ALOGE("Successfully loaded %s", filename);
+ //ALOGE("Successfully loaded %s", filename);
return true;
}
@@ -460,7 +460,7 @@
return false;
}
-bool RS::init(int targetApi, bool forceCpu, bool synchronous) {
+bool RS::init(int targetApi, uint32_t flags) {
if (initDispatch(targetApi) == false) {
ALOGE("Couldn't initialize dispatch table");
return false;
@@ -472,7 +472,12 @@
return false;
}
- mContext = RS::dispatch->ContextCreate(mDev, 0, targetApi, RS_CONTEXT_TYPE_NORMAL, forceCpu, synchronous);
+ if (flags >= RS_CONTEXT_MAX) {
+ ALOGE("Invalid flags passed");
+ return false;
+ }
+
+ mContext = RS::dispatch->ContextCreate(mDev, 0, targetApi, RS_CONTEXT_TYPE_NORMAL, flags);
if (mContext == 0) {
ALOGE("Context creation failed");
return false;
diff --git a/cpp/RenderScript.h b/cpp/RenderScript.h
index 8ed8d0e..1fe7b87 100644
--- a/cpp/RenderScript.h
+++ b/cpp/RenderScript.h
@@ -20,7 +20,7 @@
#include "rsCppStructs.h"
#ifdef RS_SERVER
-#define RS_VERSION 18
+#define RS_VERSION 19
#endif
#endif
diff --git a/cpp/rsCppStructs.h b/cpp/rsCppStructs.h
index 9ec8076..f8a14ed 100644
--- a/cpp/rsCppStructs.h
+++ b/cpp/rsCppStructs.h
@@ -59,13 +59,20 @@
RS_YUV_MAX = 3
};
+ enum RSInitFlags {
+ RS_INIT_SYNCHRONOUS = 1,
+ RS_INIT_LOW_LATENCY = 2,
+ RS_INIT_MAX = 4
+ };
+
+
class RS : public android::RSC::LightRefBase<RS> {
public:
RS();
virtual ~RS();
- bool init(bool forceCpu = false, bool synchronous = false);
+ bool init(uint32_t flags);
void setErrorHandler(ErrorHandlerFunc_t func);
ErrorHandlerFunc_t getErrorHandler() { return mErrorFunc; }
@@ -86,7 +93,7 @@
static bool usingNative;
static bool initDispatch(int targetApi);
- bool init(int targetApi, bool forceCpu, bool synchronous);
+ bool init(int targetApi, uint32_t flags);
static void * threadProc(void *);
static bool gInitialized;
diff --git a/cpp/rsDispatch.h b/cpp/rsDispatch.h
index 139ef52..6e208f9 100644
--- a/cpp/rsDispatch.h
+++ b/cpp/rsDispatch.h
@@ -26,7 +26,7 @@
typedef RsDevice (*DeviceCreateFnPtr) ();
typedef void (*DeviceDestroyFnPtr) (RsDevice dev);
typedef void (*DeviceSetConfigFnPtr) (RsDevice dev, RsDeviceParam p, int32_t value);
-typedef RsContext (*ContextCreateFnPtr)(RsDevice vdev, uint32_t version, uint32_t sdkVersion, RsContextType ct, bool forceCpu, bool synchronous);
+typedef RsContext (*ContextCreateFnPtr)(RsDevice vdev, uint32_t version, uint32_t sdkVersion, RsContextType ct, uint32_t flags);
typedef void (*GetNameFnPtr)(RsContext, void * obj, const char **name);
typedef void (*ContextDestroyFnPtr) (RsContext);
diff --git a/rs.h b/rs.h
index 8a0761a..566d9ea 100644
--- a/rs.h
+++ b/rs.h
@@ -55,7 +55,7 @@
void rsDeviceDestroy(RsDevice dev);
void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value);
RsContext rsContextCreate(RsDevice dev, uint32_t version, uint32_t sdkVersion,
- RsContextType ct, bool forceCpu, bool synchronous);
+ RsContextType ct, uint32_t flags);
}
#include "rsgApiFuncDecl.h"
diff --git a/rsContext.cpp b/rsContext.cpp
index 0457595..65ee4d3 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -516,12 +516,15 @@
}
Context * Context::createContext(Device *dev, const RsSurfaceConfig *sc,
- RsContextType ct, bool forceCpu,
- bool synchronous) {
+ RsContextType ct, uint32_t flags) {
Context * rsc = new Context();
- rsc->mForceCpu = forceCpu;
- rsc->mSynchronous = synchronous;
+ if (flags & RS_CONTEXT_LOW_LATENCY) {
+ rsc->mForceCpu = true;
+ }
+ if (flags & RS_CONTEXT_SYNCHRONOUS) {
+ rsc->mSynchronous = true;
+ }
rsc->mContextType = ct;
if (!rsc->initContext(dev, sc)) {
@@ -903,10 +906,10 @@
}
extern "C" RsContext rsContextCreate(RsDevice vdev, uint32_t version, uint32_t sdkVersion,
- RsContextType ct, bool forceCpu, bool synchronous) {
+ RsContextType ct, uint32_t flags) {
//ALOGV("rsContextCreate dev=%p", vdev);
Device * dev = static_cast<Device *>(vdev);
- Context *rsc = Context::createContext(dev, NULL, ct, forceCpu, synchronous);
+ Context *rsc = Context::createContext(dev, NULL, ct, flags);
if (rsc) {
rsc->setTargetSdkVersion(sdkVersion);
}
diff --git a/rsContext.h b/rsContext.h
index a29313e..1dc7c62 100644
--- a/rsContext.h
+++ b/rsContext.h
@@ -85,7 +85,7 @@
static Context * createContext(Device *, const RsSurfaceConfig *sc,
RsContextType ct = RS_CONTEXT_TYPE_NORMAL,
- bool forceCpu = false, bool synchronous = false);
+ uint32_t flags = 0);
static Context * createContextLite();
~Context();
diff --git a/rsDefines.h b/rsDefines.h
index 0287f67..741f67b 100644
--- a/rsDefines.h
+++ b/rsDefines.h
@@ -395,6 +395,13 @@
} RsScriptCall;
+enum RsContextFlags {
+ RS_CONTEXT_SYNCHRONOUS = 1,
+ RS_CONTEXT_LOW_LATENCY = 2,
+ RS_CONTEXT_MAX = 4
+};
+
+
#ifdef __cplusplus
};
#endif