drm_hwcomposer: CI: Raise clang-tidy level from NONE to COARSE for *.h
To improve CI coverage.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
diff --git a/.ci/Makefile b/.ci/Makefile
index d78fde6..17c163b 100644
--- a/.ci/Makefile
+++ b/.ci/Makefile
@@ -64,10 +64,13 @@
TIDY_CHECKS_COARSE := \
$(TIDY_CHECKS_NORMAL) \
+ -cppcoreguidelines-non-private-member-variables-in-classes \
-cppcoreguidelines-pro-bounds-array-to-pointer-decay \
-cppcoreguidelines-pro-bounds-constant-array-index \
-cppcoreguidelines-pro-bounds-pointer-arithmetic \
-cppcoreguidelines-pro-type-cstyle-cast \
+ -cppcoreguidelines-pro-type-reinterpret-cast \
+ -cppcoreguidelines-pro-type-static-cast-downcast \
-cppcoreguidelines-pro-type-union-access \
-cppcoreguidelines-pro-type-vararg \
-cppcoreguidelines-avoid-magic-numbers \
@@ -78,6 +81,7 @@
-misc-non-private-member-variables-in-classes \
-modernize-avoid-c-arrays \
-modernize-use-trailing-return-type \
+ -modernize-use-nodiscard \
-readability-braces-around-statements \
-readability-convert-member-functions-to-static \
-readability-implicit-bool-conversion \
@@ -88,39 +92,39 @@
TIDY_FILES := \
drm/UEventListener.h:COARSE \
drm/DrmFbImporter.h:FINE \
- drm/ResourceManager.h: \
- drm/DrmMode.h: \
- drm/DrmDevice.h: \
- drm/DrmProperty.h: \
- drm/DrmConnector.h: \
- drm/DrmCrtc.h: \
- drm/VSyncWorker.h: \
- drm/DrmPlane.h: \
+ drm/ResourceManager.h:COARSE \
+ drm/DrmMode.h:COARSE \
+ drm/DrmDevice.h:COARSE \
+ drm/DrmProperty.h:COARSE \
+ drm/DrmConnector.h:COARSE \
+ drm/DrmCrtc.h:COARSE \
+ drm/VSyncWorker.h:COARSE \
+ drm/DrmPlane.h:COARSE \
drm/DrmUnique.h:FINE \
- drm/DrmEncoder.h: \
- bufferinfo/legacy/BufferInfoMinigbm.h: \
- bufferinfo/legacy/BufferInfoLibdrm.h: \
- bufferinfo/legacy/BufferInfoMaliMediatek.h: \
- bufferinfo/legacy/BufferInfoMaliHisi.h: \
- bufferinfo/legacy/BufferInfoImagination.h: \
- bufferinfo/legacy/BufferInfoMaliMeson.h: \
- bufferinfo/BufferInfoGetter.h: \
- bufferinfo/BufferInfoMapperMetadata.h: \
- include/drmhwcgralloc.h: \
- include/drmhwcomposer.h: \
- utils/Worker.h: \
+ drm/DrmEncoder.h:COARSE \
+ bufferinfo/legacy/BufferInfoMinigbm.h:COARSE \
+ bufferinfo/legacy/BufferInfoLibdrm.h:COARSE \
+ bufferinfo/legacy/BufferInfoMaliMediatek.h:COARSE \
+ bufferinfo/legacy/BufferInfoMaliHisi.h:COARSE \
+ bufferinfo/legacy/BufferInfoImagination.h:COARSE \
+ bufferinfo/legacy/BufferInfoMaliMeson.h:COARSE \
+ bufferinfo/BufferInfoGetter.h:COARSE \
+ bufferinfo/BufferInfoMapperMetadata.h:COARSE \
+ include/drmhwcgralloc.h:COARSE \
+ include/drmhwcomposer.h:COARSE \
+ utils/Worker.h:COARSE \
utils/UniqueFd.h:FINE \
- utils/autolock.h: \
+ utils/autolock.h:COARSE \
utils/log.h:FINE \
utils/properties.h:FINE \
- compositor/DrmDisplayCompositor.h: \
- compositor/Planner.h: \
- compositor/DrmDisplayComposition.h: \
- backend/BackendManager.h: \
- backend/BackendClient.h: \
- backend/Backend.h: \
- backend/BackendRCarDu.h: \
- DrmHwcTwo.h: \
+ compositor/DrmDisplayCompositor.h:COARSE \
+ compositor/Planner.h:COARSE \
+ compositor/DrmDisplayComposition.h:COARSE \
+ backend/BackendManager.h:COARSE \
+ backend/BackendClient.h:COARSE \
+ backend/Backend.h:COARSE \
+ backend/BackendRCarDu.h:COARSE \
+ DrmHwcTwo.h:COARSE \
TIDY_FILES += \
backend/BackendClient.cpp:COARSE \
diff --git a/DrmHwcTwo.cpp b/DrmHwcTwo.cpp
index ad9c2c2..f94937f 100644
--- a/DrmHwcTwo.cpp
+++ b/DrmHwcTwo.cpp
@@ -1235,7 +1235,7 @@
// TODO(rsglobal): Avoid extra fd duplication
layer->acquire_fence = UniqueFd(fcntl(acquire_fence_.Get(), F_DUPFD_CLOEXEC));
layer->display_frame = display_frame_;
- layer->alpha = lround(65535.0F * alpha_);
+ layer->alpha = std::lround(65535.0F * alpha_);
layer->blending = blending_;
layer->source_crop = source_crop_;
layer->transform = transform_;
diff --git a/DrmHwcTwo.h b/DrmHwcTwo.h
index beb2e5f..f8c3e77 100644
--- a/DrmHwcTwo.h
+++ b/DrmHwcTwo.h
@@ -18,9 +18,9 @@
#define ANDROID_DRM_HWC_TWO_H_
#include <hardware/hwcomposer2.h>
-#include <math.h>
#include <array>
+#include <cmath>
#include <map>
#include <optional>
@@ -87,16 +87,16 @@
void PopulateDrmLayer(DrmHwcLayer *layer);
- bool RequireScalingOrPhasing() {
+ bool RequireScalingOrPhasing() const {
float src_width = source_crop_.right - source_crop_.left;
float src_height = source_crop_.bottom - source_crop_.top;
- float dest_width = display_frame_.right - display_frame_.left;
- float dest_height = display_frame_.bottom - display_frame_.top;
+ auto dest_width = float(display_frame_.right - display_frame_.left);
+ auto dest_height = float(display_frame_.bottom - display_frame_.top);
bool scaling = src_width != dest_width || src_height != dest_height;
- bool phasing = (source_crop_.left - floor(source_crop_.left) != 0) ||
- (source_crop_.top - floor(source_crop_.top) != 0);
+ bool phasing = (source_crop_.left - std::floor(source_crop_.left) != 0) ||
+ (source_crop_.top - std::floor(source_crop_.top) != 0);
return scaling || phasing;
}
@@ -132,9 +132,9 @@
HWC2::Composition sf_type_ = HWC2::Composition::Invalid;
HWC2::Composition validated_type_ = HWC2::Composition::Invalid;
- buffer_handle_t buffer_ = NULL;
+ buffer_handle_t buffer_ = nullptr;
hwc_rect_t display_frame_;
- float alpha_ = 1.0f;
+ float alpha_ = 1.0F;
hwc_frect_t source_crop_;
DrmHwcTransform transform_ = DrmHwcTransform::kIdentity;
uint32_t z_order_ = 0;
@@ -234,7 +234,7 @@
/* Statistics */
struct Stats {
- Stats minus(Stats b) {
+ Stats minus(Stats b) const {
return {total_frames_ - b.total_frames_,
total_pixops_ - b.total_pixops_,
gpu_pixops_ - b.gpu_pixops_,
@@ -257,7 +257,7 @@
DrmMode mode;
bool disabled{};
- bool IsInterlaced() {
+ bool IsInterlaced() const {
return (mode.flags() & DRM_MODE_FLAG_INTERLACE) != 0;
}
};
@@ -357,8 +357,8 @@
std::unique_ptr<Backend> backend_;
VSyncWorker vsync_worker_;
- DrmConnector *connector_ = NULL;
- DrmCrtc *crtc_ = NULL;
+ DrmConnector *connector_ = nullptr;
+ DrmCrtc *crtc_ = nullptr;
hwc2_display_t handle_;
HWC2::DisplayType type_;
uint32_t layer_idx_ = 0;
diff --git a/bufferinfo/BufferInfoGetter.h b/bufferinfo/BufferInfoGetter.h
index 7b088df..694b0f2 100644
--- a/bufferinfo/BufferInfoGetter.h
+++ b/bufferinfo/BufferInfoGetter.h
@@ -31,8 +31,7 @@
class BufferInfoGetter {
public:
- virtual ~BufferInfoGetter() {
- }
+ virtual ~BufferInfoGetter() = default;
virtual int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) = 0;
@@ -53,8 +52,6 @@
return 0;
}
- int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override = 0;
-
static std::unique_ptr<LegacyBufferInfoGetter> CreateInstance();
static uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
diff --git a/compositor/DrmDisplayComposition.h b/compositor/DrmDisplayComposition.h
index cbc0a90..d077aee 100644
--- a/compositor/DrmDisplayComposition.h
+++ b/compositor/DrmDisplayComposition.h
@@ -52,7 +52,7 @@
}
private:
- DrmPlane *plane_ = NULL;
+ DrmPlane *plane_ = nullptr;
size_t source_layer_ = kUndefinedSourceLayer;
};
@@ -85,8 +85,8 @@
}
private:
- DrmCrtc *crtc_ = NULL;
- Planner *planner_ = NULL;
+ DrmCrtc *crtc_ = nullptr;
+ Planner *planner_ = nullptr;
std::vector<DrmHwcLayer> layers_;
std::vector<DrmCompositionPlane> composition_planes_;
diff --git a/compositor/DrmDisplayCompositor.h b/compositor/DrmDisplayCompositor.h
index f6333eb..41e708f 100644
--- a/compositor/DrmDisplayCompositor.h
+++ b/compositor/DrmDisplayCompositor.h
@@ -63,9 +63,9 @@
auto ExecuteAtomicCommit(AtomicCommitArgs &args) -> int;
- private:
DrmDisplayCompositor(const DrmDisplayCompositor &) = delete;
+ private:
auto CommitFrame(AtomicCommitArgs &args) -> int;
struct KmsState {
diff --git a/compositor/Planner.h b/compositor/Planner.h
index ff059f5..c148b6e 100644
--- a/compositor/Planner.h
+++ b/compositor/Planner.h
@@ -36,7 +36,7 @@
// Removes and returns the next available plane from planes
static DrmPlane *PopPlane(std::vector<DrmPlane *> *planes) {
if (planes->empty())
- return NULL;
+ return nullptr;
DrmPlane *plane = planes->front();
planes->erase(planes->begin());
return plane;
diff --git a/drm/DrmConnector.h b/drm/DrmConnector.h
index f2305aa..2bcb543 100644
--- a/drm/DrmConnector.h
+++ b/drm/DrmConnector.h
@@ -17,9 +17,9 @@
#ifndef ANDROID_DRM_CONNECTOR_H_
#define ANDROID_DRM_CONNECTOR_H_
-#include <stdint.h>
#include <xf86drmMode.h>
+#include <cstdint>
#include <string>
#include <vector>
diff --git a/drm/DrmCrtc.h b/drm/DrmCrtc.h
index 7972bef..85e067a 100644
--- a/drm/DrmCrtc.h
+++ b/drm/DrmCrtc.h
@@ -17,9 +17,10 @@
#ifndef ANDROID_DRM_CRTC_H_
#define ANDROID_DRM_CRTC_H_
-#include <stdint.h>
#include <xf86drmMode.h>
+#include <cstdint>
+
#include "DrmMode.h"
#include "DrmProperty.h"
diff --git a/drm/DrmDevice.h b/drm/DrmDevice.h
index 4cbbd60..b5508af 100644
--- a/drm/DrmDevice.h
+++ b/drm/DrmDevice.h
@@ -17,8 +17,7 @@
#ifndef ANDROID_DRM_H_
#define ANDROID_DRM_H_
-#include <stdint.h>
-
+#include <cstdint>
#include <map>
#include <tuple>
@@ -86,7 +85,7 @@
}
DrmFbImporter &GetDrmFbImporter() {
- return *mDrmFbImporter.get();
+ return *mDrmFbImporter;
}
static auto IsKMSDev(const char *path) -> bool;
diff --git a/drm/DrmEncoder.h b/drm/DrmEncoder.h
index 4c01bc1..b130b7d 100644
--- a/drm/DrmEncoder.h
+++ b/drm/DrmEncoder.h
@@ -17,9 +17,9 @@
#ifndef ANDROID_DRM_ENCODER_H_
#define ANDROID_DRM_ENCODER_H_
-#include <stdint.h>
#include <xf86drmMode.h>
+#include <cstdint>
#include <set>
#include <vector>
diff --git a/drm/DrmMode.h b/drm/DrmMode.h
index 41b9e15..20515f9 100644
--- a/drm/DrmMode.h
+++ b/drm/DrmMode.h
@@ -17,10 +17,10 @@
#ifndef ANDROID_DRM_MODE_H_
#define ANDROID_DRM_MODE_H_
-#include <stdio.h>
#include <xf86drmMode.h>
#include <cstdint>
+#include <cstdio>
#include <string>
#include "DrmUnique.h"
@@ -32,7 +32,7 @@
class DrmMode {
public:
DrmMode() = default;
- DrmMode(drmModeModeInfoPtr m);
+ explicit DrmMode(drmModeModeInfoPtr m);
bool operator==(const drmModeModeInfo &m) const;
diff --git a/drm/DrmPlane.h b/drm/DrmPlane.h
index 7fab2ba..6487776 100644
--- a/drm/DrmPlane.h
+++ b/drm/DrmPlane.h
@@ -17,9 +17,9 @@
#ifndef ANDROID_DRM_PLANE_H_
#define ANDROID_DRM_PLANE_H_
-#include <stdint.h>
#include <xf86drmMode.h>
+#include <cstdint>
#include <vector>
#include "DrmCrtc.h"
diff --git a/drm/DrmProperty.h b/drm/DrmProperty.h
index 68f300f..26a7c38 100644
--- a/drm/DrmProperty.h
+++ b/drm/DrmProperty.h
@@ -17,9 +17,9 @@
#ifndef ANDROID_DRM_PROPERTY_H_
#define ANDROID_DRM_PROPERTY_H_
-#include <stdint.h>
#include <xf86drmMode.h>
+#include <cstdint>
#include <map>
#include <string>
#include <vector>
@@ -62,14 +62,14 @@
auto AddEnumToMap(const std::string &name, E key, std::map<E, uint64_t> &map)
-> bool;
- operator bool() const {
+ explicit operator bool() const {
return id_ != 0;
}
private:
class DrmPropertyEnum {
public:
- DrmPropertyEnum(drm_mode_property_enum *e);
+ explicit DrmPropertyEnum(drm_mode_property_enum *e);
~DrmPropertyEnum() = default;
uint64_t value_;
diff --git a/drm/ResourceManager.h b/drm/ResourceManager.h
index bb91882..b02bf36 100644
--- a/drm/ResourceManager.h
+++ b/drm/ResourceManager.h
@@ -17,7 +17,7 @@
#ifndef RESOURCEMANAGER_H
#define RESOURCEMANAGER_H
-#include <string.h>
+#include <cstring>
#include "DrmDevice.h"
#include "DrmFbImporter.h"
@@ -40,7 +40,7 @@
int getDisplayCount() const {
return num_displays_;
}
- bool ForcedScalingWithGpu() {
+ bool ForcedScalingWithGpu() const {
return scale_with_gpu_;
}
diff --git a/drm/VSyncWorker.h b/drm/VSyncWorker.h
index 74ff487..67aaa16 100644
--- a/drm/VSyncWorker.h
+++ b/drm/VSyncWorker.h
@@ -20,9 +20,9 @@
#include <hardware/hardware.h>
#include <hardware/hwcomposer.h>
#include <hardware/hwcomposer2.h>
-#include <stdint.h>
#include <atomic>
+#include <cstdint>
#include <functional>
#include <map>
diff --git a/include/drmhwcgralloc.h b/include/drmhwcgralloc.h
index 09c7499..958a636 100644
--- a/include/drmhwcgralloc.h
+++ b/include/drmhwcgralloc.h
@@ -17,10 +17,10 @@
#ifndef ANDROID_DRMHWCGRALLOC_H_
#define ANDROID_DRMHWCGRALLOC_H_
-#include <stdint.h>
+#include <cstdint>
#define HWC_DRM_BO_MAX_PLANES 4
-typedef struct hwc_drm_bo {
+struct hwc_drm_bo {
uint32_t width;
uint32_t height;
uint32_t format; /* DRM_FORMAT_* from drm_fourcc.h */
@@ -33,6 +33,8 @@
int prime_fds[HWC_DRM_BO_MAX_PLANES];
uint64_t modifiers[HWC_DRM_BO_MAX_PLANES];
int acquire_fence_fd;
-} hwc_drm_bo_t;
+};
+
+using hwc_drm_bo_t = hwc_drm_bo;
#endif // ANDROID_DRMHWCGRALLOC_H_
diff --git a/include/drmhwcomposer.h b/include/drmhwcomposer.h
index d02445b..75a5b39 100644
--- a/include/drmhwcomposer.h
+++ b/include/drmhwcomposer.h
@@ -19,9 +19,9 @@
#include <hardware/hardware.h>
#include <hardware/hwcomposer.h>
-#include <stdbool.h>
-#include <stdint.h>
+#include <cstdbool>
+#include <cstdint>
#include <vector>
#include "drm/DrmFbImporter.h"
@@ -61,7 +61,7 @@
};
struct DrmHwcLayer {
- buffer_handle_t sf_handle = NULL;
+ buffer_handle_t sf_handle = nullptr;
hwc_drm_bo_t buffer_info{};
std::shared_ptr<DrmFbIdHandle> FbIdHandle;
diff --git a/utils/Worker.h b/utils/Worker.h
index 73a80da..ab01d5f 100644
--- a/utils/Worker.h
+++ b/utils/Worker.h
@@ -17,10 +17,9 @@
#ifndef ANDROID_WORKER_H_
#define ANDROID_WORKER_H_
-#include <stdint.h>
-#include <stdlib.h>
-
#include <condition_variable>
+#include <cstdint>
+#include <cstdlib>
#include <mutex>
#include <string>
#include <thread>