예제 #1
0
void CGlobalSettings::SetScreenNoL(TInt aScreenNo)
	{
	RWsSession session;
	ASSERT_EQUALS(session.Connect(), KErrNone);
	TInt maxScreens=session.NumberOfScreens();
	
	if (maxScreens>aScreenNo)
		{
		INFO_PRINTF2(_L("New screen number for all output selected: %i"),aScreenNo);
			{
			CWsScreenDevice screen(session);
			screen.Construct(aScreenNo);
			screen.SetCurrentRotations(0,CFbsBitGc::TGraphicsOrientation(0));
			screen.SetScreenMode(0);
			screen.SetAppScreenMode(0);
			}
		settings_instance.iScreen=aScreenNo;
		session.Flush();
		session.Close();
		}
	else
		{
		INFO_PRINTF1(_L("**************************"));
		INFO_PRINTF1(_L(""));
		INFO_PRINTF3(_L("Can't set screen output to %i. Only got %i screens"),aScreenNo,maxScreens);
		INFO_PRINTF2(_L("Screen number for all output remains at: %i"),settings_instance.iScreen);

		INFO_PRINTF1(_L(""));
		INFO_PRINTF1(_L("**************************"));
		session.Flush();
		session.Close();
		User::Leave(KErrTEFUnitFail);
		}
	}
void CMultipleSurfacesAppUi::BringToFront()
	{
	RWindow window = iAppView->Window();
	RWsSession wsSession = iAppView->ControlEnv()->WsSession();
	wsSession.SetWindowGroupOrdinalPosition(window.WindowGroupId(), 0);
	wsSession.Flush();
	wsSession.Finish();		
	}
예제 #3
0
/**
Draws a stretched bitmap with or without a mask.

@param aUseMask set to ETrue to use a alpha mask. Normally used for 16MU display modes that do not store the alpha.
@param aSrcMode is the source display mode
@param aDstMode is the destination display mode
@param aSession is the windows server session
@param aWindow is a reference to the window
@param aGc is the graphics context of the window
@param aNumIterations is the number of iterations to run the test
*/
void CAlphaBlendTest::DoDrawBitmapL(TBool aUseMask, TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
	{		
	const TSize bitmapSize = aWindow.Size();
	
	// Construct target bitmap.
	CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget);
	CleanupStack::PushL(bitmapDevice);
	
	// Construct GC.
	CFbsBitGc* bitmapGc = NULL;
	User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));
	CleanupStack::PushL(bitmapGc);
	
	// Construct source bitmap.	
	TSize smallerSize(bitmapSize.iWidth/2,  bitmapSize.iHeight/2);
	CFbsBitmap* source = CreateSoftwareBitmapLC(smallerSize, aSrcMode);
	VerticalGradientAlphaL(source, TRgb(0x00000000), TRgb(0xffffffff));	
	CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(smallerSize, EGray256);	// match size to src
	VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe));
		
	bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
	bitmapGc->SetBrushColor(TRANSPARENT_BLACK);
	bitmapGc->Clear();
	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
	aGc->Activate(aWindow);
	TPoint point(0,0);
	bitmapGc->BitBlt(point, bitmapTarget);
	aGc->Deactivate();
	aSession.Flush();

	TBuf <20> testName;
	if (!aUseMask)
		{
		testName=_L("DrawBitmap");
		iProfiler->InitResults();
		for(int i=0; i<aNumIterations; i++)
			{
			bitmapGc->DrawBitmap(TRect(point, bitmapSize), source);
			iProfiler->MarkResultSetL();
			}
		}
	else
		{
		testName=_L("DrawBitmapMasked");
		iProfiler->InitResults();
		for(int i=0; i<aNumIterations; i++)
			{
			bitmapGc->DrawBitmapMasked(TRect(point, bitmapSize), source,TRect(point, smallerSize), sourceAlpha, EFalse);
			iProfiler->MarkResultSetL();
			}
		}
	INFO_PRINTF4(_L("%S(Stretched) with src = %S, dst = %S"), &testName, &ColorModeName(aSrcMode), &ColorModeName(aDstMode));
	iProfiler->ResultsAnalysis(testName, 0, aSrcMode, aDstMode, aNumIterations);
	// copy up to screen for sanity check
	BitBlt(aSession, aWindow, aGc, *bitmapTarget);
	CleanupStack::PopAndDestroy(5, bitmapTarget);
	}
예제 #4
0
/**
BitBlts a bitmap to the windows GC.

@param aSession is the windows server session
@param aWindow is a reference to the window
@param aGc is the graphics context of the window
@param aImage is the bitmap to bitblt
*/		
void CAlphaBlendTest::BitBlt(RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, CFbsBitmap& aImage)
	{
	aWindow.Invalidate();
	aWindow.BeginRedraw();
	aGc->Activate(aWindow);
	aGc->BitBlt(TPoint(0,0), &aImage);
	aGc->Deactivate();
	aWindow.EndRedraw();	
	aSession.Flush();	
	}
// Failures are written to WSERV.log
void CWsGraphicShareBase::Test(TInt aCondition)
	{
	if(!aCondition)
		{
		TLogMessageText buf;
		_LIT(Fail,"AUTO Failed in WsGraphics Test : DrawSharedGraphic");
		buf.Format(Fail);
		iWs.LogMessage(buf);
		iWs.Flush();
		RProcess().Terminate(KErrTestExeFailure); // terminate this process immediately. Expect TWsGraph test step (TAutoServer.exe) to capture this
		}
	}
예제 #6
0
/**
Alpha blends two bitmaps together

@param aDisplayMode1 is the source display mode
@param aDisplayMode2 is the destination display mode
@param aSession is the windows server session
@param aWindow is a reference to the window
@param aGc is the graphics context of the window
@param aNumIterations is the number of iterations to run the test
*/	
void CAlphaBlendTest::DoAlphaBlendBitmapsBitmapTestL(TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
	{
	const TSize bitmapSize = aWindow.Size();	

	CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget);
	CleanupStack::PushL(bitmapDevice);
	
	CFbsBitGc* bitmapGc=NULL;
	User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));	
	CleanupStack::PushL(bitmapGc);
		
	CFbsBitmap* sourceUnder  = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
	CFbsBitmap* sourceOver   = CreateSoftwareBitmapLC(bitmapSize, aSrcMode);
	CFbsBitmap* sourceAlpha  = CreateSoftwareBitmapLC(bitmapSize, EGray256);

	VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe));
	VerticalGradientAlphaL(sourceUnder, TRgb(0xff000000), TRgb(0x00ffffff));
	VerticalGradientAlphaL(sourceOver, TRgb(0x00ffffff), TRgb(0xff000000));
	RDebug::Printf("DABBBT 2");

	TPoint point(0,0);
	TRect  rect(bitmapSize);
	
	bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
	bitmapGc->SetBrushColor(TRANSPARENT_BLACK);

	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
	bitmapGc->Clear();
	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
	bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point);		

	aGc->Activate(aWindow);
	aGc->BitBlt(point, bitmapTarget);
	aGc->Deactivate();
	aSession.Flush();

	iProfiler->InitResults();
	// blend sourceUnder with sourceOver using alpha mask
	for(TInt i=0; i<aNumIterations; i++)
	{
		bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
		bitmapGc->Clear();
		bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
		bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point);
		iProfiler->MarkResultSetL();
	}
	iProfiler->ResultsAnalysis(_L("DoAlphaBlendBitmapsBitmapTestL"), 0, aSrcMode, aDstMode, aNumIterations);
	
	// copy up to screen for sanity check
	BitBlt(aSession, aWindow, aGc, *bitmapTarget);	
	CleanupStack::PopAndDestroy(6, bitmapTarget); // sourceAlpha, sourceOver, sourceUnder, bitmapGc, bitmapDevice, bitmapTarget
	}	
예제 #7
0
/**
Clears the window to a colour

@param aSession is the windows server session
@param aWindow is a reference to the window
@param aGc is the graphics context of the window
@param aColor is the colour to clear the window with
*/
void CAlphaBlendTest::ClearWindow(RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TRgb aColor)
{
	// clear so we can see bitmap version has completed
	aWindow.Invalidate();
	aWindow.BeginRedraw();
	aGc->Activate(aWindow);
	aGc->SetBrushColor(aColor);
	aGc->Clear();
	aGc->Deactivate();
	aWindow.EndRedraw();
	aSession.Flush();
}
예제 #8
0
TInt LoadsOfText(TInt aOwningGroup)
	{
	RWsSession ws;
	ws.Connect();
	CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws);
	device->Construct();
	RWindowGroup group(ws);
	group.Construct(ENullWsHandle);
	group.SetOwningWindowGroup(aOwningGroup);
	TSize scrSize(device->SizeInPixels());
