diff options
-rw-r--r-- | kms++/inc/kms++/framebuffer.h | 2 | ||||
-rw-r--r-- | kms++/src/framebuffer.cpp | 20 | ||||
-rw-r--r-- | kmscube/cube-gbm.cpp | 7 |
3 files changed, 25 insertions, 4 deletions
diff --git a/kms++/inc/kms++/framebuffer.h b/kms++/inc/kms++/framebuffer.h index cbf705d..faf2e71 100644 --- a/kms++/inc/kms++/framebuffer.h +++ b/kms++/inc/kms++/framebuffer.h @@ -13,6 +13,8 @@ public: uint32_t width() const { return m_width; } uint32_t height() const { return m_height; } + + void flush(); protected: Framebuffer(Card& card, uint32_t width, uint32_t height); diff --git a/kms++/src/framebuffer.cpp b/kms++/src/framebuffer.cpp index a7f589c..39c4e16 100644 --- a/kms++/src/framebuffer.cpp +++ b/kms++/src/framebuffer.cpp @@ -23,14 +23,28 @@ Framebuffer::Framebuffer(Card& card, uint32_t id) { auto fb = drmModeGetFB(card.fd(), id); - m_width = fb->width; - m_height = fb->height; + if (fb) { + m_width = fb->width; + m_height = fb->height; - drmModeFreeFB(fb); + drmModeFreeFB(fb); + } else { + m_width = m_height = 0; + } card.m_framebuffers.push_back(this); } +void Framebuffer::flush() +{ + drmModeClip clip { }; + clip.x1 = clip.y1 = 0; + clip.x2 = width(); + clip.y2 = height(); + + drmModeDirtyFB(card().fd(), id(), &clip, 1); +} + Framebuffer::~Framebuffer() { auto& fbs = card().m_framebuffers; diff --git a/kmscube/cube-gbm.cpp b/kmscube/cube-gbm.cpp index 1528684..993434b 100644 --- a/kmscube/cube-gbm.cpp +++ b/kmscube/cube-gbm.cpp @@ -132,8 +132,13 @@ public: uint32_t height = gbm_bo_get_height(bo); uint32_t stride = gbm_bo_get_stride(bo); uint32_t handle = gbm_bo_get_handle(bo).u32; + PixelFormat format = (PixelFormat)gbm_bo_get_format(bo); - fb = new ExtFramebuffer(card, width, height, 24, 32, stride, handle); + uint32_t handles[4] { handle }; + uint32_t strides[4] { stride }; + uint32_t offsets[4] { 0 }; + + fb = new ExtFramebuffer(card, width, height, format, handles, strides, offsets); gbm_bo_set_user_data(bo, fb, drm_fb_destroy_callback); |