Fix google-build-using-namespace warnings in driver.
* Replace "using namespace ..." statements with
using declarations of the required names.
* Put extern "C" functions inside a namespace to save
a lot of using declarations. Their linkage names are not
changed but can access names in the namespace easily.
Bug: 32670901
Test: build with WITH_TIDY=1
Change-Id: I7a2d45ecab47bc9064701fd288fe31f47b28fcc9
diff --git a/driver/rsdAllocation.cpp b/driver/rsdAllocation.cpp
index 3816c23..83d4407 100644
--- a/driver/rsdAllocation.cpp
+++ b/driver/rsdAllocation.cpp
@@ -44,8 +44,21 @@
#include <malloc.h>
#endif
-using namespace android;
-using namespace android::renderscript;
+#ifndef RS_COMPATIBILITY_LIB
+using android::GraphicBufferMapper;
+using android::PIXEL_FORMAT_RGBA_8888;
+using android::Rect;
+#endif
+
+using android::renderscript::Allocation;
+using android::renderscript::Context;
+using android::renderscript::Element;
+using android::renderscript::Type;
+using android::renderscript::rs_allocation;
+using android::renderscript::rsBoxFilter565;
+using android::renderscript::rsBoxFilter8888;
+using android::renderscript::rsMax;
+using android::renderscript::rsRound;
#ifndef RS_COMPATIBILITY_LIB
const static GLenum gFaceOrder[] = {
diff --git a/driver/rsdBcc.cpp b/driver/rsdBcc.cpp
index 5aa1c94..4c1f521 100644
--- a/driver/rsdBcc.cpp
+++ b/driver/rsdBcc.cpp
@@ -31,9 +31,14 @@
#include "utils/StopWatch.h"
#endif
-using namespace android;
-using namespace android::renderscript;
-
+using android::renderscript::Allocation;
+using android::renderscript::Context;
+using android::renderscript::Element;
+using android::renderscript::ObjectBase;
+using android::renderscript::RsdCpuReference;
+using android::renderscript::Script;
+using android::renderscript::ScriptC;
+using android::renderscript::rs_script;
bool rsdScriptInit(const Context *rsc,
ScriptC *script,
diff --git a/driver/rsdCore.cpp b/driver/rsdCore.cpp
index a5e942a..07ca2a6 100644
--- a/driver/rsdCore.cpp
+++ b/driver/rsdCore.cpp
@@ -44,8 +44,11 @@
#include <sys/syscall.h>
#include <string.h>
-using namespace android;
-using namespace android::renderscript;
+using android::renderscript::Allocation;
+using android::renderscript::Context;
+using android::renderscript::RsHalInitEnums;
+using android::renderscript::RsdCpuReference;
+using android::renderscript::Script;
static void Shutdown(Context *rsc);
static void SetPriority(const Context *rsc, int32_t priority);
@@ -56,6 +59,9 @@
#define NATIVE_FUNC(a) nullptr
#endif
+namespace android {
+namespace renderscript {
+
extern "C" bool rsdHalQueryHal(RsHalInitEnums entry, void **fnPtr) {
switch(entry) {
case RS_HAL_CORE_SHUTDOWN:
@@ -268,7 +274,8 @@
return true;
}
-
+} // namespace renderscript
+} // namespace android
extern const RsdCpuReference::CpuSymbol * rsdLookupRuntimeStub(Context * pContext, char const* name);
diff --git a/driver/rsdElement.cpp b/driver/rsdElement.cpp
index 06a0790..10db080 100644
--- a/driver/rsdElement.cpp
+++ b/driver/rsdElement.cpp
@@ -18,9 +18,9 @@
#include "rsdCore.h"
#include "rsElement.h"
-using namespace android;
-using namespace android::renderscript;
-
+using android::renderscript::Context;
+using android::renderscript::Element;
+using android::renderscript::rs_element;
bool rsdElementInit(const Context *, const Element *e) {
return true;
diff --git a/driver/rsdFrameBuffer.cpp b/driver/rsdFrameBuffer.cpp
index f458bf9..7617580 100644
--- a/driver/rsdFrameBuffer.cpp
+++ b/driver/rsdFrameBuffer.cpp
@@ -26,8 +26,8 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-using namespace android;
-using namespace android::renderscript;
+using android::renderscript::Context;
+using android::renderscript::FBOCache;
void setDepthAttachment(const Context *rsc, const FBOCache *fb) {
RsdFrameBufferObj *fbo = (RsdFrameBufferObj*)fb->mHal.drv;
diff --git a/driver/rsdFrameBufferObj.cpp b/driver/rsdFrameBufferObj.cpp
index 1e91c98..e7daf52 100644
--- a/driver/rsdFrameBufferObj.cpp
+++ b/driver/rsdFrameBufferObj.cpp
@@ -23,8 +23,7 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-using namespace android;
-using namespace android::renderscript;
+using android::renderscript::Context;
RsdFrameBufferObj::RsdFrameBufferObj() {
mFBOId = 0;
diff --git a/driver/rsdGL.cpp b/driver/rsdGL.cpp
index beb2cf0..689b99e 100644
--- a/driver/rsdGL.cpp
+++ b/driver/rsdGL.cpp
@@ -43,8 +43,7 @@
#include <gui/Surface.h>
-using namespace android;
-using namespace android::renderscript;
+using android::renderscript::Context;
static int32_t gGLContextCount = 0;
diff --git a/driver/rsdMesh.cpp b/driver/rsdMesh.cpp
index 01d2140..8d87b93 100644
--- a/driver/rsdMesh.cpp
+++ b/driver/rsdMesh.cpp
@@ -24,8 +24,8 @@
#include "rsdMeshObj.h"
#include "rsdShaderCache.h"
-using namespace android;
-using namespace android::renderscript;
+using android::renderscript::Context;
+using android::renderscript::Mesh;
bool rsdMeshInit(const Context *rsc, const Mesh *m) {
RsdMeshObj *drv = nullptr;
diff --git a/driver/rsdMeshObj.cpp b/driver/rsdMeshObj.cpp
index 974b41d..205acb6 100644
--- a/driver/rsdMeshObj.cpp
+++ b/driver/rsdMeshObj.cpp
@@ -26,8 +26,11 @@
#include "rsdMeshObj.h"
#include "rsdGL.h"
-using namespace android;
-using namespace android::renderscript;
+using android::String8;
+using android::renderscript::Allocation;
+using android::renderscript::Context;
+using android::renderscript::Element;
+using android::renderscript::Mesh;
RsdMeshObj::RsdMeshObj(const Context *rsc, const Mesh *rsMesh) {
mRSMesh = rsMesh;
diff --git a/driver/rsdProgram.cpp b/driver/rsdProgram.cpp
index f2b5452..cab44df 100644
--- a/driver/rsdProgram.cpp
+++ b/driver/rsdProgram.cpp
@@ -30,8 +30,11 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-using namespace android;
-using namespace android::renderscript;
+using android::renderscript::Allocation;
+using android::renderscript::Context;
+using android::renderscript::Program;
+using android::renderscript::ProgramFragment;
+using android::renderscript::ProgramVertex;
bool rsdProgramVertexInit(const Context *rsc, const ProgramVertex *pv,
const char* shader, size_t shaderLen,
diff --git a/driver/rsdProgramRaster.cpp b/driver/rsdProgramRaster.cpp
index e5a0291..823d1a8 100644
--- a/driver/rsdProgramRaster.cpp
+++ b/driver/rsdProgramRaster.cpp
@@ -25,8 +25,8 @@
#include <GLES/glext.h>
-using namespace android;
-using namespace android::renderscript;
+using android::renderscript::Context;
+using android::renderscript::ProgramRaster;
bool rsdProgramRasterInit(const Context *, const ProgramRaster *) {
return true;
diff --git a/driver/rsdProgramStore.cpp b/driver/rsdProgramStore.cpp
index 79d2fdd..8388c0f 100644
--- a/driver/rsdProgramStore.cpp
+++ b/driver/rsdProgramStore.cpp
@@ -24,9 +24,8 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
-
-using namespace android;
-using namespace android::renderscript;
+using android::renderscript::Context;
+using android::renderscript::ProgramStore;
struct DrvProgramStore {
GLenum blendSrc;
diff --git a/driver/rsdRuntimeStubs.cpp b/driver/rsdRuntimeStubs.cpp
index b7bb1aa..0c7ad96 100644
--- a/driver/rsdRuntimeStubs.cpp
+++ b/driver/rsdRuntimeStubs.cpp
@@ -32,8 +32,25 @@
#include <time.h>
-using namespace android;
-using namespace android::renderscript;
+#ifndef RS_COMPATIBILITY_LIB
+using android::renderscript::Font;
+#endif
+
+using android::renderscript::Allocation;
+using android::renderscript::Context;
+using android::renderscript::Element;
+using android::renderscript::RsdCpuReference;
+using android::renderscript::Mesh;
+using android::renderscript::ObjectBase;
+using android::renderscript::ObjectBaseRef;
+using android::renderscript::ProgramFragment;
+using android::renderscript::ProgramRaster;
+using android::renderscript::ProgramStore;
+using android::renderscript::ProgramVertex;
+using android::renderscript::Sampler;
+using android::renderscript::Script;
+using android::renderscript::Type;
+using android::renderscript::rs_object_base;
typedef __fp16 half;
typedef half half2 __attribute__((ext_vector_type(2)));
diff --git a/driver/rsdSampler.cpp b/driver/rsdSampler.cpp
index 28b594f..8436437 100644
--- a/driver/rsdSampler.cpp
+++ b/driver/rsdSampler.cpp
@@ -29,9 +29,9 @@
#include <GLES/glext.h>
#endif
-using namespace android;
-using namespace android::renderscript;
-
+using android::renderscript::Context;
+using android::renderscript::Sampler;
+using android::renderscript::rs_sampler;
bool rsdSamplerInit(const Context *, const Sampler *s) {
return true;
diff --git a/driver/rsdScriptGroup.cpp b/driver/rsdScriptGroup.cpp
index ed800a3..0c35552 100644
--- a/driver/rsdScriptGroup.cpp
+++ b/driver/rsdScriptGroup.cpp
@@ -24,9 +24,13 @@
#include "rsdBcc.h"
#include "rsdAllocation.h"
-using namespace android;
-using namespace android::renderscript;
-
+using android::renderscript::Allocation;
+using android::renderscript::Context;
+using android::renderscript::RsdCpuReference;
+using android::renderscript::ScriptGroup;
+using android::renderscript::ScriptGroupBase;
+using android::renderscript::ScriptKernelID;
+using android::renderscript::rs_script_group;
bool rsdScriptGroupInit(const Context *rsc, ScriptGroupBase *sg) {
RsdHal *dc = (RsdHal *)rsc->mHal.drv;
diff --git a/driver/rsdShader.cpp b/driver/rsdShader.cpp
index eaf679a..6d66141 100644
--- a/driver/rsdShader.cpp
+++ b/driver/rsdShader.cpp
@@ -26,8 +26,13 @@
#include "rsdShader.h"
#include "rsdShaderCache.h"
-using namespace android;
-using namespace android::renderscript;
+using android::String8;
+using android::renderscript::Allocation;
+using android::renderscript::Context;
+using android::renderscript::Element;
+using android::renderscript::Program;
+using android::renderscript::Sampler;
+using android::renderscript::rsMin;
RsdShader::RsdShader(const Program *p, uint32_t type,
const char * shaderText, size_t shaderLength,
diff --git a/driver/rsdShaderCache.cpp b/driver/rsdShaderCache.cpp
index c6052e2..3b82641 100644
--- a/driver/rsdShaderCache.cpp
+++ b/driver/rsdShaderCache.cpp
@@ -24,9 +24,8 @@
#include <GLES/gl.h>
#include <GLES2/gl2.h>
-using namespace android;
-using namespace android::renderscript;
-
+using android::String8;
+using android::renderscript::Context;
RsdShaderCache::RsdShaderCache() {
mEntries.setCapacity(16);
@@ -289,4 +288,3 @@
}
mEntries.clear();
}
-
diff --git a/driver/rsdType.cpp b/driver/rsdType.cpp
index 869a86d..8c4afd3 100644
--- a/driver/rsdType.cpp
+++ b/driver/rsdType.cpp
@@ -29,9 +29,9 @@
#include <GLES/glext.h>
#endif
-using namespace android;
-using namespace android::renderscript;
-
+using android::renderscript::Context;
+using android::renderscript::Type;
+using android::renderscript::rs_type;
bool rsdTypeInit(const Context *, const Type *t) {
return true;
diff --git a/driver/rsdVertexArray.cpp b/driver/rsdVertexArray.cpp
index 64fc3aa..1efe3b0 100644
--- a/driver/rsdVertexArray.cpp
+++ b/driver/rsdVertexArray.cpp
@@ -25,8 +25,7 @@
#include "rsdVertexArray.h"
#include "rsdShaderCache.h"
-using namespace android;
-using namespace android::renderscript;
+using android::renderscript::Context;
RsdVertexArray::RsdVertexArray(const Attrib *attribs, uint32_t numAttribs) {
mAttribs = attribs;
@@ -135,4 +134,3 @@
mAttrsEnabled[ct] = false;
}
}
-