//
	RWindow window(ws);
	window.Construct(group,ENullWsHandle);
	window.SetExtent(TPoint(), scrSize);
	window.Activate();
//
	CWindowGc *gc;
	device->CreateContext(gc);
	window.BeginRedraw();
	gc->Activate(window);
	gc->Clear();
	window.EndRedraw();
	TFontSpec fspec(KTestFontTypefaceName,200);
	CFbsFont *font;
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips((CFont *&)font, fspec));
	gc->UseFont(font);
	TBuf<100> loadsatext(_L("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890zyxwvutsrqponmlkjihgfedcba"));
	TInt ascent=font->AscentInPixels();
	TInt fheight=font->HeightInPixels();
	for(TInt nTimes=0;nTimes<10;nTimes++)
		{
		TPoint pos;
//		for(pos.iY=ascent;pos.iY<scrSize.iHeight;pos.iY+=font->HeightInPixels())
//			gc->DrawText(loadsatext,pos);
		for(pos.iY=0;pos.iY<scrSize.iHeight;pos.iY+=fheight)
			gc->DrawText(loadsatext,TRect(pos,TPoint(scrSize.iWidth,pos.iY+fheight)),ascent);
		gc->Clear();
		}
	gc->Deactivate();
//
	ws.Flush();
	delete gc;
	device->ReleaseFont(font);
	window.Close();
	group.Close();
	delete device;
	ws.Close();
	return(KErrNone);
	}
예제 #9
0
/**
* Runs the test in a second thread.
*
* @param aFunctionIndex The drawing function command to be executed. All commands are defined in TestFunctionIndex.
*/
TInt CTW32CmdBuf::DoTestCmdBufFunctionL(TTestFunctionIndex aFunctionIndex)
	{
	RWsSession session;
	User::LeaveIfError(session.Connect());
	CleanupClosePushL(session);
	CWsScreenDevice *device = new(ELeave) CWsScreenDevice(session);
	CleanupStack::PushL(device);
	User::LeaveIfError(device->Construct(CTestBase::iScreenNo));
	CWindowGc* gc;
	User::LeaveIfError(device->CreateContext(gc));
	CleanupStack::PushL(gc);
	RWindowGroup group(session);
	User::LeaveIfError(group.Construct(1, EFalse));
	CleanupClosePushL(group);
	RWindow window(session);
	User::LeaveIfError(window.Construct(group, 2));
	CleanupClosePushL(window);
	window.SetExtent(TPoint(0,0), TSize(200, 200));
	User::LeaveIfError(window.SetRequiredDisplayMode(EColor64K));
	window.Activate();	
	gc->Activate(window);
	session.SetAutoFlush(EFalse);
	window.Invalidate();
	window.BeginRedraw();
	for(TInt i=KMinTestIterations; i<KMaxTestIterations; ++i)
		{
		for(TInt j=0; j<i; ++j)
			{
			gc->Clear();
			}

		CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
		CleanupStack::PushL(bitmap);
		User::LeaveIfError(bitmap->Create(TSize(100, 100), EColor64K));
		CFbsBitmap* mask = new(ELeave) CFbsBitmap;
		CleanupStack::PushL(mask);
		User::LeaveIfError(mask->Create(TSize(100, 100), EColor64K));
		KTestFunctions[aFunctionIndex](gc, bitmap, mask);
		CleanupStack::PopAndDestroy(2);
		session.Flush();	
		}	
	window.EndRedraw();	
	gc->Deactivate();
	CleanupStack::PopAndDestroy(5);
	return KErrNone;
	}
