void BootupAnimation::renderInStateLogo()
{
	if (!m_logoSurf || !m_logoBrightSurf)
		return;

	const int kLowAlpha  = 0x00 - 0x80;
	const int kHighAlpha = 0xFF;

	static int sCurrAlpha = kLowAlpha;
	static int sDelta = 0x08;

	HostBase* host = HostBase::instance();
	const HostInfo& info = host->getInfo();

	int w = (int) (m_logoSurf->width());
	int h = (int) (m_logoSurf->height());

	int dx = (info.displayWidth  - w) / 2;
	int dy = (info.displayHeight - h) / 2;
	int dr = dx + w;
	int db = dy + h;

	m_ctxt->push();

	m_ctxt->setStrokeColor(PColor32(0x00, 0x00, 0x00, 0x00));
	m_ctxt->setFillColor(PColor32(0x00, 0x00, 0x00, 0xFF));
	m_ctxt->drawRect(0, 0, (int) info.displayWidth, (int) info.displayHeight);

	if (m_rotation != 0) {
		m_ctxt->translate((int)info.displayWidth/2, (int) info.displayHeight/2);
		m_ctxt->rotate(m_rotation);
		m_ctxt->translate((int) -info.displayWidth/2, (int) -info.displayHeight/2);
	}

	if (m_logoSurf) {
		m_ctxt->bitblt(m_logoSurf, dx, dy, dr, db);
	}

	if (m_logoBrightSurf) {
		m_ctxt->setFillOpacity(MAX(MIN(sCurrAlpha, 0xFF), 0x00));
		m_ctxt->bitblt(m_logoBrightSurf, dx, dy, dr, db);
	}

	m_ctxt->pop();

	m_ctxt->flip();

	sCurrAlpha += sDelta;
	if (sCurrAlpha <= kLowAlpha) {
		sDelta = 0x0F;
		sCurrAlpha = kLowAlpha;
	}
	else if (sCurrAlpha >= kHighAlpha) {
		sDelta = -0x0F;
		sCurrAlpha = kHighAlpha;
	}
}
void BootupAnimationTransition::init()
{
	HostBase* host = HostBase::instance();
	const HostInfo& info = host->getInfo();
	
	m_bounds = QRect(-info.displayWidth/2, -info.displayHeight/2, info.displayWidth, info.displayHeight);

	std::string imageRootPath = Settings::LunaSettings()->lunaSystemResourcesPath + "/";
	std::string imagePath;

	imagePath = imageRootPath + "hp-logo.png";
	QPixmap logoPixmap(imagePath.c_str());
	if (logoPixmap.isNull())
		g_warning("Failed to load image: %s", imagePath.c_str());
	
	m_screenPixmap = new QPixmap(info.displayWidth, info.displayHeight);

	m_rotation = Settings::LunaSettings()->homeButtonOrientationAngle;
	
	// prepare the full screen pixmap for the animation
	QPainter painter(m_screenPixmap);
	painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
	painter.fillRect(QRect(0, 0, info.displayWidth, info.displayHeight), QColor(0x00, 0x00, 0x00, 0xFF));
	if (m_rotation != 0) {
		painter.translate(info.displayWidth/2, info.displayHeight/2);
		painter.rotate(m_rotation);
		painter.translate(-info.displayWidth/2, -info.displayHeight/2);
	}

	painter.drawPixmap(info.displayWidth/2 - logoPixmap.width()/ 2, info.displayHeight/2 - logoPixmap.height()/ 2, logoPixmap);
	painter.setRenderHint(QPainter::SmoothPixmapTransform, false);
	painter.end();

	m_opacityAnimationPtr = new QPropertyAnimation();
	m_opacityAnimationPtr->setPropertyName("opacity");
	m_opacityAnimationPtr->setEasingCurve(QEasingCurve::Linear);
	m_opacityAnimationPtr->setTargetObject(this);
	m_opacityAnimationPtr->setDuration(kFadeAnimDuration); 
	m_opacityAnimationPtr->setStartValue(1.0);
	m_opacityAnimationPtr->setEndValue(0.0);
	
	m_scaleAnimationPtr   = new QPropertyAnimation();
	m_scaleAnimationPtr->setPropertyName("scale");
	m_scaleAnimationPtr->setEasingCurve(QEasingCurve::Linear);
	m_scaleAnimationPtr->setTargetObject(this);
	m_scaleAnimationPtr->setDuration(kFadeAnimDuration); 
	m_scaleAnimationPtr->setStartValue(1.0);
	m_scaleAnimationPtr->setEndValue(2.0);

	m_fadeAnimationGroupPtr = new QParallelAnimationGroup();
	m_fadeAnimationGroupPtr->addAnimation(m_opacityAnimationPtr);	
	m_fadeAnimationGroupPtr->addAnimation(m_scaleAnimationPtr);
	connect(m_fadeAnimationGroupPtr, SIGNAL(finished()), SLOT(fadeAnimationFinished()));
}
int main( int argc, char** argv)
{
	appArgc = argc;
	appArgv = argv;

	std::set_terminate(generateGoodBacktraceTerminateHandler);

	g_thread_init(NULL);

	const char *renderMode;
#if defined(TARGET_DEVICE) && defined(HAVE_OPENGL)
	::setenv("QT_PLUGIN_PATH", "/usr/plugins", 1);
	renderMode = "HW egl";
#elif defined(TARGET_DEVICE) || defined(TARGET_EMULATOR)
	::setenv("QT_PLUGIN_PATH", "/usr/plugins", 1);	
	renderMode = "Software";
#elif defined(HAVE_OPENGL)
	renderMode = "HW OpenGL";
#else
	renderMode = "Software";
#endif

	g_debug("SysMgr compiled against Qt %s, running on %s, %s render mode requested", QT_VERSION_STR, qVersion(), renderMode);

	// Command-Line options
  	parseCommandlineOptions(argc, argv);

    if (s_debugTrapStr && 0 == strcasecmp(s_debugTrapStr, "on")) {
        debugCrashes = true;
    }

	if (s_mallocStatsFileStr) {
		setupMallocStats(s_mallocStatsFileStr);
	}

    sysmgrPid = getpid();

	// Load Settings (first!)
	Settings* settings = Settings::LunaSettings();

	// Initialize logging handler
	g_log_set_default_handler(logFilter, NULL);

#if defined(TARGET_DESKTOP)
	// use terminal logging when running on desktop
	settings->logger_useTerminal = true;
#endif

	// disable color logging using an environment variable. Useful when run from QtCreator
	const char* useColor = ::getenv("COLOR_LOGGING");
	if (useColor)
		settings->logger_useColor = (useColor[0] != 0 && useColor[0] != '0');

	HostBase* host = HostBase::instance();
	// the resolution is just a hint, the actual
	// resolution may get picked up from the fb driver on arm
	host->init(settings->displayWidth, settings->displayHeight);

#if defined(TARGET_DEVICE) && defined(HAVE_OPENGL)
	if (settings->forceSoftwareRendering)
		::setenv("QT_QPA_PLATFORM", "palm-soft", 0);
	else
		::setenv("QT_QPA_PLATFORM", "palm", 0);
#else
    // Do not override the value if the variable exists
    ::setenv("QT_QPA_PLATFORM", "palm", 0);
#endif
	
	
#if defined(TARGET_DEVICE) && defined(HAVE_OPENGL)
	if (!settings->forceSoftwareRendering)
		::setenv("QWS_DISPLAY", "egl", 1);
#endif

    // Install the handler for signals that we want to trap:
    // Note: We install the handlers after we initialize the setting because
    // we may do something different depending on the settings values.
    installOuterCrashHandler(SIGILL);
    installOuterCrashHandler(SIGSEGV);
    installOuterCrashHandler(SIGTERM);

    // Not needed anymore?
    ::prctl(PR_SET_NAME, (unsigned long) "WebAppMgr", 0, 0, 0);
    ::prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);

    const HostInfo* info = &(HostBase::instance()->getInfo());
    WebAppManager::instance()->setHostInfo(info);

    initMallocStatsCb(WebAppManager::instance()->mainLoop(), s_mallocStatsInterval);

    logInit();

    // Start the Browser App Launcher
    #ifdef NO_WEBKIT_INIT
        //WindowServer::instance()->bootupFinished();
    #else
        WebAppManager::instance()->run(); // Sync execution of the task
    #endif

    return 0;
}
Beispiel #4
0
/**
 * Main program entry point
 *
 * This function is the one called by the operating system to start Luna.
 * 
 * This function sets {@link appArgc appArgc} and {@link appArgv appArgv}.
 * 
 * @see appArgc
 * @see appArgv
 *
 * @param	argc		Number of command-line arguments
 * @param	argv		Pointer to list of char* of each of the arguments
 *
 * @return			0 = success, anything else = failure
 */
