Exemple #1
0
QAbstractAnimationJob* QQuickAnchorAnimation::transition(QQuickStateActions &actions,
                        QQmlProperties &modified,
                        TransitionDirection direction,
                        QObject *defaultTarget)
{
    Q_UNUSED(modified);
    Q_UNUSED(defaultTarget);
    Q_D(QQuickAnchorAnimation);
    QQuickAnimationPropertyUpdater *data = new QQuickAnimationPropertyUpdater;
    data->interpolatorType = QMetaType::QReal;
    data->interpolator = d->interpolator;
    data->reverse = direction == Backward ? true : false;
    data->fromSourced = false;
    data->fromDefined = false;

    for (int ii = 0; ii < actions.count(); ++ii) {
        QQuickAction &action = actions[ii];
        if (action.event && action.event->type() == QQuickActionEvent::AnchorChanges
            && (d->targets.isEmpty() || d->targets.contains(static_cast<QQuickAnchorChanges*>(action.event)->object()))) {
            data->actions << static_cast<QQuickAnchorChanges*>(action.event)->additionalActions();
        }
    }

    QQuickBulkValueAnimator *animator = new QQuickBulkValueAnimator;
    if (data->actions.count()) {
        animator->setAnimValue(data);
        animator->setFromSourcedValue(&data->fromSourced);
    } else {
        delete data;
    }

    animator->setDuration(d->duration);
    animator->setEasingCurve(d->easing);
    return initInstance(animator);
}
	NyARGrayscaleRaster::NyARGrayscaleRaster(int i_width, int i_height,bool i_is_alloc)
		:NyARRaster_BasicClass(i_width,i_height,NyARBufferType::INT1D_GRAY_8)
	{
		if(!initInstance(this->_size,NyARBufferType::INT1D_GRAY_8,i_is_alloc)){
			throw NyARException();
		}
	}
Exemple #3
0
int  WINAPI _tWinMain(  HINSTANCE hInstance,
                      HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    MSG msg;
    HACCEL hAccelTable;

    myRegisterClass(hInstance);

    // Perform application initialization:
    if (!initInstance (hInstance, nCmdShow))
    {
        return FALSE;
    }

    hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MAIN));

    // Main message loop:
    while (GetMessage(&msg, NULL, 0, 0))
    {
        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return (int) msg.wParam;
}
	NyARGrayscaleRaster::NyARGrayscaleRaster(int i_width, int i_height,int i_raster_type,bool i_is_alloc)
		:NyARRaster_BasicClass(i_width,i_height,i_raster_type)
	{
		if(!initInstance(this->_size,i_raster_type,i_is_alloc)){
			throw NyARException();
		}
	}
