Add named objects and implement support for ProgramFragmentStore and ProgramFragment to be used by name in scripts.
diff --git a/rsContext.cpp b/rsContext.cpp
index 82d6499..ffd03d5 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -57,14 +57,17 @@
eglQuerySurface(mDisplay, mSurface, EGL_HEIGHT, &mHeight);
}
-bool Context::runScript(Script *s)
+bool Context::runScript(Script *s, uint32_t launchID)
{
ObjectBaseRef<ProgramFragment> frag(mFragment);
ObjectBaseRef<ProgramVertex> vtx(mVertex);
ObjectBaseRef<ProgramFragmentStore> store(mFragmentStore);
+ bool ret = s->run(this, launchID);
-
+ mFragment.set(frag);
+ mVertex.set(vtx);
+ mFragmentStore.set(store);
return true;
}
@@ -107,7 +110,7 @@
glClear(GL_COLOR_BUFFER_BIT);
glClear(GL_DEPTH_BUFFER_BIT);
- return mRootScript->run(this, 0);
+ return runScript(mRootScript.get(), 0);
}
void Context::setupCheck()
@@ -243,6 +246,33 @@
pv->setupGL();
}
+void Context::assignName(ObjectBase *obj, const char *name)
+{
+ rsAssert(!obj->getName());
+ obj->setName(name);
+ mNames.add(obj);
+}
+
+void Context::removeName(ObjectBase *obj)
+{
+ for(size_t ct=0; ct < mNames.size(); ct++) {
+ if (obj == mNames[ct]) {
+ mNames.removeAt(ct);
+ return;
+ }
+ }
+}
+
+ObjectBase * Context::lookupName(const char *name) const
+{
+ for(size_t ct=0; ct < mNames.size(); ct++) {
+ if (!strcmp(name, mNames[ct]->getName())) {
+ return mNames[ct];
+ }
+ }
+ return NULL;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////
//
@@ -286,6 +316,11 @@
rsc->setVertex(pv);
}
+void rsi_AssignName(Context *rsc, void * obj, const char *name)
+{
+ ObjectBase *ob = static_cast<ObjectBase *>(obj);
+ rsc->assignName(ob, name);
+}
}