Removed unnecessary change based on comments.
Now using android utils lib.
collada_to_a3d seems to work with android util libs.
Integrating old changelist
Changing assert to rsAssrt in VertexArray
making context compile.
Change-Id: I33890defa777f09253bfab630d97782359ec49d7
Added serialization code to rsLib
Integrated old changelist
Change-Id: Ie4746113f6d1817fbb3264f97fdddde25b779311
Added serialization code to rsLib
Change-Id: Ie4746113f6d1817fbb3264f97fdddde25b779311
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index e5ff1d7..4db6a04 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -13,12 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+#ifndef ANDROID_RS_BUILD_FOR_HOST
#include "rsContext.h"
#include <GLES/gl.h>
#include <GLES2/gl2.h>
#include <GLES/glext.h>
+#else
+#include "rsContextHostStub.h"
+
+#include <OpenGL/gl.h>
+#include <OpenGl/glext.h>
+#endif
using namespace android;
using namespace android::renderscript;
@@ -167,7 +173,9 @@
0, format, type, ptr);
}
if (mTextureGenMipmap) {
+#ifndef ANDROID_RS_BUILD_FOR_HOST
glGenerateMipmap(GL_TEXTURE_2D);
+#endif //ANDROID_RS_BUILD_FOR_HOST
}
rsc->checkError("Allocation::uploadToTexture");
@@ -286,7 +294,7 @@
void Allocation::addProgramToDirty(const Program *p)
{
- mToDirtyList.add(p);
+ mToDirtyList.push(p);
}
void Allocation::removeProgramToDirty(const Program *p)
@@ -318,6 +326,60 @@
}
+void Allocation::serialize(OStream *stream) const
+{
+ // Need to identify ourselves
+ stream->addU32((uint32_t)getClassId());
+
+ String8 name(getName());
+ stream->addString(&name);
+
+ // First thing we need to serialize is the type object since it will be needed
+ // to initialize the class
+ mType->serialize(stream);
+
+ uint32_t dataSize = mType->getSizeBytes();
+ // Write how much data we are storing
+ stream->addU32(dataSize);
+ // Now write the data
+ stream->addByteArray(mPtr, dataSize);
+}
+
+Allocation *Allocation::createFromStream(Context *rsc, IStream *stream)
+{
+ // First make sure we are reading the correct object
+ A3DClassID classID = (A3DClassID)stream->loadU32();
+ if(classID != A3D_CLASS_ID_ALLOCATION) {
+ LOGE("allocation loading skipped due to invalid class id\n");
+ return NULL;
+ }
+
+ String8 name;
+ stream->loadString(&name);
+
+ Type *type = Type::createFromStream(rsc, stream);
+ if(!type) {
+ return NULL;
+ }
+ type->compute();
+
+ // Number of bytes we wrote out for this allocation
+ uint32_t dataSize = stream->loadU32();
+ if(dataSize != type->getSizeBytes()) {
+ LOGE("failed to read allocation because numbytes written is not the same loaded type wants\n");
+ delete type;
+ return NULL;
+ }
+
+ Allocation *alloc = new Allocation(rsc, type);
+ alloc->setName(name.string(), name.size());
+
+ // Read in all of our allocation data
+ stream->loadByteArray(alloc->getPtr(), dataSize);
+
+ return alloc;
+}
+
void Allocation::sendDirty() const
{
for (size_t ct=0; ct < mToDirtyList.size(); ct++) {
@@ -514,6 +576,8 @@
return 0;
}
+#ifndef ANDROID_RS_BUILD_FOR_HOST
+
RsAllocation rsi_AllocationCreateBitmapRef(Context *rsc, RsType vtype,
void *bmp, void *callbackData, RsBitmapCallback_t callback)
{
@@ -615,6 +679,7 @@
a->read(data);
}
+#endif //ANDROID_RS_BUILD_FOR_HOST
}
}