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/ScriptIntrinsics.cpp b/cpp/ScriptIntrinsics.cpp
index 38224e6..b1a6dcf 100644
--- a/cpp/ScriptIntrinsics.cpp
+++ b/cpp/ScriptIntrinsics.cpp
@@ -33,7 +33,7 @@
 
 }
 
-sp<ScriptIntrinsic3DLUT> ScriptIntrinsic3DLUT::create(sp<RS> rs, sp<const Element> e) {
+sp<ScriptIntrinsic3DLUT> ScriptIntrinsic3DLUT::create(const sp<RS>& rs, const sp<const Element>& e) {
     if (e->isCompatible(Element::U8_4(rs)) == false) {
         rs->throwError(RS_ERROR_INVALID_ELEMENT, "Element not supported for intrinsic");
         return nullptr;
@@ -45,7 +45,7 @@
     : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_3DLUT, e) {
 
 }
-void ScriptIntrinsic3DLUT::forEach(sp<Allocation> ain, sp<Allocation> aout) {
+void ScriptIntrinsic3DLUT::forEach(const sp<Allocation>& ain, const sp<Allocation>& aout) {
     if (ain->getType()->getElement()->isCompatible(mElement) == false ||
         aout->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "3DLUT forEach element mismatch");
@@ -53,7 +53,7 @@
     }
     Script::forEach(0, ain, aout, nullptr, 0);
 }
-void ScriptIntrinsic3DLUT::setLUT(sp<Allocation> lut) {
+void ScriptIntrinsic3DLUT::setLUT(const sp<Allocation>& lut) {
     sp<const Type> t = lut->getType();
     if (!t->getElement()->isCompatible(mElement)) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "setLUT element does not match");
@@ -67,7 +67,7 @@
     Script::setVar(0, lut);
 }
 
-sp<ScriptIntrinsicBlend> ScriptIntrinsicBlend::create(sp<RS> rs, sp<const Element> e) {
+sp<ScriptIntrinsicBlend> ScriptIntrinsicBlend::create(const sp<RS>& rs, const sp<const Element>& e) {
     if (e->isCompatible(Element::U8_4(rs)) == false) {
         rs->throwError(RS_ERROR_INVALID_ELEMENT, "Element not supported for intrinsic");
         return nullptr;
@@ -79,7 +79,7 @@
     : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_BLEND, e) {
 }
 
-void ScriptIntrinsicBlend::forEachClear(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachClear(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -87,7 +87,7 @@
     Script::forEach(0, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachSrc(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachSrc(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -95,7 +95,7 @@
     Script::forEach(1, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachDst(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachDst(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -103,7 +103,7 @@
     Script::forEach(2, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachSrcOver(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachSrcOver(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -111,7 +111,7 @@
     Script::forEach(3, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachDstOver(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachDstOver(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -119,7 +119,7 @@
     Script::forEach(4, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachSrcIn(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachSrcIn(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -127,7 +127,7 @@
     Script::forEach(5, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachDstIn(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachDstIn(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -135,7 +135,7 @@
     Script::forEach(6, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachSrcOut(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachSrcOut(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -143,7 +143,7 @@
     Script::forEach(7, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachDstOut(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachDstOut(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -151,7 +151,7 @@
     Script::forEach(8, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachSrcAtop(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachSrcAtop(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -159,7 +159,7 @@
     Script::forEach(9, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachDstAtop(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachDstAtop(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -167,7 +167,7 @@
     Script::forEach(10, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachXor(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachXor(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -175,7 +175,7 @@
     Script::forEach(11, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachMultiply(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachMultiply(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -183,7 +183,7 @@
     Script::forEach(14, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachAdd(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachAdd(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -191,7 +191,7 @@
     Script::forEach(34, in, out, nullptr, 0);
 }
 
-void ScriptIntrinsicBlend::forEachSubtract(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicBlend::forEachSubtract(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (in->getType()->getElement()->isCompatible(mElement) == false ||
         out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blend");
@@ -202,7 +202,7 @@
 
 
 
-sp<ScriptIntrinsicBlur> ScriptIntrinsicBlur::create(sp<RS> rs, sp<const Element> e) {
+sp<ScriptIntrinsicBlur> ScriptIntrinsicBlur::create(const sp<RS>& rs, const sp<const Element>& e) {
     if ((e->isCompatible(Element::U8_4(rs)) == false) &&
         (e->isCompatible(Element::U8(rs)) == false)) {
         rs->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blur");
@@ -216,7 +216,7 @@
 
 }
 
-void ScriptIntrinsicBlur::setInput(sp<Allocation> in) {
+void ScriptIntrinsicBlur::setInput(const sp<Allocation>& in) {
     if (in->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blur input");
         return;
@@ -224,7 +224,7 @@
     Script::setVar(1, in);
 }
 
-void ScriptIntrinsicBlur::forEach(sp<Allocation> out) {
+void ScriptIntrinsicBlur::forEach(const sp<Allocation>& out) {
     if (out->getType()->getElement()->isCompatible(mElement) == false) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element in blur output");
         return;
@@ -242,7 +242,7 @@
 
 
 
-sp<ScriptIntrinsicColorMatrix> ScriptIntrinsicColorMatrix::create(sp<RS> rs) {
+sp<ScriptIntrinsicColorMatrix> ScriptIntrinsicColorMatrix::create(const sp<RS>& rs) {
     return new ScriptIntrinsicColorMatrix(rs, Element::RGBA_8888(rs));
 }
 
@@ -253,7 +253,7 @@
 
 }
 
-void ScriptIntrinsicColorMatrix::forEach(sp<Allocation> in, sp<Allocation> out) {
+void ScriptIntrinsicColorMatrix::forEach(const sp<Allocation>& in, const sp<Allocation>& out) {
     if (!(in->getType()->getElement()->isCompatible(Element::U8(mRS))) &&
         !(in->getType()->getElement()->isCompatible(Element::U8_2(mRS))) &&
         !(in->getType()->getElement()->isCompatible(Element::U8_3(mRS))) &&
@@ -335,7 +335,7 @@
 
 
 
-sp<ScriptIntrinsicConvolve3x3> ScriptIntrinsicConvolve3x3::create(sp<RS> rs, sp<const Element> e) {
+sp<ScriptIntrinsicConvolve3x3> ScriptIntrinsicConvolve3x3::create(const sp<RS>& rs, const sp<const Element>& e) {
     if (!(e->isCompatible(Element::U8(rs))) &&
         !(e->isCompatible(Element::U8_2(rs))) &&
         !(e->isCompatible(Element::U8_3(rs))) &&
@@ -356,7 +356,7 @@
 
 }
 
-void ScriptIntrinsicConvolve3x3::setInput(sp<Allocation> in) {
+void ScriptIntrinsicConvolve3x3::setInput(const sp<Allocation>& in) {
     if (!(in->getType()->getElement()->isCompatible(mElement))) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Element mismatch in Convolve3x3");
         return;
@@ -364,7 +364,7 @@
     Script::setVar(1, in);
 }
 
-void ScriptIntrinsicConvolve3x3::forEach(sp<Allocation> out) {
+void ScriptIntrinsicConvolve3x3::forEach(const sp<Allocation>& out) {
     if (!(out->getType()->getElement()->isCompatible(mElement))) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Element mismatch in Convolve3x3");
         return;
@@ -376,7 +376,7 @@
     Script::setVar(0, (void*)v, sizeof(float) * 9);
 }
 
-sp<ScriptIntrinsicConvolve5x5> ScriptIntrinsicConvolve5x5::create(sp<RS> rs, sp<const Element> e) {
+sp<ScriptIntrinsicConvolve5x5> ScriptIntrinsicConvolve5x5::create(const sp<RS>& rs, const sp<const Element>& e) {
     if (!(e->isCompatible(Element::U8(rs))) &&
         !(e->isCompatible(Element::U8_2(rs))) &&
         !(e->isCompatible(Element::U8_3(rs))) &&
@@ -397,7 +397,7 @@
 
 }
 
-void ScriptIntrinsicConvolve5x5::setInput(sp<Allocation> in) {
+void ScriptIntrinsicConvolve5x5::setInput(const sp<Allocation>& in) {
     if (!(in->getType()->getElement()->isCompatible(mElement))) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Element mismatch in Convolve5x5 input");
         return;
@@ -405,7 +405,7 @@
     Script::setVar(1, in);
 }
 
-void ScriptIntrinsicConvolve5x5::forEach(sp<Allocation> out) {
+void ScriptIntrinsicConvolve5x5::forEach(const sp<Allocation>& out) {
     if (!(out->getType()->getElement()->isCompatible(mElement))) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Element mismatch in Convolve5x5 output");
         return;
@@ -418,7 +418,7 @@
     Script::setVar(0, (void*)v, sizeof(float) * 25);
 }
 
-sp<ScriptIntrinsicHistogram> ScriptIntrinsicHistogram::create(sp<RS> rs, sp<const Element> e) {
+sp<ScriptIntrinsicHistogram> ScriptIntrinsicHistogram::create(const sp<RS>& rs, const sp<const Element>& e) {
     return new ScriptIntrinsicHistogram(rs, e);
 }
 
@@ -427,7 +427,7 @@
 
 }
 
-void ScriptIntrinsicHistogram::setOutput(sp<Allocation> out) {
+void ScriptIntrinsicHistogram::setOutput(const sp<Allocation>& out) {
     if (!(out->getType()->getElement()->isCompatible(Element::U32(mRS))) &&
         !(out->getType()->getElement()->isCompatible(Element::U32_2(mRS))) &&
         !(out->getType()->getElement()->isCompatible(Element::U32_3(mRS))) &&
@@ -467,7 +467,7 @@
 
 }
 
-void ScriptIntrinsicHistogram::forEach(sp<Allocation> ain) {
+void ScriptIntrinsicHistogram::forEach(const sp<Allocation>& ain) {
     if (ain->getType()->getElement()->getVectorSize() <
         mOut->getType()->getElement()->getVectorSize()) {
         mRS->throwError(RS_ERROR_INVALID_PARAMETER,
@@ -486,7 +486,7 @@
 }
 
 
-void ScriptIntrinsicHistogram::forEach_dot(sp<Allocation> ain) {
+void ScriptIntrinsicHistogram::forEach_dot(const sp<Allocation>& ain) {
     if (mOut->getType()->getElement()->getVectorSize() != 1) {
         mRS->throwError(RS_ERROR_INVALID_PARAMETER,
                         "Output Histogram allocation must have vector size of 1 " \
@@ -503,7 +503,7 @@
     Script::forEach(1, ain, nullptr, nullptr, 0);
 }
 
-sp<ScriptIntrinsicLUT> ScriptIntrinsicLUT::create(sp<RS> rs, sp<const Element> e) {
+sp<ScriptIntrinsicLUT> ScriptIntrinsicLUT::create(const sp<RS>& rs, const sp<const Element>& e) {
     if (!(e->isCompatible(Element::U8_4(rs)))) {
         rs->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element for LUT");
         return nullptr;
@@ -523,7 +523,7 @@
     setVar(0, LUT);
 }
 
-void ScriptIntrinsicLUT::forEach(sp<Allocation> ain, sp<Allocation> aout) {
+void ScriptIntrinsicLUT::forEach(const sp<Allocation>& ain, const sp<Allocation>& aout) {
     if (mDirty) {
         LUT->copy1DFrom((void*)mCache);
         mDirty = false;
@@ -568,7 +568,7 @@
 
 }
 
-sp<ScriptIntrinsicResize> ScriptIntrinsicResize::create(sp<RS> rs) {
+sp<ScriptIntrinsicResize> ScriptIntrinsicResize::create(const sp<RS>& rs) {
     return new ScriptIntrinsicResize(rs, nullptr);
 }
 
@@ -576,7 +576,7 @@
     : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_RESIZE, e) {
 
 }
-void ScriptIntrinsicResize::forEach_bicubic(sp<Allocation> aout) {
+void ScriptIntrinsicResize::forEach_bicubic(const sp<Allocation>& aout) {
     if (aout == mInput) {
         mRS->throwError(RS_ERROR_INVALID_PARAMETER, "Resize Input and Ouput cannot be the same");
     }
@@ -587,7 +587,7 @@
     }
     Script::forEach(0, nullptr, aout, nullptr, 0);
 }
-void ScriptIntrinsicResize::setInput(sp<Allocation> ain) {
+void ScriptIntrinsicResize::setInput(const sp<Allocation>& ain) {
     if (!(ain->getType()->getElement()->isCompatible(Element::U8(mRS))) &&
         !(ain->getType()->getElement()->isCompatible(Element::U8_2(mRS))) &&
         !(ain->getType()->getElement()->isCompatible(Element::U8_3(mRS))) &&
@@ -605,7 +605,7 @@
 }
 
 
-sp<ScriptIntrinsicYuvToRGB> ScriptIntrinsicYuvToRGB::create(sp<RS> rs, sp<const Element> e) {
+sp<ScriptIntrinsicYuvToRGB> ScriptIntrinsicYuvToRGB::create(const sp<RS>& rs, const sp<const Element>& e) {
     if (!(e->isCompatible(Element::U8_4(rs)))) {
         rs->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element for YuvToRGB");
         return nullptr;
@@ -618,7 +618,7 @@
 
 }
 
-void ScriptIntrinsicYuvToRGB::setInput(sp<Allocation> in) {
+void ScriptIntrinsicYuvToRGB::setInput(const sp<Allocation>& in) {
     if (!(in->getType()->getElement()->isCompatible(Element::YUV(mRS)))) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element for input in YuvToRGB");
         return;
@@ -626,7 +626,7 @@
     Script::setVar(0, in);
 }
 
-void ScriptIntrinsicYuvToRGB::forEach(sp<Allocation> out) {
+void ScriptIntrinsicYuvToRGB::forEach(const sp<Allocation>& out) {
     if (!(out->getType()->getElement()->isCompatible(mElement))) {
         mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Invalid element for output in YuvToRGB");
         return;