kmscube: use drmModeAddFB2 version of ExtFB
[android/external-libkmsxx.git] / kmscube / cube-gbm.cpp
index a65f693d597dad45dc7c092fff58cd7a88542afd..993434b186370429553e049efcc819b8cdf341f3 100644 (file)
@@ -9,8 +9,8 @@
 #include <xf86drmMode.h>
 #include <gbm.h>
 
-#include <kms++.h>
-#include "test.h"
+#include <kms++/kms++.h>
+#include <kms++util/kms++util.h>
 #include "cube-egl.h"
 #include "cube-gles2.h"
 
@@ -89,7 +89,7 @@ class GbmEglSurface
 {
 public:
        GbmEglSurface(Card& card, GbmDevice& gdev, const EglState& egl, int width, int height)
-               : card(card), gdev(gdev), egl(egl), m_width(width), m_height(height),
+               : card(card), egl(egl), m_width(width), m_height(height),
                  bo_prev(0), bo_next(0)
        {
                gsurface = unique_ptr<GbmSurface>(new GbmSurface(gdev, width, height));
@@ -132,15 +132,20 @@ 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);
 
                return fb;
        }
 
-       struct Framebuffer* lock_next()
+       Framebuffer* lock_next()
        {
                bo_prev = bo_next;
                bo_next = gsurface->lock_front_buffer();
@@ -161,7 +166,6 @@ public:
 
 private:
        Card& card;
-       GbmDevice& gdev;
        const EglState& egl;
 
        unique_ptr<GbmSurface> gsurface;
@@ -201,9 +205,9 @@ public:
 
                m_surface1->make_current();
                m_surface1->swap_buffers();
-               struct Framebuffer* fb = m_surface1->lock_next();
+               Framebuffer* fb = m_surface1->lock_next();
 
-               struct Framebuffer* planefb = 0;
+               Framebuffer* planefb = 0;
 
                if (m_plane) {
                        m_surface2->make_current();
@@ -272,9 +276,9 @@ private:
                m_surface1->make_current();
                m_scene1->draw(m_frame_num * m_rotation_mult);
                m_surface1->swap_buffers();
-               struct Framebuffer* fb = m_surface1->lock_next();
+               Framebuffer* fb = m_surface1->lock_next();
 
-               struct Framebuffer* planefb = 0;
+               Framebuffer* planefb = 0;
 
                if (m_plane) {
                        m_surface2->make_current();
@@ -379,7 +383,7 @@ void main_gbm()
        for (auto& out : outputs)
                out->start_flipping();
 
-       struct pollfd fds[2] = { };
+       struct pollfd fds[2] = { };
        fds[0].fd = 0;
        fds[0].events =  POLLIN;
        fds[1].fd = card.fd();