mirror of
https://github.com/hyprwm/aquamarine.git
synced 2024-12-22 11:39:49 +01:00
misc: make for loops const reference (#66)
we all like the dreams and prayers that compilers can optimize things further with const.
This commit is contained in:
parent
abb3c81c59
commit
7cc3d3179c
11 changed files with 62 additions and 62 deletions
|
@ -35,7 +35,7 @@ static SDRMFormat guessFormatFrom(std::vector<SDRMFormat> formats, bool cursor)
|
||||||
if (auto it = std::find_if(formats.begin(), formats.end(), [](const auto& f) { return f.drmFormat == DRM_FORMAT_XRGB8888; }); it != formats.end())
|
if (auto it = std::find_if(formats.begin(), formats.end(), [](const auto& f) { return f.drmFormat == DRM_FORMAT_XRGB8888; }); it != formats.end())
|
||||||
return *it;
|
return *it;
|
||||||
|
|
||||||
for (auto& f : formats) {
|
for (auto const& f : formats) {
|
||||||
auto name = fourccToName(f.drmFormat);
|
auto name = fourccToName(f.drmFormat);
|
||||||
|
|
||||||
/* 10 bpp RGB */
|
/* 10 bpp RGB */
|
||||||
|
@ -43,7 +43,7 @@ static SDRMFormat guessFormatFrom(std::vector<SDRMFormat> formats, bool cursor)
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& f : formats) {
|
for (auto const& f : formats) {
|
||||||
auto name = fourccToName(f.drmFormat);
|
auto name = fourccToName(f.drmFormat);
|
||||||
|
|
||||||
/* 8 bpp RGB */
|
/* 8 bpp RGB */
|
||||||
|
@ -93,11 +93,11 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti
|
||||||
if (!RENDERABLE.empty()) {
|
if (!RENDERABLE.empty()) {
|
||||||
TRACE(allocator->backend->log(AQ_LOG_TRACE, std::format("GBM: Renderable has {} formats, clipping", RENDERABLE.size())));
|
TRACE(allocator->backend->log(AQ_LOG_TRACE, std::format("GBM: Renderable has {} formats, clipping", RENDERABLE.size())));
|
||||||
|
|
||||||
for (auto& f : FORMATS) {
|
for (auto const& f : FORMATS) {
|
||||||
if (f.drmFormat != attrs.format)
|
if (f.drmFormat != attrs.format)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (auto& m : f.modifiers) {
|
for (auto const& m : f.modifiers) {
|
||||||
if (m == DRM_FORMAT_MOD_INVALID)
|
if (m == DRM_FORMAT_MOD_INVALID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti
|
||||||
bo = gbm_bo_create(allocator->gbmDevice, attrs.size.x, attrs.size.y, attrs.format, flags);
|
bo = gbm_bo_create(allocator->gbmDevice, attrs.size.x, attrs.size.y, attrs.format, flags);
|
||||||
} else {
|
} else {
|
||||||
TRACE(allocator->backend->log(AQ_LOG_TRACE, std::format("GBM: Using modifier-based allocation, modifiers: {}", explicitModifiers.size())));
|
TRACE(allocator->backend->log(AQ_LOG_TRACE, std::format("GBM: Using modifier-based allocation, modifiers: {}", explicitModifiers.size())));
|
||||||
for (auto& mod : explicitModifiers) {
|
for (auto const& mod : explicitModifiers) {
|
||||||
TRACE(allocator->backend->log(AQ_LOG_TRACE, std::format("GBM: | mod 0x{:x}", mod)));
|
TRACE(allocator->backend->log(AQ_LOG_TRACE, std::format("GBM: | mod 0x{:x}", mod)));
|
||||||
}
|
}
|
||||||
bo = gbm_bo_create_with_modifiers2(allocator->gbmDevice, attrs.size.x, attrs.size.y, attrs.format, explicitModifiers.data(), explicitModifiers.size(), flags);
|
bo = gbm_bo_create_with_modifiers2(allocator->gbmDevice, attrs.size.x, attrs.size.y, attrs.format, explicitModifiers.data(), explicitModifiers.size(), flags);
|
||||||
|
|
|
@ -67,7 +67,7 @@ Hyprutils::Memory::CSharedPointer<CBackend> Aquamarine::CBackend::create(const s
|
||||||
|
|
||||||
backend->log(AQ_LOG_DEBUG, "Creating an Aquamarine backend!");
|
backend->log(AQ_LOG_DEBUG, "Creating an Aquamarine backend!");
|
||||||
|
|
||||||
for (auto& b : backends) {
|
for (auto const& b : backends) {
|
||||||
if (b.backendType == AQ_BACKEND_WAYLAND) {
|
if (b.backendType == AQ_BACKEND_WAYLAND) {
|
||||||
auto ref = SP<CWaylandBackend>(new CWaylandBackend(backend));
|
auto ref = SP<CWaylandBackend>(new CWaylandBackend(backend));
|
||||||
backend->implementations.emplace_back(ref);
|
backend->implementations.emplace_back(ref);
|
||||||
|
@ -79,7 +79,7 @@ Hyprutils::Memory::CSharedPointer<CBackend> Aquamarine::CBackend::create(const s
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& r : ref) {
|
for (auto const& r : ref) {
|
||||||
backend->implementations.emplace_back(r);
|
backend->implementations.emplace_back(r);
|
||||||
}
|
}
|
||||||
} else if (b.backendType == AQ_BACKEND_HEADLESS) {
|
} else if (b.backendType == AQ_BACKEND_HEADLESS) {
|
||||||
|
@ -109,7 +109,7 @@ bool Aquamarine::CBackend::start() {
|
||||||
int started = 0;
|
int started = 0;
|
||||||
|
|
||||||
auto optionsForType = [this](eBackendType type) -> SBackendImplementationOptions {
|
auto optionsForType = [this](eBackendType type) -> SBackendImplementationOptions {
|
||||||
for (auto& o : implementationOptions) {
|
for (auto const& o : implementationOptions) {
|
||||||
if (o.backendType == type)
|
if (o.backendType == type)
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ bool Aquamarine::CBackend::start() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: obviously change this when (if) we add different allocators.
|
// TODO: obviously change this when (if) we add different allocators.
|
||||||
for (auto& b : implementations) {
|
for (auto const& b : implementations) {
|
||||||
if (b->drmFD() >= 0) {
|
if (b->drmFD() >= 0) {
|
||||||
auto fd = reopenDRMNode(b->drmFD());
|
auto fd = reopenDRMNode(b->drmFD());
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
@ -162,7 +162,7 @@ bool Aquamarine::CBackend::start() {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ready = true;
|
ready = true;
|
||||||
for (auto& b : implementations) {
|
for (auto const& b : implementations) {
|
||||||
b->onReady();
|
b->onReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,15 +180,15 @@ void Aquamarine::CBackend::log(eBackendLogLevel level, const std::string& msg) {
|
||||||
|
|
||||||
std::vector<Hyprutils::Memory::CSharedPointer<SPollFD>> Aquamarine::CBackend::getPollFDs() {
|
std::vector<Hyprutils::Memory::CSharedPointer<SPollFD>> Aquamarine::CBackend::getPollFDs() {
|
||||||
std::vector<Hyprutils::Memory::CSharedPointer<SPollFD>> result;
|
std::vector<Hyprutils::Memory::CSharedPointer<SPollFD>> result;
|
||||||
for (auto& i : implementations) {
|
for (auto const& i : implementations) {
|
||||||
auto pollfds = i->pollFDs();
|
auto pollfds = i->pollFDs();
|
||||||
for (auto& p : pollfds) {
|
for (auto const& p : pollfds) {
|
||||||
log(AQ_LOG_DEBUG, std::format("backend: poll fd {} for implementation {}", p->fd, backendTypeToName(i->type())));
|
log(AQ_LOG_DEBUG, std::format("backend: poll fd {} for implementation {}", p->fd, backendTypeToName(i->type())));
|
||||||
result.emplace_back(p);
|
result.emplace_back(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& sfd : sessionFDs) {
|
for (auto const& sfd : sessionFDs) {
|
||||||
log(AQ_LOG_DEBUG, std::format("backend: poll fd {} for session", sfd->fd));
|
log(AQ_LOG_DEBUG, std::format("backend: poll fd {} for session", sfd->fd));
|
||||||
result.emplace_back(sfd);
|
result.emplace_back(sfd);
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ std::vector<Hyprutils::Memory::CSharedPointer<SPollFD>> Aquamarine::CBackend::ge
|
||||||
}
|
}
|
||||||
|
|
||||||
int Aquamarine::CBackend::drmFD() {
|
int Aquamarine::CBackend::drmFD() {
|
||||||
for (auto& i : implementations) {
|
for (auto const& i : implementations) {
|
||||||
int fd = i->drmFD();
|
int fd = i->drmFD();
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -215,14 +215,14 @@ bool Aquamarine::CBackend::hasSession() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SDRMFormat> Aquamarine::CBackend::getPrimaryRenderFormats() {
|
std::vector<SDRMFormat> Aquamarine::CBackend::getPrimaryRenderFormats() {
|
||||||
for (auto& b : implementations) {
|
for (auto const& b : implementations) {
|
||||||
if (b->type() != AQ_BACKEND_DRM && b->type() != AQ_BACKEND_WAYLAND)
|
if (b->type() != AQ_BACKEND_DRM && b->type() != AQ_BACKEND_WAYLAND)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return b->getRenderFormats();
|
return b->getRenderFormats();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& b : implementations) {
|
for (auto const& b : implementations) {
|
||||||
return b->getRenderFormats();
|
return b->getRenderFormats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ void Aquamarine::CBackend::dispatchIdle() {
|
||||||
auto cpy = idle.pending;
|
auto cpy = idle.pending;
|
||||||
idle.pending.clear();
|
idle.pending.clear();
|
||||||
|
|
||||||
for (auto& i : cpy) {
|
for (auto const& i : cpy) {
|
||||||
if (i && *i)
|
if (i && *i)
|
||||||
(*i)();
|
(*i)();
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ void Aquamarine::CHeadlessBackend::dispatchTimers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& copy : toFire) {
|
for (auto const& copy : toFire) {
|
||||||
if (copy.what)
|
if (copy.what)
|
||||||
copy.what();
|
copy.what();
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ void Aquamarine::CHeadlessBackend::updateTimerFD() {
|
||||||
const auto clocknow = std::chrono::steady_clock::now();
|
const auto clocknow = std::chrono::steady_clock::now();
|
||||||
bool any = false;
|
bool any = false;
|
||||||
|
|
||||||
for (auto& t : timers.timers) {
|
for (auto const& t : timers.timers) {
|
||||||
auto delta = std::chrono::duration_cast<std::chrono::microseconds>(t.when - clocknow).count() * 1000 /* µs -> ns */;
|
auto delta = std::chrono::duration_cast<std::chrono::microseconds>(t.when - clocknow).count() * 1000 /* µs -> ns */;
|
||||||
|
|
||||||
if (delta < lowestNs)
|
if (delta < lowestNs)
|
||||||
|
|
|
@ -264,7 +264,7 @@ static bool isDRMCard(const char* sysname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Aquamarine::CSession::onReady() {
|
void Aquamarine::CSession::onReady() {
|
||||||
for (auto& d : libinputDevices) {
|
for (auto const& d : libinputDevices) {
|
||||||
if (d->keyboard)
|
if (d->keyboard)
|
||||||
backend->events.newKeyboard.emit(SP<IKeyboard>(d->keyboard));
|
backend->events.newKeyboard.emit(SP<IKeyboard>(d->keyboard));
|
||||||
if (d->mouse)
|
if (d->mouse)
|
||||||
|
@ -278,7 +278,7 @@ void Aquamarine::CSession::onReady() {
|
||||||
if (d->tabletPad)
|
if (d->tabletPad)
|
||||||
backend->events.newTabletPad.emit(SP<ITabletPad>(d->tabletPad));
|
backend->events.newTabletPad.emit(SP<ITabletPad>(d->tabletPad));
|
||||||
|
|
||||||
for (auto& t : d->tabletTools) {
|
for (auto const& t : d->tabletTools) {
|
||||||
backend->events.newTabletTool.emit(SP<ITabletTool>(t));
|
backend->events.newTabletTool.emit(SP<ITabletTool>(t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ void Aquamarine::CSession::dispatchUdevEvents() {
|
||||||
|
|
||||||
dev_t deviceNum = udev_device_get_devnum(device);
|
dev_t deviceNum = udev_device_get_devnum(device);
|
||||||
SP<CSessionDevice> sessionDevice;
|
SP<CSessionDevice> sessionDevice;
|
||||||
for (auto& sDev : sessionDevices) {
|
for (auto const& sDev : sessionDevices) {
|
||||||
if (sDev->dev == deviceNum) {
|
if (sDev->dev == deviceNum) {
|
||||||
sessionDevice = sDev;
|
sessionDevice = sDev;
|
||||||
break;
|
break;
|
||||||
|
@ -498,7 +498,7 @@ void Aquamarine::CSession::handleLibinputEvent(libinput_event* e) {
|
||||||
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
|
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto& axis : LAXES) {
|
for (auto const& axis : LAXES) {
|
||||||
if (!libinput_event_pointer_has_axis(pe, axis))
|
if (!libinput_event_pointer_has_axis(pe, axis))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -860,7 +860,7 @@ Aquamarine::CLibinputDevice::~CLibinputDevice() {
|
||||||
}
|
}
|
||||||
|
|
||||||
SP<CLibinputTabletTool> Aquamarine::CLibinputDevice::toolFrom(libinput_tablet_tool* tool) {
|
SP<CLibinputTabletTool> Aquamarine::CLibinputDevice::toolFrom(libinput_tablet_tool* tool) {
|
||||||
for (auto& t : tabletTools) {
|
for (auto const& t : tabletTools) {
|
||||||
if (t->libinputTool == tool)
|
if (t->libinputTool == tool)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ bool Aquamarine::CWaylandBackend::dispatchEvents() {
|
||||||
|
|
||||||
// dispatch frames
|
// dispatch frames
|
||||||
if (backend->ready) {
|
if (backend->ready) {
|
||||||
for (auto& f : idleCallbacks) {
|
for (auto const& f : idleCallbacks) {
|
||||||
f();
|
f();
|
||||||
}
|
}
|
||||||
idleCallbacks.clear();
|
idleCallbacks.clear();
|
||||||
|
@ -187,7 +187,7 @@ bool Aquamarine::CWaylandBackend::setCursor(Hyprutils::Memory::CSharedPointer<IB
|
||||||
}
|
}
|
||||||
|
|
||||||
void Aquamarine::CWaylandBackend::onReady() {
|
void Aquamarine::CWaylandBackend::onReady() {
|
||||||
for (auto& o : outputs) {
|
for (auto const& o : outputs) {
|
||||||
o->swapchain = CSwapchain::create(backend->primaryAllocator, self.lock());
|
o->swapchain = CSwapchain::create(backend->primaryAllocator, self.lock());
|
||||||
if (!o->swapchain) {
|
if (!o->swapchain) {
|
||||||
backend->log(AQ_LOG_ERROR, std::format("Output {} failed: swapchain creation failed", o->name));
|
backend->log(AQ_LOG_ERROR, std::format("Output {} failed: swapchain creation failed", o->name));
|
||||||
|
@ -257,7 +257,7 @@ Aquamarine::CWaylandPointer::CWaylandPointer(SP<CCWlPointer> pointer_, Hyprutils
|
||||||
pointer->setEnter([this](CCWlPointer* r, uint32_t serial, wl_proxy* surface, wl_fixed_t x, wl_fixed_t y) {
|
pointer->setEnter([this](CCWlPointer* r, uint32_t serial, wl_proxy* surface, wl_fixed_t x, wl_fixed_t y) {
|
||||||
backend->lastEnterSerial = serial;
|
backend->lastEnterSerial = serial;
|
||||||
|
|
||||||
for (auto& o : backend->outputs) {
|
for (auto const& o : backend->outputs) {
|
||||||
if (o->waylandState.surface->resource() != surface)
|
if (o->waylandState.surface->resource() != surface)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ Aquamarine::CWaylandPointer::CWaylandPointer(SP<CCWlPointer> pointer_, Hyprutils
|
||||||
});
|
});
|
||||||
|
|
||||||
pointer->setLeave([this](CCWlPointer* r, uint32_t serial, wl_proxy* surface) {
|
pointer->setLeave([this](CCWlPointer* r, uint32_t serial, wl_proxy* surface) {
|
||||||
for (auto& o : backend->outputs) {
|
for (auto const& o : backend->outputs) {
|
||||||
if (o->waylandState.surface->resource() != surface)
|
if (o->waylandState.surface->resource() != surface)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ SP<IBackendImplementation> Aquamarine::CWaylandOutput::getBackend() {
|
||||||
SP<CWaylandBuffer> Aquamarine::CWaylandOutput::wlBufferFromBuffer(SP<IBuffer> buffer) {
|
SP<CWaylandBuffer> Aquamarine::CWaylandOutput::wlBufferFromBuffer(SP<IBuffer> buffer) {
|
||||||
std::erase_if(backendState.buffers, [this](const auto& el) { return el.first.expired() || !swapchain->contains(el.first.lock()); });
|
std::erase_if(backendState.buffers, [this](const auto& el) { return el.first.expired() || !swapchain->contains(el.first.lock()); });
|
||||||
|
|
||||||
for (auto& [k, v] : backendState.buffers) {
|
for (auto const& [k, v] : backendState.buffers) {
|
||||||
if (k != buffer)
|
if (k != buffer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -153,9 +153,9 @@ static std::vector<SP<CSessionDevice>> scanGPUs(SP<CBackend> backend) {
|
||||||
d = canonicalFilePath.string();
|
d = canonicalFilePath.string();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& d : explicitDevices) {
|
for (auto const& d : explicitDevices) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (auto& vd : devices) {
|
for (auto const& vd : devices) {
|
||||||
if (vd->path == d) {
|
if (vd->path == d) {
|
||||||
vecDevices.emplace_back(vd);
|
vecDevices.emplace_back(vd);
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -169,7 +169,7 @@ static std::vector<SP<CSessionDevice>> scanGPUs(SP<CBackend> backend) {
|
||||||
backend->log(AQ_LOG_ERROR, std::format("drm: Explicit device {} not found", d));
|
backend->log(AQ_LOG_ERROR, std::format("drm: Explicit device {} not found", d));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (auto& d : devices) {
|
for (auto const& d : devices) {
|
||||||
vecDevices.push_back(d);
|
vecDevices.push_back(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ std::vector<SP<CDRMBackend>> Aquamarine::CDRMBackend::attempt(SP<CBackend> backe
|
||||||
std::vector<SP<CDRMBackend>> backends;
|
std::vector<SP<CDRMBackend>> backends;
|
||||||
SP<CDRMBackend> newPrimary;
|
SP<CDRMBackend> newPrimary;
|
||||||
|
|
||||||
for (auto& gpu : gpus) {
|
for (auto const& gpu : gpus) {
|
||||||
auto drmBackend = SP<CDRMBackend>(new CDRMBackend(backend));
|
auto drmBackend = SP<CDRMBackend>(new CDRMBackend(backend));
|
||||||
drmBackend->self = drmBackend;
|
drmBackend->self = drmBackend;
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ void Aquamarine::CDRMBackend::restoreAfterVT() {
|
||||||
|
|
||||||
std::vector<SP<SDRMConnector>> noMode;
|
std::vector<SP<SDRMConnector>> noMode;
|
||||||
|
|
||||||
for (auto& c : connectors) {
|
for (auto const& c : connectors) {
|
||||||
if (!c->crtc || !c->output)
|
if (!c->crtc || !c->output)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ void Aquamarine::CDRMBackend::restoreAfterVT() {
|
||||||
backend->log(AQ_LOG_ERROR, std::format("drm: crtc {} failed restore", c->crtc->id));
|
backend->log(AQ_LOG_ERROR, std::format("drm: crtc {} failed restore", c->crtc->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& c : noMode) {
|
for (auto const& c : noMode) {
|
||||||
if (!c->output)
|
if (!c->output)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -525,7 +525,7 @@ bool Aquamarine::CDRMBackend::initMgpu() {
|
||||||
void Aquamarine::CDRMBackend::buildGlFormats(const std::vector<SGLFormat>& fmts) {
|
void Aquamarine::CDRMBackend::buildGlFormats(const std::vector<SGLFormat>& fmts) {
|
||||||
std::vector<SDRMFormat> result;
|
std::vector<SDRMFormat> result;
|
||||||
|
|
||||||
for (auto& fmt : fmts) {
|
for (auto const& fmt : fmts) {
|
||||||
if (fmt.external)
|
if (fmt.external)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -550,7 +550,7 @@ void Aquamarine::CDRMBackend::recheckCRTCs() {
|
||||||
backend->log(AQ_LOG_DEBUG, "drm: Rechecking CRTCs");
|
backend->log(AQ_LOG_DEBUG, "drm: Rechecking CRTCs");
|
||||||
|
|
||||||
std::vector<SP<SDRMConnector>> recheck, changed;
|
std::vector<SP<SDRMConnector>> recheck, changed;
|
||||||
for (auto& c : connectors) {
|
for (auto const& c : connectors) {
|
||||||
if (c->crtc && c->status == DRM_MODE_CONNECTED) {
|
if (c->crtc && c->status == DRM_MODE_CONNECTED) {
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm: Skipping connector {}, has crtc {} and is connected", c->szName, c->crtc->id));
|
backend->log(AQ_LOG_DEBUG, std::format("drm: Skipping connector {}, has crtc {} and is connected", c->szName, c->crtc->id));
|
||||||
continue;
|
continue;
|
||||||
|
@ -562,7 +562,7 @@ void Aquamarine::CDRMBackend::recheckCRTCs() {
|
||||||
|
|
||||||
for (size_t i = 0; i < crtcs.size(); ++i) {
|
for (size_t i = 0; i < crtcs.size(); ++i) {
|
||||||
bool taken = false;
|
bool taken = false;
|
||||||
for (auto& c : connectors) {
|
for (auto const& c : connectors) {
|
||||||
if (c->crtc != crtcs.at(i))
|
if (c->crtc != crtcs.at(i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -580,7 +580,7 @@ void Aquamarine::CDRMBackend::recheckCRTCs() {
|
||||||
bool assigned = false;
|
bool assigned = false;
|
||||||
|
|
||||||
// try to use a connected connector
|
// try to use a connected connector
|
||||||
for (auto& c : recheck) {
|
for (auto const& c : recheck) {
|
||||||
if (!(c->possibleCrtcs & (1 << i)))
|
if (!(c->possibleCrtcs & (1 << i)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -606,7 +606,7 @@ void Aquamarine::CDRMBackend::recheckCRTCs() {
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm: slot {} crtc {} unassigned", i, crtcs.at(i)->id));
|
backend->log(AQ_LOG_DEBUG, std::format("drm: slot {} crtc {} unassigned", i, crtcs.at(i)->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& c : connectors) {
|
for (auto const& c : connectors) {
|
||||||
if (c->status == DRM_MODE_CONNECTED)
|
if (c->status == DRM_MODE_CONNECTED)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -615,7 +615,7 @@ void Aquamarine::CDRMBackend::recheckCRTCs() {
|
||||||
|
|
||||||
// if any connectors get a crtc and are connected, we need to rescan to assign them outputs.
|
// if any connectors get a crtc and are connected, we need to rescan to assign them outputs.
|
||||||
bool rescan = false;
|
bool rescan = false;
|
||||||
for (auto& c : changed) {
|
for (auto const& c : changed) {
|
||||||
if (!c->output && c->status == DRM_MODE_CONNECTED) {
|
if (!c->output && c->status == DRM_MODE_CONNECTED) {
|
||||||
rescan = true;
|
rescan = true;
|
||||||
continue;
|
continue;
|
||||||
|
@ -745,7 +745,7 @@ void Aquamarine::CDRMBackend::scanLeases() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& c : connectors) {
|
for (auto const& c : connectors) {
|
||||||
if (!c->output || !c->output->lease)
|
if (!c->output || !c->output->lease)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -767,7 +767,7 @@ void Aquamarine::CDRMBackend::scanLeases() {
|
||||||
|
|
||||||
auto l = c->output->lease;
|
auto l = c->output->lease;
|
||||||
|
|
||||||
for (auto& c2 : connectors) {
|
for (auto const& c2 : connectors) {
|
||||||
if (!c2->output || c2->output->lease != c->output->lease)
|
if (!c2->output || c2->output->lease != c->output->lease)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -872,7 +872,7 @@ void Aquamarine::CDRMBackend::onReady() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& c : connectors) {
|
for (auto const& c : connectors) {
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm: onReady: connector {}", c->id));
|
backend->log(AQ_LOG_DEBUG, std::format("drm: onReady: connector {}", c->id));
|
||||||
if (!c->output)
|
if (!c->output)
|
||||||
continue;
|
continue;
|
||||||
|
@ -894,7 +894,7 @@ void Aquamarine::CDRMBackend::onReady() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SDRMFormat> Aquamarine::CDRMBackend::getRenderFormats() {
|
std::vector<SDRMFormat> Aquamarine::CDRMBackend::getRenderFormats() {
|
||||||
for (auto& p : planes) {
|
for (auto const& p : planes) {
|
||||||
if (p->type != DRM_PLANE_TYPE_PRIMARY)
|
if (p->type != DRM_PLANE_TYPE_PRIMARY)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -909,7 +909,7 @@ std::vector<SDRMFormat> Aquamarine::CDRMBackend::getRenderableFormats() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SDRMFormat> Aquamarine::CDRMBackend::getCursorFormats() {
|
std::vector<SDRMFormat> Aquamarine::CDRMBackend::getCursorFormats() {
|
||||||
for (auto& p : planes) {
|
for (auto const& p : planes) {
|
||||||
if (p->type != DRM_PLANE_TYPE_CURSOR)
|
if (p->type != DRM_PLANE_TYPE_CURSOR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1408,7 +1408,7 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) {
|
||||||
if (COMMITTED & COutputState::eOutputStateProperties::AQ_OUTPUT_STATE_FORMAT) {
|
if (COMMITTED & COutputState::eOutputStateProperties::AQ_OUTPUT_STATE_FORMAT) {
|
||||||
// verify the format is valid for the primary plane
|
// verify the format is valid for the primary plane
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
for (auto& f : getRenderFormats()) {
|
for (auto const& f : getRenderFormats()) {
|
||||||
if (f.drmFormat == STATE.drmFormat) {
|
if (f.drmFormat == STATE.drmFormat) {
|
||||||
ok = true;
|
ok = true;
|
||||||
break;
|
break;
|
||||||
|
@ -2001,7 +2001,7 @@ SP<CDRMLease> Aquamarine::CDRMLease::create(std::vector<SP<IOutput>> outputs) {
|
||||||
|
|
||||||
auto backend = ((CDRMBackend*)outputs.at(0)->getBackend().get())->self.lock();
|
auto backend = ((CDRMBackend*)outputs.at(0)->getBackend().get())->self.lock();
|
||||||
|
|
||||||
for (auto& o : outputs) {
|
for (auto const& o : outputs) {
|
||||||
if (o->getBackend() != backend) {
|
if (o->getBackend() != backend) {
|
||||||
backend->log(AQ_LOG_ERROR, "drm lease: Mismatched backends");
|
backend->log(AQ_LOG_ERROR, "drm lease: Mismatched backends");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2012,7 +2012,7 @@ SP<CDRMLease> Aquamarine::CDRMLease::create(std::vector<SP<IOutput>> outputs) {
|
||||||
|
|
||||||
auto lease = SP<CDRMLease>(new CDRMLease);
|
auto lease = SP<CDRMLease>(new CDRMLease);
|
||||||
|
|
||||||
for (auto& o : outputs) {
|
for (auto const& o : outputs) {
|
||||||
auto drmo = ((CDRMOutput*)o.get())->self.lock();
|
auto drmo = ((CDRMOutput*)o.get())->self.lock();
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm lease: output {}, connector {}", drmo->name, drmo->connector->id));
|
backend->log(AQ_LOG_DEBUG, std::format("drm lease: output {}, connector {}", drmo->name, drmo->connector->id));
|
||||||
|
|
||||||
|
@ -2041,7 +2041,7 @@ SP<CDRMLease> Aquamarine::CDRMLease::create(std::vector<SP<IOutput>> outputs) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& o : lease->outputs) {
|
for (auto const& o : lease->outputs) {
|
||||||
o->lease = lease;
|
o->lease = lease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ bool CDRMRenderer::initDRMFormats() {
|
||||||
|
|
||||||
std::vector<SGLFormat> dmaFormats;
|
std::vector<SGLFormat> dmaFormats;
|
||||||
|
|
||||||
for (auto& fmt : formats) {
|
for (auto const& fmt : formats) {
|
||||||
std::vector<std::pair<uint64_t, bool>> mods;
|
std::vector<std::pair<uint64_t, bool>> mods;
|
||||||
|
|
||||||
auto ret = getModsForFormat(fmt);
|
auto ret = getModsForFormat(fmt);
|
||||||
|
@ -170,7 +170,7 @@ bool CDRMRenderer::initDRMFormats() {
|
||||||
// EGL can always do implicit modifiers.
|
// EGL can always do implicit modifiers.
|
||||||
mods.push_back({DRM_FORMAT_MOD_INVALID, true});
|
mods.push_back({DRM_FORMAT_MOD_INVALID, true});
|
||||||
|
|
||||||
for (auto& [mod, external] : mods) {
|
for (auto const& [mod, external] : mods) {
|
||||||
dmaFormats.push_back(SGLFormat{
|
dmaFormats.push_back(SGLFormat{
|
||||||
.drmFormat = (uint32_t)fmt,
|
.drmFormat = (uint32_t)fmt,
|
||||||
.modifier = mod,
|
.modifier = mod,
|
||||||
|
@ -179,7 +179,7 @@ bool CDRMRenderer::initDRMFormats() {
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE(backend->log(AQ_LOG_TRACE, std::format("EGL: GPU Supports Format {} (0x{:x})", fourccToName((uint32_t)fmt), fmt)));
|
TRACE(backend->log(AQ_LOG_TRACE, std::format("EGL: GPU Supports Format {} (0x{:x})", fourccToName((uint32_t)fmt), fmt)));
|
||||||
for (auto& [mod, external] : mods) {
|
for (auto const& [mod, external] : mods) {
|
||||||
auto modName = drmGetFormatModifierName(mod);
|
auto modName = drmGetFormatModifierName(mod);
|
||||||
TRACE(backend->log(AQ_LOG_TRACE, std::format("EGL: | {}with modifier 0x{:x}: {}", (external ? "external only " : ""), mod, modName ? modName : "?unknown?")));
|
TRACE(backend->log(AQ_LOG_TRACE, std::format("EGL: | {}with modifier 0x{:x}: {}", (external ? "external only " : ""), mod, modName ? modName : "?unknown?")));
|
||||||
free(modName);
|
free(modName);
|
||||||
|
@ -455,7 +455,7 @@ SGLTex CDRMRenderer::glTex(Hyprutils::Memory::CSharedPointer<IBuffer> buffa) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool external = false;
|
bool external = false;
|
||||||
for (auto& fmt : formats) {
|
for (auto const& fmt : formats) {
|
||||||
if (fmt.drmFormat != dma.format || fmt.modifier != dma.modifier)
|
if (fmt.drmFormat != dma.format || fmt.modifier != dma.modifier)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -802,7 +802,7 @@ void CDRMRenderer::onBufferAttachmentDrop(CDRMRendererBufferAttachment* attachme
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDRMRenderer::verifyDestinationDMABUF(const SDMABUFAttrs& attrs) {
|
bool CDRMRenderer::verifyDestinationDMABUF(const SDMABUFAttrs& attrs) {
|
||||||
for (auto& fmt : formats) {
|
for (auto const& fmt : formats) {
|
||||||
if (fmt.drmFormat != attrs.format)
|
if (fmt.drmFormat != attrs.format)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -310,16 +310,16 @@ bool Aquamarine::CDRMAtomicImpl::commit(Hyprutils::Memory::CSharedPointer<SDRMCo
|
||||||
bool Aquamarine::CDRMAtomicImpl::reset() {
|
bool Aquamarine::CDRMAtomicImpl::reset() {
|
||||||
CDRMAtomicRequest request(backend);
|
CDRMAtomicRequest request(backend);
|
||||||
|
|
||||||
for (auto& crtc : backend->crtcs) {
|
for (auto const& crtc : backend->crtcs) {
|
||||||
request.add(crtc->id, crtc->props.mode_id, 0);
|
request.add(crtc->id, crtc->props.mode_id, 0);
|
||||||
request.add(crtc->id, crtc->props.active, 0);
|
request.add(crtc->id, crtc->props.active, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& conn : backend->connectors) {
|
for (auto const& conn : backend->connectors) {
|
||||||
request.add(conn->id, conn->props.crtc_id, 0);
|
request.add(conn->id, conn->props.crtc_id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& plane : backend->planes) {
|
for (auto const& plane : backend->planes) {
|
||||||
request.planeProps(plane, nullptr, 0, {});
|
request.planeProps(plane, nullptr, 0, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ bool Aquamarine::CDRMLegacyImpl::commit(Hyprutils::Memory::CSharedPointer<SDRMCo
|
||||||
|
|
||||||
bool Aquamarine::CDRMLegacyImpl::reset() {
|
bool Aquamarine::CDRMLegacyImpl::reset() {
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
for (auto& connector : backend->connectors) {
|
for (auto const& connector : backend->connectors) {
|
||||||
if (!connector->crtc)
|
if (!connector->crtc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ using namespace Hyprutils::Memory;
|
||||||
#define SP CSharedPointer
|
#define SP CSharedPointer
|
||||||
|
|
||||||
bool Aquamarine::CAttachmentManager::has(eAttachmentType type) {
|
bool Aquamarine::CAttachmentManager::has(eAttachmentType type) {
|
||||||
for (auto& a : attachments) {
|
for (auto const& a : attachments) {
|
||||||
if (a->type() == type)
|
if (a->type() == type)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ bool Aquamarine::CAttachmentManager::has(eAttachmentType type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SP<IAttachment> Aquamarine::CAttachmentManager::get(eAttachmentType type) {
|
SP<IAttachment> Aquamarine::CAttachmentManager::get(eAttachmentType type) {
|
||||||
for (auto& a : attachments) {
|
for (auto const& a : attachments) {
|
||||||
if (a->type() == type)
|
if (a->type() == type)
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
using namespace Aquamarine;
|
using namespace Aquamarine;
|
||||||
|
|
||||||
Hyprutils::Memory::CSharedPointer<SOutputMode> Aquamarine::IOutput::preferredMode() {
|
Hyprutils::Memory::CSharedPointer<SOutputMode> Aquamarine::IOutput::preferredMode() {
|
||||||
for (auto& m : modes) {
|
for (auto const& m : modes) {
|
||||||
if (m->preferred)
|
if (m->preferred)
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue