void BootupAnimation::startActivity()
{
	luna_assert(m_state == StateLogo);
	luna_assert(m_renderThread);

	setActivityProgress(0, 1);
	m_state = StateActivity;
}
void BootupAnimation::start()
{

	init();
	luna_assert(m_state == StateIdle);
	luna_assert(m_renderThread == 0);

	m_state = StateLogo;
	m_renderThread = g_thread_create(BootupAnimation::renderThread,
										this, true, NULL);
}
void BootupAnimation::stop()
{
	luna_assert(m_state == StateLogo);
	luna_assert(m_renderThread);

	s_frameTime = s_frameTimeFast;
	m_logoAlpha = 0xFF;
	m_logoScale = 1.0f;
	m_state = StateIdle;
	g_thread_join(m_renderThread);
	m_renderThread = 0;
	//At this point, the render thread has terminated and we have
	//done a deinit of all resources.  exit
	exit(0);
}
void RemoteWindowDataSoftware::sendWindowUpdate(int x, int y, int w, int h)
{
	luna_assert(m_channel);
	if (!m_directRendering) {
		m_channel->sendAsyncMessage(new ViewHost_UpdateWindowRegion(key(), x, y, w, h));
	}
}
void RemoteWindowDataSoftware::resize(int newWidth, int newHeight)
{
	if (m_width == newWidth && m_height == newHeight)
		return;

	luna_assert(m_ipcBuffer);

	if (m_context) {
		m_surface->releaseRef();
		m_context->releaseRef();
		m_surface = 0;
		m_context = 0;
	}

	delete m_ipcBuffer;
	m_ipcBuffer = 0;
	m_displayOpened = false;

	const int size = newWidth * newHeight * sizeof(uint32_t);
	m_ipcBuffer = PIpcBuffer::create(size);
	m_width = newWidth;
	m_height = newHeight;

	luna_assert(m_ipcBuffer);

	if (m_hasAlpha)
		memset(m_ipcBuffer->data(), 0x00, size);
	else
		memset(m_ipcBuffer->data(), 0xFF, size);

	m_context = PGContext::create();
	m_surface = m_context->wrapBitmapData(m_width, m_height, true,
										  data());

	if (m_directRendering) {
		if (!m_displayOpened) {
			m_context->setDisplay(PPrimary, 1, PFORMAT_8888, 3);
			m_displayOpened = true;
		} else {
			m_context->setSurface(0);
		}
	} else {
		m_context->setSurface(m_surface);
	}
}
void RemoteWindowDataSoftware::beginPaint()
{
	luna_assert(m_context && m_surface);

	if (m_directRendering) {
	}
	else {
		lock();

		m_context->setSurface(m_surface);
	}
}
void WindowServerLuna::slotFullEraseDevice()
{
	LSHandle* handle = SystemService::instance()->serviceHandle();
	LSError err;
	LSErrorInit(&err);

	luna_assert(handle != 0);
	LSCall(handle, "palm://com.palm.storage/erase/EraseAll", "{}", &WindowServerLuna::cbFullEraseCallback, this, NULL, &err);

	if (LSErrorIsSet(&err)) {
		LSErrorPrint(&err, stderr);
		LSErrorFree(&err);
	}
	else {
		m_fullErasePending = true;
	}
}
void BootupAnimationTransition::start()
{
	luna_assert(!m_fadeAnimationGroupPtr.isNull());
	
	m_fadeAnimationGroupPtr->start();
}
void BootupAnimation::stopActivity()
{
	luna_assert(m_renderThread);

	setActivityProgress(1, 1);    
}
void* RemoteWindowDataSoftware::data()
{
	luna_assert(m_ipcBuffer);
	return m_ipcBuffer->data();
}
void RemoteWindowDataSoftware::unlock()
{
	luna_assert(m_ipcBuffer);
	m_ipcBuffer->unlock();
}