Renderer::Renderer() {
    setupLayersAndExtensions();
    setupDebug();
    initInstance();
    initDebug();
    initDevice();
}
int CCApplication::Run()
{
	IW_CALLSTACK("CCApplication::Run");
	
	if ( ! initInstance() || !applicationDidFinishLaunching() )
	{
		return 0;
	}
	
	int64 updateTime = s3eTimerGetMs();
	
	while (!s3eDeviceCheckQuitRequest()) 
	{ 
		int64 currentTime = s3eTimerGetMs();
		if (currentTime - updateTime > m_nAnimationInterval)
		{
			updateTime = currentTime;
			
			s3eDeviceYield(0);
			s3eKeyboardUpdate();
			s3ePointerUpdate();
			
			ccAccelerationUpdate();
			CCDirector::sharedDirector()->mainLoop();
		}
		else 
		{
			s3eDeviceYield(0);
		}
		
	}
	return -1;
}
Exemple #7
0
// hashAdd is used when a new redis server add to rebalance tokens
int hashAdd(struct redisServer *server, wstr ip, int port, int id)
{
    size_t ninstance, ntoken_per_instance, extra_ntoken, target_idx, ntoken;
    struct token *token, *tokens;
    struct redisInstance *instance, *target_instance;
    struct redisInstance add_instance;
    size_t *sub_ntoken;
    int i;

    if (initInstance(&add_instance, id, ip, port, DIRTY) == WHEAT_WRONG)
        return WHEAT_WRONG;
    arrayPush(server->instances, &add_instance);

    // `sub_ntoken`'s element is the amount of tokens every instance should
    // take out
    ninstance = narray(server->instances);
    sub_ntoken = wmalloc(sizeof(int)*ninstance);
    ntoken_per_instance = WHEAT_KEYSPACE / ninstance;
    extra_ntoken = WHEAT_KEYSPACE % ninstance;
    for (i = 0; i < ninstance; i++) {
        instance = arrayIndex(server->instances,i);
        sub_ntoken[i] = instance->ntoken - ntoken_per_instance;
    }
    if (!extra_ntoken) {
        for (i = 0; i < extra_ntoken; i++) {
            sub_ntoken[i]--;
        }
    }

    target_idx = ninstance-1;
    extra_ntoken = sub_ntoken[target_idx];
    target_instance = arrayIndex(server->instances, target_idx);
    token = tokens = &server->tokens[0];
    while (extra_ntoken) {
        size_t skip = random() % ntoken_per_instance + 1;
        while (skip--) {
            token = &tokens[token->next_instance];
        }
        if (token->instance_id != target_idx &&
                sub_ntoken[token->instance_id]) {
            wheatLog(WHEAT_DEBUG, "token: %d", token->pos);
            instance = arrayIndex(server->instances, token->instance_id);
            token->instance_id = target_idx;
            instance->ntoken--;
            target_instance->ntoken++;
        }
    }

    ntoken = 0;
    for (i = 0; i < ninstance; i++) {
        instance = arrayIndex(server->instances,i);
        ntoken += instance->ntoken;
    }
    ASSERT(ntoken == WHEAT_KEYSPACE);

    wfree(sub_ntoken);
    return WHEAT_OK;
}
Exemple #8
0
int PASCAL WinMain( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show )
{
    char buffer[PATH_MAX];

#if !defined( __WATCOMC__ ) && defined( __NT__ )
    _argc = __argc;
    _argv = __argv;
#endif
    EXEName = _cmdname( buffer );
    InstanceHandle = inst;
    showHow = show;
    prev = prev;
    cmdline = cmdline;

    InitMem();

#ifndef __NT__
    if( prev != NULL && !HasShare() ) {
        MessageBox( NULLHANDLE, "SHARE.EXE must be loaded before starting Windows in order to run multiple instances of the editor",
                    EditorName, MB_OK );
        MyGetInstanceData( (unsigned short) prev, (void near *) &Root, sizeof( Root ) );
        SetFocus( Root );
        return( 0 );
    }
#endif

    Comspec = getenv( "COMSPEC" );
#ifdef __NT__
    VarAddGlobalStr( "OS", "winnt" );
#else
    VarAddGlobalStr( "OS", "win" );
#endif
    SetConfigFileName( CFG_NAME );
    ReadProfile();

    ShowStartupDialog();

    initApplication();
    if( !initInstance() ) {
        return( 0 );
    }
    InitializeEditor();
    SetSaveConfig();
    if( !BAD_ID( CurrentWindow ) ) {
        SetFocus( Root );
    }

    SetWindowCursorForReal();
    ResizeRoot();
    EditMain();

    FiniMem();

    return( 0 );

} /* WinMain */
int CCApplication::run()
{
    // Initialize instance and cocos2d.
    if (! initInstance() || ! applicationDidFinishLaunching())
    {
        return 0;
    }

    return cocos2d::CCApplication::sharedApplication()->exec();
}
int CCApplication::run()
{
        // Initialize instance and cocos2d.
        if (! initInstance() || ! applicationDidFinishLaunching())
        {
                return 0;
        }
	
	return -1;
}
// Constructor
TaoServerTask::TaoServerTask(const int maxIncomingQMsgs)
        : OsServerTask("TaoServerTask-%d", NULL, maxIncomingQMsgs)
        , mOutgoingQ("TaoServerTask::mOutgoingQ")
{
        mClientHandle = 0;
        mEventClient = 0;
        if (TAO_SUCCESS == initInstance())
        {

        }
}
IpfixRecordAnonymizer* AnonymizerCfg::createInstance()
{
	if (!instance) {
		instance = new IpfixRecordAnonymizer();
	}

	initInstance(this, instance, _elem->getElementChildren());
	instance->setCopyMode(getBool("copyMode", false));

	return instance;
}
Exemple #13
0
static PP_Bool Instance_DidCreate(PP_Instance instance,
                                  uint32_t argc,
                                  const char* argn[],
                                  const char* argv[]) {

	PP_Var v =  CStrToVar("Hello a World (NEWLIB)");
  ppb_messaging_interface->PostMessage(instance,v);
  //fprintf(stdout,"Hello a World (NEWLIB)");

  initInstance(); //CLM ADDED
  return PP_TRUE;
}
Exemple #14
0
 /*FIXME: change m_wait from 30 to 10, hold to 1*/
 ConnBoshMultStat::ConnBoshMultStat( ConnectionDataHandler* cdh, ConnectionBase* connection,
                                 const LogSink& logInstance, const std::string& boshHost,
                                 const std::string& xmppServer, int xmppPort )
   : ConnectionBase( cdh ),
     m_logInstance( logInstance ), m_parser( this ), m_boshHost( boshHost ), m_path( "/http-bind/" ),
     m_rid( 0 ),  m_initialStreamSent( false ), m_openRequests( 0 ),
     m_maxOpenRequests( 2 ), m_wait( 10 ), m_hold( 1 ), m_streamRestart( false ),
     m_lastRequestTime( std::time( 0 ) ), m_minTimePerRequest( 0 ), m_bufferContentLength( 0 ),
     m_connMode( ModePipelining )
 {
   initInstance( connection, xmppServer, xmppPort );
 }
