From 5f4d39ad0059ceec48c59d5ed87457a6bcb1c5f1 Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Fri, 7 Nov 2014 06:46:15 +0800 Subject: [PATCH] Usermode/AxWin4 - Tweak handling of AcessNative (doesn't have SHM and mmap) --- .../axwin4_src/Server/CSurface.cpp | 23 ++++++++++++++----- .../axwin4_src/Server/CWindow.cpp | 3 ++- Usermode/Applications/axwin4_src/UI/main.c | 19 ++++++++++----- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/Usermode/Applications/axwin4_src/Server/CSurface.cpp b/Usermode/Applications/axwin4_src/Server/CSurface.cpp index 07d8bfb6..27078d87 100644 --- a/Usermode/Applications/axwin4_src/Server/CSurface.cpp +++ b/Usermode/Applications/axwin4_src/Server/CSurface.cpp @@ -31,16 +31,27 @@ CSurface::~CSurface() 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( _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); } diff --git a/Usermode/Applications/axwin4_src/Server/CWindow.cpp b/Usermode/Applications/axwin4_src/Server/CWindow.cpp index a0067a72..392fd47f 100644 --- a/Usermode/Applications/axwin4_src/Server/CWindow.cpp +++ b/Usermode/Applications/axwin4_src/Server/CWindow.cpp @@ -16,7 +16,8 @@ CWindow::CWindow(CCompositor& compositor, CClient& client, const ::std::string& m_surface(0,0,0,0), m_compositor(compositor), m_client(client), - m_name(name) + m_name(name), + m_is_shown(false) { _SysDebug("CWindow::CWindow()"); } diff --git a/Usermode/Applications/axwin4_src/UI/main.c b/Usermode/Applications/axwin4_src/UI/main.c index 37ee08c7..c831558d 100644 --- a/Usermode/Applications/axwin4_src/UI/main.c +++ b/Usermode/Applications/axwin4_src/UI/main.c @@ -44,16 +44,23 @@ tAxWin4_Window *CreateBGWin(int w, int h) // 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); -- 2.20.1