int main( int argc, char** argv)
{
	appArgc = argc;
	appArgv = argv;

	std::set_terminate(generateGoodBacktraceTerminateHandler);

	g_thread_init(NULL);

	const char *renderMode;
#if defined(TARGET_DEVICE) && defined(HAVE_OPENGL)
	::setenv("QT_PLUGIN_PATH", "/usr/plugins", 1);
	renderMode = "HW egl";
#elif defined(TARGET_DEVICE) || defined(TARGET_EMULATOR)
	::setenv("QT_PLUGIN_PATH", "/usr/plugins", 1);	
	renderMode = "Software";
#elif defined(HAVE_OPENGL)
	renderMode = "HW OpenGL";
#else
	renderMode = "Software";
#endif

	WindowServer::markBootStart();

	g_debug("SysMgr compiled against Qt %s, running on %s, %s render mode requested", QT_VERSION_STR, qVersion(), renderMode);

	// Command-Line options
  	parseCommandlineOptions(argc, argv);

    if (s_debugTrapStr && 0 == strcasecmp(s_debugTrapStr, "on")) {
        debugCrashes = true;
    }

	if (s_mallocStatsFileStr) {
		setupMallocStats(s_mallocStatsFileStr);
	}

    sysmgrPid = getpid();

	// Load Settings (first!)
	Settings* settings = Settings::LunaSettings();

	// Initialize logging handler
	g_log_set_default_handler(logFilter, NULL);

#if defined(TARGET_DESKTOP)
	// use terminal logging when running on desktop
	settings->logger_useTerminal = true;
#endif

	// disable color logging using an environment variable. Useful when run from QtCreator
	const char* useColor = ::getenv("COLOR_LOGGING");
	if (useColor)
		settings->logger_useColor = (useColor[0] != 0 && useColor[0] != '0');

	HostBase* host = HostBase::instance();
	// the resolution is just a hint, the actual
	// resolution may get picked up from the fb driver on arm
	host->init(settings->displayWidth, settings->displayHeight);

#if defined(TARGET_DEVICE)
	pid_t animPid= spawnBootupAnimationProcess();
	if(animPid < 0) { // failed to start the Animation process
		return -1;
	}
#endif

#if defined(TARGET_DEVICE) && defined(HAVE_OPENGL) && defined(HAVE_QPA)
	if (settings->forceSoftwareRendering)
		::setenv("QT_QPA_PLATFORM", "palm-soft", 1);
	else
		::setenv("QT_QPA_PLATFORM", "palm", 1);
#endif
	
	
#if defined(TARGET_DEVICE) && defined(HAVE_OPENGL)
	if (!settings->forceSoftwareRendering)
		::setenv("QWS_DISPLAY", "egl", 1);
#endif


	pid_t webKitPid= spawnWebKitProcess();
	if(webKitPid < 0) { // failed to start the WebKit process
		return -1;
	}

	// Tie LunaSysMgr to Processor 0
	setCpuAffinity(getpid(), 1);

	// Tie WebAppMgr to Processor 1
	setCpuAffinity(webKitPid, 0);

	// Safe to create logging threads now
	logInit();

	// Initialize Ipc Server
	(void) IpcServer::instance();

	// Ipc Server is ready, so signal the WebAppMgr process (via pipe) to go ahead and connect
	::write(WebAppMgrPipeFd, &msgOkToContinue, 1);
	::close(WebAppMgrPipeFd);
	WebAppMgrPipeFd = -1;


#if !defined(TARGET_DESKTOP)
	// Set "nice" property
	setpriority(PRIO_PROCESS,getpid(),-1);
#endif

#if !defined(TARGET_DESKTOP) && !defined(HAVE_QPA)
	QWSServer::setDefaultMouse("HiddTp");
	QWSServer::setDefaultKeyboard("HiddKbd");
	::setenv("QWS_DBLCLICK_DISTANCE", QString("%0").arg(Settings::LunaSettings()->tapRadius).toAscii().constData(), 1);
#endif

	qInstallMsgHandler(qtMsgHandler);
	QApplication app(argc, argv);
	QApplication::setStartDragDistance(settings->tapRadius);
	QApplication::setDoubleClickInterval (Settings::LunaSettings()->tapDoubleClickDuration);
	host->show();
	
	initMallocStatsCb(HostBase::instance()->mainLoop(), s_mallocStatsInterval);

	// Initialize Preferences handler
	(void) Preferences::instance();

	// Initialize Localization handler
	(void) Localization::instance();

	//Register vibration/haptics support
	HapticsController::instance()->startService();

	(void) DeviceInfo::instance();

	// Initialize Security handler
	(void) Security::instance();

	// Initialize the System Service
	SystemService::instance()->init();

	// Initialize the application mgr
	ApplicationManager::instance()->init();

	// Initialize the Application Installer
	ApplicationInstaller::instance();

	// Start the window manager
	WindowServer *windowServer = WindowServer::instance();
	windowServer->installEventFilter(windowServer);

	// Initialize the SysMgr MemoryMonitor
	MemoryMonitor::instance();

	// load all set policies
	EASPolicyManager::instance()->load();

	// Launching of the System UI launcher and headless apps has been moved to WebAppMgrProxy::connectWebAppMgr

	// Did user specify an app to launch
	if (s_appToLaunchStr) {
		WebAppMgrProxy::setAppToLaunchUponConnection(s_appToLaunchStr);
	}

	app.exec();
	return 0;
}
void BootupAnimation::init()
{
	s_frameTime = s_frameTimeSlow;

	HostBase* host = HostBase::instance();
	const HostInfo& info = host->getInfo();

	m_ctxt = PGContext::create();
	m_ctxt->setDisplay(PPrimary, 0, PFORMAT_8888, 3);
	
	// Fill with black
	m_ctxt->push();
	m_ctxt->setStrokeColor(PColor32(0x00, 0x00, 0x00, 0x00));
	m_ctxt->setFillColor(PColor32(0x00, 0x00, 0x00, 0xFF));
	m_ctxt->drawRect(0, 0, (int) info.displayWidth, (int) info.displayHeight);
	m_ctxt->pop();

	std::string imageRootPath = Settings::LunaSettings()->lunaSystemResourcesPath + "/";
	std::string imagePath;

	imagePath = imageRootPath + "hp-logo.png";
	m_logoSurf = PGSurface::createFromPNGFile(imagePath.c_str());
	if (!m_logoSurf)
		g_warning("Failed to load image: %s", imagePath.c_str());

	imagePath = imageRootPath + "hp-logo-bright.png";
	m_logoBrightSurf = PGSurface::createFromPNGFile(imagePath.c_str());
	if (!m_logoBrightSurf)
		g_warning("Failed to load image: %s", imagePath.c_str());

	imagePath = imageRootPath + "activity-static.png";
	m_activityStaticSurf = PGSurface::createFromPNGFile(imagePath.c_str());
	if (!m_activityStaticSurf)
		g_warning("Failed to load image: %s", imagePath.c_str());
	
	imagePath = imageRootPath + "activity-spinner.png";
	m_activitySpinnerSurf = PGSurface::createFromPNGFile(imagePath.c_str());
	if (!m_activitySpinnerSurf)
		g_warning("Failed to load image: %s", imagePath.c_str());

	imagePath = imageRootPath + "activity-progress.png";
	m_activityProgressSurf = PGSurface::createFromPNGFile(imagePath.c_str());
	if (!m_activityProgressSurf)
		g_warning("Failed to load image: %s", imagePath.c_str());

	const char* fontName = Settings::LunaSettings()->fontBootupAnimation.c_str();
	m_font = PGFont::createFromFile(fontName, s_fontHeight1);
	if (!m_font) {
		g_critical("%s: Failed to load font: %s", __PRETTY_FUNCTION__, fontName);
	}

	m_fallbackFonts = new PGFallbackFonts();

	generateUtf16AndGlyphOffsets();

	m_logoScale = 1.0f;
	m_logoAlpha = 0xFF;

	m_activityProgress = 0;
	m_activitySpinner = 0;

	switch (Settings::LunaSettings()->homeButtonOrientationAngle) {
	case 90:
		m_rotation = -90;
		break;
	case -90:
	case 270:
		m_rotation = 90;
		break;
	case 180:
		m_rotation = 180;
		break;
	default:
		m_rotation = 0;
	}
}