Replaced android::Vector with std::vector.
Change-Id: I4c6abd964dc4b1412ec2e592fc8e835fecfe53f6
diff --git a/driver/rsdBcc.cpp b/driver/rsdBcc.cpp
index b7c7f2e..419422a 100644
--- a/driver/rsdBcc.cpp
+++ b/driver/rsdBcc.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include <vector>
+
#include "../cpu_ref/rsd_cpu.h"
#include "rsdCore.h"
@@ -26,7 +28,6 @@
#include "rsScriptC.h"
#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
-#include "utils/Vector.h"
#include "utils/Timers.h"
#include "utils/StopWatch.h"
#endif
diff --git a/driver/rsdMeshObj.cpp b/driver/rsdMeshObj.cpp
index 66c3b18..5837c26 100644
--- a/driver/rsdMeshObj.cpp
+++ b/driver/rsdMeshObj.cpp
@@ -114,7 +114,7 @@
mAttribs[userNum].stride = stride;
String8 tmp(RS_SHADER_ATTR);
tmp.append(elem->mHal.state.fieldNames[fieldI]);
- mAttribs[userNum].name.setTo(tmp.string());
+ mAttribs[userNum].name = tmp.string();
// Remember which allocation this attribute came from
mAttribAllocationIndex[userNum] = ct;
diff --git a/driver/rsdShader.cpp b/driver/rsdShader.cpp
index 0b182ff..8a0b015 100644
--- a/driver/rsdShader.cpp
+++ b/driver/rsdShader.cpp
@@ -41,13 +41,13 @@
init(textureNames, textureNamesCount, textureNamesLength);
for(size_t i=0; i < textureNamesCount; i++) {
- mTextureNames.push(String8(textureNames[i], textureNamesLength[i]));
+ mTextureNames.push_back(String8(textureNames[i], textureNamesLength[i]));
}
}
RsdShader::~RsdShader() {
for (uint32_t i = 0; i < mStateBasedShaders.size(); i ++) {
- StateBasedKey *state = mStateBasedShaders.itemAt(i);
+ StateBasedKey *state = mStateBasedShaders[i];
if (state->mShaderID) {
glDeleteShader(state->mShaderID);
}
@@ -76,7 +76,7 @@
RsdShader::StateBasedKey *returnKey = NULL;
for (uint32_t i = 0; i < mStateBasedShaders.size(); i ++) {
- returnKey = mStateBasedShaders.itemAt(i);
+ returnKey = mStateBasedShaders[i];
for (uint32_t ct = 0; ct < mRSProgram->mHal.state.texturesCount; ct ++) {
uint32_t texType = 0;
@@ -108,7 +108,7 @@
// We have not created a shader for this particular state yet
state = new StateBasedKey(mTextureCount);
mCurrentState = state;
- mStateBasedShaders.add(state);
+ mStateBasedShaders.push_back(state);
createShader();
loadShader(rsc);
return mCurrentState->mShaderID;
diff --git a/driver/rsdShader.h b/driver/rsdShader.h
index fba1790..d5076e3 100644
--- a/driver/rsdShader.h
+++ b/driver/rsdShader.h
@@ -49,7 +49,7 @@
// Add ability to get all ID's to clean up the cached program objects
uint32_t getStateBasedIDCount() const { return mStateBasedShaders.size(); }
uint32_t getStateBasedID(uint32_t index) const {
- return mStateBasedShaders.itemAt(index)->mShaderID;
+ return mStateBasedShaders[index]->mShaderID;
}
uint32_t getAttribCount() const {return mAttribCount;}
@@ -116,9 +116,9 @@
android::String8 *mUniformNames;
uint32_t *mUniformArraySizes;
- android::Vector<android::String8> mTextureNames;
+ std::vector<android::String8> mTextureNames;
- android::Vector<StateBasedKey*> mStateBasedShaders;
+ std::vector<StateBasedKey*> mStateBasedShaders;
int32_t mTextureUniformIndexStart;
@@ -133,7 +133,3 @@
};
#endif //ANDROID_RSD_SHADER_H
-
-
-
-
diff --git a/driver/rsdShaderCache.cpp b/driver/rsdShaderCache.cpp
index 69b43fc..9eb1631 100644
--- a/driver/rsdShaderCache.cpp
+++ b/driver/rsdShaderCache.cpp
@@ -29,7 +29,7 @@
RsdShaderCache::RsdShaderCache() {
- mEntries.setCapacity(16);
+ mEntries.reserve(16);
mVertexDirty = true;
mFragmentDirty = true;
}
@@ -132,7 +132,7 @@
ProgramEntry *e = new ProgramEntry(vtx->getAttribCount(),
vtx->getUniformCount(),
frag->getUniformCount());
- mEntries.push(e);
+ mEntries.push_back(e);
mCurrent = e;
e->vtx = vID;
e->frag = fID;
@@ -228,7 +228,7 @@
return true;
}
-int32_t RsdShaderCache::vtxAttribSlot(const String8 &attrName) const {
+int32_t RsdShaderCache::vtxAttribSlot(const std::string &attrName) const {
for (uint32_t ct=0; ct < mCurrent->vtxAttrCount; ct++) {
if (attrName == mCurrent->vtxAttrs[ct].name) {
return mCurrent->vtxAttrs[ct].slot;
@@ -238,46 +238,45 @@
}
void RsdShaderCache::cleanupVertex(RsdShader *s) {
- int32_t numEntries = (int32_t)mEntries.size();
uint32_t numShaderIDs = s->getStateBasedIDCount();
for (uint32_t sId = 0; sId < numShaderIDs; sId ++) {
uint32_t id = s->getStateBasedID(sId);
- for (int32_t ct = 0; ct < numEntries; ct ++) {
- if (mEntries[ct]->vtx == id) {
- glDeleteProgram(mEntries[ct]->program);
- delete mEntries[ct];
- mEntries.removeAt(ct);
- numEntries = (int32_t)mEntries.size();
- ct --;
+ for (auto entry = mEntries.begin(); entry != mEntries.end();) {
+ if ((*entry)->vtx == id) {
+ glDeleteProgram((*entry)->program);
+
+ delete *entry;
+ entry = mEntries.erase(entry);
+ } else {
+ entry++;
}
}
}
}
void RsdShaderCache::cleanupFragment(RsdShader *s) {
- int32_t numEntries = (int32_t)mEntries.size();
uint32_t numShaderIDs = s->getStateBasedIDCount();
for (uint32_t sId = 0; sId < numShaderIDs; sId ++) {
uint32_t id = s->getStateBasedID(sId);
- for (int32_t ct = 0; ct < numEntries; ct ++) {
- if (mEntries[ct]->frag == id) {
- glDeleteProgram(mEntries[ct]->program);
- delete mEntries[ct];
- mEntries.removeAt(ct);
- numEntries = (int32_t)mEntries.size();
- ct --;
+ for (auto entry = mEntries.begin(); entry != mEntries.end();) {
+ if ((*entry)->frag == id) {
+ glDeleteProgram((*entry)->program);
+
+ delete *entry;
+ entry = mEntries.erase(entry);
+ } else {
+ entry++;
}
}
}
}
void RsdShaderCache::cleanupAll() {
- for (uint32_t ct=0; ct < mEntries.size(); ct++) {
- glDeleteProgram(mEntries[ct]->program);
- free(mEntries[ct]);
+ for (auto entry : mEntries) {
+ glDeleteProgram(entry->program);
+ delete entry;
}
mEntries.clear();
}
-
diff --git a/driver/rsdShaderCache.h b/driver/rsdShaderCache.h
index 6de1d63..e782fe5 100644
--- a/driver/rsdShaderCache.h
+++ b/driver/rsdShaderCache.h
@@ -17,6 +17,9 @@
#ifndef ANDROID_RSD_SHADER_CACHE_H
#define ANDROID_RSD_SHADER_CACHE_H
+#include <string>
+#include <vector>
+
namespace android {
namespace renderscript {
@@ -27,7 +30,6 @@
#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
#include <utils/String8.h>
-#include <utils/Vector.h>
#else
#include "rsUtils.h"
#endif
@@ -58,7 +60,7 @@
void cleanupAll();
- int32_t vtxAttribSlot(const android::String8 &attrName) const;
+ int32_t vtxAttribSlot(const std::string &attrName) const;
int32_t vtxUniformSlot(uint32_t a) const {return mCurrent->vtxUniforms[a].slot;}
uint32_t vtxUniformSize(uint32_t a) const {return mCurrent->vtxUniforms[a].arraySize;}
int32_t fragUniformSlot(uint32_t a) const {return mCurrent->fragUniforms[a].slot;}
@@ -143,7 +145,7 @@
UniformData *fragUniforms;
bool *fragUniformIsSTO;
};
- android::Vector<ProgramEntry*> mEntries;
+ std::vector<ProgramEntry*> mEntries;
ProgramEntry *mCurrent;
bool hasArrayUniforms(RsdShader *vtx, RsdShader *frag);
@@ -156,7 +158,3 @@
#endif //ANDROID_RSD_SHADER_CACHE_H
-
-
-
-
diff --git a/driver/rsdVertexArray.cpp b/driver/rsdVertexArray.cpp
index 4e293f6..d0a9b3e 100644
--- a/driver/rsdVertexArray.cpp
+++ b/driver/rsdVertexArray.cpp
@@ -48,7 +48,7 @@
stride = 0;
ptr = NULL;
normalized = false;
- name.setTo("");
+ name = "";
}
void RsdVertexArray::Attrib::set(uint32_t type, uint32_t size, uint32_t stride,
@@ -60,7 +60,7 @@
this->offset = offset;
this->normalized = normalized;
this->stride = stride;
- this->name.setTo(name);
+ this->name = name;
}
void RsdVertexArray::logAttrib(uint32_t idx, uint32_t slot) const {
@@ -69,7 +69,7 @@
}
ALOGV("va %i: slot=%i name=%s buf=%i ptr=%p size=%i type=0x%x stride=0x%x norm=%i offset=0x%p",
idx, slot,
- mAttribs[idx].name.string(),
+ mAttribs[idx].name.c_str(),
mAttribs[idx].buffer,
mAttribs[idx].ptr,
mAttribs[idx].size,
@@ -135,4 +135,3 @@
mAttrsEnabled[ct] = false;
}
}
-
diff --git a/driver/rsdVertexArray.h b/driver/rsdVertexArray.h
index 975121b..1bafe3b 100644
--- a/driver/rsdVertexArray.h
+++ b/driver/rsdVertexArray.h
@@ -17,6 +17,8 @@
#ifndef ANDROID_RSD_VERTEX_ARRAY_H
#define ANDROID_RSD_VERTEX_ARRAY_H
+#include <string>
+
#include "rsUtils.h"
namespace android {
@@ -39,7 +41,7 @@
uint32_t size;
uint32_t stride;
bool normalized;
- android::String8 name;
+ std::string name;
Attrib();
void clear();
@@ -74,6 +76,3 @@
#endif //ANDROID_RSD_VERTEX_ARRAY_H
-
-
-