Fix google-build-using-namespace warnings in cpu_ref.
* Remove "using namespace ..." statements.
* Replace them with using declarations of the required names.
* Enclose the C++ methods and static and extern "C" functions with
namespace android and renderscript.
* Keep global C++ functions as-is and add using declarations for them.
Bug: 32670901
Test: build with WITH_TIDY=1
Change-Id: I818de466e8786a6c4f9ce0cd8e0fe027f34d7fad
diff --git a/cpu_ref/rsCpuCore.cpp b/cpu_ref/rsCpuCore.cpp
index 23ce72f..f089435 100644
--- a/cpu_ref/rsCpuCore.cpp
+++ b/cpu_ref/rsCpuCore.cpp
@@ -42,16 +42,16 @@
}
#endif
-using namespace android;
-using namespace android::renderscript;
-
#define REDUCE_ALOGV(mtls, level, ...) do { if ((mtls)->logReduce >= (level)) ALOGV(__VA_ARGS__); } while(0)
static pthread_key_t gThreadTLSKey = 0;
static uint32_t gThreadTLSKeyCount = 0;
static pthread_mutex_t gInitMutex = PTHREAD_MUTEX_INITIALIZER;
-bool android::renderscript::gArchUseSIMD = false;
+namespace android {
+namespace renderscript {
+
+bool gArchUseSIMD = false;
RsdCpuReference::~RsdCpuReference() {
}
@@ -1041,3 +1041,6 @@
}
return nullptr;
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuIntrinsic.cpp b/cpu_ref/rsCpuIntrinsic.cpp
index 4cb3f9f..6f642b2 100644
--- a/cpu_ref/rsCpuIntrinsic.cpp
+++ b/cpu_ref/rsCpuIntrinsic.cpp
@@ -17,8 +17,8 @@
#include "rsCpuIntrinsic.h"
-using namespace android;
-using namespace android::renderscript;
+namespace android {
+namespace renderscript {
RsdCpuScriptIntrinsic::RsdCpuScriptIntrinsic(RsdCpuReferenceImpl *ctx, const Script *s,
const Element *e, RsScriptIntrinsicID iid)
@@ -119,3 +119,6 @@
mtls->kernel = mRootPtr;
mtls->fep.usr = this;
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuIntrinsic3DLUT.cpp b/cpu_ref/rsCpuIntrinsic3DLUT.cpp
index add5cd8..0c6836e 100644
--- a/cpu_ref/rsCpuIntrinsic3DLUT.cpp
+++ b/cpu_ref/rsCpuIntrinsic3DLUT.cpp
@@ -18,9 +18,6 @@
#include "rsCpuIntrinsic.h"
#include "rsCpuIntrinsicInlines.h"
-using namespace android;
-using namespace android::renderscript;
-
namespace android {
namespace renderscript {
@@ -43,10 +40,6 @@
uint32_t outstep);
};
-}
-}
-
-
void RsdCpuScriptIntrinsic3DLUT::setGlobalObj(uint32_t slot, ObjectBase *data) {
rsAssert(slot == 0);
mLUT.set(static_cast<Allocation *>(data));
@@ -179,9 +172,11 @@
mLUT.clear();
}
-
RsdCpuScriptImpl * rsdIntrinsic_3DLUT(RsdCpuReferenceImpl *ctx,
const Script *s, const Element *e) {
return new RsdCpuScriptIntrinsic3DLUT(ctx, s, e);
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuIntrinsicBLAS.cpp b/cpu_ref/rsCpuIntrinsicBLAS.cpp
index 9b0a8ed..2a5ab21 100644
--- a/cpu_ref/rsCpuIntrinsicBLAS.cpp
+++ b/cpu_ref/rsCpuIntrinsicBLAS.cpp
@@ -20,9 +20,6 @@
#include "rsCpuBLASDispatch.h"
#include "eight_bit_int_gemm.h"
-using namespace android;
-using namespace android::renderscript;
-
namespace android {
namespace renderscript {
@@ -60,9 +57,6 @@
};
-}
-}
-
void RsdCpuScriptIntrinsicBLAS::populateScript(Script *s) {
s->mHal.info.exportedVariableCount = 0;
}
@@ -739,12 +733,11 @@
RsdCpuScriptIntrinsicBLAS::~RsdCpuScriptIntrinsicBLAS() {
}
-
-
-
-
RsdCpuScriptImpl * rsdIntrinsic_BLAS(RsdCpuReferenceImpl *ctx,
const Script *s, const Element *e) {
return new RsdCpuScriptIntrinsicBLAS(ctx, s);
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuIntrinsicBlend.cpp b/cpu_ref/rsCpuIntrinsicBlend.cpp
index 0b5f0c7..797bff0 100644
--- a/cpu_ref/rsCpuIntrinsicBlend.cpp
+++ b/cpu_ref/rsCpuIntrinsicBlend.cpp
@@ -18,9 +18,6 @@
#include "rsCpuIntrinsic.h"
#include "rsCpuIntrinsicInlines.h"
-using namespace android;
-using namespace android::renderscript;
-
namespace android {
namespace renderscript {
@@ -109,6 +106,9 @@
extern void rsdIntrinsicBlendSub_K(void *dst, const void *src, uint32_t count8);
#endif
+namespace android {
+namespace renderscript {
+
void RsdCpuScriptIntrinsicBlend::kernel(const RsExpandKernelDriverInfo *info,
uint32_t xstart, uint32_t xend,
uint32_t outstep) {
@@ -509,3 +509,6 @@
const Script *s, const Element *e) {
return new RsdCpuScriptIntrinsicBlend(ctx, s, e);
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuIntrinsicBlur.cpp b/cpu_ref/rsCpuIntrinsicBlur.cpp
index 9d51e68..a74a5b3 100644
--- a/cpu_ref/rsCpuIntrinsicBlur.cpp
+++ b/cpu_ref/rsCpuIntrinsicBlur.cpp
@@ -17,13 +17,9 @@
#include "rsCpuIntrinsic.h"
#include "rsCpuIntrinsicInlines.h"
-using namespace android;
-using namespace android::renderscript;
-
namespace android {
namespace renderscript {
-
class RsdCpuScriptIntrinsicBlur : public RsdCpuScriptIntrinsic {
public:
void populateScript(Script *) override;
@@ -53,9 +49,6 @@
void ComputeGaussianWeights();
};
-}
-}
-
void RsdCpuScriptIntrinsicBlur::ComputeGaussianWeights() {
memset(mFp, 0, sizeof(mFp));
@@ -148,6 +141,9 @@
out[0] = blurredPixel;
}
+} // namespace renderscript
+} // namespace android
+
extern "C" void rsdIntrinsicBlurU1_K(uchar *out, uchar const *in, size_t w, size_t h,
size_t p, size_t x, size_t y, size_t count, size_t r, uint16_t const *tab);
@@ -160,6 +156,8 @@
extern void rsdIntrinsicBlurHFU1_K(void *dst, const void *pin, const void *gptr, int rct, int x1, int ct);
#endif
+using android::renderscript::gArchUseSIMD;
+
static void OneVFU4(float4 *out,
const uchar *ptrIn, int iStride, const float* gPtr, int ct,
int x1, int x2) {
@@ -247,6 +245,9 @@
}
}
+using android::renderscript::rsMin;
+using android::renderscript::rsMax;
+
static void OneHU4(const RsExpandKernelDriverInfo *info, uchar4 *out, int32_t x,
const float4 *ptrIn, const float* gPtr, int iradius) {
@@ -278,6 +279,9 @@
}
+namespace android {
+namespace renderscript {
+
void RsdCpuScriptIntrinsicBlur::kernelU4(const RsExpandKernelDriverInfo *info,
uint32_t xstart, uint32_t xend,
uint32_t outstep) {
@@ -471,8 +475,10 @@
mAlloc.clear();
}
-
RsdCpuScriptImpl * rsdIntrinsic_Blur(RsdCpuReferenceImpl *ctx, const Script *s, const Element *e) {
return new RsdCpuScriptIntrinsicBlur(ctx, s, e);
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuIntrinsicColorMatrix.cpp b/cpu_ref/rsCpuIntrinsicColorMatrix.cpp
index 5638f84..0c3ffa2 100644
--- a/cpu_ref/rsCpuIntrinsicColorMatrix.cpp
+++ b/cpu_ref/rsCpuIntrinsicColorMatrix.cpp
@@ -101,9 +101,6 @@
-using namespace android;
-using namespace android::renderscript;
-
namespace android {
namespace renderscript {
@@ -202,9 +199,6 @@
};
-}
-}
-
Key_t RsdCpuScriptIntrinsicColorMatrix::computeKey(
const Element *ein, const Element *eout) {
@@ -316,6 +310,9 @@
return key;
}
+} // namespace renderscript
+} // namespace android
+
#if defined(ARCH_ARM_USE_INTRINSICS) && !defined(ARCH_ARM64_USE_INTRINSICS)
#define DEF_SYM(x) \
@@ -460,6 +457,8 @@
extern void rsdIntrinsicColorMatrix4x4_K(void *dst, const void *src,
const short *coef, uint32_t count);
+using android::renderscript::Key_t;
+
void * selectKernel(Key_t key)
{
void * kernel = nullptr;
@@ -478,6 +477,9 @@
}
#endif
+namespace android {
+namespace renderscript {
+
bool RsdCpuScriptIntrinsicColorMatrix::build(Key_t key) {
#if defined(ARCH_ARM_USE_INTRINSICS) && !defined(ARCH_ARM64_USE_INTRINSICS)
mBufSize = 4096;
@@ -1039,3 +1041,6 @@
return new RsdCpuScriptIntrinsicColorMatrix(ctx, s, e);
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuIntrinsicConvolve3x3.cpp b/cpu_ref/rsCpuIntrinsicConvolve3x3.cpp
index 46802fc..c2b4bd9 100644
--- a/cpu_ref/rsCpuIntrinsicConvolve3x3.cpp
+++ b/cpu_ref/rsCpuIntrinsicConvolve3x3.cpp
@@ -18,9 +18,6 @@
#include "rsCpuIntrinsic.h"
#include "rsCpuIntrinsicInlines.h"
-using namespace android;
-using namespace android::renderscript;
-
namespace android {
namespace renderscript {
@@ -62,10 +59,6 @@
uint32_t outstep);
};
-}
-}
-
-
void RsdCpuScriptIntrinsicConvolve3x3::setGlobalObj(uint32_t slot, ObjectBase *data) {
rsAssert(slot == 1);
mAlloc.set(static_cast<Allocation *>(data));
@@ -502,8 +495,10 @@
mAlloc.clear();
}
-
RsdCpuScriptImpl * rsdIntrinsic_Convolve3x3(RsdCpuReferenceImpl *ctx, const Script *s, const Element *e) {
return new RsdCpuScriptIntrinsicConvolve3x3(ctx, s, e);
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuIntrinsicConvolve5x5.cpp b/cpu_ref/rsCpuIntrinsicConvolve5x5.cpp
index 92e739f..7ea9cf8 100644
--- a/cpu_ref/rsCpuIntrinsicConvolve5x5.cpp
+++ b/cpu_ref/rsCpuIntrinsicConvolve5x5.cpp
@@ -18,9 +18,6 @@
#include "rsCpuIntrinsic.h"
#include "rsCpuIntrinsicInlines.h"
-using namespace android;
-using namespace android::renderscript;
-
namespace android {
namespace renderscript {
@@ -64,9 +61,6 @@
};
-}
-}
-
void RsdCpuScriptIntrinsicConvolve5x5::setGlobalObj(uint32_t slot, ObjectBase *data) {
rsAssert(slot == 1);
alloc.set(static_cast<Allocation *>(data));
@@ -699,9 +693,11 @@
alloc.clear();
}
-
RsdCpuScriptImpl * rsdIntrinsic_Convolve5x5(RsdCpuReferenceImpl *ctx,
const Script *s, const Element *e) {
return new RsdCpuScriptIntrinsicConvolve5x5(ctx, s, e);
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuIntrinsicHistogram.cpp b/cpu_ref/rsCpuIntrinsicHistogram.cpp
index 88d991b..f3b7146 100644
--- a/cpu_ref/rsCpuIntrinsicHistogram.cpp
+++ b/cpu_ref/rsCpuIntrinsicHistogram.cpp
@@ -17,9 +17,6 @@
#include "rsCpuIntrinsic.h"
#include "rsCpuIntrinsicInlines.h"
-using namespace android;
-using namespace android::renderscript;
-
namespace android {
namespace renderscript {
@@ -77,9 +74,6 @@
};
-}
-}
-
void RsdCpuScriptIntrinsicHistogram::setGlobalObj(uint32_t slot, ObjectBase *data) {
rsAssert(slot == 1);
mAllocOut.set(static_cast<Allocation *>(data));
@@ -324,8 +318,10 @@
void RsdCpuScriptIntrinsicHistogram::invokeFreeChildren() {
}
-
RsdCpuScriptImpl * rsdIntrinsic_Histogram(RsdCpuReferenceImpl *ctx, const Script *s, const Element *e) {
return new RsdCpuScriptIntrinsicHistogram(ctx, s, e);
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuIntrinsicLUT.cpp b/cpu_ref/rsCpuIntrinsicLUT.cpp
index b038d94..e55c062 100644
--- a/cpu_ref/rsCpuIntrinsicLUT.cpp
+++ b/cpu_ref/rsCpuIntrinsicLUT.cpp
@@ -18,9 +18,6 @@
#include "rsCpuIntrinsic.h"
#include "rsCpuIntrinsicInlines.h"
-using namespace android;
-using namespace android::renderscript;
-
namespace android {
namespace renderscript {
@@ -43,9 +40,6 @@
uint32_t outstep);
};
-}
-}
-
void RsdCpuScriptIntrinsicLUT::setGlobalObj(uint32_t slot, ObjectBase *data) {
rsAssert(slot == 0);
@@ -97,9 +91,11 @@
lut.clear();
}
-
RsdCpuScriptImpl * rsdIntrinsic_LUT(RsdCpuReferenceImpl *ctx,
const Script *s, const Element *e) {
return new RsdCpuScriptIntrinsicLUT(ctx, s, e);
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuIntrinsicResize.cpp b/cpu_ref/rsCpuIntrinsicResize.cpp
index 430edcb..ff42d79 100644
--- a/cpu_ref/rsCpuIntrinsicResize.cpp
+++ b/cpu_ref/rsCpuIntrinsicResize.cpp
@@ -18,9 +18,6 @@
#include "rsCpuIntrinsic.h"
#include "rsCpuIntrinsicInlines.h"
-using namespace android;
-using namespace android::renderscript;
-
namespace android {
namespace renderscript {
@@ -66,10 +63,6 @@
uint32_t outstep);
};
-}
-}
-
-
void RsdCpuScriptIntrinsicResize::setGlobalObj(uint32_t slot, ObjectBase *data) {
rsAssert(slot == 0);
mAlloc.set(static_cast<Allocation *>(data));
@@ -695,8 +688,10 @@
mAlloc.clear();
}
-
RsdCpuScriptImpl * rsdIntrinsic_Resize(RsdCpuReferenceImpl *ctx, const Script *s, const Element *e) {
return new RsdCpuScriptIntrinsicResize(ctx, s, e);
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuIntrinsicYuvToRGB.cpp b/cpu_ref/rsCpuIntrinsicYuvToRGB.cpp
index 6155a96..db6bd5e 100644
--- a/cpu_ref/rsCpuIntrinsicYuvToRGB.cpp
+++ b/cpu_ref/rsCpuIntrinsicYuvToRGB.cpp
@@ -26,9 +26,6 @@
#include "hardware/gralloc.h"
#endif
-using namespace android;
-using namespace android::renderscript;
-
namespace android {
namespace renderscript {
@@ -51,9 +48,6 @@
uint32_t outstep);
};
-}
-}
-
void RsdCpuScriptIntrinsicYuvToRGB::setGlobalObj(uint32_t slot, ObjectBase *data) {
rsAssert(slot == 0);
@@ -220,8 +214,10 @@
alloc.clear();
}
-
RsdCpuScriptImpl * rsdIntrinsic_YuvToRGB(RsdCpuReferenceImpl *ctx,
const Script *s, const Element *e) {
return new RsdCpuScriptIntrinsicYuvToRGB(ctx, s, e);
}
+
+} // namespace renderscript
+} // namespace android
diff --git a/cpu_ref/rsCpuRuntimeMath.cpp b/cpu_ref/rsCpuRuntimeMath.cpp
index b416462..6a8f7b6 100644
--- a/cpu_ref/rsCpuRuntimeMath.cpp
+++ b/cpu_ref/rsCpuRuntimeMath.cpp
@@ -27,8 +27,9 @@
#include "rsCpuCore.h"
#include "rsCpuScript.h"
-using namespace android;
-using namespace android::renderscript;
+using android::renderscript::Matrix2x2;
+using android::renderscript::Matrix3x3;
+using android::renderscript::Matrix4x4;
#define EXPORT_F32_FN_F32(func) \
float __attribute__((overloadable)) SC_##func(float v) { \
diff --git a/cpu_ref/rsCpuScriptGroup.cpp b/cpu_ref/rsCpuScriptGroup.cpp
index 9cc9b69..f7a330a 100644
--- a/cpu_ref/rsCpuScriptGroup.cpp
+++ b/cpu_ref/rsCpuScriptGroup.cpp
@@ -19,8 +19,8 @@
#include "rsScriptGroup.h"
#include "rsCpuScriptGroup.h"
-using namespace android;
-using namespace android::renderscript;
+namespace android {
+namespace renderscript {
CpuScriptGroupImpl::CpuScriptGroupImpl(RsdCpuReferenceImpl *ctx, const ScriptGroupBase *sg) {
mCtx = ctx;
@@ -294,3 +294,6 @@
}
}
}
+
+} // namespace renderscript
+} // namespace android