mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-12-22 13:29:48 +01:00
background: handle missing assets (#158)
* background: fix background not rendering when resource gatherer is busy * asyncResourceGatherer: check cairo_surface_status * background: clear resource id when texture is invalid
This commit is contained in:
parent
149b6737c2
commit
8086d896e6
2 changed files with 18 additions and 5 deletions
|
@ -167,11 +167,17 @@ void CAsyncResourceGatherer::apply() {
|
|||
std::lock_guard<std::mutex> lg(asyncLoopState.assetsMutex);
|
||||
const auto ASSET = &assets[t.id];
|
||||
|
||||
const auto SURFACESTATUS = cairo_surface_status((cairo_surface_t*)t.cairosurface);
|
||||
const auto CAIROFORMAT = cairo_image_surface_get_format((cairo_surface_t*)t.cairosurface);
|
||||
const GLint glIFormat = CAIROFORMAT == CAIRO_FORMAT_RGB96F ? GL_RGB32F : GL_RGBA;
|
||||
const GLint glFormat = CAIROFORMAT == CAIRO_FORMAT_RGB96F ? GL_RGB : GL_RGBA;
|
||||
const GLint glType = CAIROFORMAT == CAIRO_FORMAT_RGB96F ? GL_FLOAT : GL_UNSIGNED_BYTE;
|
||||
|
||||
if (SURFACESTATUS != CAIRO_STATUS_SUCCESS) {
|
||||
Debug::log(ERR, "Resource {} invalid ({})", t.id, cairo_status_to_string(SURFACESTATUS));
|
||||
ASSET->texture.m_iType = TEXTURE_INVALID;
|
||||
}
|
||||
|
||||
ASSET->texture.m_vSize = t.size;
|
||||
ASSET->texture.allocate();
|
||||
|
||||
|
@ -186,6 +192,7 @@ void CAsyncResourceGatherer::apply() {
|
|||
|
||||
cairo_destroy((cairo_t*)t.cairo);
|
||||
cairo_surface_destroy((cairo_surface_t*)t.cairosurface);
|
||||
|
||||
} else {
|
||||
Debug::log(ERR, "Unsupported type in ::apply() {}", (int)t.type);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,13 @@ bool CBackground::draw(const SRenderData& data) {
|
|||
asset = g_pRenderer->asyncResourceGatherer->getAssetByID(resourceID);
|
||||
|
||||
if (!asset)
|
||||
return false;
|
||||
return true;
|
||||
|
||||
if (asset->texture.m_iType == TEXTURE_INVALID) {
|
||||
g_pRenderer->asyncResourceGatherer->unloadAsset(asset);
|
||||
resourceID = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((blurPasses > 0 || isScreenshot) && !blurredFB.isAllocated()) {
|
||||
// make it brah
|
||||
|
|
Loading…
Reference in a new issue