TInt CVwsSession::RemoveView(const RMessage2& /*aMessage*/,const TVwsViewId& aViewId)
	{
	TBool systemView=iServer.IsSystemDefaultView(aViewId);
	TInt index=IndexById(aViewId);
	if (index==iActiveViewIndex && !systemView)
		{
		LOG4(CVwsLog::ENormal,_L("Not removing the currently active view [\"%x,%x\"]"),aViewId.iAppUid.iUid,aViewId.iViewUid.iUid);
		return KErrInUse;
		}
	else if (index>=0)
		{
		iViewIdArray.Delete(index);
		if (iActiveViewIndex>index)
			{
			iActiveViewIndex--;
			iLastActiveViewIndex--;
			}
#ifdef _DEBUG
		if (systemView)
			{
			LOG4(CVwsLog::ENormal,_L("Removed system default view [\"%x,%x\"]"),aViewId.iAppUid.iUid,aViewId.iViewUid.iUid);
			}
#endif
		return KErrNone;
		}

	return KErrNotFound;
	}
Exemple #2
0
ULONG GetLayerNum(ULONG nID)
{
	int nCount=nID;
	int nLg4 = LOG4(nCount);
	while (nLg4)
	{
		nCount -=(1<<((nLg4-1)<<1));
		nLg4--;
	}
	if (nCount>=0)
		return LOG4(nID);
	else
		return (LOG4(nID)-1);
}
void CVwsSession::RequestViewEventL(const RMessage2& aMessage)
	{
	iViewEventMessage=aMessage;
	const TInt error=aMessage.Int1();
	switch (iState)
		{
		case EWaitingForClientRequest:
			{
			LOG4(CVwsLog::ENormal,_L("Client \"%x\" requested view event [session state: EWaitingClientRequest, last error: %d]"),iAppUid.iUid,error);
			iState=EClientRequestPending;
			CVwsEvent* headEvent=iEventQueue->Head();
			if (headEvent)
				{
				STATIC_CAST(CVwsSessionEvent*,headEvent)->HandleViewEventRequestL(error,iViewEventMessage);
				}
			}
			break;
		case EClientRequestPending:
			LOG3(CVwsLog::ENormal,_L("PANIC Client \"%x\" for requesting view event when one is already pending"),iAppUid.iUid);
			PanicClient(aMessage,EVwsViewEventRequestAlreadyPending);
			break;
		default:
			ASSERT(EFalse);
		}
	}
void CVwsEventQueue::HandleEventProcessed()
	{
	if (iQueueSize==1)
		{
		Head()->HandleLastOnQueue();
		DeleteHead();
		LOG3(CVwsLog::ELoud,_L("Completed event at head of %S, queue empty"),&iQueueName);
		iState=EEmpty;
		}
	else if (iQueueSize>0)
		{
		DeleteHead();
		LOG4(CVwsLog::ELoud,_L("Completed event at head of %S, processing next [queue size %d]"),&iQueueName,iQueueSize);
		// Start processing next event in the queue.
		TInt err=KErrGeneral;
		while (iQueueSize>0 && err)
				{
				TRAP(err, Head()->ProcessEventL());
				if (err)
					{
					DeleteHead();
					if (0==iQueueSize)
						{
						iState=EEmpty;
						}
					}
				}
		}
	}
void CVwsEventQueue::HandleSessionRemoval(const TThreadId& aClientThreadId)
	{
	if (iQueueSize>0)
		{
		LOG4(CVwsLog::ELoud,_L("Session removed - handling removal in head event of %S [queue size %d]"),&iQueueName,iQueueSize);
		Head()->HandleSessionRemoval(aClientThreadId);
		}
	}
void CVwsSession::RemoveViewL(const RMessage2& aMessage)
	{
	TVwsViewId viewId(ViewIdFromMessageL(aMessage));
	LOG4(CVwsLog::ENormal,_L("Removing view \"%x,%x\""),viewId.iAppUid.iUid,viewId.iViewUid.iUid);
	if (RemoveView(aMessage,viewId)==KErrNotFound)
		{
		PanicClient(aMessage,EVwsViewNotFound);
		}
	}
Exemple #7
0
	void fun(int i)
	{

		LOG_PRE;
		//LOG_FUNC(lg, sl, debug);
		LOG_FUNC4(lg, debug);
		//std::cout << "0123456789abcdef0123456789abcdef" << std::endl;
		LOG4(lg, debug) << i;
	}
TInt CVwsEventQueue::DoAddToTail(CVwsEvent* aEvent)
	{
	if (iQueueSize<KQueueSize)
		{
		iQueue[iQueueEnd]=aEvent;
		iQueueEnd=(iQueueEnd+1)%KQueueSize;
		iQueueSize++;
		aEvent->HandleAddedToQueue();
		LOG4(CVwsLog::ELoud,_L("Added event to tail of %S [queue size %d]"),&iQueueName,iQueueSize);
		return KErrNone;
		}

	return KErrOverflow;
	}
void CVwsSession::CompleteViewEvent(TInt aNotification)
	{
	ASSERT(iState==EClientRequestPending);

	if (iState==EClientRequestPending)
		{
		LOG4(CVwsLog::ENormal,_L("Completing view event in client \"%x\" with \"%d\""),iAppUid.iUid,aNotification);
		iViewEventMessage.Complete(aNotification);
		iState=EWaitingForClientRequest;
		}
	else
		{
		LOG3(CVwsLog::ELoud,_L("Completing view event in client \"%x\" - ERROR: No pending client request!"),iAppUid.iUid);
		}
	}
