Add ExtFramebuffer
authorTomi Valkeinen <tomi.valkeinen@iki.fi>
Fri, 2 Oct 2015 18:27:55 +0000 (21:27 +0300)
committerTomi Valkeinen <tomi.valkeinen@iki.fi>
Sat, 3 Oct 2015 13:59:19 +0000 (16:59 +0300)
Add ExtFramebuffer for cases where the buffer have been allocated
externally.

libkms++/decls.h
libkms++/extframebuffer.cpp [new file with mode: 0644]
libkms++/extframebuffer.h [new file with mode: 0644]
libkms++/kms++.h

index 1415f1f9f10c50b22d435f0b17d87dcaa0261a20..f9753f290b84eab26bffb5853c467e3a11b83111 100644 (file)
@@ -9,6 +9,7 @@ class Crtc;
 class Encoder;
 class Framebuffer;
 class DumbFramebuffer;
 class Encoder;
 class Framebuffer;
 class DumbFramebuffer;
+class ExtFramebuffer;
 class DrmObject;
 class Plane;
 class Property;
 class DrmObject;
 class Plane;
 class Property;
diff --git a/libkms++/extframebuffer.cpp b/libkms++/extframebuffer.cpp
new file mode 100644 (file)
index 0000000..de9d737
--- /dev/null
@@ -0,0 +1,35 @@
+
+#include <cstring>
+#include <stdexcept>
+#include <sys/mman.h>
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+
+#include "kms++.h"
+
+using namespace std;
+
+namespace kms
+{
+
+ExtFramebuffer::ExtFramebuffer(Card& card, uint32_t width, uint32_t height, uint32_t depth, uint32_t bpp, uint32_t stride, uint32_t handle)
+       :Framebuffer(card, width, height)
+{
+       uint32_t id;
+       int r = drmModeAddFB(card.fd(), width, height, depth, bpp, stride, handle, &id);
+       if (r)
+               throw invalid_argument("fob");
+       m_id = id;
+}
+
+ExtFramebuffer::~ExtFramebuffer()
+{
+       drmModeRmFB(card().fd(), id());
+}
+
+void ExtFramebuffer::print_short() const
+{
+       printf("Framebuffer %d\n", id());
+}
+
+}
diff --git a/libkms++/extframebuffer.h b/libkms++/extframebuffer.h
new file mode 100644 (file)
index 0000000..cc0863a
--- /dev/null
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "framebuffer.h"
+
+namespace kms
+{
+
+class ExtFramebuffer : public Framebuffer
+{
+public:
+       ExtFramebuffer(Card& card, uint32_t width, uint32_t height, uint32_t depth, uint32_t bpp, uint32_t stride, uint32_t handle);
+       virtual ~ExtFramebuffer();
+
+       void print_short() const;
+
+private:
+       uint32_t m_pitch;
+       uint32_t m_bpp;
+       uint32_t m_depth;
+};
+}
index c446a9efac6216ebd83f386e37acb9aca5ebb762..c518a47ef9fe8d7dd0d223fea159ade148d1fd4b 100644 (file)
@@ -7,6 +7,7 @@
 #include "encoder.h"
 #include "framebuffer.h"
 #include "dumbframebuffer.h"
 #include "encoder.h"
 #include "framebuffer.h"
 #include "dumbframebuffer.h"
+#include "extframebuffer.h"
 #include "plane.h"
 #include "property.h"
 #include "pipeline.h"
 #include "plane.h"
 #include "property.h"
 #include "pipeline.h"