diff options
Diffstat (limited to 'libs/rs/rsComponent.cpp')
-rw-r--r-- | libs/rs/rsComponent.cpp | 110 |
1 files changed, 34 insertions, 76 deletions
diff --git a/libs/rs/rsComponent.cpp b/libs/rs/rsComponent.cpp index 15a56f7..fbaa75f 100644 --- a/libs/rs/rsComponent.cpp +++ b/libs/rs/rsComponent.cpp @@ -16,7 +16,11 @@ #include "rsComponent.h" +#ifndef ANDROID_RS_BUILD_FOR_HOST #include <GLES/gl.h> +#else +#include <OpenGL/gl.h> +#endif using namespace android; using namespace android::renderscript; @@ -148,11 +152,19 @@ void Component::set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize) case RS_TYPE_UNSIGNED_64: mTypeBits = 64; break; + + case RS_TYPE_BOOLEAN: + mTypeBits = 8; + break; } mBits = mTypeBits * mVectorSize; } +bool Component::isReference() const +{ + return (mType >= RS_TYPE_ELEMENT); +} @@ -188,82 +200,6 @@ uint32_t Component::getGLFormat() const return 0; } -static const char * gCTypeStrings[] = { - 0, - 0,//"F16", - "float", - "double", - "char", - "short", - "int", - 0,//"S64", - "char",//U8", - "short",//U16", - "int",//U32", - 0,//"U64", - 0,//"UP_565", - 0,//"UP_5551", - 0,//"UP_4444", - 0,//"ELEMENT", - 0,//"TYPE", - 0,//"ALLOCATION", - 0,//"SAMPLER", - 0,//"SCRIPT", - 0,//"MESH", - 0,//"PROGRAM_FRAGMENT", - 0,//"PROGRAM_VERTEX", - 0,//"PROGRAM_RASTER", - 0,//"PROGRAM_STORE", -}; - -static const char * gCVecTypeStrings[] = { - 0, - 0,//"F16", - "vecF32", - "vecF64", - "vecI8", - "vecI16", - "vecI32", - 0,//"S64", - "vecU8",//U8", - "vecU16",//U16", - "vecU32",//U32", - 0,//"U64", - 0,//"UP_565", - 0,//"UP_5551", - 0,//"UP_4444", - 0,//"ELEMENT", - 0,//"TYPE", - 0,//"ALLOCATION", - 0,//"SAMPLER", - 0,//"SCRIPT", - 0,//"MESH", - 0,//"PROGRAM_FRAGMENT", - 0,//"PROGRAM_VERTEX", - 0,//"PROGRAM_RASTER", - 0,//"PROGRAM_STORE", -}; - -String8 Component::getCType() const -{ - char buf[64]; - if (mVectorSize == 1) { - return String8(gCTypeStrings[mType]); - } - - // Yuck, acc WAR - // Appears to have problems packing chars - if (mVectorSize == 4 && mType == RS_TYPE_UNSIGNED_8) { - return String8("int"); - } - - - String8 s(gCVecTypeStrings[mType]); - sprintf(buf, "_%i_t", mVectorSize); - s.append(buf); - return s; -} - String8 Component::getGLSLType() const { if (mType == RS_TYPE_SIGNED_32) { @@ -298,6 +234,7 @@ static const char * gTypeStrings[] = { "U16", "U32", "U64", + "BOOLEAN", "UP_565", "UP_5551", "UP_4444", @@ -334,4 +271,25 @@ void Component::dumpLOGV(const char *prefix) const prefix, gTypeStrings[mType], gKindStrings[mKind], mVectorSize, mBits); } +void Component::serialize(OStream *stream) const +{ + stream->addU8((uint8_t)mType); + stream->addU8((uint8_t)mKind); + stream->addU8((uint8_t)(mNormalized ? 1 : 0)); + stream->addU32(mVectorSize); +} + +void Component::loadFromStream(IStream *stream) +{ + mType = (RsDataType)stream->loadU8(); + mKind = (RsDataKind)stream->loadU8(); + uint8_t temp = stream->loadU8(); + mNormalized = temp != 0; + mVectorSize = stream->loadU32(); + + set(mType, mKind, mNormalized, mVectorSize); +} + + + |