static TCGvoid EngineHandleCmd(struct android_app* app, TCGint cmd)
{
    struct Engine* engine = (struct Engine*)app->userData;
    switch (cmd)
    {
    case APP_CMD_SAVE_STATE:
        // The system has asked us to save our current state.  Do so.
        engine->app->savedState = TCG_MALLOC(sizeof(struct SavedState), eTCG_MAIN);
        *((struct SavedState*)engine->app->savedState) = engine->state;
        engine->app->savedStateSize = sizeof(struct SavedState);
        break;

    case APP_CMD_INIT_WINDOW:
        //窗口初始化
        _Lock.Lock();
        g_bWindowMax = TCG_TRUE;
        _Lock.UnLock();
        
        if (engine->app->window != NULL)
        {
            g_WindowType = engine->app->window;
        }
        break;

    case APP_CMD_TERM_WINDOW:
        //窗口销毁
        _Lock.Lock();
        g_bWindowMax = TCG_FALSE;
        _Lock.UnLock();
        break;

    case APP_CMD_GAINED_FOCUS:
        // When our app gains focus, we start monitoring the accelerometer.
        if (engine->accelerometerSensor != NULL)
        {
            ASensorEventQueue_enableSensor(engine->sensorEventQueue,
                    engine->accelerometerSensor);
            // We'd like to get 60 events per second (in us).
            ASensorEventQueue_setEventRate(engine->sensorEventQueue,
                    engine->accelerometerSensor, (1000L/60)*1000);
        }
        break;

    case APP_CMD_LOST_FOCUS:
        // When our app loses focus, we stop monitoring the accelerometer.
        // This is to avoid consuming battery while not being used.
        if (engine->accelerometerSensor != NULL)
        {
            ASensorEventQueue_disableSensor(engine->sensorEventQueue,
                    engine->accelerometerSensor);
        }
        // Also stop animating.
        engine->animating = 0;
        break;

    default:
        break;
    }
}
示例#2
0
void ChatDialog::InitWindow()
{
	 m_pInput = static_cast<CRichEditUI*>(GetPaintMgr()->FindControl(kInputRichEditControlName));
	 m_pMsgView = static_cast<CRichEditUI*>(GetPaintMgr()->FindControl(kViewRichEditControlName));

	 if (theApp->HasMsgForUserInQueue(friend_.m_loadName))
	 {
		 theLockMsgQue.Lock();
		 typedef std::map<CString,std::vector<CMsg*> >::iterator iter;
		 iter it;
		 for (it=theMsgQueue.begin();it!=theMsgQueue.end();++it)
		 {
			 if(it->first==friend_.m_loadName)
			 {
				 std::vector<CMsg*> msg = it->second;
				 for (int i=0;i<msg.size();++i)
				 {
					 ShowMsg(msg[i]);
				 }
				theMsgQueue.erase(it);
				 break;
			 }
		 }
		 theLockMsgQue.UnLock();
	 }
}
TCGvoid CPlaybackAdapter::PlayFrame()
{
    /* For multithread rendering, we will parse event always. */
    while (TCG_TRUE)
    {
#ifdef ANDROID
        _Lock.Lock();
        TCGbool bWindowMax = g_bWindowMax;
        _Lock.UnLock();

        if (m_parser.IsEglSwapEvent() || !bWindowMax)
        {
            m_parser.ClearEglSwapFlag();
        }
        if (!bWindowMax)
        {
            continue;
        }
#endif
        m_parser.ParseSingleEvent();
        m_player.SyncLog();

#if defined(USE_FILE) || TCG_AUTO_TEST
        if (g_bParserFinish && IsRenderFinish())
        {
            break;
        }
#endif
    }

    m_player.ResetFrame();
    m_player.SyncLog();
}
示例#4
0
void ChatDialog::OnExit(TNotifyUI& msg)
{
	thelockChatDlgList.Lock();
	POSITION pos,temp;
	for (pos=theChatDialogList.GetHeadPosition();pos!=NULL;)
	{
		temp = pos;
		ChatDialog* pDlg = (ChatDialog*)theChatDialogList.GetNext(pos);
		if (pDlg&&pDlg==this)
		{
			theChatDialogList.RemoveAt(temp);
		}
	}
	thelockChatDlgList.UnLock();
	Close();
}
示例#5
0
void COSError::LogMessage(const TCHAR* msg)
{
	static CLock lock;
	TCHAR txt[512];
	size_t len = CTimeWrap::GetNow(txt, _countof(txt));
	_stprintf_s(txt + len, _countof(txt) - len, _T("  %s%s"), msg, _T("\r\n"));
	lock.Lock();
	try
	{
		if(m_proc!=NULL)
			m_proc(txt);
		 else if(m_show_out)
			 _tprintf_s(_T("%s"), txt);

		if(m_log != NULL)
			_fputts(txt, m_log);
	}
	catch(...)
	{
	}
	lock.UnLock();
}