void CQualityProfileApi_ProfileReadStep::InitializeQualityProfileInfoL()
	{
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);

	TBuf<32> privatePath;
	User::LeaveIfError(fs.PrivatePath(privatePath));

	TParse parse;
	parse.Set(privatePath, NULL, NULL);
	parse.AddDir(KLbsDir);
	
	RArray<TQualityProfile> qualityArray;
	CleanupClosePushL(qualityArray);
	
	qualityArray.Reserve(5);

	// Only want to use the first file that is found.
	// The way TFindFile::FindByDir works, it will search
	// C: and D: before Z:, which is what we want.
	TFindFile findFile(fs);
	TInt err = findFile.FindByDir(KQualityProfileIniName, parse.Path());
	if (err == KErrNone)
		{
		GetQualityProfileInfoL(fs, qualityArray, findFile.File());
		}
	
	// Publish the quality profile info
	LbsQualityProfile::InitializeL(qualityArray);
	
	CleanupStack::PopAndDestroy(&qualityArray);
	CleanupStack::PopAndDestroy(&fs);
	}
Beispiel #2
0
	TInt GetRecogniserInfo(TUid aImplementationUid, RArray<TDataType>& aMimeTypes)
		{
		TInt size = SendReceive(EGetRecog, TIpcArgs(aImplementationUid.iUid));
		if (size < 0) return size;
		TInt err = aMimeTypes.Reserve(size/sizeof(TDataType));
		if (err) return err;
		RBuf8 buf;
		err = buf.Create(size);
		if (err) return err;
		err = SendReceive(EGetRecog2, TIpcArgs(&buf));
		if (err) { buf.Close(); return err; }

		const TDataType* ptr = (const TDataType*)buf.Ptr();
		for (TInt i = 0; i < size/sizeof(TDataType); i++)
			{
			err = aMimeTypes.Append(ptr[i]);
			if (err) break;
			}
		buf.Close();
		return err;
		}
void CDisplayChannelTest::CheckResolutions()
/**
 Validate that the APIs to get / set resolutions.

 Tests<br>
 NumberOfResolutions, GetResolutions, GetResolution, GetRotation
 */
	{
	test.Next(_L("Test NumberOfResolutions, GetResolutions, GetResolution, GetRotation"));

	// Get and reserve space for expected number of resolutions
	TInt n = iDisp.NumberOfResolutions();
	test_Compare(n, >=, 1);
	
	iResolutions.Reset();
	test_KErrNone(iResolutions.Reserve(n));
	for (TInt i = 0; i < n; ++i)
		{
		test_KErrNone(iResolutions.Append(RDisplayChannel::TResolution(TSize(0,0), TSize(0,0), 0)));
		}
	
	// Retrieve the resolutions and make sure the number of resolutions returned matches the 
	// expected number. It is assumed that the display state won't be changed during the execution
	// of this test.
	TInt actualResolutions = 0;	
	TPtr8 resPtr(reinterpret_cast<TUint8*>(&iResolutions[0]), 
			sizeof(RDisplayChannel::TResolution) * n, sizeof(RDisplayChannel::TResolution) * n);
	test_KErrNone(iDisp.GetResolutions(resPtr, actualResolutions));
	test_Equal(n, actualResolutions);	

	test.Printf(_L("Supported resolutions"));
	for (TInt res = 0; res < n; ++res)
		{
		RDisplayChannel::TResolution& r = iResolutions[res];
		test.Printf(_L("pixelX = %d heightX = %d twipsX = %d twipsY = %d flags = 0x%08x\n"), 
				r.iPixelSize.iWidth, r.iPixelSize.iHeight, r.iTwipsSize.iWidth, r.iTwipsSize.iHeight, r.iFlags);		
		
		// If either pixel height or pixel width is zero then both must be zero
		// If either pixel height or pixel width is non-zero then both must be positive
		test((r.iPixelSize.iHeight == 0 && r.iPixelSize.iWidth == 0) ||
			 (r.iPixelSize.iHeight > 0 && r.iPixelSize.iWidth > 0));

		// Test resolutions are sane
		test(r.iPixelSize.iHeight <= KMaxExpectedPixelRes && r.iPixelSize.iWidth <= KMaxExpectedPixelRes);

		// If either twips height or pixel width is zero then both must be zero
		// If either twips height or pixel width is non-zero then both must be positive
		test((r.iTwipsSize.iHeight == 0 && r.iTwipsSize.iWidth == 0) ||
			 (r.iTwipsSize.iHeight > 0 && r.iTwipsSize.iWidth > 0));
		
		// twips resolution can be zero iff pixel resolution is also zero
		test((r.iPixelSize.iHeight == 0 && r.iTwipsSize.iHeight == 0) ||
			 (r.iPixelSize.iHeight > 0  && r.iTwipsSize.iHeight > 0));

		// At least one rotation must be supported. Ignore other bits in the flags field
		test(r.iFlags & RDisplayChannel::ERotationAll != 0);
		}

	// Get current resolution in pixels
	TSize currentResolution;
	test_KErrNone(iDisp.GetResolution(currentResolution));

	// Get current resolution in twips
	TSize currentTwips;
	test_KErrNone(iDisp.GetTwips(currentTwips));

	RDisplayChannel::TDisplayRotation currentRotation = iDisp.CurrentRotation();
	test(IsValidRotation(currentRotation));

	// The current resolution and rotation must be in the list of supported resolutions
	TBool foundCurrentRes = EFalse;
	for (TInt j = iResolutions.Count() - 1; j >= 0; --j)
		{
		if (iResolutions[j].iPixelSize == currentResolution &&
			iResolutions[j].iTwipsSize == currentTwips &&
			iResolutions[j].iFlags & currentRotation)
			{
			foundCurrentRes = ETrue;
			break;
			}
		}
	test(foundCurrentRes);
	
	// Now and try every supported resolution
	TInt err;
	for (TInt k = iResolutions.Count() - 1; k >= 0; --k)
		{
		err = iDisp.SetResolution(iResolutions[k].iPixelSize);
		test(err == KErrNone || err == KErrNotSupported);
		}
	// attempt to set back to original resolution, this could fail
	err = iDisp.SetResolution(currentResolution);
	test(err == KErrNone || err == KErrNotSupported);
	}
