Remove libutils.so dependency from libRSDriver, libRSCpuRef, and most
parts of libRS_internal.
NOTE: we're resolving dependencies to provide a model for vendors.
For us, all this code is above the HAL, thus the dependencies
are acceptable; whereas for vendors, their equivalent of this code is
below the HAL, and so the dependencies are not acceptable.
This CL resolves the libutils dependency by:
- Implement the timings functions in android::renderscript namespace
using NDK APIs, instead of using libutils counterparts.
- Replace android::Vector and android::String8 by std::vector and
std::string.
- PROPERTY_VALUE_MAX is replaced as PROP_VALUE_MAX.
This CL didn't resolve the libutils dependency of rsFont.cpp and
rsDebugger.cpp in libRS_internal:
The dependent functionality in rsDebugHelper.h is off by default, and
only intended for use during development; and rsFont.cpp is part of
graphics API which is not implemented below the HAL and is not used as
a model by vendors.
Additionally, this CL fixed the bug that mNodes was sorted in a
decreasing order. Nodes in ScriptGroup should be executed in
ascending order. The bad sort was only for support lib; so there was a
previously-unknown bug in support lib implementation of ScriptGroup.
Background:
libutils contains a collection of things like Vector, String8,
CallStack. It served the purpose similar to a STL library, when there
was no stable STL implementation available in Android. And most
importantly, it is not part of NDK.
Support lib used to use our own implementations of android::Vector and
android::String8, because it can only depend on NDK, similarly for the
timing related functions.
As part of the Treble requirements, native RS, including vendor version
libRS_internal, libRSDriver, libRSCpuRef could only depend on NDK
too. So we need to break the dependency on libutils. And since we now
have reasonable support of STLs, we should use that instead.
Bug: 34396220
Test: mm, and all CTS tests pass on Bullhead;
RsTest and RSTest_CompatLib (both native and compat path) also pass.
Change-Id: Ib9a37d16235c1dcd0f5bae3b95c374e394483c91
diff --git a/driver/rsdMeshObj.cpp b/driver/rsdMeshObj.cpp
index 205acb6..1571725 100644
--- a/driver/rsdMeshObj.cpp
+++ b/driver/rsdMeshObj.cpp
@@ -26,7 +26,8 @@
#include "rsdMeshObj.h"
#include "rsdGL.h"
-using android::String8;
+#include <string>
+
using android::renderscript::Allocation;
using android::renderscript::Context;
using android::renderscript::Element;
@@ -115,9 +116,9 @@
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;
// Remember which allocation this attribute came from
mAttribAllocationIndex[userNum] = ct;
diff --git a/driver/rsdShader.cpp b/driver/rsdShader.cpp
index 6d66141..6d35cd2 100644
--- a/driver/rsdShader.cpp
+++ b/driver/rsdShader.cpp
@@ -26,7 +26,6 @@
#include "rsdShader.h"
#include "rsdShaderCache.h"
-using android::String8;
using android::renderscript::Allocation;
using android::renderscript::Context;
using android::renderscript::Element;
@@ -46,13 +45,13 @@
init(textureNames, textureNamesCount, textureNamesLength);
for(size_t i=0; i < textureNamesCount; i++) {
- mTextureNames.push(String8(textureNames[i], textureNamesLength[i]));
+ mTextureNames.push_back(std::string(textureNames[i], textureNamesLength[i]));
}
}
RsdShader::~RsdShader() {
for (uint32_t i = 0; i < mStateBasedShaders.size(); i ++) {
- StateBasedKey *state = mStateBasedShaders.itemAt(i);
+ StateBasedKey *state = mStateBasedShaders.at(i);
if (state->mShaderID) {
glDeleteShader(state->mShaderID);
}
@@ -81,7 +80,7 @@
RsdShader::StateBasedKey *returnKey = nullptr;
for (uint32_t i = 0; i < mStateBasedShaders.size(); i ++) {
- returnKey = mStateBasedShaders.itemAt(i);
+ returnKey = mStateBasedShaders.at(i);
for (uint32_t ct = 0; ct < mRSProgram->mHal.state.texturesCount; ct ++) {
uint32_t texType = 0;
@@ -113,7 +112,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 1b5c010..b52fe92 100644
--- a/driver/rsdShader.h
+++ b/driver/rsdShader.h
@@ -18,6 +18,7 @@
#define ANDROID_RSD_SHADER_H
#include <string>
+#include <vector>
// ---------------------------------------------------------------------------
namespace android {
@@ -49,7 +50,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.at(index)->mShaderID;
}
uint32_t getAttribCount() const {return mAttribCount;}
@@ -116,9 +117,9 @@
std::string *mUniformNames;
uint32_t *mUniformArraySizes;
- android::Vector<android::String8> mTextureNames;
+ std::vector<std::string> mTextureNames;
- android::Vector<StateBasedKey*> mStateBasedShaders;
+ std::vector<StateBasedKey*> mStateBasedShaders;
int32_t mTextureUniformIndexStart;
diff --git a/driver/rsdShaderCache.cpp b/driver/rsdShaderCache.cpp
index 3b82641..f62bb63 100644
--- a/driver/rsdShaderCache.cpp
+++ b/driver/rsdShaderCache.cpp
@@ -24,11 +24,10 @@
#include <GLES/gl.h>
#include <GLES2/gl2.h>
-using android::String8;
using android::renderscript::Context;
RsdShaderCache::RsdShaderCache() {
- mEntries.setCapacity(16);
+ mEntries.resize(16);
mVertexDirty = true;
mFragmentDirty = true;
}
@@ -138,7 +137,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;
@@ -236,7 +235,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;
@@ -255,7 +254,7 @@
glDeleteProgram(mEntries[ct]->program);
delete mEntries[ct];
- mEntries.removeAt(ct);
+ mEntries.erase(mEntries.begin() + ct);
numEntries = (int32_t)mEntries.size();
ct --;
}
@@ -273,7 +272,7 @@
glDeleteProgram(mEntries[ct]->program);
delete mEntries[ct];
- mEntries.removeAt(ct);
+ mEntries.erase(mEntries.begin() + ct);
numEntries = (int32_t)mEntries.size();
ct --;
}
diff --git a/driver/rsdShaderCache.h b/driver/rsdShaderCache.h
index 7e78f81..9e6c17c 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 {
@@ -52,7 +55,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;}
@@ -137,7 +140,7 @@
UniformData *fragUniforms;
bool *fragUniformIsSTO;
};
- android::Vector<ProgramEntry*> mEntries;
+ std::vector<ProgramEntry*> mEntries;
ProgramEntry *mCurrent;
bool hasArrayUniforms(RsdShader *vtx, RsdShader *frag);
diff --git a/driver/rsdVertexArray.cpp b/driver/rsdVertexArray.cpp
index 1efe3b0..987639e 100644
--- a/driver/rsdVertexArray.cpp
+++ b/driver/rsdVertexArray.cpp
@@ -47,7 +47,7 @@
stride = 0;
ptr = nullptr;
normalized = false;
- name.setTo("");
+ name.assign("");
}
void RsdVertexArray::Attrib::set(uint32_t type, uint32_t size, uint32_t stride,
@@ -59,7 +59,7 @@
this->offset = offset;
this->normalized = normalized;
this->stride = stride;
- this->name.setTo(name);
+ this->name.assign(name);
}
void RsdVertexArray::logAttrib(uint32_t idx, uint32_t slot) const {
@@ -68,7 +68,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,
diff --git a/driver/rsdVertexArray.h b/driver/rsdVertexArray.h
index 34a4663..618647a 100644
--- a/driver/rsdVertexArray.h
+++ b/driver/rsdVertexArray.h
@@ -19,6 +19,8 @@
#include "rsUtils.h"
+#include <string>
+
namespace android {
namespace renderscript {
@@ -39,7 +41,7 @@
uint32_t size;
uint32_t stride;
bool normalized;
- android::String8 name;
+ std::string name;
Attrib();
void clear();