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);