Skip to content

Commit

Permalink
fixup! windowing/gbm: move to OO structure
Browse files Browse the repository at this point in the history
  • Loading branch information
lrusak committed Dec 12, 2017
1 parent cfa487f commit d20e7eb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
25 changes: 13 additions & 12 deletions xbmc/windowing/gbm/DRMUtils.cpp
Expand Up @@ -35,8 +35,14 @@

#include "DRMUtils.h"

static drmModeResPtr m_drm_resources = nullptr;
static drmModeCrtcPtr m_orig_crtc = nullptr;
CDRMUtils::CDRMUtils()
: m_connector(new connector)
, m_encoder(new encoder)
, m_crtc(new crtc)
, m_primary_plane(new plane)
, m_overlay_plane(new plane)
{
}

void CDRMUtils::WaitVBlank()
{
Expand Down Expand Up @@ -451,12 +457,6 @@ int CDRMUtils::Open(const char* device)

bool CDRMUtils::InitDrm()
{
m_connector = new connector;
m_encoder = new encoder;
m_crtc = new crtc;
m_primary_plane = new plane;
m_overlay_plane = new plane;

for(int i = 0; i < 10; ++i)
{
if (m_fd >= 0)
Expand Down Expand Up @@ -507,6 +507,7 @@ bool CDRMUtils::InitDrm()
}

drmModeFreeResources(m_drm_resources);
m_drm_resources = nullptr;

if(m_fd < 0)
{
Expand Down Expand Up @@ -562,17 +563,17 @@ void CDRMUtils::DestroyDrm()
if (m_drm_resources)
{
drmModeFreeResources(m_drm_resources);
m_drm_resources = nullptr;
}

drmDropMaster(m_fd);
close(m_fd);

m_drm_resources = nullptr;

m_primary_plane = nullptr;
m_overlay_plane = nullptr;
m_connector = nullptr;
m_encoder = nullptr;
m_crtc = nullptr;
m_primary_plane = nullptr;
m_overlay_plane = nullptr;
m_fd = -1;
m_mode = nullptr;
}
Expand Down
9 changes: 6 additions & 3 deletions xbmc/windowing/gbm/DRMUtils.h
Expand Up @@ -64,7 +64,7 @@ struct drm_fb
class CDRMUtils
{
public:
CDRMUtils() = default;
CDRMUtils();
virtual ~CDRMUtils() = default;
virtual void FlipPage(struct gbm_bo *bo) {};
virtual bool SetVideoMode(RESOLUTION_INFO res, struct gbm_bo *bo) { return false; };
Expand All @@ -76,11 +76,12 @@ class CDRMUtils
void WaitVBlank();

int m_fd;
struct plane *m_primary_plane = nullptr;
struct plane *m_overlay_plane = nullptr;

struct connector *m_connector = nullptr;
struct encoder *m_encoder = nullptr;
struct crtc *m_crtc = nullptr;
struct plane *m_primary_plane = nullptr;
struct plane *m_overlay_plane = nullptr;
drmModeModeInfo *m_mode = nullptr;

protected:
Expand All @@ -98,4 +99,6 @@ class CDRMUtils
static void DrmFbDestroyCallback(struct gbm_bo *bo, void *data);

int m_crtc_index;
drmModeResPtr m_drm_resources = nullptr;
drmModeCrtcPtr m_orig_crtc = nullptr;
};

0 comments on commit d20e7eb

Please sign in to comment.