void CWsGraphicShareBase::DoTestDrawGraphicCompareL(TPtrC aShare)
	{
	// UID of the shared graphic
	TUid uid1 = {0x12000021};
	TWsGraphicId twsGraphicId1(uid1);

	_LIT8(KTestData,"HelloWorld");
	
	CFbsBitmap bitmap1;
	CFbsBitmap mask1;
	
	TSize screenSize = iScreen->SizeInPixels();
	User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0));
	mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode());
	
		CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1);
	
	// divide the screen into two equal rectangles
	TRect position1(0,0,screenSize.iWidth/2,screenSize.iHeight);
	TRect position2(screenSize.iWidth/2,0,screenSize.iWidth,screenSize.iHeight);
	
	// draw the new graphic and attempt to draw the shared graphic
	iGc->Activate(*iWin);
	iWin->Invalidate();
	iWin->BeginRedraw();
	iGc->Clear(position1);
	iGc->Clear(position2);

	iGc->DrawWsGraphic(bTest->Id(),position1,KTestData);
	iGc->DrawWsGraphic(twsGraphicId1.Uid(),position2,KTestData);

	iGc->Deactivate();	
	iWin->EndRedraw();
	
	iWs.Flush();
	iWs.Finish();
	// compare the graphic in both positions
	if (aShare==_L("false"))
		Test(!iScreen->RectCompare(position1,position2));
	else
		Test(iScreen->RectCompare(position1,position2));	
		
	delete bTest;
	}
void CWsGraphicShareBase::ConstructL()
	{
	User::LeaveIfError(iWs.Connect());
	iScreen=new(ELeave) CWsScreenDevice(iWs);
	User::LeaveIfError(iScreen->Construct(iScreenNumber));
	iGc=new(ELeave) CWindowGc(iScreen);
	User::LeaveIfError(iGc->Construct());
	iGroupWin=new(ELeave) RWindowGroup(iWs);
	iGroupWin->Construct(1);
		
	iWin=new(ELeave) RWindow(iWs);
	iWin->Construct(*iGroupWin,ENullWsHandle);
	iWin->SetRequiredDisplayMode(EColor256);
	iWin->SetExtent(TPoint(0,0),iScreen->SizeInPixels());
	iWin->Activate();
	iWin->BeginRedraw();
	iWin->EndRedraw();
	iWs.Flush();
	}	
void CCustomCmdTestDeviceSecurityCheck::SimulatePasswordEntry()
	{
    RWsSession wsSession;
    TInt err = wsSession.Connect();
    TEST(KErrNone == err);
    
    const TInt okButtonPos1 = 60; //the position of ok button
    const TInt okButtonPos2 = 600; //the position of ok button
    //Simulate the key press ,(comma) in to pin notifier dialogue
	TRawEvent eventDown;
	TRawEvent eventUp;

	eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma);
	UserSvr::AddEvent(eventDown);
	eventUp.Set(TRawEvent::EKeyUp, EStdKeyComma);
	UserSvr::AddEvent(eventUp);
	User::After(100000);

	//Enter wrong pwd if iWrongPwd is ETrue
	if(iWrongPwd)
		{
		eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma);
		UserSvr::AddEvent(eventDown);
		eventUp.Set(TRawEvent::EKeyUp, EStdKeyComma);
		UserSvr::AddEvent(eventUp);
		User::After(100000);
		
		//Reset it to false as wrong password should be entered only once
		iWrongPwd = EFalse;
		}

    eventDown.Set(TRawEvent::EButton1Down, okButtonPos1,okButtonPos2);
    UserSvr::AddEvent(eventDown);
    eventUp.Set(TRawEvent::EButton1Up, okButtonPos1,okButtonPos2);
    UserSvr::AddEvent(eventUp);
    User::After(100000);
    
    wsSession.Flush();
    wsSession.Close();
	}
예제 #13
0
void CTScreenDevice::ConstructL()
	{
	//The following is just another test... it doesn't leave any resources for use by the test class AFAICT...
	RWsSession aSession;
	CWsScreenDevice *device1;
	CWsScreenDevice *device2;
	CWsScreenDevice *device3;

	aSession.Connect();
	device1=new(ELeave) CWsScreenDevice(aSession);
	device1->Construct(iTest->iScreenNumber);
	delete device1;
	device1=new(ELeave) CWsScreenDevice(aSession);
	device1->Construct(iTest->iScreenNumber);
	device2=new(ELeave) CWsScreenDevice(aSession);
	device2->Construct(iTest->iScreenNumber);
	device3=new(ELeave) CWsScreenDevice(aSession);
	device3->Construct(iTest->iScreenNumber);
	delete device3;
	CFbsFont *font;
	User::LeaveIfError(device1->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec()));
	RWindowGroup group(aSession);
	group.Construct(777);
	group.SetOwningWindowGroup(TheClient->iGroup->GroupWin()->Identifier());
	RWindow win(aSession);
	win.Construct(group,77);
	CWindowGc *gc=new(ELeave) CWindowGc(device1);
	gc->Construct();
	gc->Activate(win);
	gc->UseFont(font);
	device1->ReleaseFont(font);
	aSession.Flush();
	delete gc;
	win.Close();
	group.Close();
	delete device1;
	delete device2;
	aSession.Close();
	}
