Skip to content

Commit

Permalink
squash: improved error handling of hw cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed Jun 29, 2015
1 parent ff96cd0 commit aff4309
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions xbmc/linux/RBP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,13 @@ void CRBP::Deinitialize()
m_initialized = false;
m_omx_initialized = false;
uninit_cursor();
if (m_mb && m_p)
gpu_free_internal(m_p, m_mb);
delete m_p;
m_p = NULL;
if (m_mb)
{
if (m_p)
gpu_free_internal(m_p, m_mb);
delete m_p;
m_p = NULL;
mbox_close(m_mb);
m_mb = 0;
}
m_mb = 0;
vcsm_exit();
}

Expand Down Expand Up @@ -416,7 +414,7 @@ static int gpu_malloc_uncached_internal(int numbytes, GPU_MEM_PTR_T *p, int mb)

p->numbytes = numbytes;
p->suballoc = 0;
p->vcsm_handle = vcsm_malloc_cache(numbytes, VCSM_CACHE_TYPE_NONE, (char *)"Mouse pointer" );
p->vcsm_handle = vcsm_malloc_cache(numbytes, VCSM_CACHE_TYPE_NONE, (char *)"Mouse pointer");
assert(p->vcsm_handle);
p->vc_handle = vcsm_vc_hdl_from_hdl(p->vcsm_handle);
assert(p->vc_handle);
Expand Down Expand Up @@ -465,21 +463,22 @@ const static uint32_t default_cursor_pixels[] =
void CRBP::init_cursor()
{
//printf("%s\n", __func__);
if (!m_mb)
return;
if (!m_p)
{
m_p = new GPU_MEM_PTR_T;
gpu_malloc_uncached_internal(64 * 64 * 4, m_p, m_mb);
set_cursor(default_cursor_pixels, 16, 16, 0, 0);
if (m_p)
gpu_malloc_uncached_internal(64 * 64 * 4, m_p, m_mb);
}
if (m_mb && m_p && m_p->arm && m_p->vc)
set_cursor(default_cursor_pixels, 16, 16, 0, 0);
}

void CRBP::set_cursor(const void *pixels, int width, int height, int hotspot_x, int hotspot_y)
{
if (!m_p || !m_p->arm || !pixels || width * height > 64 * 64)
{
assert(0);
if (!m_mb || !m_p || !m_p->arm || !m_p->vc || !pixels || width * height > 64 * 64)
return;
}
//printf("%s %dx%d %p\n", __func__, width, height, pixels);
memcpy(m_p->arm, pixels, width * height * 4);
unsigned int s = mailbox_set_cursor_info(m_mb, width, height, 0, m_p->vc, hotspot_x, hotspot_y);
Expand All @@ -488,6 +487,9 @@ void CRBP::set_cursor(const void *pixels, int width, int height, int hotspot_x,

void CRBP::update_cursor(int x, int y, bool enabled)
{
if (!m_mb || !m_p || !m_p->arm || !m_p->vc)
return;

RESOLUTION res = g_graphicsContext.GetVideoResolution();
CRect gui(0, 0, CDisplaySettings::Get().GetResolutionInfo(res).iWidth, CDisplaySettings::Get().GetResolutionInfo(res).iHeight);
CRect display(0, 0, CDisplaySettings::Get().GetResolutionInfo(res).iScreenWidth, CDisplaySettings::Get().GetResolutionInfo(res).iScreenHeight);
Expand All @@ -501,9 +503,10 @@ void CRBP::update_cursor(int x, int y, bool enabled)

void CRBP::uninit_cursor()
{
if (!m_mb || !m_p || !m_p->arm || !m_p->vc)
return;
//printf("%s\n", __func__);
if (m_mb)
mailbox_set_cursor_position(m_mb, 0, 0, 0);
mailbox_set_cursor_position(m_mb, 0, 0, 0);
}

#endif

0 comments on commit aff4309

Please sign in to comment.