refactor: use std::ranges whenever possible (#10584)
This commit is contained in:
parent
9bf1b49144
commit
9190443d95
50 changed files with 137 additions and 146 deletions
|
|
@ -255,7 +255,7 @@ EGLDeviceEXT CHyprOpenGLImpl::eglDeviceFromDRMFD(int drmFD) {
|
|||
CHyprOpenGLImpl::CHyprOpenGLImpl() : m_drmFD(g_pCompositor->m_drmFD) {
|
||||
const std::string EGLEXTENSIONS = (const char*)eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
|
||||
|
||||
Debug::log(LOG, "Supported EGL extensions: ({}) {}", std::count(EGLEXTENSIONS.begin(), EGLEXTENSIONS.end(), ' '), EGLEXTENSIONS);
|
||||
Debug::log(LOG, "Supported EGL extensions: ({}) {}", std::ranges::count(EGLEXTENSIONS, ' '), EGLEXTENSIONS);
|
||||
|
||||
m_exts.KHR_display_reference = EGLEXTENSIONS.contains("KHR_display_reference");
|
||||
|
||||
|
|
@ -331,7 +331,7 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() : m_drmFD(g_pCompositor->m_drmFD) {
|
|||
Debug::log(LOG, "Using: {}", (char*)glGetString(GL_VERSION));
|
||||
Debug::log(LOG, "Vendor: {}", (char*)glGetString(GL_VENDOR));
|
||||
Debug::log(LOG, "Renderer: {}", (char*)glGetString(GL_RENDERER));
|
||||
Debug::log(LOG, "Supported extensions: ({}) {}", std::count(m_extensions.begin(), m_extensions.end(), ' '), m_extensions);
|
||||
Debug::log(LOG, "Supported extensions: ({}) {}", std::ranges::count(m_extensions, ' '), m_extensions);
|
||||
|
||||
m_exts.EXT_read_format_bgra = m_extensions.contains("GL_EXT_read_format_bgra");
|
||||
|
||||
|
|
@ -415,7 +415,7 @@ std::optional<std::vector<uint64_t>> CHyprOpenGLImpl::getModsForFormat(EGLint fo
|
|||
}
|
||||
|
||||
// if the driver doesn't mark linear as external, add it. It's allowed unless the driver says otherwise. (e.g. nvidia)
|
||||
if (!linearIsExternal && std::find(mods.begin(), mods.end(), DRM_FORMAT_MOD_LINEAR) == mods.end() && mods.size() == 0)
|
||||
if (!linearIsExternal && std::ranges::find(mods, DRM_FORMAT_MOD_LINEAR) == mods.end() && mods.size() == 0)
|
||||
mods.push_back(DRM_FORMAT_MOD_LINEAR);
|
||||
|
||||
return result;
|
||||
|
|
@ -490,7 +490,7 @@ void CHyprOpenGLImpl::initDRMFormats() {
|
|||
free(fmtName);
|
||||
|
||||
mods.clear();
|
||||
std::sort(modifierData.begin(), modifierData.end(), [](const auto& a, const auto& b) {
|
||||
std::ranges::sort(modifierData, [](const auto& a, const auto& b) {
|
||||
if (a.first == 0)
|
||||
return false;
|
||||
if (a.second.contains("DCC"))
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ CHyprRenderer::CHyprRenderer() {
|
|||
if (!DRMV)
|
||||
continue;
|
||||
std::string name = std::string{DRMV->name, DRMV->name_len};
|
||||
std::transform(name.begin(), name.end(), name.begin(), tolower);
|
||||
std::ranges::transform(name, name.begin(), tolower);
|
||||
|
||||
if (name.contains("nvidia"))
|
||||
m_nvidia = true;
|
||||
|
|
@ -76,7 +76,7 @@ CHyprRenderer::CHyprRenderer() {
|
|||
|
||||
if (DRMV) {
|
||||
std::string name = std::string{DRMV->name, DRMV->name_len};
|
||||
std::transform(name.begin(), name.end(), name.begin(), tolower);
|
||||
std::ranges::transform(name, name.begin(), tolower);
|
||||
|
||||
if (name.contains("nvidia"))
|
||||
m_nvidia = true;
|
||||
|
|
@ -1794,7 +1794,7 @@ void CHyprRenderer::arrangeLayersForMonitor(const MONITORID& monitor) {
|
|||
}
|
||||
|
||||
for (auto& la : PMONITOR->m_layerSurfaceLayers) {
|
||||
std::stable_sort(la.begin(), la.end(), [](const PHLLSREF& a, const PHLLSREF& b) { return a->m_order > b->m_order; });
|
||||
std::ranges::stable_sort(la, [](const PHLLSREF& a, const PHLLSREF& b) { return a->m_order > b->m_order; });
|
||||
}
|
||||
|
||||
for (auto const& la : PMONITOR->m_layerSurfaceLayers)
|
||||
|
|
@ -2171,7 +2171,7 @@ void CHyprRenderer::recheckSolitaryForMonitor(PHLMONITOR pMonitor) {
|
|||
}
|
||||
|
||||
SP<CRenderbuffer> CHyprRenderer::getOrCreateRenderbuffer(SP<Aquamarine::IBuffer> buffer, uint32_t fmt) {
|
||||
auto it = std::find_if(m_renderbuffers.begin(), m_renderbuffers.end(), [&](const auto& other) { return other->m_hlBuffer == buffer; });
|
||||
auto it = std::ranges::find_if(m_renderbuffers, [&](const auto& other) { return other->m_hlBuffer == buffer; });
|
||||
|
||||
if (it != m_renderbuffers.end())
|
||||
return *it;
|
||||
|
|
@ -2364,7 +2364,7 @@ SExplicitSyncSettings CHyprRenderer::getExplicitSyncSettings(SP<Aquamarine::IOut
|
|||
void CHyprRenderer::addWindowToRenderUnfocused(PHLWINDOW window) {
|
||||
static auto PFPS = CConfigValue<Hyprlang::INT>("misc:render_unfocused_fps");
|
||||
|
||||
if (std::find(m_renderUnfocused.begin(), m_renderUnfocused.end(), window) != m_renderUnfocused.end())
|
||||
if (std::ranges::find(m_renderUnfocused, window) != m_renderUnfocused.end())
|
||||
return;
|
||||
|
||||
m_renderUnfocused.emplace_back(window);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ Vector2D CDecorationPositioner::getEdgeDefinedPoint(uint32_t edges, PHLWINDOW pW
|
|||
void CDecorationPositioner::uncacheDecoration(IHyprWindowDecoration* deco) {
|
||||
std::erase_if(m_windowPositioningDatas, [&](const auto& data) { return !data->pWindow.lock() || data->pDecoration == deco; });
|
||||
|
||||
const auto WIT = std::find_if(m_windowDatas.begin(), m_windowDatas.end(), [&](const auto& other) { return other.first.lock() == deco->m_window.lock(); });
|
||||
const auto WIT = std::ranges::find_if(m_windowDatas, [&](const auto& other) { return other.first.lock() == deco->m_window.lock(); });
|
||||
if (WIT == m_windowDatas.end())
|
||||
return;
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ void CDecorationPositioner::repositionDeco(IHyprWindowDecoration* deco) {
|
|||
}
|
||||
|
||||
CDecorationPositioner::SWindowPositioningData* CDecorationPositioner::getDataFor(IHyprWindowDecoration* pDecoration, PHLWINDOW pWindow) {
|
||||
auto it = std::find_if(m_windowPositioningDatas.begin(), m_windowPositioningDatas.end(), [&](const auto& el) { return el->pDecoration == pDecoration; });
|
||||
auto it = std::ranges::find_if(m_windowPositioningDatas, [&](const auto& el) { return el->pDecoration == pDecoration; });
|
||||
|
||||
if (it != m_windowPositioningDatas.end())
|
||||
return it->get();
|
||||
|
|
@ -89,15 +89,14 @@ void CDecorationPositioner::sanitizeDatas() {
|
|||
std::erase_if(m_windowPositioningDatas, [](const auto& other) {
|
||||
if (!validMapped(other->pWindow))
|
||||
return true;
|
||||
if (std::find_if(other->pWindow->m_windowDecorations.begin(), other->pWindow->m_windowDecorations.end(), [&](const auto& el) { return el.get() == other->pDecoration; }) ==
|
||||
other->pWindow->m_windowDecorations.end())
|
||||
if (std::ranges::find_if(other->pWindow->m_windowDecorations, [&](const auto& el) { return el.get() == other->pDecoration; }) == other->pWindow->m_windowDecorations.end())
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
void CDecorationPositioner::forceRecalcFor(PHLWINDOW pWindow) {
|
||||
const auto WIT = std::find_if(m_windowDatas.begin(), m_windowDatas.end(), [&](const auto& other) { return other.first.lock() == pWindow; });
|
||||
const auto WIT = std::ranges::find_if(m_windowDatas, [&](const auto& other) { return other.first.lock() == pWindow; });
|
||||
if (WIT == m_windowDatas.end())
|
||||
return;
|
||||
|
||||
|
|
@ -110,7 +109,7 @@ void CDecorationPositioner::onWindowUpdate(PHLWINDOW pWindow) {
|
|||
if (!validMapped(pWindow))
|
||||
return;
|
||||
|
||||
const auto WIT = std::find_if(m_windowDatas.begin(), m_windowDatas.end(), [&](const auto& other) { return other.first.lock() == pWindow; });
|
||||
const auto WIT = std::ranges::find_if(m_windowDatas, [&](const auto& other) { return other.first.lock() == pWindow; });
|
||||
if (WIT == m_windowDatas.end())
|
||||
return;
|
||||
|
||||
|
|
@ -128,8 +127,7 @@ void CDecorationPositioner::onWindowUpdate(PHLWINDOW pWindow) {
|
|||
}
|
||||
|
||||
if (WINDOWDATA->lastWindowSize == pWindow->m_realSize->value() /* position not changed */
|
||||
&& std::all_of(m_windowPositioningDatas.begin(), m_windowPositioningDatas.end(),
|
||||
[pWindow](const auto& data) { return pWindow != data->pWindow.lock() || !data->needsReposition; })
|
||||
&& std::ranges::all_of(m_windowPositioningDatas, [pWindow](const auto& data) { return pWindow != data->pWindow.lock() || !data->needsReposition; })
|
||||
/* all window datas are either not for this window or don't need a reposition */
|
||||
&& !WINDOWDATA->needsRecalc /* window doesn't need recalc */
|
||||
)
|
||||
|
|
@ -143,7 +141,7 @@ void CDecorationPositioner::onWindowUpdate(PHLWINDOW pWindow) {
|
|||
WINDOWDATA->needsRecalc = false;
|
||||
const bool EPHEMERAL = pWindow->m_realSize->isBeingAnimated();
|
||||
|
||||
std::sort(datas.begin(), datas.end(), [](const auto& a, const auto& b) { return a->positioningInfo.priority > b->positioningInfo.priority; });
|
||||
std::ranges::sort(datas, [](const auto& a, const auto& b) { return a->positioningInfo.priority > b->positioningInfo.priority; });
|
||||
|
||||
CBox wb = pWindow->getWindowMainSurfaceBox();
|
||||
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ void CRenderPass::renderDebugData() {
|
|||
}
|
||||
}
|
||||
|
||||
const auto DISCARDED_ELEMENTS = std::count_if(m_passElements.begin(), m_passElements.end(), [](const auto& e) { return e->discard; });
|
||||
const auto DISCARDED_ELEMENTS = std::ranges::count_if(m_passElements, [](const auto& e) { return e->discard; });
|
||||
auto tex = g_pHyprOpenGL->renderText(std::format("occlusion layers: {}\npass elements: {} ({} discarded)\nviewport: {:X0}", m_occludedRegions.size(), m_passElements.size(),
|
||||
DISCARDED_ELEMENTS, g_pHyprOpenGL->m_renderData.pMonitor->m_pixelSize),
|
||||
Colors::WHITE, 12);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue