diff --git a/core/jni/android/opengl/poly_clip.cpp b/core/jni/android/opengl/poly_clip.cpp index 5c652205b223c..271675c307660 100644 --- a/core/jni/android/opengl/poly_clip.cpp +++ b/core/jni/android/opengl/poly_clip.cpp @@ -35,12 +35,12 @@ namespace android { -#define SWAP(a, b, temp) {temp = a; a = b; b = temp;} +#define SWAP(a, b, temp) {(temp) = a; (a) = b; (b) = temp;} #define COORD(vert, i) ((float *)(vert))[i] #define CLIP_AND_SWAP(elem, sign, k, p, q, r) { \ - poly_clip_to_halfspace(p, q, &v->elem-(float *)v, sign, sign*k); \ - if (q->n==0) {p1->n = 0; return POLY_CLIP_OUT;} \ + poly_clip_to_halfspace(p, q, &v->elem-(float *)v, sign, (sign)*(k)); \ + if ((q)->n==0) {p1->n = 0; return POLY_CLIP_OUT;} \ SWAP(p, q, r); \ } diff --git a/core/jni/android_view_GraphicBuffer.cpp b/core/jni/android_view_GraphicBuffer.cpp index ea0d4a356c7f5..59c337b63f1dc 100644 --- a/core/jni/android_view_GraphicBuffer.cpp +++ b/core/jni/android_view_GraphicBuffer.cpp @@ -49,7 +49,7 @@ namespace android { // Debug static const bool kDebugGraphicBuffer = false; -#define LOCK_CANVAS_USAGE GraphicBuffer::USAGE_SW_READ_OFTEN | GraphicBuffer::USAGE_SW_WRITE_OFTEN +#define LOCK_CANVAS_USAGE (GraphicBuffer::USAGE_SW_READ_OFTEN | GraphicBuffer::USAGE_SW_WRITE_OFTEN) // ---------------------------------------------------------------------------- // JNI Helpers diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h index 59f073ff593ce..2a859132e7832 100644 --- a/libs/hwui/DisplayListOp.h +++ b/libs/hwui/DisplayListOp.h @@ -621,8 +621,8 @@ public: } #define SET_TEXTURE(ptr, posRect, offsetRect, texCoordsRect, xDim, yDim) \ - TextureVertex::set(ptr++, posRect.xDim - offsetRect.left, posRect.yDim - offsetRect.top, \ - texCoordsRect.xDim, texCoordsRect.yDim) + TextureVertex::set((ptr)++, (posRect).xDim - (offsetRect).left, (posRect).yDim - (offsetRect).top, \ + (texCoordsRect).xDim, (texCoordsRect).yDim) /** * This multi-draw operation builds a mesh on the stack by generating a quad diff --git a/libs/hwui/Matrix.cpp b/libs/hwui/Matrix.cpp index 709156c4098b0..a936661f86f9c 100644 --- a/libs/hwui/Matrix.cpp +++ b/libs/hwui/Matrix.cpp @@ -419,7 +419,7 @@ void Matrix4::mapPoint3d(Vector3& vec) const { vec.z = orig.x * data[2] + orig.y * data[6] + orig.z * data[kScaleZ] + data[kTranslateZ]; } -#define MUL_ADD_STORE(a, b, c) a = (a) * (b) + (c) +#define MUL_ADD_STORE(a, b, c) ((a) = (a) * (b) + (c)) void Matrix4::mapPoint(float& x, float& y) const { if (isSimple()) { diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index b68240ac75195..9d821f38fab6e 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -838,7 +838,7 @@ void OpenGLRenderer::composeLayerRect(Layer* layer, const Rect& rect) { */ #define DRAW_DOUBLE_STENCIL_IF(COND, DRAW_COMMAND) { \ DRAW_COMMAND; \ - if (CC_UNLIKELY(Properties::debugOverdraw && getTargetFbo() == 0 && COND)) { \ + if (CC_UNLIKELY(Properties::debugOverdraw && getTargetFbo() == 0 && (COND))) { \ glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); \ DRAW_COMMAND; \ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); \ diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index 171873de1f9ab..8fec42972c2fa 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -224,9 +224,9 @@ enum DebugLevel { /////////////////////////////////////////////////////////////////////////////// // Converts a number of mega-bytes into bytes -#define MB(s) s * 1024 * 1024 +#define MB(s) ((s) * 1024 * 1024) // Converts a number of kilo-bytes into bytes -#define KB(s) s * 1024 +#define KB(s) ((s) * 1024) enum class ProfileType { None, diff --git a/libs/hwui/RenderProperties.h b/libs/hwui/RenderProperties.h index 395279806adb3..6a6e8dbb3fcd4 100644 --- a/libs/hwui/RenderProperties.h +++ b/libs/hwui/RenderProperties.h @@ -47,7 +47,7 @@ class RenderNode; class RenderProperties; // The __VA_ARGS__ will be executed if a & b are not equal -#define RP_SET(a, b, ...) (a != b ? (a = b, ##__VA_ARGS__, true) : false) +#define RP_SET(a, b, ...) ((a) != (b) ? ((a) = (b), ##__VA_ARGS__, true) : false) #define RP_SET_AND_DIRTY(a, b) RP_SET(a, b, mPrimitiveFields.mMatrixOrPivotDirty = true) // Keep in sync with View.java:LAYER_TYPE_* diff --git a/libs/hwui/utils/LinearAllocator.cpp b/libs/hwui/utils/LinearAllocator.cpp index 5bba420a258f6..d92bc0cd1fcae 100644 --- a/libs/hwui/utils/LinearAllocator.cpp +++ b/libs/hwui/utils/LinearAllocator.cpp @@ -48,8 +48,8 @@ #define ALIGN_SZ (sizeof(int)) #endif -#define ALIGN(x) ((x + ALIGN_SZ - 1 ) & ~(ALIGN_SZ - 1)) -#define ALIGN_PTR(p) ((void*)(ALIGN((size_t)p))) +#define ALIGN(x) (((x) + ALIGN_SZ - 1 ) & ~(ALIGN_SZ - 1)) +#define ALIGN_PTR(p) ((void*)(ALIGN((size_t)(p)))) #if LOG_NDEBUG #define ADD_ALLOCATION()