uint64_t CSurface::GetSHMHandle()
{
- // 1. Free local buffer
- delete m_data;
- // 2. Allocate a copy in SHM
- m_fd = _SysOpen("/Devices/shm/anon", OPENFLAG_WRITE|OPENFLAG_READ);
- if(m_fd==-1) throw ::std::system_error(errno, ::std::system_category());
size_t size = m_rect.m_w*m_rect.m_h*4;
- _SysTruncate(m_fd, size);
+ if( m_fd == -1 )
+ {
+ // 2. Allocate a copy in SHM
+ m_fd = _SysOpen("/Devices/shm/anon", OPENFLAG_WRITE|OPENFLAG_READ);
+ if(m_fd == -1) {
+ _SysDebug("GetSHMHandle: Unable to open anon SHM");
+ return -1;
+ }
+ // 1. Free local buffer
+ delete m_data;
+ _SysTruncate(m_fd, size);
+ }
+ else
+ {
+ _SysMUnMap(m_data, size);
+ }
// 3. mmap shm copy
m_data = static_cast<uint32_t*>( _SysMMap(nullptr, size, MMAP_PROT_WRITE, 0, m_fd, 0) );
if(!m_data) throw ::std::system_error(errno, ::std::system_category());
+
return _SysMarshalFD(m_fd);
}
// Load background image
uint32_t *buf = AxWin4_GetWindowBuffer(bgwin);
- for( size_t y = 0; y < h; y ++ )
+ if( buf )
{
- for(size_t x = 0; x < w; x ++ )
+ for( size_t y = 0; y < h; y ++ )
{
- uint8_t r = y * 256 / h;
- uint8_t g = 0;
- uint8_t b = x * 256 / w;
- buf[y*w+x] = (r << 16) | (g << 8) | b;
+ for(size_t x = 0; x < w; x ++ )
+ {
+ uint8_t r = y * 256 / h;
+ uint8_t g = 0;
+ uint8_t b = x * 256 / w;
+ buf[y*w+x] = (r << 16) | (g << 8) | b;
+ }
}
}
+ else
+ {
+ //AxWin4_FillRect(bgwin, 0, 0, w, h, 0x0000CC);
+ }
//AxWin4_DamageRect(bgwin, 0, 0, w, h);
AxWin4_ShowWindow(bgwin, true);