예제 #14
0
void MainL()	
	{	
	RWsSession ws;
	ws.Connect();
 	CWsScreenDevice* scr = new(ELeave) CWsScreenDevice(ws);
	scr->Construct();
 	CWindowGc* gc = new(ELeave) CWindowGc(scr);
	gc->Construct();
 	RWindowGroup grp(ws);
	grp.Construct(0xc0decafe, ETrue);
 	RWindow win(ws);
	win.Construct(grp, 0xbeefcafe);
	win.SetExtent(TPoint(20,160), TSize(320,240));
	win.Activate();
 	win.Invalidate();
	win.BeginRedraw();
	gc->Activate(win);
 	gc->SetPenStyle(CGraphicsContext::ENullPen);
	gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
 	TBool color = EFalse;

if (Profiler::Start() == KErrNotFound)
	{
	_LIT(KProfiler,"profiler");
	_LIT(KStart,"start -noui -drive=S");
	RProcess p;
	if (p.Create(KProfiler,KStart) == KErrNone)
		{
		p.Resume();
		p.Close();
		}
	}

	for (TInt col=0; col<KCol; ++col)
		{
		color = !color;		
		for (TInt row=0; row<KRow; ++row)
			{
			TRect rect;
			rect.iTl.iX = col * KSize.iWidth;
			rect.iTl.iY = row * KSize.iHeight;
			rect.SetSize(KSize);
			color = !color;
			gc->SetBrushColor(color? KRgbBlue : KRgbBlack);
			gc->DrawRect(rect);
			}
	}
	
	
	
	gc->Deactivate();
	win.EndRedraw();
	ws.Flush();
 	User::After(3000000);
 	win.Close();
	grp.Close();
	delete gc;
	delete scr;
	ws.Close();

	Profiler::Stop();
	Profiler::Close();
	Profiler::Unload();

	} 
