summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/androidfw/Asset.cpp2
-rw-r--r--libs/androidfw/BackupHelpers.cpp34
-rw-r--r--libs/androidfw/ResourceTypes.cpp4
-rw-r--r--libs/androidfw/ZipUtils.cpp4
-rw-r--r--libs/common_time/common_time_server_api.cpp2
-rw-r--r--libs/common_time/common_time_server_packets.cpp12
-rw-r--r--libs/hwui/Android.mk6
-rw-r--r--libs/hwui/AnimationContext.h4
-rw-r--r--libs/hwui/AnimatorManager.cpp2
-rw-r--r--libs/hwui/AnimatorManager.h2
-rw-r--r--libs/hwui/Caches.h2
-rw-r--r--libs/hwui/CanvasProperty.h4
-rw-r--r--libs/hwui/CanvasState.h2
-rw-r--r--libs/hwui/DeferredDisplayList.cpp2
-rw-r--r--libs/hwui/DeferredDisplayList.h2
-rw-r--r--libs/hwui/DisplayListOp.h4
-rw-r--r--libs/hwui/Dither.h2
-rw-r--r--libs/hwui/FrameInfo.h2
-rw-r--r--libs/hwui/FrameInfoVisualizer.h2
-rw-r--r--libs/hwui/GradientCache.h2
-rw-r--r--libs/hwui/JankTracker.h2
-rw-r--r--libs/hwui/LayerCache.h2
-rw-r--r--libs/hwui/Matrix.cpp2
-rw-r--r--libs/hwui/Matrix.h4
-rw-r--r--libs/hwui/OpenGLRenderer.cpp2
-rw-r--r--[-rwxr-xr-x]libs/hwui/OpenGLRenderer.h2
-rw-r--r--libs/hwui/PatchCache.h2
-rw-r--r--libs/hwui/PathCache.h2
-rw-r--r--libs/hwui/ProgramCache.h2
-rw-r--r--libs/hwui/Properties.h4
-rw-r--r--libs/hwui/Rect.h2
-rw-r--r--libs/hwui/RenderBufferCache.h2
-rw-r--r--libs/hwui/RenderNode.h2
-rw-r--r--libs/hwui/RenderProperties.h2
-rw-r--r--libs/hwui/ResourceCache.h2
-rw-r--r--libs/hwui/SkiaCanvas.cpp2
-rw-r--r--libs/hwui/SkiaCanvasProxy.h2
-rw-r--r--libs/hwui/TessellationCache.cpp6
-rw-r--r--libs/hwui/TextDropShadowCache.h4
-rw-r--r--libs/hwui/Texture.h4
-rw-r--r--libs/hwui/font/CacheTexture.cpp14
-rw-r--r--libs/hwui/renderstate/RenderState.cpp2
-rw-r--r--libs/hwui/renderthread/RenderTask.h2
-rw-r--r--libs/hwui/renderthread/RenderThread.cpp2
-rw-r--r--libs/hwui/thread/Barrier.h2
-rw-r--r--libs/hwui/thread/Future.h2
-rw-r--r--libs/hwui/thread/Signal.h2
-rw-r--r--libs/hwui/thread/TaskManager.h2
-rw-r--r--libs/hwui/thread/TaskProcessor.h2
-rw-r--r--libs/hwui/utils/LinearAllocator.cpp4
-rw-r--r--libs/storage/Android.mk2
-rw-r--r--libs/storage/IMountService.cpp2
-rw-r--r--libs/storage/IObbActionListener.cpp2
53 files changed, 102 insertions, 86 deletions
diff --git a/libs/androidfw/Asset.cpp b/libs/androidfw/Asset.cpp
index 4e14b13dc8bd..2cfa6666e9ab 100644
--- a/libs/androidfw/Asset.cpp
+++ b/libs/androidfw/Asset.cpp
@@ -69,7 +69,7 @@ String8 Asset::getAssetAllocations()
res.append(cur->getAssetSource());
off64_t size = (cur->getLength()+512)/1024;
char buf[64];
- sprintf(buf, ": %dK\n", (int)size);
+ snprintf(buf, sizeof(buf), ": %dK\n", (int)size);
res.append(buf);
}
cur = cur->mNext;
diff --git a/libs/androidfw/BackupHelpers.cpp b/libs/androidfw/BackupHelpers.cpp
index 9300794cf310..78e9d91c4d67 100644
--- a/libs/androidfw/BackupHelpers.cpp
+++ b/libs/androidfw/BackupHelpers.cpp
@@ -442,7 +442,7 @@ back_up_files(int oldSnapshotFD, BackupDataWriter* dataStream, int newSnapshotFD
return 0;
}
-static void calc_tar_checksum(char* buf) {
+static void calc_tar_checksum(char* buf, size_t buf_size) {
// [ 148 : 8 ] checksum -- to be calculated with this field as space chars
memset(buf + 148, ' ', 8);
@@ -453,11 +453,13 @@ static void calc_tar_checksum(char* buf) {
// Now write the real checksum value:
// [ 148 : 8 ] checksum: 6 octal digits [leading zeroes], NUL, SPC
- sprintf(buf + 148, "%06o", sum); // the trailing space is already in place
+ snprintf(buf + 148, buf_size - 148, "%06o", sum); // the trailing space is
+ // already in place
}
// Returns number of bytes written
-static int write_pax_header_entry(char* buf, const char* key, const char* value) {
+static int write_pax_header_entry(char* buf, size_t buf_size,
+ const char* key, const char* value) {
// start with the size of "1 key=value\n"
int len = strlen(key) + strlen(value) + 4;
if (len > 9) len++;
@@ -466,7 +468,7 @@ static int write_pax_header_entry(char* buf, const char* key, const char* value)
// since PATH_MAX is 4096 we don't expect to have to generate any single
// header entry longer than 9999 characters
- return sprintf(buf, "%d %s=%s\n", len, key, value);
+ return snprintf(buf, buf_size, "%d %s=%s\n", len, key, value);
}
// Wire format to the backup manager service is chunked: each chunk is prefixed by
@@ -550,8 +552,12 @@ int write_tarfile(const String8& packageName, const String8& domain,
// read/write up to this much at a time.
const size_t BUFSIZE = 32 * 1024;
char* buf = (char *)calloc(1,BUFSIZE);
- char* paxHeader = buf + 512; // use a different chunk of it as separate scratch
- char* paxData = buf + 1024;
+ const size_t PAXHEADER_OFFSET = 512;
+ const size_t PAXHEADER_SIZE = 512;
+ const size_t PAXDATA_SIZE = BUFSIZE - (PAXHEADER_SIZE + PAXHEADER_OFFSET);
+ char* const paxHeader = buf + PAXHEADER_OFFSET; // use a different chunk of
+ // it as separate scratch
+ char* const paxData = paxHeader + PAXHEADER_SIZE;
if (buf == NULL) {
ALOGE("Out of mem allocating transfer buffer");
@@ -630,21 +636,21 @@ int write_tarfile(const String8& packageName, const String8& domain,
// already preflighted
if (needExtended) {
char sizeStr[32]; // big enough for a 64-bit unsigned value in decimal
- char* p = paxData;
// construct the pax extended header data block
- memset(paxData, 0, BUFSIZE - (paxData - buf));
+ memset(paxData, 0, PAXDATA_SIZE);
// size header -- calc len in digits by actually rendering the number
// to a string - brute force but simple
+ int paxLen = 0;
snprintf(sizeStr, sizeof(sizeStr), "%lld", (long long)s.st_size);
- p += write_pax_header_entry(p, "size", sizeStr);
+ paxLen += write_pax_header_entry(paxData, PAXDATA_SIZE, "size", sizeStr);
// fullname was generated above with the ustar paths
- p += write_pax_header_entry(p, "path", fullname.string());
+ paxLen += write_pax_header_entry(paxData + paxLen, PAXDATA_SIZE - paxLen,
+ "path", fullname.string());
// Now we know how big the pax data is
- int paxLen = p - paxData;
// Now build the pax *header* templated on the ustar header
memcpy(paxHeader, buf, 512);
@@ -659,10 +665,10 @@ int write_tarfile(const String8& packageName, const String8& domain,
// [ 124 : 12 ] size of pax extended header data
memset(paxHeader + 124, 0, 12);
- snprintf(paxHeader + 124, 12, "%011o", (unsigned int)(p - paxData));
+ snprintf(paxHeader + 124, 12, "%011o", (unsigned int)paxLen);
// Checksum and write the pax block header
- calc_tar_checksum(paxHeader);
+ calc_tar_checksum(paxHeader, PAXHEADER_SIZE);
send_tarfile_chunk(writer, paxHeader, 512);
// Now write the pax data itself
@@ -671,7 +677,7 @@ int write_tarfile(const String8& packageName, const String8& domain,
}
// Checksum and write the 512-byte ustar file header block to the output
- calc_tar_checksum(buf);
+ calc_tar_checksum(buf, BUFSIZE);
send_tarfile_chunk(writer, buf, 512);
// Now write the file data itself, for real files. We honor tar's convention that
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index ceeb12bab205..44486774a0f2 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -3116,7 +3116,7 @@ String8 ResTable_config::toString() const {
struct ResTable::Header
{
- Header(ResTable* _owner) : owner(_owner), ownedData(NULL), header(NULL),
+ explicit Header(ResTable* _owner) : owner(_owner), ownedData(NULL), header(NULL),
resourceIDMap(NULL), resourceIDMapSize(0) { }
~Header()
@@ -6759,7 +6759,7 @@ bool ResTable::getIdmapInfo(const void* idmap, size_t sizeBytes,
#define CHAR16_TO_CSTR(c16, len) (String8(String16(c16,len)).string())
#define CHAR16_ARRAY_EQ(constant, var, len) \
- ((len == (sizeof(constant)/sizeof(constant[0]))) && (0 == memcmp((var), (constant), (len))))
+ (((len) == (sizeof(constant)/sizeof((constant)[0]))) && (0 == memcmp((var), (constant), (len))))
static void print_complex(uint32_t complex, bool isFraction)
{
diff --git a/libs/androidfw/ZipUtils.cpp b/libs/androidfw/ZipUtils.cpp
index 6fa0f14ecb8e..5abfc8ee917e 100644
--- a/libs/androidfw/ZipUtils.cpp
+++ b/libs/androidfw/ZipUtils.cpp
@@ -150,7 +150,7 @@ bail:
class FileReader {
public:
- FileReader(FILE* fp) :
+ explicit FileReader(FILE* fp) :
mFp(fp), mReadBuf(new unsigned char[kReadBufSize])
{
}
@@ -170,7 +170,7 @@ public:
class FdReader {
public:
- FdReader(int fd) :
+ explicit FdReader(int fd) :
mFd(fd), mReadBuf(new unsigned char[kReadBufSize])
{
}
diff --git a/libs/common_time/common_time_server_api.cpp b/libs/common_time/common_time_server_api.cpp
index e0f35a9def8b..60e65677b2f9 100644
--- a/libs/common_time/common_time_server_api.cpp
+++ b/libs/common_time/common_time_server_api.cpp
@@ -285,7 +285,7 @@ void CommonTimeServer::reevaluateAutoDisableState(bool commonClockHasClients) {
if (res > 0) \
write(fd, buffer, res); \
} while (0)
-#define checked_percentage(a, b) ((0 == b) ? 0.0f : ((100.0f * a) / b))
+#define checked_percentage(a, b) ((0 == (b)) ? 0.0f : ((100.0f * (a)) / (b)))
status_t CommonTimeServer::dumpClockInterface(int fd,
const Vector<String16>& /* args */,
diff --git a/libs/common_time/common_time_server_packets.cpp b/libs/common_time/common_time_server_packets.cpp
index 9833c37f2519..c7c893d34499 100644
--- a/libs/common_time/common_time_server_packets.cpp
+++ b/libs/common_time/common_time_server_packets.cpp
@@ -48,12 +48,12 @@ const uint16_t TimeServicePacketHeader::kCurVersion = 1;
#define SERIALIZE_INT32(field_name) SERIALIZE_FIELD(field_name, int32_t, htonl)
#define SERIALIZE_INT64(field_name) SERIALIZE_FIELD(field_name, int64_t, htonq)
-#define DESERIALIZE_FIELD(field_name, type, converter) \
- do { \
- if ((offset + sizeof(field_name)) > length) \
- return -1; \
- field_name = converter(*((type*)(data + offset))); \
- offset += sizeof(field_name); \
+#define DESERIALIZE_FIELD(field_name, type, converter) \
+ do { \
+ if ((offset + sizeof(field_name)) > length) \
+ return -1; \
+ (field_name) = converter(*((type*)(data + offset))); \
+ offset += sizeof(field_name); \
} while (0)
#define DESERIALIZE_INT16(field_name) DESERIALIZE_FIELD(field_name, int16_t, ntohs)
#define DESERIALIZE_INT32(field_name) DESERIALIZE_FIELD(field_name, int32_t, ntohl)
diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk
index c9d4af69c0df..5dcfa4e102fd 100644
--- a/libs/hwui/Android.mk
+++ b/libs/hwui/Android.mk
@@ -181,7 +181,6 @@ LOCAL_SRC_FILES := $(hwui_src_files)
LOCAL_C_INCLUDES := $(hwui_c_includes) $(call hwui_proto_include)
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH) \
- $(hwui_c_includes) \
$(call hwui_proto_include)
include $(LOCAL_PATH)/hwui_static_deps.mk
@@ -205,7 +204,6 @@ LOCAL_SRC_FILES := \
LOCAL_C_INCLUDES := $(hwui_c_includes) $(call hwui_proto_include)
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH) \
- $(hwui_c_includes) \
$(call hwui_proto_include)
include $(LOCAL_PATH)/hwui_static_deps.mk
@@ -238,6 +236,7 @@ LOCAL_SHARED_LIBRARIES := libmemunreachable
LOCAL_CFLAGS := \
$(hwui_cflags) \
-DHWUI_NULL_GPU
+LOCAL_C_INCLUDES := $(hwui_c_includes)
LOCAL_SRC_FILES += \
$(hwui_test_common_src_files) \
@@ -293,6 +292,7 @@ LOCAL_MULTILIB := both
LOCAL_MODULE_STEM_32 := hwuitest
LOCAL_MODULE_STEM_64 := hwuitest64
LOCAL_CFLAGS := $(hwui_cflags)
+LOCAL_C_INCLUDES := $(hwui_c_includes)
# set to libhwui_static_null_gpu to skip actual GL commands
LOCAL_WHOLE_STATIC_LIBRARIES := libhwui_static
@@ -321,6 +321,8 @@ LOCAL_CFLAGS := \
$(hwui_cflags) \
-DHWUI_NULL_GPU
+LOCAL_C_INCLUDES := $(hwui_c_includes)
+
LOCAL_WHOLE_STATIC_LIBRARIES := libhwui_static_null_gpu
LOCAL_STATIC_LIBRARIES := libgoogle-benchmark
diff --git a/libs/hwui/AnimationContext.h b/libs/hwui/AnimationContext.h
index 909ed36a2127..395dc73cfdf0 100644
--- a/libs/hwui/AnimationContext.h
+++ b/libs/hwui/AnimationContext.h
@@ -57,7 +57,7 @@ public:
private:
friend class AnimationContext;
- AnimationHandle(AnimationContext& context);
+ explicit AnimationHandle(AnimationContext& context);
AnimationHandle(RenderNode& animatingNode, AnimationContext& context);
~AnimationHandle();
@@ -75,7 +75,7 @@ private:
class AnimationContext {
PREVENT_COPY_AND_ASSIGN(AnimationContext);
public:
- ANDROID_API AnimationContext(renderthread::TimeLord& clock);
+ ANDROID_API explicit AnimationContext(renderthread::TimeLord& clock);
ANDROID_API virtual ~AnimationContext();
nsecs_t frameTimeMs() { return mFrameTimeMs; }
diff --git a/libs/hwui/AnimatorManager.cpp b/libs/hwui/AnimatorManager.cpp
index f170e9cda8af..9d5860ca0d1a 100644
--- a/libs/hwui/AnimatorManager.cpp
+++ b/libs/hwui/AnimatorManager.cpp
@@ -168,7 +168,7 @@ void AnimatorManager::endAllStagingAnimators() {
class EndActiveAnimatorsFunctor {
public:
- EndActiveAnimatorsFunctor(AnimationContext& context) : mContext(context) {}
+ explicit EndActiveAnimatorsFunctor(AnimationContext& context) : mContext(context) {}
void operator() (sp<BaseRenderNodeAnimator>& animator) {
animator->forceEndNow(mContext);
diff --git a/libs/hwui/AnimatorManager.h b/libs/hwui/AnimatorManager.h
index 61f6179d217c..8e6f820608b5 100644
--- a/libs/hwui/AnimatorManager.h
+++ b/libs/hwui/AnimatorManager.h
@@ -35,7 +35,7 @@ class TreeInfo;
class AnimatorManager {
PREVENT_COPY_AND_ASSIGN(AnimatorManager);
public:
- AnimatorManager(RenderNode& parent);
+ explicit AnimatorManager(RenderNode& parent);
~AnimatorManager();
void addAnimator(const sp<BaseRenderNodeAnimator>& animator);
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index eac9359beab3..317c122c62b8 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -77,7 +77,7 @@ public:
return sInstance != nullptr;
}
private:
- Caches(RenderState& renderState);
+ explicit Caches(RenderState& renderState);
static Caches* sInstance;
public:
diff --git a/libs/hwui/CanvasProperty.h b/libs/hwui/CanvasProperty.h
index 6074394d0720..56671bba654b 100644
--- a/libs/hwui/CanvasProperty.h
+++ b/libs/hwui/CanvasProperty.h
@@ -28,7 +28,7 @@ namespace uirenderer {
class CanvasPropertyPrimitive : public VirtualLightRefBase {
PREVENT_COPY_AND_ASSIGN(CanvasPropertyPrimitive);
public:
- CanvasPropertyPrimitive(float initialValue) : value(initialValue) {}
+ explicit CanvasPropertyPrimitive(float initialValue) : value(initialValue) {}
float value;
};
@@ -36,7 +36,7 @@ public:
class CanvasPropertyPaint : public VirtualLightRefBase {
PREVENT_COPY_AND_ASSIGN(CanvasPropertyPaint);
public:
- CanvasPropertyPaint(const SkPaint& initialValue) : value(initialValue) {}
+ explicit CanvasPropertyPaint(const SkPaint& initialValue) : value(initialValue) {}
SkPaint value;
};
diff --git a/libs/hwui/CanvasState.h b/libs/hwui/CanvasState.h
index b9e87ae5595d..22feef523f49 100644
--- a/libs/hwui/CanvasState.h
+++ b/libs/hwui/CanvasState.h
@@ -73,7 +73,7 @@ public:
class CanvasState {
public:
- CanvasState(CanvasStateClient& renderer);
+ explicit CanvasState(CanvasStateClient& renderer);
~CanvasState();
/**
diff --git a/libs/hwui/DeferredDisplayList.cpp b/libs/hwui/DeferredDisplayList.cpp
index 1b0f42466bff..689179dd8fb4 100644
--- a/libs/hwui/DeferredDisplayList.cpp
+++ b/libs/hwui/DeferredDisplayList.cpp
@@ -62,7 +62,7 @@ public:
class DrawBatch : public Batch {
public:
- DrawBatch(const DeferInfo& deferInfo) : mAllOpsOpaque(true),
+ explicit DrawBatch(const DeferInfo& deferInfo) : mAllOpsOpaque(true),
mBatchId(deferInfo.batchId), mMergeId(deferInfo.mergeId) {
mOps.clear();
}
diff --git a/libs/hwui/DeferredDisplayList.h b/libs/hwui/DeferredDisplayList.h
index 98ccf11b1c2a..15703ea3feef 100644
--- a/libs/hwui/DeferredDisplayList.h
+++ b/libs/hwui/DeferredDisplayList.h
@@ -77,7 +77,7 @@ public:
class DeferredDisplayList {
friend struct DeferStateStruct; // used to give access to allocator
public:
- DeferredDisplayList(const Rect& bounds)
+ explicit DeferredDisplayList(const Rect& bounds)
: mBounds(bounds) {
clear();
}
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h
index 59f073ff593c..2a859132e783 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/Dither.h b/libs/hwui/Dither.h
index b589b80496f0..6af3e8384472 100644
--- a/libs/hwui/Dither.h
+++ b/libs/hwui/Dither.h
@@ -37,7 +37,7 @@ class Program;
*/
class Dither {
public:
- Dither(Caches& caches);
+ explicit Dither(Caches& caches);
void clear();
void setupProgram(Program& program, GLuint* textureUnit);
diff --git a/libs/hwui/FrameInfo.h b/libs/hwui/FrameInfo.h
index 0baca391be79..afab84c3542c 100644
--- a/libs/hwui/FrameInfo.h
+++ b/libs/hwui/FrameInfo.h
@@ -65,7 +65,7 @@ namespace FrameInfoFlags {
class ANDROID_API UiFrameInfoBuilder {
public:
- UiFrameInfoBuilder(int64_t* buffer) : mBuffer(buffer) {
+ explicit UiFrameInfoBuilder(int64_t* buffer) : mBuffer(buffer) {
memset(mBuffer, 0, UI_THREAD_FRAME_INFO_SIZE * sizeof(int64_t));
}
diff --git a/libs/hwui/FrameInfoVisualizer.h b/libs/hwui/FrameInfoVisualizer.h
index 83adf1985c72..719d0f8c5032 100644
--- a/libs/hwui/FrameInfoVisualizer.h
+++ b/libs/hwui/FrameInfoVisualizer.h
@@ -45,7 +45,7 @@ typedef RingBuffer<FrameInfo, 120> FrameInfoSource;
class FrameInfoVisualizer {
public:
- FrameInfoVisualizer(FrameInfoSource& source);
+ explicit FrameInfoVisualizer(FrameInfoSource& source);
~FrameInfoVisualizer();
bool consumeProperties();
diff --git a/libs/hwui/GradientCache.h b/libs/hwui/GradientCache.h
index dccd45072522..49be19ab1c81 100644
--- a/libs/hwui/GradientCache.h
+++ b/libs/hwui/GradientCache.h
@@ -103,7 +103,7 @@ inline hash_t hash_type(const GradientCacheEntry& entry) {
*/
class GradientCache: public OnEntryRemoved<GradientCacheEntry, Texture*> {
public:
- GradientCache(Extensions& extensions);
+ explicit GradientCache(Extensions& extensions);
~GradientCache();
/**
diff --git a/libs/hwui/JankTracker.h b/libs/hwui/JankTracker.h
index 84b8c3f3f155..a23dd7807169 100644
--- a/libs/hwui/JankTracker.h
+++ b/libs/hwui/JankTracker.h
@@ -56,7 +56,7 @@ struct ProfileData {
// TODO: Replace DrawProfiler with this
class JankTracker {
public:
- JankTracker(nsecs_t frameIntervalNanos);
+ explicit JankTracker(nsecs_t frameIntervalNanos);
~JankTracker();
void addFrame(const FrameInfo& frame);
diff --git a/libs/hwui/LayerCache.h b/libs/hwui/LayerCache.h
index 6fe7b3aae859..7a1a9ae3dd5d 100644
--- a/libs/hwui/LayerCache.h
+++ b/libs/hwui/LayerCache.h
@@ -105,7 +105,7 @@ private:
mHeight = Layer::computeIdealHeight(layerHeight);
}
- LayerEntry(Layer* layer):
+ explicit LayerEntry(Layer* layer):
mLayer(layer), mWidth(layer->getWidth()), mHeight(layer->getHeight()) {
}
diff --git a/libs/hwui/Matrix.cpp b/libs/hwui/Matrix.cpp
index 709156c4098b..a936661f86f9 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/Matrix.h b/libs/hwui/Matrix.h
index 9cde5d6aa04e..ba9cbbe02ec1 100644
--- a/libs/hwui/Matrix.h
+++ b/libs/hwui/Matrix.h
@@ -81,11 +81,11 @@ public:
loadIdentity();
}
- Matrix4(const float* v) {
+ explicit Matrix4(const float* v) {
load(v);
}
- Matrix4(const SkMatrix& v) {
+ Matrix4(const SkMatrix& v) { // NOLINT, implicit
load(v);
}
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index b68240ac7519..9d821f38fab6 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/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index dacd8ccaa6ea..ec450bd63296 100755..100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -116,7 +116,7 @@ enum ModelViewMode {
*/
class OpenGLRenderer : public CanvasStateClient {
public:
- OpenGLRenderer(RenderState& renderState);
+ explicit OpenGLRenderer(RenderState& renderState);
virtual ~OpenGLRenderer();
void initProperties();
diff --git a/libs/hwui/PatchCache.h b/libs/hwui/PatchCache.h
index 66ef6a0279ba..bc5981d53457 100644
--- a/libs/hwui/PatchCache.h
+++ b/libs/hwui/PatchCache.h
@@ -51,7 +51,7 @@ class Caches;
class PatchCache {
public:
- PatchCache(RenderState& renderState);
+ explicit PatchCache(RenderState& renderState);
~PatchCache();
void init();
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h
index 6368ddd49966..e1fcc311776e 100644
--- a/libs/hwui/PathCache.h
+++ b/libs/hwui/PathCache.h
@@ -288,7 +288,7 @@ private:
class PathProcessor: public TaskProcessor<SkBitmap*> {
public:
- PathProcessor(Caches& caches);
+ explicit PathProcessor(Caches& caches);
~PathProcessor() { }
virtual void onProcess(const sp<Task<SkBitmap*> >& task) override;
diff --git a/libs/hwui/ProgramCache.h b/libs/hwui/ProgramCache.h
index 1dadda1a4c83..9ac885b665e7 100644
--- a/libs/hwui/ProgramCache.h
+++ b/libs/hwui/ProgramCache.h
@@ -40,7 +40,7 @@ namespace uirenderer {
*/
class ProgramCache {
public:
- ProgramCache(Extensions& extensions);
+ explicit ProgramCache(Extensions& extensions);
~ProgramCache();
Program* get(const ProgramDescription& description);
diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h
index 171873de1f9a..8fec42972c2f 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/Rect.h b/libs/hwui/Rect.h
index de4fa55bb508..dbd188fa15c5 100644
--- a/libs/hwui/Rect.h
+++ b/libs/hwui/Rect.h
@@ -73,7 +73,7 @@ public:
bottom(height) {
}
- inline Rect(const SkRect& rect):
+ inline Rect(const SkRect& rect): // NOLINT, implicit
left(rect.fLeft),
top(rect.fTop),
right(rect.fRight),
diff --git a/libs/hwui/RenderBufferCache.h b/libs/hwui/RenderBufferCache.h
index f77f4c95b5ba..644433145cd0 100644
--- a/libs/hwui/RenderBufferCache.h
+++ b/libs/hwui/RenderBufferCache.h
@@ -82,7 +82,7 @@ private:
mBuffer(nullptr), mFormat(format), mWidth(width), mHeight(height) {
}
- RenderBufferEntry(RenderBuffer* buffer):
+ explicit RenderBufferEntry(RenderBuffer* buffer):
mBuffer(buffer), mFormat(buffer->getFormat()),
mWidth(buffer->getWidth()), mHeight(buffer->getHeight()) {
}
diff --git a/libs/hwui/RenderNode.h b/libs/hwui/RenderNode.h
index f80be5ec9ae9..1eaf5d61d465 100644
--- a/libs/hwui/RenderNode.h
+++ b/libs/hwui/RenderNode.h
@@ -146,7 +146,7 @@ public:
void setName(const char* name) {
if (name) {
- char* lastPeriod = strrchr(name, '.');
+ const char* lastPeriod = strrchr(name, '.');
if (lastPeriod) {
mName.setTo(lastPeriod + 1);
} else {
diff --git a/libs/hwui/RenderProperties.h b/libs/hwui/RenderProperties.h
index 395279806adb..6a6e8dbb3fcd 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/ResourceCache.h b/libs/hwui/ResourceCache.h
index 4583c8de87e8..3ac78642c7ee 100644
--- a/libs/hwui/ResourceCache.h
+++ b/libs/hwui/ResourceCache.h
@@ -42,7 +42,7 @@ enum ResourceType {
class ResourceReference {
public:
- ResourceReference(ResourceType type) {
+ explicit ResourceReference(ResourceType type) {
refCount = 0; destroyed = false; resourceType = type;
}
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp
index ce67554645d1..0693804d5770 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -208,7 +208,7 @@ SkiaCanvas::SkiaCanvas(const SkBitmap& bitmap) {
class ClipCopier : public SkCanvas::ClipVisitor {
public:
- ClipCopier(SkCanvas* dstCanvas) : m_dstCanvas(dstCanvas) {}
+ explicit ClipCopier(SkCanvas* dstCanvas) : m_dstCanvas(dstCanvas) {}
virtual void clipRect(const SkRect& rect, SkRegion::Op op, bool antialias) {
m_dstCanvas->clipRect(rect, op, antialias);
diff --git a/libs/hwui/SkiaCanvasProxy.h b/libs/hwui/SkiaCanvasProxy.h
index 973c55fe2236..c03c523cd106 100644
--- a/libs/hwui/SkiaCanvasProxy.h
+++ b/libs/hwui/SkiaCanvasProxy.h
@@ -39,7 +39,7 @@ namespace uirenderer {
*/
class ANDROID_API SkiaCanvasProxy : public SkCanvas {
public:
- SkiaCanvasProxy(Canvas* canvas, bool filterHwuiCalls = false);
+ explicit SkiaCanvasProxy(Canvas* canvas, bool filterHwuiCalls = false);
virtual ~SkiaCanvasProxy() {}
protected:
diff --git a/libs/hwui/TessellationCache.cpp b/libs/hwui/TessellationCache.cpp
index cfdc0848c8b0..d9e811684610 100644
--- a/libs/hwui/TessellationCache.cpp
+++ b/libs/hwui/TessellationCache.cpp
@@ -136,7 +136,7 @@ public:
class TessellationCache::TessellationProcessor : public TaskProcessor<VertexBuffer*> {
public:
- TessellationProcessor(Caches& caches)
+ explicit TessellationProcessor(Caches& caches)
: TaskProcessor<VertexBuffer*>(&caches.tasks) {}
~TessellationProcessor() {}
@@ -150,7 +150,7 @@ public:
class TessellationCache::Buffer {
public:
- Buffer(const sp<Task<VertexBuffer*> >& task)
+ explicit Buffer(const sp<Task<VertexBuffer*> >& task)
: mTask(task)
, mBuffer(nullptr) {
}
@@ -270,7 +270,7 @@ void tessellateShadows(
class ShadowProcessor : public TaskProcessor<TessellationCache::vertexBuffer_pair_t> {
public:
- ShadowProcessor(Caches& caches)
+ explicit ShadowProcessor(Caches& caches)
: TaskProcessor<TessellationCache::vertexBuffer_pair_t>(&caches.tasks) {}
~ShadowProcessor() {}
diff --git a/libs/hwui/TextDropShadowCache.h b/libs/hwui/TextDropShadowCache.h
index d536c40756ff..13e87749029a 100644
--- a/libs/hwui/TextDropShadowCache.h
+++ b/libs/hwui/TextDropShadowCache.h
@@ -111,7 +111,7 @@ inline hash_t hash_type(const ShadowText& entry) {
* Alpha texture used to represent a shadow.
*/
struct ShadowTexture: public Texture {
- ShadowTexture(Caches& caches): Texture(caches) {
+ explicit ShadowTexture(Caches& caches): Texture(caches) {
}
float left;
@@ -121,7 +121,7 @@ struct ShadowTexture: public Texture {
class TextDropShadowCache: public OnEntryRemoved<ShadowText, ShadowTexture*> {
public:
TextDropShadowCache();
- TextDropShadowCache(uint32_t maxByteSize);
+ explicit TextDropShadowCache(uint32_t maxByteSize);
~TextDropShadowCache();
/**
diff --git a/libs/hwui/Texture.h b/libs/hwui/Texture.h
index 9749f734fd1f..b72742f45654 100644
--- a/libs/hwui/Texture.h
+++ b/libs/hwui/Texture.h
@@ -34,7 +34,7 @@ class Layer;
*/
class Texture : public GpuMemoryTracker {
public:
- Texture(Caches& caches)
+ explicit Texture(Caches& caches)
: GpuMemoryTracker(GpuObjectType::Texture)
, mCaches(caches)
{ }
@@ -171,7 +171,7 @@ private:
class AutoTexture {
public:
- AutoTexture(Texture* texture)
+ explicit AutoTexture(Texture* texture)
: texture(texture) {}
~AutoTexture() {
if (texture && texture->cleanup) {
diff --git a/libs/hwui/font/CacheTexture.cpp b/libs/hwui/font/CacheTexture.cpp
index 8ba4761c1b2e..fcdde45c49f2 100644
--- a/libs/hwui/font/CacheTexture.cpp
+++ b/libs/hwui/font/CacheTexture.cpp
@@ -188,15 +188,21 @@ void CacheTexture::allocatePixelBuffer() {
bool CacheTexture::upload() {
const Rect& dirtyRect = mDirtyRect;
- uint32_t x = mHasUnpackRowLength ? dirtyRect.left : 0;
- uint32_t y = dirtyRect.top;
- uint32_t width = mHasUnpackRowLength ? dirtyRect.getWidth() : getWidth();
- uint32_t height = dirtyRect.getHeight();
+ // align the x direction to 32 and y direction to 4 for better performance
+ uint32_t x = (((uint32_t)dirtyRect.left) & (~0x1F));
+ uint32_t y = (((uint32_t)dirtyRect.top) & (~0x3));
+ uint32_t r = ((((uint32_t)dirtyRect.right) + 0x1F) & (~0x1F)) - x;
+ uint32_t b = ((((uint32_t)dirtyRect.bottom) + 0x3) & (~0x3)) - y;
+ uint32_t width = (r > getWidth() ? getWidth() : r);
+ uint32_t height = (b > getHeight() ? getHeight() : b);
// The unpack row length only needs to be specified when a new
// texture is bound
if (mHasUnpackRowLength) {
glPixelStorei(GL_UNPACK_ROW_LENGTH, getWidth());
+ } else {
+ x = 0;
+ width = getWidth();
}
mPixelBuffer->upload(x, y, width, height);
diff --git a/libs/hwui/renderstate/RenderState.cpp b/libs/hwui/renderstate/RenderState.cpp
index e78cd7296f42..5e600644ca19 100644
--- a/libs/hwui/renderstate/RenderState.cpp
+++ b/libs/hwui/renderstate/RenderState.cpp
@@ -211,7 +211,7 @@ void RenderState::debugOverdraw(bool enable, bool clear) {
class DecStrongTask : public renderthread::RenderTask {
public:
- DecStrongTask(VirtualLightRefBase* object) : mObject(object) {}
+ explicit DecStrongTask(VirtualLightRefBase* object) : mObject(object) {}
virtual void run() override {
mObject->decStrong(nullptr);
diff --git a/libs/hwui/renderthread/RenderTask.h b/libs/hwui/renderthread/RenderTask.h
index 89c3a7d08a62..9ea671be5b86 100644
--- a/libs/hwui/renderthread/RenderTask.h
+++ b/libs/hwui/renderthread/RenderTask.h
@@ -73,7 +73,7 @@ typedef void* (*RunnableMethod)(void* data);
class MethodInvokeRenderTask : public RenderTask {
public:
- MethodInvokeRenderTask(RunnableMethod method)
+ explicit MethodInvokeRenderTask(RunnableMethod method)
: mMethod(method), mReturnPtr(nullptr) {}
void* payload() { return mData; }
diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp
index 9fb30c928c00..3c1c0bceba58 100644
--- a/libs/hwui/renderthread/RenderThread.cpp
+++ b/libs/hwui/renderthread/RenderThread.cpp
@@ -128,7 +128,7 @@ class DispatchFrameCallbacks : public RenderTask {
private:
RenderThread* mRenderThread;
public:
- DispatchFrameCallbacks(RenderThread* rt) : mRenderThread(rt) {}
+ explicit DispatchFrameCallbacks(RenderThread* rt) : mRenderThread(rt) {}
virtual void run() override {
mRenderThread->dispatchFrameCallbacks();
diff --git a/libs/hwui/thread/Barrier.h b/libs/hwui/thread/Barrier.h
index 0a7acb0fbbfd..17f82ba9d67d 100644
--- a/libs/hwui/thread/Barrier.h
+++ b/libs/hwui/thread/Barrier.h
@@ -24,7 +24,7 @@ namespace uirenderer {
class Barrier {
public:
- Barrier(Condition::WakeUpType type = Condition::WAKE_UP_ALL) : mType(type), mOpened(false) { }
+ explicit Barrier(Condition::WakeUpType type = Condition::WAKE_UP_ALL) : mType(type), mOpened(false) { }
~Barrier() { }
void open() {
diff --git a/libs/hwui/thread/Future.h b/libs/hwui/thread/Future.h
index a3ff3bcc3698..177eebd9b85f 100644
--- a/libs/hwui/thread/Future.h
+++ b/libs/hwui/thread/Future.h
@@ -27,7 +27,7 @@ namespace uirenderer {
template<typename T>
class Future: public LightRefBase<Future<T> > {
public:
- Future(Condition::WakeUpType type = Condition::WAKE_UP_ONE): mBarrier(type), mResult() { }
+ explicit Future(Condition::WakeUpType type = Condition::WAKE_UP_ONE): mBarrier(type), mResult() { }
~Future() { }
/**
diff --git a/libs/hwui/thread/Signal.h b/libs/hwui/thread/Signal.h
index d4cfeeb29c17..93e6f4c27535 100644
--- a/libs/hwui/thread/Signal.h
+++ b/libs/hwui/thread/Signal.h
@@ -26,7 +26,7 @@ namespace uirenderer {
class Signal {
public:
- Signal(Condition::WakeUpType type = Condition::WAKE_UP_ALL) : mType(type), mSignaled(false) { }
+ explicit Signal(Condition::WakeUpType type = Condition::WAKE_UP_ALL) : mType(type), mSignaled(false) { }
~Signal() { }
void signal() {
diff --git a/libs/hwui/thread/TaskManager.h b/libs/hwui/thread/TaskManager.h
index e4808f7b7181..0e4ffdca496d 100644
--- a/libs/hwui/thread/TaskManager.h
+++ b/libs/hwui/thread/TaskManager.h
@@ -78,7 +78,7 @@ private:
class WorkerThread: public Thread {
public:
- WorkerThread(const String8 name): mSignal(Condition::WAKE_UP_ONE), mName(name) { }
+ explicit WorkerThread(const String8 name): mSignal(Condition::WAKE_UP_ONE), mName(name) { }
bool addTask(const TaskWrapper& task);
size_t getTaskCount() const;
diff --git a/libs/hwui/thread/TaskProcessor.h b/libs/hwui/thread/TaskProcessor.h
index 82538e9c7342..58674505c457 100644
--- a/libs/hwui/thread/TaskProcessor.h
+++ b/libs/hwui/thread/TaskProcessor.h
@@ -36,7 +36,7 @@ public:
template<typename T>
class TaskProcessor: public TaskProcessorBase {
public:
- TaskProcessor(TaskManager* manager): mManager(manager) { }
+ explicit TaskProcessor(TaskManager* manager): mManager(manager) { }
virtual ~TaskProcessor() { }
void add(const sp<Task<T> >& task) {
diff --git a/libs/hwui/utils/LinearAllocator.cpp b/libs/hwui/utils/LinearAllocator.cpp
index 5bba420a258f..d92bc0cd1fca 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()
diff --git a/libs/storage/Android.mk b/libs/storage/Android.mk
index fae2bf7c3457..d0eb6d4eb425 100644
--- a/libs/storage/Android.mk
+++ b/libs/storage/Android.mk
@@ -11,4 +11,6 @@ LOCAL_MODULE:= libstorage
LOCAL_CFLAGS += -Wall -Werror
+LOCAL_SHARED_LIBRARIES := libbinder
+
include $(BUILD_STATIC_LIBRARY)
diff --git a/libs/storage/IMountService.cpp b/libs/storage/IMountService.cpp
index c643ed008a3b..74638e7eccc3 100644
--- a/libs/storage/IMountService.cpp
+++ b/libs/storage/IMountService.cpp
@@ -55,7 +55,7 @@ enum {
class BpMountService: public BpInterface<IMountService>
{
public:
- BpMountService(const sp<IBinder>& impl)
+ explicit BpMountService(const sp<IBinder>& impl)
: BpInterface<IMountService>(impl)
{
}
diff --git a/libs/storage/IObbActionListener.cpp b/libs/storage/IObbActionListener.cpp
index 9656e655e22c..a71341bc1364 100644
--- a/libs/storage/IObbActionListener.cpp
+++ b/libs/storage/IObbActionListener.cpp
@@ -26,7 +26,7 @@ enum {
// This is a stub that real consumers should override.
class BpObbActionListener: public BpInterface<IObbActionListener> {
public:
- BpObbActionListener(const sp<IBinder>& impl)
+ explicit BpObbActionListener(const sp<IBinder>& impl)
: BpInterface<IObbActionListener>(impl)
{ }