void doScreenShotOfSurface(std::string fileName, const uint id, const uint layer_id);
int getWindowWidth() const;
int getWindowHeight() const;
+ virtual void finishFrame();
+ virtual void scheduleRepaint(void *data);
protected:
struct wl_display* m_wlDisplay;
bool m_error;
int m_width;
int m_height;
+ bool m_bRepaintNeeded;
+ bool m_bRepaintScheduled;
+ bool m_bUseFrameTimer;
+ struct wl_event_source* m_finishFrameTimer;
struct wl_list m_listFrameCallback;
struct wl_list m_nativeSurfaceList;
static void* eventLoopCallback(void* ptr);
static void registryHandleGlobalClient(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
static void surfaceListenerFrame(void* data, struct wl_callback* callback, uint32_t time);
+ static int finishFrameHandler(void *data);
// wl_surface interface
static void surfaceIFDestroy(struct wl_client *client, struct wl_resource *resource);
m_serverInfo = (void*)serverInfo;
}
+
+ int WaylandBaseWindowSystem::finishFrameHandler(void *data)
+ {
+ BaseWindowSystem* windowSystem = static_cast<BaseWindowSystem*>(data);
+ if (windowSystem)
+ {
+ windowSystem->finishFrame();
+ }
+ return 1;
+ }
}
WaylandBaseWindowSystem::WaylandBaseWindowSystem(const char* displayname, int width, int height, Scene* pScene, InputManager* pInputManager)
, m_error(false)
, m_width(width)
, m_height(height)
+, m_bRepaintNeeded(false)
+, m_bRepaintScheduled(false)
+, m_bUseFrameTimer(true)
+, m_finishFrameTimer(NULL)
, m_listFrameCallback()
, m_inputEvent(NULL)
, m_connectionList()
m_systemState = IDLE_STATE;
}
+
+ // update the frame timer
+ if (true == m_bUseFrameTimer)
+ {
+ wl_event_source_timer_update(m_finishFrameTimer, 10);
+ }
}
void WaylandBaseWindowSystem::renderHWLayer(Layer *layer)
wl_list_insert_list(windowSystem->m_listFrameCallback.prev, &nativeSurface->pending.frame_callback_list);
wl_list_init(&nativeSurface->pending.frame_callback_list);
- idleEventRepaint(windowSystem);
+ windowSystem->scheduleRepaint(windowSystem);
LOG_DEBUG("WaylandBaseWindowSystem", "surfaceIFCommit OUT");
}
LOG_DEBUG("WaylandBaseWindowSystem", "repaint OUT");
}
+void WaylandBaseWindowSystem::finishFrame()
+{
+ if (m_bRepaintNeeded)
+ {
+ repaint(getTime());
+ m_bRepaintNeeded = false;
+ return;
+ }
+ m_bRepaintScheduled = false;
+}
+
void WaylandBaseWindowSystem::idleEventRepaint(void *data)
{
- WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>( (WaylandBaseWindowSystem*)data);
LOG_DEBUG("WaylandBaseWindowSystem", "idleEventRepaint IN");
- windowSystem->repaint(getTime());
+ WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>(data);
+ if (windowSystem)
+ {
+ windowSystem->finishFrame();
+ }
LOG_DEBUG("WaylandBaseWindowSystem", "idleEventRepaint OUT");
}
+void WaylandBaseWindowSystem::scheduleRepaint(void *data)
+{
+ m_bRepaintNeeded = true;
+
+ if (m_bRepaintScheduled)
+ return;
+
+ struct wl_event_loop *loop = wl_display_get_event_loop(m_wlDisplay);
+ if (loop)
+ {
+ wl_event_loop_add_idle(loop, WaylandBaseWindowSystem::idleEventRepaint, data);
+ m_bRepaintScheduled = true;
+ }
+}
+
bool WaylandBaseWindowSystem::initCompositor()
{
LOG_DEBUG("WaylandBaseWindowSystem", "initCompositor START");
}
LOG_DEBUG("WaylandBaseWindowSystem", "SUCCESS:init GraphicSystem");
+ if (true == m_bUseFrameTimer)
+ {
+ struct wl_event_loop *loop = wl_display_get_event_loop(m_wlDisplay);
+ m_finishFrameTimer = wl_event_loop_add_timer(loop, finishFrameHandler, this);
+ }
+
// create input event
status = createInputEvent();
if (false == status)
struct wl_callback* callback = wl_surface_frame(m_wlSurfaceClient);
wl_callback_add_listener(callback, &g_frameListener, NULL);
wl_surface_commit(m_wlSurfaceClient);
- wl_display_roundtrip(m_wlDisplayClient);
}
void WaylandBaseWindowSystem::cleanup()