void CFbRenderStage::ConstructL(MWsGraphicDrawerEnvironment * aEnv,MWsScreen * aScreen, MWsScreenRedraw* /*aScreenRedraw*/, CWsRenderStage* aNextStage)
	{
	BaseConstructL();
	iNextScreenDevice = aNextStage->ObjectInterface<MWsScreenDevice>();
	STD_ASSERT_ALWAYS(iNextScreenDevice, EPluginPanicScreenDeviceMissing);
	iNextScene = aNextStage->ObjectInterface<MWsScene>();
	STD_ASSERT_ALWAYS(iNextScene, EPluginPanicSceneMissing);
	iDisplayControl = aNextStage->ObjectInterface<MWsDisplayControl>();	//can be NULL
	iDisplayMapping = aNextStage->ObjectInterface<MWsDisplayMapping>();	//can be NULL
	MWsIniFile* iniFile = aEnv->ObjectInterface<MWsIniFile>();
	STD_ASSERT_ALWAYS(iniFile, EPluginPanicIniFileMissing);

	//initialize render target
	_LIT(KFlickerBufferMode,"FLICKERBUFFERMODE");
	TPtrC flickerBufferModeName;
	TDisplayMode displayMode = ENone;
	if (iniFile->FindVar(iNextScreenDevice->ScreenNumber(), KFlickerBufferMode, flickerBufferModeName))
		displayMode = ParseDisplayMode(flickerBufferModeName);
	if (displayMode == ENone)
		{
		// Display render stage MWsScreenDevice::DisplayMode now reports the supported screendriver display mode in 32bpp. 
		// It is necessary in order to maintain BC with 3rd party apps and DSA framework.
		// The reported display mode may be different from the actual UI surface pixel format, so flicker buffer
	    // must not rely on DisplayMode() to determine pixel format for its rendering target.
		//
		MWsUiBuffer* uiBuf = aNextStage->ObjectInterface<MWsUiBuffer>();
		if (uiBuf)
			{
			displayMode = SgUtils::PixelFormatToDisplayMode(uiBuf->PixelFormat());
			}
		}
	STD_ASSERT_DEBUG(displayMode!=ENone, EPluginPanicNoDisplayModeFound);
	
	const TUint32 usage = ESgUsageDirectGdiTarget | ESgUsageWindowGcSource;
	const TSgCpuAccess cpuAccess = ESgCpuAccessReadWrite;
	TSize size;
	if (iDisplayControl)
		{
		iDisplayPolicy = CDisplayPolicy::NewL(aEnv,aScreen,iNextScreenDevice->ScreenNumber());
		
		//calculate min UI buffer size depending on physical resolutions
		TInt ret = iDisplayControl->NumberOfResolutions();
		RArray<MDisplayControlBase::TResolution> resolutions;
		CleanupClosePushL(resolutions);
		if(ret > 0)
			{
			User::LeaveIfError(resolutions.Reserve(ret));
			User::LeaveIfError(iDisplayControl->GetResolutions(resolutions));
			}
		iDisplayPolicy->CalculateMinBufferSize(resolutions, ret);				
		CleanupStack::PopAndDestroy(&resolutions);
		
		if (iDisplayPolicy->PolicyEnabled())
			{
			iDisplayPolicy->AdjustStageBufferSize(TSize(0,0),size);
			}
		else
			{
			size = iNextScreenDevice->SizeInPixels();
			}
		}
	else
		{
		size = iNextScreenDevice->SizeInPixels();
		}

	iRenderTarget = CRenderTarget::NewL(iniFile, usage, cpuAccess, displayMode, size, iNextScreenDevice->ScreenNumber());
	
	//initialize drawable sources
	MWsGraphicsContext* gc = aNextStage->ObjectInterface<MWsGraphicsContext>();
	STD_ASSERT_ALWAYS(gc, EPluginPanicNoContext);
	iDrawableSourceProvider = gc->ObjectInterface<MWsDrawableSourceProvider>();
	STD_ASSERT_ALWAYS(iDrawableSourceProvider, EPluginPanicNoDrawableSourceProvider);

	for(TInt i = 0; i < CRenderTarget::EAspectRatioCount; i++)
		{
		CRenderTarget::TAspectRatio aspectRatio = (CRenderTarget::TAspectRatio)i;
		const TInt err = iDrawableSourceProvider->CreateDrawableSource(iRenderTarget->ImageId(aspectRatio), iDrawableSources[aspectRatio]);
		STD_ASSERT_ALWAYS(err == KErrNone, EPluginPanicDrawableSourceInitializationFailed);
		}
	
	iController = CRenderStageController::NewL(this);
	
	// Pre-allocate update region buffers. 
	const TInt KUpdateRegionPreAllocationBufferLen = 8;
	TRect* rectangleList = (TRect*) (User::Alloc(KUpdateRegionPreAllocationBufferLen * sizeof(TRect)));
	if (rectangleList)
		{
		CleanupStack::PushL(rectangleList);
		iUpdateRegion = new (ELeave) RRegion(KUpdateRegionPreAllocationBufferLen, rectangleList);
		CleanupStack::Pop(rectangleList);
		}
	else
		{
		iUpdateRegion = new (ELeave) RRegion();
		}

	//
	SetNext(aNextStage);
	}