예제 #15
0
void CAlphaBlendTest::DoDrawBlendedTestL(TBlendTestFunc aTestFunc, TInt aAlpha, TDisplayMode aDisplayMode, RWsSession& aSession, TInt aNumIterations)
	{
	SetScreenModeL(aDisplayMode);
	const TSize devSize = iScreenDevice->SizeInPixels();
	// For fair back to back tests of rotated mode we need graphics clipped to a square test area.
	// Although if we aren't going to be comparing rotated results against each other it might be better
	// to allow the tests to use the full available area.
	TSize testSize;
	testSize.iWidth=Min(devSize.iWidth,devSize.iHeight);
	testSize.iHeight=testSize.iWidth;

	TFontSpec testFontSpec; 
	if (aTestFunc==EBlendTestDrawTextAntiAliased || aTestFunc==EBlendTestDrawTextIType)
		{
		testFontSpec.iTypeface.iName=KFontTypeface;
		if (aTestFunc==EBlendTestDrawTextAntiAliased)
			{
			testFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
			}
		else
			{
			testFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
			testFontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
			testFontSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
			}
		}
	testFontSpec.iHeight=12;
	// Set bold because sets more pixels, so tests blending code more
	testFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
	_LIT(KTestBlendTextString,"BLENDTESTWITHBIGSOLIDCHARACTERS0123456789HAVEWERUNOUTOFSCREENYET?OKAFEWMORECHARACTERSJUSTTOMAKESURE");
	const TInt maxTextLen=KTestBlendTextString().Length();
//
	TBool orientations[4];
	iGc->OrientationsAvailable(orientations);
// Use for loop to test across multiple rotations, however the implementation hardly varies at the moment
// so very little point in testing the differences, if in future an optimised route is added for normal
// rotation this test would be worth switching back to looping upto EGraphicsOrientationRotated270.
//
//	const TInt KMaxOrientation=CFbsBitGc::EGraphicsOrientationRotated270;
	const TInt KMaxOrientation=CFbsBitGc::EGraphicsOrientationNormal;
	for (TInt orient = CFbsBitGc::EGraphicsOrientationNormal; orient <= KMaxOrientation; orient++)
		{
		if (orientations[orient])
			{
			iGc->SetOrientation((CFbsBitGc::TGraphicsOrientation)orient);
			User::After(100000);	// Let rotate sort itself out
			iGc->Reset();
			iGc->SetClippingRect(TRect(testSize));
			iGc->SetPenStyle(CGraphicsContext::ESolidPen);
			iGc->SetBrushColor(TRgb(0x80,0x80,0xFF));
			iGc->Clear();
			iGc->SetBrushColor(TRgb(10,128,240,aAlpha));
			iGc->SetPenColor(TRgb(240,128,10,aAlpha));
			iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
			aSession.Flush();

			CFbsFont* font=NULL;
			TInt fontHeight=0;
			TInt testParam=0;
			TSize orientatedTestSize=testSize;
			TBuf <32> testName;	
			TGlyphBitmapType checkGlyphBitmapType=EDefaultGlyphBitmap;
			TGlyphBitmapType actualGlyphBitmapType=EDefaultGlyphBitmap;
			TPtrC textPtr;
			switch(aTestFunc)
				{
			case EBlendTestVerticalLine:
				_LIT(KDrawRectVerticalLine,"DrawRectVertLine");
				testName=KDrawRectVerticalLine;
				break;
			case EBlendTestDrawRect:
				_LIT(KDrawRectAlpha,"DrawRectAlpha");
				testName=KDrawRectAlpha;
				iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
				iGc->SetPenStyle(CGraphicsContext::ENullPen);
				break;
			case EBlendTestDrawTextIType:
				_LIT(KDrawTextIType,"DrawTextIT");
				testName=KDrawTextIType;
				testParam=testSize.iHeight;
				checkGlyphBitmapType=EFourColourBlendGlyphBitmap;
				goto drawTextTest;
			case EBlendTestDrawTextAntiAliased:
				_LIT(KDrawTextAA,"DrawTextAA");
				testName=KDrawTextAA;
				testParam=testSize.iHeight;
				checkGlyphBitmapType=EAntiAliasedGlyphBitmap;
				goto drawTextTest;
			case EBlendTestDrawVerticalText:
				_LIT(KDrawTextVert,"DrawTextVert");
				orientatedTestSize.SetSize(orientatedTestSize.iHeight,orientatedTestSize.iWidth);
				testName=KDrawTextVert;
				testParam=testSize.iWidth;
				checkGlyphBitmapType=EMonochromeGlyphBitmap;
				goto drawTextTest;
			case EBlendTestDrawText:
				_LIT(KDrawText,"DrawText");
				testParam=testSize.iHeight;
				testName=KDrawText;
				checkGlyphBitmapType=EMonochromeGlyphBitmap;
drawTextTest:	User::LeaveIfError(iScreenDevice->BitmapDevice().GetNearestFontInPixels((CFont* &)font,testFontSpec));
				fontHeight=font->HeightInPixels();
				iGc->UseFont(font);
				actualGlyphBitmapType=font->FontSpecInTwips().iFontStyle.BitmapType();
				TInt displayLen=Min(font->TextCount(KTestBlendTextString,orientatedTestSize.iWidth)+1,maxTextLen);
				textPtr.Set(KTestBlendTextString().Left(displayLen));
				iScreenDevice->BitmapDevice().ReleaseFont(font);
				break;
				}
			if (checkGlyphBitmapType!=EDefaultGlyphBitmap)
				{
				if (actualGlyphBitmapType!=checkGlyphBitmapType)
					{
					INFO_PRINTF3(_L("Failed to load correct glyph type font, wanted %d, got %d"),checkGlyphBitmapType, actualGlyphBitmapType);
					break;
					}
				}
			_LIT(KAppendAlphaTxt,"[A=0x%02x]");
			testName.AppendFormat(KAppendAlphaTxt,aAlpha);
			iProfiler->InitResults();	
			for(TInt iter=0; iter<aNumIterations; iter++)
				{
				switch(aTestFunc)
					{
				case EBlendTestVerticalLine:
					for(TInt xpos=0; xpos<testSize.iWidth; xpos++)
						iGc->DrawLine(TPoint(xpos,0),TPoint(xpos,testSize.iHeight));
					break;
				case EBlendTestDrawRect:
					iGc->DrawRect(TRect(testSize));
					break;
				case EBlendTestDrawText:
				case EBlendTestDrawVerticalText:
				case EBlendTestDrawTextAntiAliased:
				case EBlendTestDrawTextIType:
					{
					for(TInt pos=0;pos<testParam;pos+=fontHeight)
						{
						if (aTestFunc==EBlendTestDrawVerticalText)
							iGc->DrawTextVertical(textPtr,TPoint(pos,0),EFalse);
						else
							iGc->DrawText(textPtr,TPoint(0,pos));
						}
					break;
					}
					}
				iProfiler->MarkResultSetL();
				}
			INFO_PRINTF3(_L("%S %S"), &testName, &ColorModeName(aDisplayMode));
			iProfiler->ResultsAnalysis(testName, orient, aDisplayMode, aDisplayMode, aNumIterations);
			}
		}
	iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
	}