TaoClientTask::TaoClientTask(const int maxIncomingQMsgs, TaoServerTask *pTaoServerTask)
: OsServerTask("TaoClient", NULL, maxIncomingQMsgs),
mMutex(OsRWMutex::Q_PRIORITY)
{
        mpConnectionSocket = 0;
        mpTaoServerTask = pTaoServerTask;
        mpAgent = NULL;
        initInstance();
        if (!isStarted())
        {
                start();
        }
}
// Constructor
TaoServerTask::TaoServerTask(const UtlString& name,
                void* pArg,
                const int maxRequestQMsgs,
                const int priority,
                const int options,
                const int stackSize)
                : OsServerTask(name.data(), pArg, maxRequestQMsgs, priority, options, stackSize)
                , mOutgoingQ("TaoServerTask::mOutgoingQ")
{
        mClientHandle = 0;
        mEventClient = 0;
        if (TAO_SUCCESS == initInstance())
        {
        }
}
int CCApplication::Run()
{
	IW_CALLSTACK("CCApplication::Run");
	
	s3eBool quitRequested = 0;

	if ( ! initInstance() || !applicationDidFinishLaunching() )
	{
		return 0;
	}
	
	int64 updateTime = s3eTimerGetMs();
	
	while (true) 
	{ 
		int64 currentTime = s3eTimerGetMs();
		if (currentTime - updateTime > m_nAnimationInterval)
		{
			updateTime = currentTime;
			
			s3eDeviceYield(0);
			s3eKeyboardUpdate();
			s3ePointerUpdate();
			
			ccAccelerationUpdate();

			quitRequested = s3eDeviceCheckQuitRequest() ;
			if( quitRequested && CCDirector::sharedDirector()->getOpenGLView() != NULL ) {
				CCDirector::sharedDirector()->end() ;
				// end status will be processed in CCDirector::sharedDirector()->mainLoop();
			}

			CCDirector::sharedDirector()->mainLoop();

			if( quitRequested ) {
				break ;
			}
		}
		else 
		{
			s3eDeviceYield(0);
		}
		
	}
	return -1;
}
// Constructor
TaoClientTask::TaoClientTask(TaoServerTask *pTaoServerTask,
                const UtlString& name,
                void* pArg,
                const int maxRequestQMsgs,
                const int priority,
                const int options,
                const int stackSize)
