diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..f0dfdf1 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,101 @@ +WarningsAsErrors: '*' +HeaderFilterRegex: '.*\.hpp' +FormatStyle: file +Checks: > + -*, + bugprone-*, + -bugprone-easily-swappable-parameters, + -bugprone-forward-declararion-namespace, + -bugprone-forward-declararion-namespace, + -bugprone-macro-parentheses, + -bugprone-narrowing-conversions, + -bugprone-branch-clone, + -bugprone-assignment-in-if-condition, + concurrency-*, + -concurrency-mt-unsafe, + cppcoreguidelines-*, + -cppcoreguidelines-owning-memory, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-pro-bounds-constant-array-index, + -cppcoreguidelines-avoid-const-or-ref-data-members, + -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-avoid-goto, + -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + -cppcoreguidelines-avoid-do-while, + -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-special-member-functions, + -cppcoreguidelines-explicit-virtual-functions, + -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-pro-bounds-pointer-arithmetic, + -cppcoreguidelines-narrowing-conversions, + -cppcoreguidelines-pro-type-union-access, + -cppcoreguidelines-pro-type-member-init, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-macro-to-enum, + -cppcoreguidelines-init-variables, + -cppcoreguidelines-pro-type-cstyle-cast, + -cppcoreguidelines-pro-type-vararg, + -cppcoreguidelines-pro-type-reinterpret-cast, + google-global-names-in-headers, + -google-readability-casting, + google-runtime-operator, + misc-*, + -misc-unused-parameters, + -misc-no-recursion, + -misc-non-private-member-variables-in-classes, + -misc-include-cleaner, + -misc-use-anonymous-namespace, + -misc-const-correctness, + modernize-*, + -modernize-return-braced-init-list, + -modernize-use-trailing-return-type, + -modernize-use-using, + -modernize-use-override, + -modernize-avoid-c-arrays, + -modernize-macro-to-enum, + -modernize-loop-convert, + -modernize-use-nodiscard, + -modernize-pass-by-value, + -modernize-use-auto, + performance-*, + -performance-avoid-endl, + -performance-unnecessary-value-param, + portability-std-allocator-const, + readability-*, + -readability-function-cognitive-complexity, + -readability-function-size, + -readability-identifier-length, + -readability-magic-numbers, + -readability-uppercase-literal-suffix, + -readability-braces-around-statements, + -readability-redundant-access-specifiers, + -readability-else-after-return, + -readability-container-data-pointer, + -readability-implicit-bool-conversion, + -readability-avoid-nested-conditional-operator, + -readability-redundant-member-init, + -readability-redundant-string-init, + -readability-avoid-const-params-in-decls, + -readability-named-parameter, + -readability-convert-member-functions-to-static, + -readability-qualified-auto, + -readability-make-member-function-const, + -readability-isolate-declaration, + -readability-inconsistent-declaration-parameter-name, + -clang-diagnostic-error, + +CheckOptions: + performance-for-range-copy.WarnOnAllAutoCopies: true + performance-inefficient-string-concatenation.StrictMode: true + readability-braces-around-statements.ShortStatementLines: 0 + readability-identifier-naming.ClassCase: CamelCase + readability-identifier-naming.ClassIgnoredRegexp: I.* + readability-identifier-naming.ClassPrefix: C # We can't use regex here?!?!?!? + readability-identifier-naming.EnumCase: CamelCase + readability-identifier-naming.EnumPrefix: e + readability-identifier-naming.EnumConstantCase: UPPER_CASE + readability-identifier-naming.FunctionCase: camelBack + readability-identifier-naming.NamespaceCase: CamelCase + readability-identifier-naming.NamespacePrefix: N + readability-identifier-naming.StructPrefix: S + readability-identifier-naming.StructCase: CamelCase diff --git a/src/allocator/GBM.cpp b/src/allocator/GBM.cpp index a061111..aacd2eb 100644 --- a/src/allocator/GBM.cpp +++ b/src/allocator/GBM.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -24,23 +25,23 @@ static SDRMFormat guessFormatFrom(std::vector formats, bool cursor, */ if (!scanout) { if (auto it = - std::find_if(formats.begin(), formats.end(), [](const auto& f) { return f.drmFormat == DRM_FORMAT_ARGB2101010 || f.drmFormat == DRM_FORMAT_ABGR2101010; }); + std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_ARGB2101010 || f.drmFormat == DRM_FORMAT_ABGR2101010; }); it != formats.end()) return *it; } - if (auto it = std::find_if(formats.begin(), formats.end(), [](const auto& f) { return f.drmFormat == DRM_FORMAT_XRGB2101010 || f.drmFormat == DRM_FORMAT_XBGR2101010; }); + if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_XRGB2101010 || f.drmFormat == DRM_FORMAT_XBGR2101010; }); it != formats.end()) return *it; } if (!scanout || cursor /* don't set opaque for cursor plane */) { - if (auto it = std::find_if(formats.begin(), formats.end(), [](const auto& f) { return f.drmFormat == DRM_FORMAT_ARGB8888 || f.drmFormat == DRM_FORMAT_ABGR8888; }); + if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_ARGB8888 || f.drmFormat == DRM_FORMAT_ABGR8888; }); it != formats.end()) return *it; } - if (auto it = std::find_if(formats.begin(), formats.end(), [](const auto& f) { return f.drmFormat == DRM_FORMAT_XRGB8888 || f.drmFormat == DRM_FORMAT_XBGR8888; }); + if (auto it = std::ranges::find_if(formats, [](const auto& f) { return f.drmFormat == DRM_FORMAT_XRGB8888 || f.drmFormat == DRM_FORMAT_XBGR8888; }); it != formats.end()) return *it; @@ -119,7 +120,7 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti TRACE(allocator->backend->log(AQ_LOG_TRACE, std::format("GBM: Renderable has {} formats, clipping", RENDERABLE.size()))); if (params.scanout && !CURSOR && !MULTIGPU) { // regular scanout plane, check if the format is renderable - auto rformat = std::find_if(RENDERABLE.begin(), RENDERABLE.end(), [f](const auto& e) { return e.drmFormat == f.drmFormat; }); + auto rformat = std::ranges::find_if(RENDERABLE, [f](const auto& e) { return e.drmFormat == f.drmFormat; }); if (rformat == RENDERABLE.end()) { TRACE(allocator->backend->log(AQ_LOG_TRACE, std::format("GBM: Dropping format {} as it's not renderable", fourccToName(f.drmFormat)))); @@ -322,8 +323,7 @@ SP Aquamarine::CGBMAllocator::create(int drmfd_, Hyprutils::Memor return allocator; } -Aquamarine::CGBMAllocator::CGBMAllocator(int fd_, Hyprutils::Memory::CWeakPointer backend_) : fd(fd_), backend(backend_) { - gbmDevice = gbm_create_device(fd_); +Aquamarine::CGBMAllocator::CGBMAllocator(int fd_, Hyprutils::Memory::CWeakPointer backend_) : fd(fd_), backend(backend_), gbmDevice(gbm_create_device(fd_)) { if (!gbmDevice) { backend->log(AQ_LOG_ERROR, std::format("Couldn't open a GBM device at fd {}", fd_)); return; diff --git a/src/allocator/Swapchain.cpp b/src/allocator/Swapchain.cpp index 32c224d..143542a 100644 --- a/src/allocator/Swapchain.cpp +++ b/src/allocator/Swapchain.cpp @@ -1,3 +1,4 @@ +#include #include #include #include "FormatUtils.hpp" @@ -114,7 +115,7 @@ bool Aquamarine::CSwapchain::resize(size_t newSize) { } bool Aquamarine::CSwapchain::contains(SP buffer) { - return std::find(buffers.begin(), buffers.end(), buffer) != buffers.end(); + return std::ranges::find(buffers, buffer) != buffers.end(); } const SSwapchainOptions& Aquamarine::CSwapchain::currentOptions() { diff --git a/src/backend/Backend.cpp b/src/backend/Backend.cpp index 9f4b080..8bb9f47 100644 --- a/src/backend/Backend.cpp +++ b/src/backend/Backend.cpp @@ -5,8 +5,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -44,13 +44,12 @@ Aquamarine::CBackend::CBackend() { ; } -Aquamarine::SBackendImplementationOptions::SBackendImplementationOptions() { - backendType = AQ_BACKEND_WAYLAND; - backendRequestMode = AQ_BACKEND_REQUEST_IF_AVAILABLE; +Aquamarine::SBackendImplementationOptions::SBackendImplementationOptions() : backendType(AQ_BACKEND_WAYLAND), backendRequestMode(AQ_BACKEND_REQUEST_IF_AVAILABLE) { + ; } -Aquamarine::SBackendOptions::SBackendOptions() { - logFunction = nullptr; +Aquamarine::SBackendOptions::SBackendOptions() : logFunction(nullptr) { + ; } Hyprutils::Memory::CSharedPointer Aquamarine::CBackend::create(const std::vector& backends, const SBackendOptions& options) { diff --git a/src/backend/Headless.cpp b/src/backend/Headless.cpp index b556a07..6dabb71 100644 --- a/src/backend/Headless.cpp +++ b/src/backend/Headless.cpp @@ -1,8 +1,8 @@ #include #include -#include +#include #include -#include +#include #include "Shared.hpp" using namespace Aquamarine; diff --git a/src/backend/Session.cpp b/src/backend/Session.cpp index b2d37a2..dc83926 100644 --- a/src/backend/Session.cpp +++ b/src/backend/Session.cpp @@ -340,7 +340,6 @@ void Aquamarine::CSession::dispatchUdevEvents() { } udev_device_unref(device); - return; } void Aquamarine::CSession::dispatchLibinputEvents() { diff --git a/src/backend/Wayland.cpp b/src/backend/Wayland.cpp index ec81b07..40e59e9 100644 --- a/src/backend/Wayland.cpp +++ b/src/backend/Wayland.cpp @@ -1,9 +1,10 @@ +#include #include #include #include #include "Shared.hpp" #include "FormatUtils.hpp" -#include +#include #include #include #include @@ -403,7 +404,7 @@ bool Aquamarine::CWaylandBackend::initDmabuf() { backend->log(AQ_LOG_DEBUG, std::format("zwp_linux_dmabuf_v1: Got format {} with modifier {}", fourccToName(fmt.drmFormat), modName ? modName : "UNKNOWN")); free(modName); - auto it = std::find_if(dmabufFormats.begin(), dmabufFormats.end(), [&fmt](const auto& e) { return e.drmFormat == fmt.drmFormat; }); + auto it = std::ranges::find_if(dmabufFormats, [&fmt](const auto& e) { return e.drmFormat == fmt.drmFormat; }); if (it == dmabufFormats.end()) { dmabufFormats.emplace_back(SDRMFormat{.drmFormat = fmt.drmFormat, .modifiers = {fmt.modifier}}); continue; @@ -739,7 +740,7 @@ bool Aquamarine::CWaylandOutput::setCursor(Hyprutils::Memory::CSharedPointer pointer, uint32_t serial) { diff --git a/src/backend/drm/DRM.cpp b/src/backend/drm/DRM.cpp index 38222b4..af4681f 100644 --- a/src/backend/drm/DRM.cpp +++ b/src/backend/drm/DRM.cpp @@ -1,4 +1,5 @@ #include "aquamarine/output/Output.hpp" +#include #include #include #include @@ -306,7 +307,7 @@ std::vector> Aquamarine::CDRMBackend::attempt(SP backe } Aquamarine::CDRMBackend::~CDRMBackend() { - for (auto conn : connectors) { + for (auto& conn : connectors) { conn->disconnect(); conn.reset(); } @@ -582,14 +583,14 @@ void Aquamarine::CDRMBackend::buildGlFormats(const std::vector& fmts) if (fmt.external && fmt.modifier != DRM_FORMAT_MOD_INVALID) continue; - if (auto it = std::find_if(result.begin(), result.end(), [fmt](const auto& e) { return fmt.drmFormat == e.drmFormat; }); it != result.end()) { + if (auto it = std::ranges::find_if(result, [fmt](const auto& e) { return fmt.drmFormat == e.drmFormat; }); it != result.end()) { it->modifiers.emplace_back(fmt.modifier); continue; } result.emplace_back(SDRMFormat{ - fmt.drmFormat, - {fmt.modifier}, + .drmFormat = fmt.drmFormat, + .modifiers = {fmt.modifier}, }); } @@ -774,7 +775,7 @@ void Aquamarine::CDRMBackend::scanConnectors() { continue; } - auto it = std::find_if(connectors.begin(), connectors.end(), [connectorID](const auto& e) { return e->id == connectorID; }); + auto it = std::ranges::find_if(connectors, [connectorID](const auto& e) { return e->id == connectorID; }); if (it == connectors.end()) { backend->log(AQ_LOG_DEBUG, std::format("drm: Initializing connector id {}", connectorID)); conn = connectors.emplace_back(SP(new SDRMConnector())); @@ -1077,7 +1078,7 @@ bool Aquamarine::SDRMPlane::init(drmModePlane* plane) { drmModeFormatModifierIterator iter = {0}; while (drmModeFormatModifierBlobIterNext(blob, &iter)) { - auto it = std::find_if(formats.begin(), formats.end(), [iter](const auto& e) { return e.drmFormat == iter.fmt; }); + auto it = std::ranges::find_if(formats, [iter](const auto& e) { return e.drmFormat == iter.fmt; }); TRACE(backend->backend->log(AQ_LOG_TRACE, std::format("drm: | Modifier {} with format {}", iter.mod, fourccToName(iter.fmt)))); @@ -1250,10 +1251,10 @@ IOutput::SParsedEDID Aquamarine::SDRMConnector::parseEDID(std::vector d const auto chromaticity = di_edid_get_chromaticity_coords(edid); if (chromaticity) { parsed.chromaticityCoords = IOutput::SChromaticityCoords{ - IOutput::xy{chromaticity->red_x, chromaticity->red_y}, - IOutput::xy{chromaticity->green_x, chromaticity->green_y}, - IOutput::xy{chromaticity->blue_x, chromaticity->blue_y}, - IOutput::xy{chromaticity->white_x, chromaticity->white_y}, + .red = IOutput::xy{.x = chromaticity->red_x, .y = chromaticity->red_y}, + .green = IOutput::xy{.x = chromaticity->green_x, .y = chromaticity->green_y}, + .blue = IOutput::xy{.x = chromaticity->blue_x, .y = chromaticity->blue_y}, + .white = IOutput::xy{.x = chromaticity->white_x, .y = chromaticity->white_y}, }; TRACE(backend->backend->log(AQ_LOG_TRACE, std::format("EDID: chromaticity coords {},{} {},{} {},{} {},{}", parsed.chromaticityCoords->red.x, parsed.chromaticityCoords->red.y, @@ -1362,7 +1363,7 @@ void Aquamarine::SDRMConnector::connect(drmModeConnector* connector) { output->modes.emplace_back(aqMode); - if (currentModeInfo && std::memcmp(&drmMode, currentModeInfo, sizeof(drmModeModeInfo))) { + if (currentModeInfo && std::memcmp(&drmMode, currentModeInfo, sizeof(drmModeModeInfo)) != 0) { output->state->setMode(aqMode); //uint64_t modeID = 0; diff --git a/src/backend/drm/Props.cpp b/src/backend/drm/Props.cpp index 961e665..7f6ffc6 100644 --- a/src/backend/drm/Props.cpp +++ b/src/backend/drm/Props.cpp @@ -20,59 +20,59 @@ struct prop_info { static const struct prop_info connector_info[] = { #define INDEX(name) (offsetof(SDRMConnector::UDRMConnectorProps, name) / sizeof(uint32_t)) - {"CRTC_ID", INDEX(crtc_id)}, - {"Colorspace", INDEX(Colorspace)}, - {"DPMS", INDEX(dpms)}, - {"EDID", INDEX(edid)}, - {"HDR_OUTPUT_METADATA", INDEX(hdr_output_metadata)}, - {"PATH", INDEX(path)}, - {"content type", INDEX(content_type)}, - {"link-status", INDEX(link_status)}, - {"max bpc", INDEX(max_bpc)}, - {"non-desktop", INDEX(non_desktop)}, - {"panel orientation", INDEX(panel_orientation)}, - {"subconnector", INDEX(subconnector)}, - {"vrr_capable", INDEX(vrr_capable)}, + {.name = "CRTC_ID", .index = INDEX(crtc_id)}, + {.name = "Colorspace", .index = INDEX(Colorspace)}, + {.name = "DPMS", .index = INDEX(dpms)}, + {.name = "EDID", .index = INDEX(edid)}, + {.name = "HDR_OUTPUT_METADATA", .index = INDEX(hdr_output_metadata)}, + {.name = "PATH", .index = INDEX(path)}, + {.name = "content type", .index = INDEX(content_type)}, + {.name = "link-status", .index = INDEX(link_status)}, + {.name = "max bpc", .index = INDEX(max_bpc)}, + {.name = "non-desktop", .index = INDEX(non_desktop)}, + {.name = "panel orientation", .index = INDEX(panel_orientation)}, + {.name = "subconnector", .index = INDEX(subconnector)}, + {.name = "vrr_capable", .index = INDEX(vrr_capable)}, #undef INDEX }; static const struct prop_info colorspace_info[] = { #define INDEX(name) (offsetof(SDRMConnector::UDRMConnectorColorspace, name) / sizeof(uint32_t)) - {"BT2020_RGB", INDEX(BT2020_RGB)}, - {"BT2020_YCC", INDEX(BT2020_YCC)}, - {"Default", INDEX(Default)}, + {.name = "BT2020_RGB", .index = INDEX(BT2020_RGB)}, + {.name = "BT2020_YCC", .index = INDEX(BT2020_YCC)}, + {.name = "Default", .index = INDEX(Default)}, #undef INDEX }; static const struct prop_info crtc_info[] = { #define INDEX(name) (offsetof(SDRMCRTC::UDRMCRTCProps, name) / sizeof(uint32_t)) - {"ACTIVE", INDEX(active)}, {"CTM", INDEX(ctm)}, - {"DEGAMMA_LUT", INDEX(degamma_lut)}, {"DEGAMMA_LUT_SIZE", INDEX(degamma_lut_size)}, - {"GAMMA_LUT", INDEX(gamma_lut)}, {"GAMMA_LUT_SIZE", INDEX(gamma_lut_size)}, - {"MODE_ID", INDEX(mode_id)}, {"OUT_FENCE_PTR", INDEX(out_fence_ptr)}, - {"VRR_ENABLED", INDEX(vrr_enabled)}, + {.name = "ACTIVE", .index = INDEX(active)}, {.name = "CTM", .index = INDEX(ctm)}, + {.name = "DEGAMMA_LUT", .index = INDEX(degamma_lut)}, {.name = "DEGAMMA_LUT_SIZE", .index = INDEX(degamma_lut_size)}, + {.name = "GAMMA_LUT", .index = INDEX(gamma_lut)}, {.name = "GAMMA_LUT_SIZE", .index = INDEX(gamma_lut_size)}, + {.name = "MODE_ID", .index = INDEX(mode_id)}, {.name = "OUT_FENCE_PTR", .index = INDEX(out_fence_ptr)}, + {.name = "VRR_ENABLED", .index = INDEX(vrr_enabled)}, #undef INDEX }; static const struct prop_info plane_info[] = { #define INDEX(name) (offsetof(SDRMPlane::UDRMPlaneProps, name) / sizeof(uint32_t)) - {"CRTC_H", INDEX(crtc_h)}, - {"CRTC_ID", INDEX(crtc_id)}, - {"CRTC_W", INDEX(crtc_w)}, - {"CRTC_X", INDEX(crtc_x)}, - {"CRTC_Y", INDEX(crtc_y)}, - {"FB_DAMAGE_CLIPS", INDEX(fb_damage_clips)}, - {"FB_ID", INDEX(fb_id)}, - {"HOTSPOT_X", INDEX(hotspot_x)}, - {"HOTSPOT_Y", INDEX(hotspot_y)}, - {"IN_FENCE_FD", INDEX(in_fence_fd)}, - {"IN_FORMATS", INDEX(in_formats)}, - {"SRC_H", INDEX(src_h)}, - {"SRC_W", INDEX(src_w)}, - {"SRC_X", INDEX(src_x)}, - {"SRC_Y", INDEX(src_y)}, - {"rotation", INDEX(rotation)}, - {"type", INDEX(type)}, + {.name = "CRTC_H", .index = INDEX(crtc_h)}, + {.name = "CRTC_ID", .index = INDEX(crtc_id)}, + {.name = "CRTC_W", .index = INDEX(crtc_w)}, + {.name = "CRTC_X", .index = INDEX(crtc_x)}, + {.name = "CRTC_Y", .index = INDEX(crtc_y)}, + {.name = "FB_DAMAGE_CLIPS", .index = INDEX(fb_damage_clips)}, + {.name = "FB_ID", .index = INDEX(fb_id)}, + {.name = "HOTSPOT_X", .index = INDEX(hotspot_x)}, + {.name = "HOTSPOT_Y", .index = INDEX(hotspot_y)}, + {.name = "IN_FENCE_FD", .index = INDEX(in_fence_fd)}, + {.name = "IN_FORMATS", .index = INDEX(in_formats)}, + {.name = "SRC_H", .index = INDEX(src_h)}, + {.name = "SRC_W", .index = INDEX(src_w)}, + {.name = "SRC_X", .index = INDEX(src_x)}, + {.name = "SRC_Y", .index = INDEX(src_y)}, + {.name = "rotation", .index = INDEX(rotation)}, + {.name = "type", .index = INDEX(type)}, #undef INDEX }; diff --git a/src/backend/drm/Renderer.cpp b/src/backend/drm/Renderer.cpp index 7d4d7d8..5388926 100644 --- a/src/backend/drm/Renderer.cpp +++ b/src/backend/drm/Renderer.cpp @@ -1,13 +1,13 @@ #include "Renderer.hpp" #include #include +#include #include #include #include #include "Math.hpp" #include "Shared.hpp" #include "FormatUtils.hpp" -#include #include using namespace Aquamarine; @@ -99,7 +99,7 @@ void main() { inline void loadGLProc(void* pProc, const char* name) { void* proc = (void*)eglGetProcAddress(name); - if (proc == NULL) { + if (!proc) { gBackend->log(AQ_LOG_ERROR, std::format("eglGetProcAddress({}) failed", name)); abort(); } @@ -129,12 +129,13 @@ std::optional>> CDRMRenderer::getModsForFo egl.eglQueryDmaBufModifiersEXT(egl.display, format, len, mods.data(), external.data(), &len); std::vector> result; + result.reserve(mods.size()); for (size_t i = 0; i < mods.size(); ++i) { - result.push_back({mods.at(i), external.at(i)}); + result.emplace_back(mods.at(i), external.at(i)); } - if (std::find(mods.begin(), mods.end(), DRM_FORMAT_MOD_LINEAR) == mods.end() && mods.size() == 0) - result.push_back({DRM_FORMAT_MOD_LINEAR, true}); + if (std::ranges::find(mods, DRM_FORMAT_MOD_LINEAR) == mods.end() && mods.size() == 0) + result.emplace_back(DRM_FORMAT_MOD_LINEAR, true); return result; } @@ -168,7 +169,7 @@ bool CDRMRenderer::initDRMFormats() { hasModifiers = hasModifiers || mods.size() > 0; // EGL can always do implicit modifiers. - mods.push_back({DRM_FORMAT_MOD_INVALID, true}); + mods.emplace_back(DRM_FORMAT_MOD_INVALID, true); for (auto const& [mod, external] : mods) { dmaFormats.push_back(SGLFormat{ @@ -212,7 +213,7 @@ SP CDRMRenderer::attempt(Hyprutils::Memory::CSharedPointerbackend = backend_; gBackend = backend_; - const std::string EGLEXTENSIONS = (const char*)eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + const std::string EGLEXTENSIONS = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); if (!EGLEXTENSIONS.contains("KHR_platform_gbm")) { backend_->log(AQ_LOG_ERROR, "CDRMRenderer: fail, no gbm support"); @@ -283,7 +284,7 @@ SP CDRMRenderer::attempt(Hyprutils::Memory::CSharedPointeregl.display, EGL_EXTENSIONS); + const std::string EGLEXTENSIONS2 = eglQueryString(renderer->egl.display, EGL_EXTENSIONS); if (EGLEXTENSIONS2.contains("IMG_context_priority")) { attrs.push_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG); @@ -407,10 +408,10 @@ EGLImageKHR CDRMRenderer::createEGLImage(const SDMABUFAttrs& attrs) { EGLint modlo; EGLint modhi; } attrNames[4] = { - {EGL_DMA_BUF_PLANE0_FD_EXT, EGL_DMA_BUF_PLANE0_OFFSET_EXT, EGL_DMA_BUF_PLANE0_PITCH_EXT, EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT}, - {EGL_DMA_BUF_PLANE1_FD_EXT, EGL_DMA_BUF_PLANE1_OFFSET_EXT, EGL_DMA_BUF_PLANE1_PITCH_EXT, EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT}, - {EGL_DMA_BUF_PLANE2_FD_EXT, EGL_DMA_BUF_PLANE2_OFFSET_EXT, EGL_DMA_BUF_PLANE2_PITCH_EXT, EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT}, - {EGL_DMA_BUF_PLANE3_FD_EXT, EGL_DMA_BUF_PLANE3_OFFSET_EXT, EGL_DMA_BUF_PLANE3_PITCH_EXT, EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT}}; + {.fd = EGL_DMA_BUF_PLANE0_FD_EXT, .offset = EGL_DMA_BUF_PLANE0_OFFSET_EXT, .pitch = EGL_DMA_BUF_PLANE0_PITCH_EXT, .modlo = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, .modhi = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT}, + {.fd = EGL_DMA_BUF_PLANE1_FD_EXT, .offset = EGL_DMA_BUF_PLANE1_OFFSET_EXT, .pitch = EGL_DMA_BUF_PLANE1_PITCH_EXT, .modlo = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT, .modhi = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT}, + {.fd = EGL_DMA_BUF_PLANE2_FD_EXT, .offset = EGL_DMA_BUF_PLANE2_OFFSET_EXT, .pitch = EGL_DMA_BUF_PLANE2_PITCH_EXT, .modlo = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT, .modhi = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT}, + {.fd = EGL_DMA_BUF_PLANE3_FD_EXT, .offset = EGL_DMA_BUF_PLANE3_OFFSET_EXT, .pitch = EGL_DMA_BUF_PLANE3_PITCH_EXT, .modlo = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT, .modhi = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT}}; for (int i = 0; i < attrs.planes; i++) { attribs.push_back(attrNames[i].fd); @@ -787,7 +788,7 @@ CDRMRenderer::SBlitResult CDRMRenderer::blit(SP from, SP to, i restoreEGL(); - return {true, explicitFD == -1 ? std::nullopt : std::optional{explicitFD}}; + return {.success = true, .syncFD = explicitFD == -1 ? std::nullopt : std::optional{explicitFD}}; } void CDRMRenderer::onBufferAttachmentDrop(CDRMRendererBufferAttachment* attachment) { diff --git a/src/backend/drm/impl/Atomic.cpp b/src/backend/drm/impl/Atomic.cpp index b11ab3c..da920a2 100644 --- a/src/backend/drm/impl/Atomic.cpp +++ b/src/backend/drm/impl/Atomic.cpp @@ -13,8 +13,7 @@ using namespace Hyprutils::Memory; using namespace Hyprutils::Math; #define SP CSharedPointer -Aquamarine::CDRMAtomicRequest::CDRMAtomicRequest(Hyprutils::Memory::CWeakPointer backend_) : backend(backend_) { - req = drmModeAtomicAlloc(); +Aquamarine::CDRMAtomicRequest::CDRMAtomicRequest(Hyprutils::Memory::CWeakPointer backend_) : backend(backend_), req(drmModeAtomicAlloc()) { if (!req) failed = true; } @@ -284,7 +283,7 @@ bool Aquamarine::CDRMAtomicImpl::prepareConnector(Hyprutils::Memory::CSharedPoin if (!enable) data.atomic.modeBlob = 0; else { - if (drmModeCreatePropertyBlob(connector->backend->gpu->fd, (drmModeModeInfo*)&data.modeInfo, sizeof(drmModeModeInfo), &data.atomic.modeBlob)) { + if (drmModeCreatePropertyBlob(connector->backend->gpu->fd, &data.modeInfo, sizeof(drmModeModeInfo), &data.atomic.modeBlob)) { connector->backend->backend->log(AQ_LOG_ERROR, "atomic drm: failed to create a modeset blob"); return false; } @@ -299,7 +298,7 @@ bool Aquamarine::CDRMAtomicImpl::prepareConnector(Hyprutils::Memory::CSharedPoin if (!prop) // TODO: allow this with legacy gamma, perhaps. connector->backend->backend->log(AQ_LOG_ERROR, "atomic drm: failed to commit gamma: no gamma_lut prop"); else if (gammaLut.empty()) { - blobId = 0; + blobId = nullptr; return true; } else { std::vector lut; diff --git a/src/backend/drm/impl/Legacy.cpp b/src/backend/drm/impl/Legacy.cpp index 6dac7e5..e9ac9a2 100644 --- a/src/backend/drm/impl/Legacy.cpp +++ b/src/backend/drm/impl/Legacy.cpp @@ -49,7 +49,7 @@ bool Aquamarine::CDRMLegacyImpl::commitInternal(Hyprutils::Memory::CSharedPointe drmModeModeInfo* mode = nullptr; if (enable) { connectors.push_back(connector->id); - mode = (drmModeModeInfo*)&data.modeInfo; + mode = &data.modeInfo; } if (mode) { @@ -165,4 +165,4 @@ bool Aquamarine::CDRMLegacyImpl::reset() { } return ok; -} \ No newline at end of file +}