summaryrefslogtreecommitdiff
path: root/libkms++
diff options
context:
space:
mode:
Diffstat (limited to 'libkms++')
-rw-r--r--libkms++/card.cpp3
-rw-r--r--libkms++/card.h2
-rw-r--r--libkms++/framebuffer.cpp12
-rw-r--r--libkms++/framebuffer.h2
4 files changed, 18 insertions, 1 deletions
diff --git a/libkms++/card.cpp b/libkms++/card.cpp
index a0e395e..48ab560 100644
--- a/libkms++/card.cpp
+++ b/libkms++/card.cpp
@@ -120,6 +120,9 @@ Card::~Card()
{
restore_modes();
+ while (m_framebuffers.size() > 0)
+ delete m_framebuffers.back();
+
for (auto pair : m_obmap)
delete pair.second;
diff --git a/libkms++/card.h b/libkms++/card.h
index bbe34e2..1bc6af7 100644
--- a/libkms++/card.h
+++ b/libkms++/card.h
@@ -11,6 +11,7 @@ namespace kms
{
class Card
{
+ friend class Framebuffer;
public:
Card();
~Card();
@@ -57,6 +58,7 @@ private:
std::vector<Crtc*> m_crtcs;
std::vector<Plane*> m_planes;
std::vector<Property*> m_properties;
+ std::vector<Framebuffer*> m_framebuffers;
int m_fd;
bool m_master;
diff --git a/libkms++/framebuffer.cpp b/libkms++/framebuffer.cpp
index a7e5ad6..2481561 100644
--- a/libkms++/framebuffer.cpp
+++ b/libkms++/framebuffer.cpp
@@ -1,3 +1,4 @@
+#include <algorithm>
#include <cstring>
#include <stdexcept>
#include <sys/mman.h>
@@ -14,6 +15,7 @@ namespace kms
Framebuffer::Framebuffer(Card& card, int width, int height)
: DrmObject(card, DRM_MODE_OBJECT_FB), m_width(width), m_height(height)
{
+ card.m_framebuffers.push_back(this);
}
Framebuffer::Framebuffer(Card& card, uint32_t id)
@@ -25,6 +27,16 @@ Framebuffer::Framebuffer(Card& card, uint32_t id)
m_height = fb->height;
drmModeFreeFB(fb);
+
+ card.m_framebuffers.push_back(this);
}
+Framebuffer::~Framebuffer()
+{
+ auto& fbs = card().m_framebuffers;
+ auto iter = find(fbs.begin(), fbs.end(), this);
+ card().m_framebuffers.erase(iter);
+}
+
+
}
diff --git a/libkms++/framebuffer.h b/libkms++/framebuffer.h
index 12374ae..77a6c32 100644
--- a/libkms++/framebuffer.h
+++ b/libkms++/framebuffer.h
@@ -8,7 +8,7 @@ class Framebuffer : public DrmObject
{
public:
Framebuffer(Card& card, uint32_t id);
- virtual ~Framebuffer() { }
+ virtual ~Framebuffer();
uint32_t width() const { return m_width; }
uint32_t height() const { return m_height; }