: OsServerTask(name, pArg, maxRequestQMsgs, priority, options, stackSize),
mMutex(OsRWMutex::Q_PRIORITY)
{
        mpConnectionSocket = 0;
        mpTaoServerTask = pTaoServerTask;
        mpAgent = NULL;
        initInstance();
        if (!isStarted())
        {
                start();
        }
}
// Constructor
TaoServerTask::TaoServerTask(CpCallManager *pCallMgr,
                PsPhoneTask *pPhoneTask,
                const UtlString& name,
                void* pArg,
                const int maxRequestQMsgs,
                const int priority,
                const int options,
                const int stackSize)
                : OsServerTask(name.data(), pArg, maxRequestQMsgs, priority, options, stackSize)
                , mOutgoingQ("TaoServerTask::mOutgoingQ")
{
        mpCallMgr = pCallMgr;
        mpPhoneTask = pPhoneTask;
        mClientHandle = 0;
        mEventClient = 0;
        if (TAO_SUCCESS == initInstance())
        {
        }
}
TaoClientTask::TaoClientTask(int port,
                                  UtlString host,
                                  TaoServerTask *pTaoServerTask,
                                  const UtlString& name,
                                  const int maxRequestQMsgs)
: OsServerTask(name, NULL, maxRequestQMsgs),
mRemotePort(port),
mRemoteHost(host),
mMutex(OsRWMutex::Q_PRIORITY)
{
        initInstance();
        mpConnectionSocket = 0;
        mpAgent = NULL;
        mpTaoServerTask = pTaoServerTask;
        if (!isStarted())
        {
                start();
        }

}
int CCApplication::run()
{
	// Initialize instance and cocos2d.
	if (! initInstance() || ! applicationDidFinishLaunching())
	{
		return 0;
	}


	for (;;) {
		long iLastTime = getCurrentMillSecond();
		CCDirector::sharedDirector()->mainLoop();
		long iCurTime = getCurrentMillSecond();
		if (iCurTime-iLastTime<m_nAnimationInterval){
			usleep((m_nAnimationInterval - iCurTime+iLastTime)*1000);
		}

	}
	return -1;
}
Exemple #22
0
int APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow )
{
    if ( registerMain( hInstance ) &&
         initInstance( hInstance, nCmdShow )
       ) {
       pPlacer = new CPlacer( hWndApp, 4 );
       if ( pPlacer &&
            pPlacer->addNew( createChild( hInstance, _T( "Label 2" ) ), ALIGN_RIGHT , 150,  0, true ) &&
            pPlacer->addNew( createChild( hInstance, _T( "Label 1" ) ), ALIGN_LEFT  , 150,  0, true ) &&
            pPlacer->addNew( createChild( hInstance, _T( "Label 4" ) ), ALIGN_BOTTOM, 0, 30 ) &&
            pPlacer->addNew( createChild( hInstance, _T( "Label 3" ) ), ALIGN_TOP   , 0, 50 ) &&
            pPlacer->addNew( createChild( hInstance, _T( "Label 5" ) ), ALIGN_CLIENT, 0, 0  )
          ) {
          pPlacer->setPlaces( 0, 0 );
          while ( ::GetMessage( &msg, NULL, 0, 0 ) ) {
                ::TranslateMessage( &msg );
                ::DispatchMessage( &msg );
          }
          delete pPlacer;
       }
    }
    return ( int ) msg.wParam;
}
int CCApplication::run()
{
    PVRFrameEnableControlWindow(false);

    // Main message loop:
    MSG msg;
    LARGE_INTEGER nFreq;
    LARGE_INTEGER nLast;
    LARGE_INTEGER nNow;

    QueryPerformanceFrequency(&nFreq);
    QueryPerformanceCounter(&nLast);

    // Initialize instance and cocos2d.
    if (! initInstance() || ! applicationDidFinishLaunching())
    {
        return 0;
    }

    CCEGLView& mainWnd = CCEGLView::sharedOpenGLView();
    mainWnd.centerWindow();
    ShowWindow(mainWnd.getHWnd(), SW_SHOW);

    while (1)
    {
        if (! PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            // Get current time tick.
            QueryPerformanceCounter(&nNow);

            // If it's the time to draw next frame, draw it, else sleep a while.
            if (nNow.QuadPart - nLast.QuadPart > m_nAnimationInterval.QuadPart)
            {
                nLast.QuadPart = nNow.QuadPart;
                CCDirector::sharedDirector()->mainLoop();

				if(!CCDirector::sharedDirector()->isPaused())
					mainWnd.dispatchInputEvents();

		/*		HMENU menu = GetMenu(mainWnd.getHWnd());
				if(menu != NULL)
					DrawMenuBar(mainWnd.getHWnd());*/
            }
            else
            {
                Sleep(0);
            }
            continue;
        }

        if (WM_QUIT == msg.message)
        {
            // Quit message loop.
            break;
        }

        // Deal with windows message.
        if (! m_hAccelTable || ! TranslateAccelerator(msg.hwnd, m_hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return (int) msg.wParam;
}
int CCApplication::run()
{
	LARGE_INTEGER nFreq;
	LARGE_INTEGER nLast;
	LARGE_INTEGER nNow;

	QueryPerformanceFrequency(&nFreq);

#if !CC_USE_GLFW_WINDOW

	PVRFrameEnableControlWindow(true);

	// 初始化窗口和游戏引擎,由子类实现
	if (!initInstance() || !applicationDidFinishLaunching())
	{
		return 0;
	}

	CCEGLView& mainWnd = CCEGLView::sharedOpenGLView();
	mainWnd.centerWindow();
	ShowWindow(mainWnd.getHWnd(), SW_SHOW);

	MSG msg;
	QueryPerformanceCounter(&nLast);

	while(1)
	{
		if (!PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			QueryPerformanceCounter(&nNow);
			if (nNow.QuadPart - nLast.QuadPart > m_nAnimationInterval.QuadPart)
			{
				nLast.QuadPart = nNow.QuadPart;
				CCDirector::sharedDirector()->mainLoop();
			}
			else
			{
				Sleep(0);
			}
			continue;
		}

		if (WM_QUIT == msg.message)
		{
			break;
		}

		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return (int)msg.wParam;

#else

	// 初始化窗口和游戏引擎,由子类实现
	if (!initInstance() || !applicationDidFinishLaunching())
	{
		return 0;
	}

	while(1)
	{
		QueryPerformanceCounter(&nLast);
		CCDirector::sharedDirector()->mainLoop();
		QueryPerformanceCounter(&nNow);
		if (nNow.QuadPart - nLast.QuadPart < m_nAnimationInterval.QuadPart)
		{
			LONGLONG diff = (m_nAnimationInterval.QuadPart - nNow.QuadPart + nLast.QuadPart) * 1000 / nFreq.QuadPart;
			Sleep((DWORD)diff);
		}
	}

#endif
}
int CCApplication::run()
{
    PVRFrameEnableControlWindow(false);
	CCLog("--- INTO CCApplication::run \n");

    // Main message loop:
    
    // Initialize instance and cocos2d.
    if (! initInstance() || ! applicationDidFinishLaunching())
    {
        return 0;
    }
    
    SDL_Joystick *joystick = SDL_JoystickOpen(0);
	
    CCEGLView& mainWnd = CCEGLView::sharedOpenGLView();
    mainWnd.centerWindow();
   CCLog(" --- BEFORE EVENT LOOP\n");
	 SDL_Event Event;
	 while (1) {
        bool gotEvent;
        
        // without the inner while loop, input performance gets really laggy    	        
		while ( SDL_PollEvent(&Event) ) {  
//		  CCLog("--- GOT NEW EVENT .... \n");
		 switch (Event.type) {
                case SDL_KEYDOWN:
                    switch (Event.key.keysym.sym) {
                        case PDLK_GESTURE_BACK: /* also maps to ESC */
                            if (PDL_GetPDKVersion() >= 200) {
                                // standard behavior is to minimize to a card when you perform a back
                                // gesture at the top level of the app
                                PDL_Minimize();
                            }
                            break;
                            case PDLK_GESTURE_DISMISS_KEYBOARD:{
                                CCDirector::sharedDirector()->getOpenGLView()->setIMEKeyboardState(false);
                            }
                            break;
                            case SDLK_BACKSPACE: {
                                CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
                            }
                            break;
                        default:
                        {
                            CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(SDL_GetKeyName(Event.key.keysym.sym), 1); 
                        }
                        break;
                    }
                    break;
                case SDL_MOUSEBUTTONDOWN:
//					CCLog(" --- GOT NEW EVENT (SDL_MOUSEBUTTONDOWN).... \n");
					mainWnd.WindowProc(SDL_MOUSEBUTTONDOWN,Event);
					break;
				case SDL_MOUSEBUTTONUP:
//					CCLog("--- GOT NEW EVENT (SDL_MOUSEBUTTONUP).... \n");
					mainWnd.WindowProc(SDL_MOUSEBUTTONUP,Event);
					break;
				case SDL_MOUSEMOTION:
					mainWnd.WindowProc(SDL_MOUSEMOTION,Event);
					break;
				case SDL_QUIT:
                    // We exit anytime we get a request to quit the app
                    // all shutdown code is registered via atexit() so this is clean.
                    exit(0);
                    break;
                case SDL_JOYAXISMOTION:
                	CCAccelerometer::sharedAccelerometer()->update(joystick, time(NULL));
                	break;
                case SDL_ACTIVEEVENT:
                      switch(Event.active.gain)
                      {
                        case 1:
                            {
                                applicationWillEnterForeground();
                                break;
                            }
                        default:
                        {
                            applicationDidEnterBackground();
                            break;
                        }
                      }
                    break;
                default:
                    break;
            }
        }   
		   // Get current time tick.
            // If it's the time to draw next frame, draw it, else sleep a while.
            CCDirector::sharedDirector()->mainLoop();
     }

    return (int) 0;
}
Exemple #26
0
CI2cOledDrv::CI2cOledDrv() {
	// TODO 自動生成されたコンストラクター・スタブ
	initInstance();

}
Exemple #27
0
QAbstractAnimationJob* QQuickParentAnimation::transition(QQuickStateActions &actions,
                        QQmlProperties &modified,
                        TransitionDirection direction,
                        QObject *defaultTarget)
{
    Q_D(QQuickParentAnimation);

    struct QQuickParentAnimationData : public QAbstractAnimationAction
    {
        QQuickParentAnimationData() : reverse(false) {}
        ~QQuickParentAnimationData() { qDeleteAll(pc); }

        QQuickStateActions actions;
        //### reverse should probably apply on a per-action basis
        bool reverse;
        QList<QQuickParentChange *> pc;
        virtual void doAction()
        {
            for (int ii = 0; ii < actions.count(); ++ii) {
                const QQuickAction &action = actions.at(ii);
                if (reverse)
                    action.event->reverse();
                else
                    action.event->execute();
            }
        }
    };

    QQuickParentAnimationData *data = new QQuickParentAnimationData;
    QQuickParentAnimationData *viaData = new QQuickParentAnimationData;

    bool hasExplicit = false;
    if (d->target && d->newParent) {
        data->reverse = false;
        QQuickAction myAction;
        QQuickParentChange *pc = new QQuickParentChange;
        pc->setObject(d->target);
        pc->setParent(d->newParent);
        myAction.event = pc;
        data->pc << pc;
        data->actions << myAction;
        hasExplicit = true;
        if (d->via) {
            viaData->reverse = false;
            QQuickAction myVAction;
            QQuickParentChange *vpc = new QQuickParentChange;
            vpc->setObject(d->target);
            vpc->setParent(d->via);
            myVAction.event = vpc;
            viaData->pc << vpc;
            viaData->actions << myVAction;
        }
        //### once actions have concept of modified,
        //    loop to match appropriate ParentChanges and mark as modified
    }

    if (!hasExplicit)
    for (int i = 0; i < actions.size(); ++i) {
        QQuickAction &action = actions[i];
        if (action.event && action.event->type() == QQuickActionEvent::ParentChange
            && (!d->target || static_cast<QQuickParentChange*>(action.event)->object() == d->target)) {

            QQuickParentChange *pc = static_cast<QQuickParentChange*>(action.event);
            QQuickAction myAction = action;
            data->reverse = action.reverseEvent;

            //### this logic differs from PropertyAnimation
            //    (probably a result of modified vs. done)
            if (d->newParent) {
                QQuickParentChange *epc = new QQuickParentChange;
                epc->setObject(static_cast<QQuickParentChange*>(action.event)->object());
                epc->setParent(d->newParent);
                myAction.event = epc;
                data->pc << epc;
                data->actions << myAction;
                pc = epc;
            } else {
                action.actionDone = true;
                data->actions << myAction;
            }

            if (d->via) {
                viaData->reverse = false;
                QQuickAction myAction;
                QQuickParentChange *vpc = new QQuickParentChange;
                vpc->setObject(pc->object());
                vpc->setParent(d->via);
                myAction.event = vpc;
                viaData->pc << vpc;
                viaData->actions << myAction;
                QQuickAction dummyAction;
                QQuickAction &xAction = pc->xIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
                QQuickAction &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
                QQuickAction &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
                QQuickAction &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction;
                QQuickItem *target = pc->object();
                QQuickItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent();

                //### this mirrors the logic in QQuickParentChange.
                bool ok;
                const QTransform &transform = targetParent->itemTransform(d->via, &ok);
                if (transform.type() >= QTransform::TxShear || !ok) {
                    qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under complex transform");
                    ok = false;
                }

                qreal scale = 1;
                qreal rotation = 0;
                bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0);
                if (ok && !isRotate) {
                    if (transform.m11() == transform.m22())
                        scale = transform.m11();
                    else {
                        qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
                        ok = false;
                    }
                } else if (ok && isRotate) {
                    if (transform.m11() == transform.m22())
                        scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
                    else {
                        qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
                        ok = false;
                    }

                    if (scale != 0)
                        rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI;
                    else {
                        qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under scale of 0");
                        ok = false;
                    }
                }

                const QPointF &point = transform.map(QPointF(xAction.toValue.toReal(),yAction.toValue.toReal()));
                qreal x = point.x();
                qreal y = point.y();
                if (ok && target->transformOrigin() != QQuickItem::TopLeft) {
                    qreal w = target->width();
                    qreal h = target->height();
                    if (pc->widthIsSet() && i < actions.size() - 1)
                        w = actions[++i].toValue.toReal();
                    if (pc->heightIsSet() && i < actions.size() - 1)
                        h = actions[++i].toValue.toReal();
                    const QPointF &transformOrigin
                            = d->computeTransformOrigin(target->transformOrigin(), w,h);
                    qreal tempxt = transformOrigin.x();
                    qreal tempyt = transformOrigin.y();
                    QTransform t;
                    t.translate(-tempxt, -tempyt);
                    t.rotate(rotation);
                    t.scale(scale, scale);
                    t.translate(tempxt, tempyt);
                    const QPointF &offset = t.map(QPointF(0,0));
                    x += offset.x();
                    y += offset.y();
                }

                if (ok) {
                    //qDebug() << x << y << rotation << scale;
                    xAction.toValue = x;
                    yAction.toValue = y;
                    sAction.toValue = sAction.toValue.toReal() * scale;
                    rAction.toValue = rAction.toValue.toReal() + rotation;
                }
            }
        }
    }

    if (data->actions.count()) {
        QSequentialAnimationGroupJob *topLevelGroup = new QSequentialAnimationGroupJob;
        QActionAnimation *viaAction = d->via ? new QActionAnimation : 0;
        QActionAnimation *targetAction = new QActionAnimation;
        //we'll assume the common case by far is to have children, and always create ag
        QParallelAnimationGroupJob *ag = new QParallelAnimationGroupJob;

        if (d->via)
            viaAction->setAnimAction(viaData);
        targetAction->setAnimAction(data);

        //take care of any child animations
        bool valid = d->defaultProperty.isValid();
        QAbstractAnimationJob* anim;
        for (int ii = 0; ii < d->animations.count(); ++ii) {
            if (valid)
                d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
            anim = d->animations.at(ii)->transition(actions, modified, direction, defaultTarget);
            if (anim)
                ag->appendAnimation(anim);
        }

        //TODO: simplify/clarify logic
        bool forwards = direction == QQuickAbstractAnimation::Forward;
        if (forwards) {
            topLevelGroup->appendAnimation(d->via ? viaAction : targetAction);
            topLevelGroup->appendAnimation(ag);
            if (d->via)
                topLevelGroup->appendAnimation(targetAction);
        } else {
            if (d->via)
                topLevelGroup->appendAnimation(targetAction);
            topLevelGroup->appendAnimation(ag);
            topLevelGroup->appendAnimation(d->via ? viaAction : targetAction);
        }
        return initInstance(topLevelGroup);
    } else {
        delete data;
        delete viaData;
    }
    return 0;
}
	NyARSingleDetectMarker::NyARSingleDetectMarker(const NyARParam* i_param,const NyARCode* i_code, double i_marker_width,int i_input_raster_type,int i_profile_id)
	{
		initInstance(i_param,i_code,i_marker_width,i_input_raster_type,i_profile_id);
		return;
	}
//-----  CFDResourceManager  --------------------------------------------------
CFDResourceManager::CFDResourceManager()
{
	initInstance();
}
Exemple #30
0
Error GrManagerImpl::initInternal(const GrManagerInitInfo& init)
{
	ANKI_LOGI("Initializing Vulkan backend");
	ANKI_CHECK(initInstance(init));
	ANKI_CHECK(initSurface(init));
	ANKI_CHECK(initDevice(init));
	vkGetDeviceQueue(m_device, m_queueIdx, 0, &m_queue);
	ANKI_CHECK(initSwapchain(init));

	{
		VkPipelineCacheCreateInfo ci = {};
		ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
		vkCreatePipelineCache(m_device, &ci, nullptr, &m_pplineCache);
	}

	ANKI_CHECK(initMemory(*init.m_config));
	ANKI_CHECK(m_dsetAlloc.init(getAllocator(), m_device));
	m_pplineLayFactory.init(getAllocator(), m_device, &m_dsetAlloc.getDescriptorSetLayoutFactory());

	for(PerFrame& f : m_perFrame)
	{
		resetFrame(f);
	}

	glslang::InitializeProcess();
	m_fences.init(getAllocator(), m_device);
	m_semaphores.init(getAllocator(), m_device);

	m_queryAlloc.init(getAllocator(), m_device);

	m_samplerCache = getAllocator().newInstance<GrObjectCache>(m_manager);

	// Set m_r8g8b8ImagesSupported
	{
		VkImageFormatProperties props = {};
		VkResult res = vkGetPhysicalDeviceImageFormatProperties(m_physicalDevice,
			VK_FORMAT_R8G8B8_UNORM,
			VK_IMAGE_TYPE_2D,
			VK_IMAGE_TILING_OPTIMAL,
			VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
			0,
			&props);

		if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
		{
			ANKI_LOGI("R8G8B8 Images are not supported. Will workaround this");
			m_r8g8b8ImagesSupported = false;
		}
		else
		{
			ANKI_ASSERT(res == VK_SUCCESS);
			ANKI_LOGI("R8G8B8 Images are supported");
			m_r8g8b8ImagesSupported = true;
		}
	}

	// Set m_s8ImagesSupported
	{
		VkImageFormatProperties props = {};
		VkResult res = vkGetPhysicalDeviceImageFormatProperties(m_physicalDevice,
			VK_FORMAT_S8_UINT,
			VK_IMAGE_TYPE_2D,
			VK_IMAGE_TILING_OPTIMAL,
			VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
			0,
			&props);

		if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
		{
			ANKI_LOGI("S8 Images are not supported. Will workaround this");
			m_s8ImagesSupported = false;
		}
		else
		{
			ANKI_ASSERT(res == VK_SUCCESS);
			ANKI_LOGI("S8 Images are supported");
			m_s8ImagesSupported = true;
		}
	}

	// Set m_d24S8ImagesSupported
	{
		VkImageFormatProperties props = {};
		VkResult res = vkGetPhysicalDeviceImageFormatProperties(m_physicalDevice,
			VK_FORMAT_D24_UNORM_S8_UINT,
			VK_IMAGE_TYPE_2D,
			VK_IMAGE_TILING_OPTIMAL,
			VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
			0,
			&props);

		if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
		{
			ANKI_LOGI("D24S8 Images are not supported. Will workaround this");
			m_d24S8ImagesSupported = false;
		}
		else
		{
			ANKI_ASSERT(res == VK_SUCCESS);
			ANKI_LOGI("D24S8 Images are supported");
			m_d24S8ImagesSupported = true;
		}
	}

	return ErrorCode::NONE;
}