Skip to content

Commit

Permalink
Second pass
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanGriffiths committed Oct 22, 2024
1 parent e913be0 commit 8fdac6f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/platforms/gbm-kms/server/gbm_display_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class GBMBoFramebuffer : public mg::FBHandle
return std::make_unique<GBMBoFramebuffer>(std::move(bo), *cached_fb);
}

auto fb_id = new std::shared_ptr<uint32_t>{
auto fb_id = std::shared_ptr<uint32_t>{
new uint32_t{0},
[drm_fd](uint32_t* fb_id)
{
Expand All @@ -79,13 +79,15 @@ class GBMBoFramebuffer : public mg::FBHandle

/* Create a KMS FB object with the gbm_bo attached to it. */
auto ret = drmModeAddFB2(drm_fd, width, height, format,
handles, strides, offsets, fb_id->get(), 0);
handles, strides, offsets, fb_id.get(), 0);
if (ret)
return nullptr;

gbm_bo_set_user_data(bo.get(), fb_id, [](gbm_bo*, void* fb_ptr) { delete static_cast<std::shared_ptr<uint32_t const>*>(fb_ptr); });
// It is weird allocating a smart pointer on the heap, but we delete it
// via gbm_bo_set_user_data()'s destroy_user_data parameter.
gbm_bo_set_user_data(bo.get(), new std::shared_ptr<uint32_t>(fb_id), [](gbm_bo*, void* fb_ptr) { delete static_cast<std::shared_ptr<uint32_t const>*>(fb_ptr); });

return std::make_unique<GBMBoFramebuffer>(std::move(bo), *fb_id);
return std::make_unique<GBMBoFramebuffer>(std::move(bo), std::move(fb_id));
}

operator uint32_t() const override
Expand Down

0 comments on commit 8fdac6f

Please sign in to comment.