Exemple #10
0
bool Curve::Intersect(const Ray &r, Float *tHit, SurfaceInteraction *isect,
                      bool testAlphaTexture) const {
    ++nTests;
    // Transform _Ray_ to object space
    Vector3f oErr, dErr;
    Ray ray = (*WorldToObject)(r, &oErr, &dErr);

    // Compute object-space control points for curve segment, _cpObj_
    Point3f cpObj[4];
    cpObj[0] = BlossomBezier(common->cpObj, uMin, uMin, uMin);
    cpObj[1] = BlossomBezier(common->cpObj, uMin, uMin, uMax);
    cpObj[2] = BlossomBezier(common->cpObj, uMin, uMax, uMax);
    cpObj[3] = BlossomBezier(common->cpObj, uMax, uMax, uMax);

    // Project curve control points to plane perpendicular to ray
    Vector3f dx, dy;
    CoordinateSystem(ray.d, &dx, &dy);
    Transform objectToRay = LookAt(ray.o, ray.o + ray.d, dx);
    Point3f cp[4] = {objectToRay(cpObj[0]), objectToRay(cpObj[1]),
                     objectToRay(cpObj[2]), objectToRay(cpObj[3])};

    // Compute refinement depth for curve, _maxDepth_
    Float L0 = 0;
    for (int i = 0; i < 2; ++i)
        L0 = std::max(
            L0, std::max(
                    std::max(std::abs(cp[i].x - 2 * cp[i + 1].x + cp[i + 2].x),
                             std::abs(cp[i].y - 2 * cp[i + 1].y + cp[i + 2].y)),
                    std::abs(cp[i].z - 2 * cp[i + 1].z + cp[i + 2].z)));
    Float eps =
        std::max(common->width[0], common->width[1]) * .05f;  // width / 20
#define LOG4(x) (std::log(x) * 0.7213475108f)
    Float fr0 = LOG4(1.41421356237f * 12.f * L0 / (8.f * eps));
#undef LOG4
    int r0 = (int)std::round(fr0);
    int maxDepth = Clamp(r0, 0, 10);
    return recursiveIntersect(ray, tHit, isect, cp, Inverse(objectToRay), uMin,
                              uMax, maxDepth);
}
Exemple #11
0
void CVwsSession::AddViewL(const RMessage2& aMessage)
	{
	TVwsViewId viewId(ViewIdFromMessageL(aMessage));

	if (iAppUid.iUid==0)
		{
		iAppUid.iUid=viewId.iAppUid.iUid;
#ifdef __DO_LOGGING__
		TBuf<64> queueName;
		queueName.Format(_L("Session Queue for \"%x\""),iAppUid.iUid);
		iEventQueue->SetName(queueName);
#endif
		}
	else if (iAppUid!=viewId.iAppUid)
		{
		// All views added by the same client should have the same app uid.
		PanicClient(aMessage,EVwsInvalidViewUid);
		}

	LOG4(CVwsLog::ENormal,_L("Adding view \"%x,%x\""),viewId.iAppUid.iUid,viewId.iViewUid.iUid);
	AddViewL(viewId);
	}
Exemple #12
0
DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscreen, DFrameBuffer *old)
{
	static int retry = 0;
	static int owidth, oheight;

	BaseWinFB *fb;
	PalEntry flashColor;
	int flashAmount;

	LOG4 ("CreateFB %d %d %d %p\n", width, height, fullscreen, old);

	if (old != NULL)
	{ // Reuse the old framebuffer if its attributes are the same
		BaseWinFB *fb = static_cast<BaseWinFB *> (old);
		if (fb->Width == width &&
			fb->Height == height &&
			fb->Windowed == !fullscreen)
		{
			return old;
		}
		old->GetFlash (flashColor, flashAmount);
		old->ObjectFlags |= OF_YesReallyDelete;
		if (old == screen) screen = NULL;
		delete old;
	}
	else
	{
		flashColor = 0;
		flashAmount = 0;
	}

	if (D3D != NULL)
	{
		fb = new D3DFB (width, height, fullscreen);
	}
	else
	{
		fb = new DDrawFB (width, height, fullscreen);
	}
	LOG1 ("New fb created @ %p\n", fb);

	// If we could not create the framebuffer, try again with slightly
	// different parameters in this order:
	// 1. Try with the closest size
	// 2. Try in the opposite screen mode with the original size
	// 3. Try in the opposite screen mode with the closest size
	// This is a somewhat confusing mass of recursion here.

	while (fb == NULL || !fb->IsValid ())
	{
		static HRESULT hr;

		if (fb != NULL)
		{
			if (retry == 0)
			{
				hr = fb->GetHR ();
			}
			delete fb;

			LOG1 ("fb is bad: %08lx\n", hr);
		}
		else
		{
			LOG ("Could not create fb at all\n");
		}
		screen = NULL;

		LOG1 ("Retry number %d\n", retry);

		switch (retry)
		{
		case 0:
			owidth = width;
			oheight = height;
		case 2:
			// Try a different resolution. Hopefully that will work.
			I_ClosestResolution (&width, &height, 8);
			LOG2 ("Retry with size %d,%d\n", width, height);
			break;

		case 1:
			// Try changing fullscreen mode. Maybe that will work.
			width = owidth;
			height = oheight;
			fullscreen = !fullscreen;
			LOG1 ("Retry with fullscreen %d\n", fullscreen);
			break;

		default:
			// I give up!
			LOG3 ("Could not create new screen (%d x %d): %08lx", owidth, oheight, hr);
			I_FatalError ("Could not create new screen (%d x %d): %08lx", owidth, oheight, hr);
		}

		++retry;
		fb = static_cast<DDrawFB *>(CreateFrameBuffer (width, height, fullscreen, NULL));
	}
	retry = 0;

	fb->SetFlash (flashColor, flashAmount);

	return fb;
}