summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpu_ref/rsCpuScript.cpp24
-rw-r--r--driver/rsdMeshObj.cpp4
-rw-r--r--driver/rsdShader.cpp32
-rw-r--r--driver/rsdShader.h20
-rw-r--r--driver/rsdShaderCache.cpp27
-rw-r--r--driver/rsdShaderCache.h4
-rw-r--r--rsCppUtils.h1
-rw-r--r--rsGrallocConsumer.h1
-rw-r--r--rsScriptC.cpp54
9 files changed, 103 insertions, 64 deletions
diff --git a/cpu_ref/rsCpuScript.cpp b/cpu_ref/rsCpuScript.cpp
index 91914888..e0b40042 100644
--- a/cpu_ref/rsCpuScript.cpp
+++ b/cpu_ref/rsCpuScript.cpp
@@ -216,9 +216,11 @@ static bool is_force_recompile() {
const static char *BCC_EXE_PATH = "/system/bin/bcc";
-static void setCompileArguments(std::vector<const char*>* args, const android::String8& bcFileName,
- const char* cacheDir, const char* resName, const char* core_lib,
- bool useRSDebugContext, const char* bccPluginName) {
+static void setCompileArguments(std::vector<const char*>* args,
+ const std::string& bcFileName,
+ const char* cacheDir, const char* resName,
+ const char* core_lib, bool useRSDebugContext,
+ const char* bccPluginName) {
rsAssert(cacheDir && resName && core_lib);
args->push_back(BCC_EXE_PATH);
args->push_back("-o");
@@ -242,27 +244,27 @@ static void setCompileArguments(std::vector<const char*>* args, const android::S
}
}
- args->push_back(bcFileName.string());
+ args->push_back(bcFileName.c_str());
args->push_back(NULL);
}
-static bool compileBitcode(const android::String8& bcFileName,
+static bool compileBitcode(const std::string &bcFileName,
const char *bitcode,
size_t bitcodeSize,
- const char** compileArguments,
- const std::string& compileCommandLine) {
+ const char **compileArguments,
+ const std::string &compileCommandLine) {
rsAssert(bitcode && bitcodeSize);
- FILE *bcfile = fopen(bcFileName.string(), "w");
+ FILE *bcfile = fopen(bcFileName.c_str(), "w");
if (!bcfile) {
- ALOGE("Could not write to %s", bcFileName.string());
+ ALOGE("Could not write to %s", bcFileName.c_str());
return false;
}
size_t nwritten = fwrite(bitcode, 1, bitcodeSize, bcfile);
fclose(bcfile);
if (nwritten != bitcodeSize) {
ALOGE("Could not write %zu bytes to %s", bitcodeSize,
- bcFileName.string());
+ bcFileName.c_str());
return false;
}
@@ -426,7 +428,7 @@ bool RsdCpuScriptImpl::init(char const *resName, char const *cacheDir,
useRSDebugContext = true;
}
- android::String8 bcFileName(cacheDir);
+ std::string bcFileName(cacheDir);
bcFileName.append("/");
bcFileName.append(resName);
bcFileName.append(".bc");
diff --git a/driver/rsdMeshObj.cpp b/driver/rsdMeshObj.cpp
index 5837c261..8f072a59 100644
--- a/driver/rsdMeshObj.cpp
+++ b/driver/rsdMeshObj.cpp
@@ -112,9 +112,9 @@ bool RsdMeshObj::init(const Context *rsc) {
mAttribs[userNum].type = rsdTypeToGLType(f->mHal.state.dataType);
mAttribs[userNum].normalized = f->mHal.state.dataType != RS_TYPE_FLOAT_32;
mAttribs[userNum].stride = stride;
- String8 tmp(RS_SHADER_ATTR);
+ std::string tmp(RS_SHADER_ATTR);
tmp.append(elem->mHal.state.fieldNames[fieldI]);
- mAttribs[userNum].name = tmp.string();
+ mAttribs[userNum].name = tmp.c_str();
// Remember which allocation this attribute came from
mAttribAllocationIndex[userNum] = ct;
diff --git a/driver/rsdShader.cpp b/driver/rsdShader.cpp
index 8a0b0153..d1a486b9 100644
--- a/driver/rsdShader.cpp
+++ b/driver/rsdShader.cpp
@@ -33,7 +33,7 @@ RsdShader::RsdShader(const Program *p, uint32_t type,
const char * shaderText, size_t shaderLength,
const char** textureNames, size_t textureNamesCount,
const size_t *textureNamesLength) {
- mUserShader.setTo(shaderText, shaderLength);
+ mUserShader.replace(0, shaderLength, shaderText);
mRSProgram = p;
mType = type;
initMemberVars();
@@ -41,7 +41,8 @@ RsdShader::RsdShader(const Program *p, uint32_t type,
init(textureNames, textureNamesCount, textureNamesLength);
for(size_t i=0; i < textureNamesCount; i++) {
- mTextureNames.push_back(String8(textureNames[i], textureNamesLength[i]));
+ mTextureNames.push_back(std::string(textureNames[i],
+ textureNamesLength[i]));
}
}
@@ -129,15 +130,15 @@ void RsdShader::init(const char** textureNames, size_t textureNamesCount,
mTextureUniformIndexStart = uniformCount;
for (uint32_t ct=0; ct < mRSProgram->mHal.state.texturesCount; ct++) {
- mUniformNames[uniformCount].setTo("UNI_");
+ mUniformNames[uniformCount] = "UNI_";
mUniformNames[uniformCount].append(textureNames[ct], textureNamesLength[ct]);
mUniformArraySizes[uniformCount] = 1;
uniformCount++;
}
}
-String8 RsdShader::getGLSLInputString() const {
- String8 s;
+std::string RsdShader::getGLSLInputString() const {
+ std::string s;
for (uint32_t ct=0; ct < mRSProgram->mHal.state.inputElementsCount; ct++) {
const Element *e = mRSProgram->mHal.state.inputElements[ct];
for (uint32_t field=0; field < e->mHal.state.fieldsCount; field++) {
@@ -237,11 +238,11 @@ bool RsdShader::loadShader(const Context *rsc) {
if (rsc->props.mLogShaders) {
ALOGV("Loading shader type %x, ID %i", mType, mCurrentState->mShaderID);
- ALOGV("%s", mShader.string());
+ ALOGV("%s", mShader.c_str());
}
if (mCurrentState->mShaderID) {
- const char * ss = mShader.string();
+ const char * ss = mShader.c_str();
RSD_CALL_GL(glShaderSource, mCurrentState->mShaderID, 1, &ss, NULL);
RSD_CALL_GL(glCompileShader, mCurrentState->mShaderID);
@@ -299,7 +300,9 @@ void RsdShader::appendUserConstants() {
mShader.append(fn);
if (e->mHal.state.fieldArraySizes[field] > 1) {
- mShader.appendFormat("[%d]", e->mHal.state.fieldArraySizes[field]);
+ mShader += "[";
+ mShader += std::to_string(e->mHal.state.fieldArraySizes[field]);
+ mShader += "]";
}
mShader.append(";\n");
}
@@ -585,27 +588,28 @@ void RsdShader::initAttribAndUniformArray() {
mUniformCount += mRSProgram->mHal.state.texturesCount;
if (mAttribCount) {
- mAttribNames = new String8[mAttribCount];
+ mAttribNames = new std::string[mAttribCount];
}
if (mUniformCount) {
- mUniformNames = new String8[mUniformCount];
+ mUniformNames = new std::string[mUniformCount];
mUniformArraySizes = new uint32_t[mUniformCount];
}
mTextureCount = mRSProgram->mHal.state.texturesCount;
}
-void RsdShader::initAddUserElement(const Element *e, String8 *names, uint32_t *arrayLengths,
- uint32_t *count, const char *prefix) {
+void RsdShader::initAddUserElement(const Element *e, std::string *names,
+ uint32_t *arrayLengths, uint32_t *count,
+ const char *prefix) {
rsAssert(e->mHal.state.fieldsCount);
for (uint32_t ct=0; ct < e->mHal.state.fieldsCount; ct++) {
const Element *ce = e->mHal.state.fields[ct];
if (ce->mHal.state.fieldsCount) {
initAddUserElement(ce, names, arrayLengths, count, prefix);
} else {
- String8 tmp(prefix);
+ std::string tmp(prefix);
tmp.append(e->mHal.state.fieldNames[ct]);
- names[*count].setTo(tmp.string());
+ names[*count] = tmp;
if (arrayLengths) {
arrayLengths[*count] = e->mHal.state.fieldArraySizes[ct];
}
diff --git a/driver/rsdShader.h b/driver/rsdShader.h
index d5076e3d..0dc5102d 100644
--- a/driver/rsdShader.h
+++ b/driver/rsdShader.h
@@ -17,7 +17,7 @@
#ifndef ANDROID_RSD_SHADER_H
#define ANDROID_RSD_SHADER_H
-#include <utils/String8.h>
+#include <string>
// ---------------------------------------------------------------------------
namespace android {
@@ -54,11 +54,11 @@ public:
uint32_t getAttribCount() const {return mAttribCount;}
uint32_t getUniformCount() const {return mUniformCount;}
- const android::String8 & getAttribName(uint32_t i) const {return mAttribNames[i];}
- const android::String8 & getUniformName(uint32_t i) const {return mUniformNames[i];}
+ const std::string & getAttribName(uint32_t i) const {return mAttribNames[i];}
+ const std::string & getUniformName(uint32_t i) const {return mUniformNames[i];}
uint32_t getUniformArraySize(uint32_t i) const {return mUniformArraySizes[i];}
- android::String8 getGLSLInputString() const;
+ std::string getGLSLInputString() const;
bool isValid() const {return mIsValid;}
void forceDirty() const {mDirty = true;}
@@ -91,7 +91,7 @@ protected:
void setupUserConstants(const android::renderscript::Context *rsc,
RsdShaderCache *sc, bool isFragment);
void initAddUserElement(const android::renderscript::Element *e,
- android::String8 *names, uint32_t *arrayLengths,
+ std::string *names, uint32_t *arrayLengths,
uint32_t *count, const char *prefix);
void setupTextures(const android::renderscript::Context *rsc, RsdShaderCache *sc);
void setupSampler(const android::renderscript::Context *rsc,
@@ -104,19 +104,19 @@ protected:
void initAttribAndUniformArray();
mutable bool mDirty;
- android::String8 mShader;
- android::String8 mUserShader;
+ std::string mShader;
+ std::string mUserShader;
uint32_t mType;
uint32_t mTextureCount;
StateBasedKey *mCurrentState;
uint32_t mAttribCount;
uint32_t mUniformCount;
- android::String8 *mAttribNames;
- android::String8 *mUniformNames;
+ std::string *mAttribNames;
+ std::string *mUniformNames;
uint32_t *mUniformArraySizes;
- std::vector<android::String8> mTextureNames;
+ std::vector<std::string> mTextureNames;
std::vector<StateBasedKey*> mStateBasedShaders;
diff --git a/driver/rsdShaderCache.cpp b/driver/rsdShaderCache.cpp
index 9eb16312..0e36b492 100644
--- a/driver/rsdShaderCache.cpp
+++ b/driver/rsdShaderCache.cpp
@@ -38,9 +38,13 @@ RsdShaderCache::~RsdShaderCache() {
cleanupAll();
}
-void RsdShaderCache::updateUniformArrayData(const Context *rsc, RsdShader *prog, uint32_t linkedID,
- UniformData *data, const char* logTag,
- UniformQueryData **uniformList, uint32_t uniListSize) {
+void RsdShaderCache::updateUniformArrayData(const Context *rsc,
+ RsdShader *prog,
+ uint32_t linkedID,
+ UniformData *data,
+ const char* logTag,
+ UniformQueryData **uniformList,
+ uint32_t uniListSize) {
for (uint32_t ct=0; ct < prog->getUniformCount(); ct++) {
if (data[ct].slot >= 0 && data[ct].arraySize > 1) {
@@ -55,14 +59,17 @@ void RsdShaderCache::updateUniformArrayData(const Context *rsc, RsdShader *prog,
if (rsc->props.mLogShaders) {
ALOGV("%s U, %s = %d, arraySize = %d\n", logTag,
- prog->getUniformName(ct).string(), data[ct].slot, data[ct].arraySize);
+ prog->getUniformName(ct).c_str(), data[ct].slot,
+ data[ct].arraySize);
}
}
}
-void RsdShaderCache::populateUniformData(RsdShader *prog, uint32_t linkedID, UniformData *data) {
+void RsdShaderCache::populateUniformData(RsdShader *prog, uint32_t linkedID,
+ UniformData *data) {
for (uint32_t ct=0; ct < prog->getUniformCount(); ct++) {
- data[ct].slot = glGetUniformLocation(linkedID, prog->getUniformName(ct));
+ data[ct].slot = glGetUniformLocation(linkedID,
+ prog->getUniformName(ct).c_str());
data[ct].arraySize = prog->getUniformArraySize(ct);
}
}
@@ -169,10 +176,12 @@ bool RsdShaderCache::link(const Context *rsc) {
}
for (uint32_t ct=0; ct < e->vtxAttrCount; ct++) {
- e->vtxAttrs[ct].slot = glGetAttribLocation(pgm, vtx->getAttribName(ct));
- e->vtxAttrs[ct].name = vtx->getAttribName(ct).string();
+ e->vtxAttrs[ct].slot =
+ glGetAttribLocation(pgm, vtx->getAttribName(ct).c_str());
+ e->vtxAttrs[ct].name = vtx->getAttribName(ct).c_str();
if (rsc->props.mLogShaders) {
- ALOGV("vtx A %i, %s = %d\n", ct, vtx->getAttribName(ct).string(), e->vtxAttrs[ct].slot);
+ ALOGV("vtx A %i, %s = %d\n", ct,
+ vtx->getAttribName(ct).c_str(), e->vtxAttrs[ct].slot);
}
}
diff --git a/driver/rsdShaderCache.h b/driver/rsdShaderCache.h
index e782fe5d..9b450921 100644
--- a/driver/rsdShaderCache.h
+++ b/driver/rsdShaderCache.h
@@ -28,9 +28,7 @@ class Context;
}
}
-#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
-#include <utils/String8.h>
-#else
+#if defined(RS_SERVER) || defined(RS_COMPATIBILITY_LIB)
#include "rsUtils.h"
#endif
class RsdShader;
diff --git a/rsCppUtils.h b/rsCppUtils.h
index 31578573..7432109c 100644
--- a/rsCppUtils.h
+++ b/rsCppUtils.h
@@ -19,7 +19,6 @@
#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
#include <utils/Log.h>
-#include <utils/String8.h>
#include <cutils/atomic.h>
#endif
diff --git a/rsGrallocConsumer.h b/rsGrallocConsumer.h
index b134862e..6f3f879f 100644
--- a/rsGrallocConsumer.h
+++ b/rsGrallocConsumer.h
@@ -23,7 +23,6 @@
#include <ui/GraphicBuffer.h>
-#include <utils/String8.h>
#include <utils/threads.h>
diff --git a/rsScriptC.cpp b/rsScriptC.cpp
index 2958e84e..96a771f1 100644
--- a/rsScriptC.cpp
+++ b/rsScriptC.cpp
@@ -31,6 +31,19 @@
#include <sys/stat.h>
+#ifdef USE_MINGW
+/* Define the default path separator for the platform. */
+#define OS_PATH_SEPARATOR '\\'
+#define OS_PATH_SEPARATOR_STR "\\"
+
+#else /* not USE_MINGW */
+
+/* Define the default path separator for the platform. */
+#define OS_PATH_SEPARATOR '/'
+#define OS_PATH_SEPARATOR_STR "/"
+
+#endif
+
using namespace android;
using namespace android::renderscript;
@@ -60,29 +73,45 @@ ScriptC::~ScriptC() {
#ifndef RS_COMPATIBILITY_LIB
bool ScriptC::createCacheDir(const char *cacheDir) {
- String8 cacheDirString, currentDir;
+ std::string currentDir;
+ const std::string cacheDirString(cacheDir);
+
struct stat statBuf;
int statReturn = stat(cacheDir, &statBuf);
if (!statReturn) {
return true;
}
- // String8 path functions strip leading /'s
- // insert if necessary
- if (cacheDir[0] == '/') {
- currentDir += "/";
- }
+ // Start from the beginning of the cacheDirString.
+ int currPos = 0;
+
+ // Reserve space in currentDir for the entire cacheDir path.
+ currentDir.reserve(cacheDirString.length());
+
+ while (currPos >= 0) {
+ /*
+ * The character at currPos should be a path separator. We need to look
+ * for the next one.
+ */
+ int nextPos = cacheDirString.find(OS_PATH_SEPARATOR_STR, currPos + 1);
+
+ if (nextPos > 0) {
+ // A new path separator has been found.
+ currentDir += cacheDirString.substr(currPos, nextPos - currPos);
+ } else {
+ // There are no more path separators.
+ currentDir += cacheDirString.substr(currPos);
+ }
+
+ currPos = nextPos;
- cacheDirString.setPathName(cacheDir);
+ statReturn = stat(currentDir.c_str(), &statBuf);
- while (cacheDirString.length()) {
- currentDir += (cacheDirString.walkPath(&cacheDirString));
- statReturn = stat(currentDir.string(), &statBuf);
if (statReturn) {
if (errno == ENOENT) {
- if (mkdir(currentDir.string(), S_IRUSR | S_IWUSR | S_IXUSR)) {
+ if (mkdir(currentDir.c_str(), S_IRUSR | S_IWUSR | S_IXUSR)) {
ALOGE("Couldn't create cache directory: %s",
- currentDir.string());
+ currentDir.c_str());
ALOGE("Error: %s", strerror(errno));
return false;
}
@@ -91,7 +120,6 @@ bool ScriptC::createCacheDir(const char *cacheDir) {
return false;
}
}
- currentDir += "/";
}
return true;
}