예제 #16
0
//
// LtkUtils::W32CrackL
// loads the autometric logging engine, dlogev.dll, into wserv
// enabling Autometric to monitor events from within wserv - key/pointer events, text drawn to screen etc
//
EXPORT_C void LtkUtils::W32CrackL()
{
#ifndef FSHELL_WSERV_SUPPORT
    User::Leave(KErrNotSupported);
#else

    // Check if P&S says it's already enabled, if so no need to do anything
    if (W32CrackIsEnabled()) return;

    _LIT(KWsIniFile, "z:\\system\\data\\wsini.ini");
    _LIT(KCWsIniFile,"c:\\system\\data\\wsini.ini");
    _LIT(KLogEv, "LOG EV\r\n");

    // Open z file
    RFs fs;
    User::LeaveIfError(fs.Connect());
    CleanupClosePushL(fs);

    RFile file;
    User::LeaveIfError(file.Open(fs, KWsIniFile, EFileRead));
    CleanupClosePushL(file);

    TInt size;
    User::LeaveIfError(file.Size(size));

    RBuf8 buf;
    buf.CreateL(size + KLogEv().Size());
    CleanupClosePushL(buf);
    User::LeaveIfError(file.Read(buf));
    TPtrC16 wptr((TUint16*)buf.Ptr(), buf.Size()/2);
    buf.Insert(2, TPtrC8((TUint8*)KLogEv().Ptr(), KLogEv().Size())); // +2 to get past the BOM
    TInt err = KErrNone;
    err = fs.MkDirAll(KCWsIniFile); // mkdir c:\system\data\ in case it is not exist
    if((err != KErrNone) && (err != KErrAlreadyExists))
    {
        User::Leave(err);
    }
    User::LeaveIfError(file.Replace(fs, KCWsIniFile, EFileWrite));
    User::LeaveIfError(file.Write(buf));
    CleanupStack::PopAndDestroy(2, &file); // file, buf

    err = RMemoryAccess::LoadDriver();
    if ((err != KErrNone) && (err != KErrAlreadyExists))
    {
        User::Leave(err);
    }

    RMemoryAccess memAccess;
    User::LeaveIfError(memAccess.Open());
    CleanupClosePushL(memAccess);

    RWsSession ws;
    User::LeaveIfError(ws.Connect(fs));
    CleanupClosePushL(ws);

#ifdef __WINS__
    // On wins the binary isn't renamed
    _LIT(KWservMatch, "wserv*.exe*");
#else
    _LIT(KWservMatch, "EwSrv.exe*");
#endif
    TFindProcess find(KWservMatch);
    TFullName name;
    User::LeaveIfError(find.Next(name));

    RProcess wservProc;
    User::LeaveIfError(wservProc.Open(find));
    if (wservProc.ExitType() != EExitPending)
    {
        // in case wserv kicks off the preferred implementation in a new process then kills itself
        // (is one retry enough or should we be looping here?)
        wservProc.Close();
        User::LeaveIfError(find.Next(name));
        User::LeaveIfError(wservProc.Open(find));
    }
    CleanupClosePushL(wservProc);
    name = wservProc.FileName();
    name[0] = 'c';
    TPtrC8 narrowName = name.Collapse();
    User::LeaveIfError(memAccess.InPlaceSetProcessFileName(wservProc, narrowName));

    // Now tell wserv to reload its wsini.ini and enable logging
    ws.LogCommand(RWsSession::ELoggingEnable);
    ws.Flush();

    // cleanup
    CleanupStack::PopAndDestroy(4, &fs);

#endif // FSHELL_WSERV_SUPPORT
}