Fix clang-tidy performance warnings.

* Use const reference type for read-only parameters.
Bug: 30407689
Test: build with WITH_TIDY=1

Change-Id: I7c19a10f0ae0b4784851bedbcaf1c4565c6616d1
diff --git a/cpp/Element.cpp b/cpp/Element.cpp
index 9a96ad1..9b4617a 100644
--- a/cpp/Element.cpp
+++ b/cpp/Element.cpp
@@ -72,7 +72,7 @@
 }
 
 
-#define CREATE_USER(N, T) android::RSC::sp<const Element> Element::N(android::RSC::sp<RS> rs) { \
+#define CREATE_USER(N, T) android::RSC::sp<const Element> Element::N(const android::RSC::sp<RS>& rs) { \
     if (rs->mElements.N == nullptr) {                               \
         rs->mElements.N = (createUser(rs, RS_TYPE_##T));            \
     }                                                               \
@@ -100,7 +100,7 @@
 CREATE_USER(MATRIX_3X3, MATRIX_3X3);
 CREATE_USER(MATRIX_2X2, MATRIX_2X2);
 
-#define CREATE_PIXEL(N, T, K) android::RSC::sp<const Element> Element::N(android::RSC::sp<RS> rs) { \
+#define CREATE_PIXEL(N, T, K) android::RSC::sp<const Element> Element::N(const android::RSC::sp<RS> &rs) { \
     if (rs->mElements.N == nullptr) {                                \
         rs->mElements.N = createPixel(rs, RS_TYPE_##T, RS_KIND_##K); \
     }                                                                \
@@ -115,19 +115,19 @@
 CREATE_PIXEL(YUV, UNSIGNED_8, PIXEL_YUV);
 CREATE_PIXEL(RGBA_5551, UNSIGNED_5_5_5_1, PIXEL_RGBA);
 
-#define CREATE_VECTOR(N, T) android::RSC::sp<const Element> Element::N##_2(android::RSC::sp<RS> rs) { \
+#define CREATE_VECTOR(N, T) android::RSC::sp<const Element> Element::N##_2(const android::RSC::sp<RS> &rs) { \
     if (rs->mElements.N##_2 == nullptr) {                                 \
         rs->mElements.N##_2 = createVector(rs, RS_TYPE_##T, 2);           \
     }                                                                     \
     return rs->mElements.N##_2;                                           \
 }                                                                         \
-android::RSC::sp<const Element> Element::N##_3(android::RSC::sp<RS> rs) { \
+android::RSC::sp<const Element> Element::N##_3(const android::RSC::sp<RS> &rs) { \
     if (rs->mElements.N##_3 == nullptr) {                                 \
         rs->mElements.N##_3 = createVector(rs, RS_TYPE_##T, 3);           \
     }                                                                     \
     return rs->mElements.N##_3;                                           \
 } \
-android::RSC::sp<const Element> Element::N##_4(android::RSC::sp<RS> rs) { \
+android::RSC::sp<const Element> Element::N##_4(const android::RSC::sp<RS> &rs) { \
     if (rs->mElements.N##_4 == nullptr) {                                 \
         rs->mElements.N##_4 = createVector(rs, RS_TYPE_##T, 4);           \
     }                                                                     \
@@ -316,12 +316,12 @@
     updateVisibleSubElements();
 }
 
-android::RSC::sp<const Element> Element::createUser(android::RSC::sp<RS> rs, RsDataType dt) {
+android::RSC::sp<const Element> Element::createUser(const android::RSC::sp<RS>& rs, RsDataType dt) {
     void * id = RS::dispatch->ElementCreate(rs->getContext(), dt, RS_KIND_USER, false, 1);
     return new Element(id, rs, dt, RS_KIND_USER, false, 1);
 }
 
-android::RSC::sp<const Element> Element::createVector(android::RSC::sp<RS> rs, RsDataType dt, uint32_t size) {
+android::RSC::sp<const Element> Element::createVector(const android::RSC::sp<RS>& rs, RsDataType dt, uint32_t size) {
     if (size < 2 || size > 4) {
         rs->throwError(RS_ERROR_INVALID_PARAMETER, "Vector size out of range 2-4.");
         return nullptr;
@@ -330,7 +330,7 @@
     return new Element(id, rs, dt, RS_KIND_USER, false, size);
 }
 
-android::RSC::sp<const Element> Element::createPixel(android::RSC::sp<RS> rs, RsDataType dt, RsDataKind dk) {
+android::RSC::sp<const Element> Element::createPixel(const android::RSC::sp<RS>& rs, RsDataType dt, RsDataKind dk) {
     if (!(dk == RS_KIND_PIXEL_L ||
           dk == RS_KIND_PIXEL_A ||
           dk == RS_KIND_PIXEL_LA ||
@@ -388,7 +388,7 @@
     return new Element(id, rs, dt, dk, true, size);
 }
 
-bool Element::isCompatible(android::RSC::sp<const Element>e) const {
+bool Element::isCompatible(const android::RSC::sp<const Element>&e) const {
     // Try strict BaseObj equality to start with.
     if (this == e.get()) {
         return true;
@@ -429,7 +429,7 @@
     free(mArraySizes);
 }
 
-void Element::Builder::add(android::RSC::sp<const Element>e, const char * name, uint32_t arraySize) {
+void Element::Builder::add(const android::RSC::sp<const Element>&e, const char * name, uint32_t arraySize) {
     // Skip padding fields after a vector 3 type.
     if (mSkipPadding) {
         const char *s1 = "#padding_";