// -----------------------------------------------------------------------------
// Ctestsdkindicators::TestIndiCntnerReplaceIndicatorIconL
// -----------------------------------------------------------------------------
//
TInt CTestSDKIndicators::TestIndiCntnerReplaceIndicatorIconL( CStifItemParser& /*aItem*/ )
    {
    // Print to UI
    _LIT( Ktestsdkindicators, "testsdkindicators" );
    _LIT( KTestIndiCntnerReplaceIndicatorIconL, "In TestIndiCntnerReplaceIndicatorIconL" );
    TestModuleIf().Printf( 0, Ktestsdkindicators, KTestIndiCntnerReplaceIndicatorIconL );
    // Print to log file
    iLog->Log( KTestIndiCntnerReplaceIndicatorIconL );
    
    TInt err = KErrNone;

    TUid Id = { EAknIndicatorEnvelope };
    
    _LIT( KFileName, "z:\\resource\\apps\\avkon2.mbm" );

    CFbsBitmap* bmp = new (ELeave) CFbsBitmap();
    bmp->Load( KFileName, EMbmAvkonQgn_stat_cyphering_on );
    CFbsBitmap* bmpMask = new (ELeave) CFbsBitmap();
    bmpMask->Load( KFileName, EMbmAvkonQgn_stat_cyphering_on_mask );
    
    iIndicatorContn->CreateIndicatorFromResourceL( R_TEST_INDICATOR, 
                CAknIndicatorContainer::EMultiColorIndicator );
    
    iIndicatorContn->ReplaceIndicatorIconL( 
            Id, 
            EAknIndicatorStateOn, 
            CAknIndicatorContainer::ELayoutModeUsual, 
            bmp, bmpMask);
    
    return err;
    }
/**
Create a checked board
@param aPixelFormat The pixel format for create the target bitmap
@param aSize The size of the bitmap
@param aChecksPerAxis Number of checks on X and Y.
 */
CFbsBitmap* CTe_graphicsperformanceSuiteStepBase::CreateCheckedBoardL(TDisplayMode aDisplayMode, TSize aSize, TSize aChecksPerAxis) const
	{
	
	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
	CleanupStack::PushL(bitmap);
	bitmap->Create(aSize, aDisplayMode);
	
	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmap);
	CleanupStack::PushL(bitmapDevice);
	
	CFbsBitGc* bitGc = NULL;
	User::LeaveIfError(bitmapDevice->CreateContext(bitGc));
	CleanupStack::PushL(bitGc);
	
	bitGc->Clear();
	bitGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
	bitGc->SetPenStyle(CGraphicsContext::ENullPen);
	TPoint point(0,0);
	const TSize checkerSize((TReal)aSize.iWidth/aChecksPerAxis.iWidth,(TReal)aSize.iHeight/aChecksPerAxis.iHeight);
	TInt brushColour = 0;
	for(point.iY = 0; point.iY < aSize.iHeight; point.iY += checkerSize.iHeight)
		{
		for(point.iX = 0; point.iX < aSize.iWidth; point.iX += checkerSize.iWidth)
			{
			bitGc->SetBrushColor(KColor16Table[brushColour++ & 0x0F]);
			TRect rect(point, checkerSize);
			bitGc->DrawRect(rect);
			}
		}
	
	CleanupStack::PopAndDestroy(2, bitmapDevice);
	CleanupStack::Pop(bitmap);
	
	return bitmap;
	}
// ---------------------------------------------------------------------------
// CBCTestButtonCase::CreateIconL
// ---------------------------------------------------------------------------
//
CGulIcon* CBCTestButtonCase::CreateIconL()
    {
    CFbsBitmap *bitmap = new( ELeave ) CFbsBitmap();
    bitmap->Load( AknIconUtils::AvkonIconFileName(), 
                  EMbmAvkonQgn_prop_set_button );
    return CGulIcon::NewL( bitmap );
    }
// --------------------------------------------------------------------------
// Ctestpubscalableicons::TestAknIconUtilsScaleBitmapL
// --------------------------------------------------------------------------
//
TInt Ctestpubscalableicons::TestAknIconUtilsScaleBitmapL( CStifItemParser& /*aItem*/ )
    {
    _LIT(Kctestpubscalableicons, "Ctestpubscalableicons");
    _LIT(Ktestakniconutilsscalebitmapl, "In TestAknIconUtilsScaleBitmapL");
    TestModuleIf().Printf(0, Kctestpubscalableicons, Ktestakniconutilsscalebitmapl);
    iLog->Log(Ktestakniconutilsscalebitmapl);

    TFileName file( KMbmFile );
    User::LeaveIfError( CompleteWithAppPath( file ) );
    CFbsBitmap* aSrcBitmap = AknIconUtils::CreateIconL( file, EMbmAvkonQgn_indi_mic );

    CleanupStack::PushL( aSrcBitmap );

    TRect aTrgRect( TSize( KWidth, KHeight ) );
    
    CFbsBitmap* aTrgBitmap = new( ELeave ) CFbsBitmap;
    aTrgBitmap->Create(TSize( KWidth, KHeight), ENone );

    AknIconUtils::ScaleBitmapL( aTrgRect, aTrgBitmap, aSrcBitmap );
    
    STIF_ASSERT_NOT_NULL( aTrgBitmap );
    
    CleanupStack::PopAndDestroy( aSrcBitmap );

    return KErrNone;
    }
/**
Creates a bitmap for given size and display mode and leaves it on the cleanup stack

@return pointer to a created CFbsBitmap 
*/
CFbsBitmap* CTe_graphicsperformanceSuiteStepBase::CreateSoftwareBitmapLC(const TSize& aSize, TDisplayMode aMode)
	{
	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
	CleanupStack::PushL(bitmap);
	User::LeaveIfError(bitmap->Create(aSize, aMode));
	return bitmap;
	}
Esempio n. 6
0
/**
Retrieves the VGImage from the cache that was created from the supplied CFbsBitmap.
The cache is first searched to find the item containing the VGImage that was created from the CFbsBitmap.
If no matching item is found, no VGImage is returned.
If the matching item is found, the touch count is checked to determine whether the
CFbsBitmap has been updated since the stored VGImage was created from it.  If it has, the matching item 
and VGImage is deleted from the cache and no VGImage is returned.
If the matching item is found and the CFbsitmap has not been updated sionce the VGImage was created,
the associated VGImage is returned.

@param aBitmap	The bitmap used to reference the item containing the VGImage.
@param aOrigin  The origin of the VGImage, relative to the top left corner of the source image.

@return	VG_INVALID_HANDLE if no VGImage exists for the supplied CFbsBitmap or if the stored VGImage is out of date.
		Otherwise the VGImage associated with the CFbsBitmap is returned.
 */
VGImage CVgImageCache::GetVgImageFromBitmap(const CFbsBitmap& aBitmap, const TPoint& aOrigin)
	{
	// search through cache to find the item with a matching bitmap ID
	CVgImageCacheItem** itemPtr = iCacheItemMap.Find(aBitmap.SerialNumber());
	++iNumMatchTries;
	if(itemPtr == NULL)
		{
		// searched all the way through cache and there is no matching image
		++iNumMatchMisses;
		return VG_INVALID_HANDLE;
		}
	CVgImageCacheItem* item = *itemPtr;
	// Check whether the VGImage held by the item is up-to-date
	// - check touch counts are equal.
	// - check origins used for creating VGImage are equal.
	if (aBitmap.TouchCount() != item->iTouchCount || aOrigin != item->iOrigin)
		{
		// VGImage in item needs updating, so remove and delete the entry
		// and return NULL to indicate that a new entry needs to be created.
		DeleteItem(item);
		return VG_INVALID_HANDLE;
		}
	// VGImage is up-to date.
	// If item is not already at front of list, move it there
	if(!iVgImageCache.IsFirst(item))
		{
		item->iLink.Deque();
		iVgImageCache.AddFirst(*item);
		}
	return item->iImage;
	}
Esempio n. 7
0
CGulIcon* CTap2MenuAppUi::LoadAppIconHard(TUid aUid)
	{
	RApaLsSession ls;
	ls.Connect();
	CGulIcon *retval = NULL;
	CArrayFixFlat<TSize> *array = new CArrayFixFlat<TSize>(3);
	CleanupStack::PushL(array);
	TInt err = ls.GetAppIconSizes(aUid, *array);
	if(err == KErrNone && array->Count() > 0)
		{
		CApaMaskedBitmap *bitmap = CApaMaskedBitmap::NewLC();
		err = ls.GetAppIcon(aUid, (*array)[0], *bitmap);
		if(err == KErrNone)
			{
			CFbsBitmap* bmp = new (ELeave) CFbsBitmap();
			CleanupStack::PushL(bmp);
			CFbsBitmap* bmp_mask = new (ELeave) CFbsBitmap();
			CleanupStack::PushL(bmp_mask);
			User::LeaveIfError(bmp->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()));
			User::LeaveIfError(bmp_mask->Create(bitmap->Mask()->SizeInPixels(), bitmap->Mask()->DisplayMode()));
			CopyBitmapL(bitmap, bmp);
			CopyBitmapL(bitmap->Mask(), bmp_mask);
			retval = CGulIcon::NewL(bmp, bmp_mask);
			CleanupStack::Pop(2); // bmp, bmp_mask
			}
			CleanupStack::PopAndDestroy(bitmap);
		}
		CleanupStack::PopAndDestroy(array);
		ls.Close();
		return retval;
	}
Esempio n. 8
0
TBool CTestContainer::CompareScreenContentWithTestBitmapL(const CBitmapFrameData& aBkgdFrame, const CBitmapFrameData& aFrame1, const TPoint& aPos)
	{
	TSize size = aFrame1.Bitmap()->SizeInPixels();

	// Create test bitmap for comparison 
	CFbsBitmap* testBitmap = new (ELeave) CFbsBitmap;
	CleanupStack::PushL(testBitmap);
	User::LeaveIfError( testBitmap->Create(size, iEikonEnv->DefaultDisplayMode()));
	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(testBitmap);
	CleanupStack::PushL(bitmapDevice);
	CFbsBitGc* bitmapGc = CFbsBitGc::NewL();
	CleanupStack::PushL(bitmapGc);
	bitmapGc->Activate(bitmapDevice);
	// Blit the background bitmap
	bitmapGc->BitBlt(aPos, aBkgdFrame.Bitmap());
	// Blit the frame bitmap with mask
	bitmapGc->BitBltMasked(aPos, aFrame1.Bitmap(), size, aFrame1.Mask(), ETrue);
	
	// Create bitmap and blit the screen contents into it for comparing it with test bitmap created above
	TRect rect(aPos,size);
	CFbsBitmap* scrBitmap = new (ELeave) CFbsBitmap;
	CleanupStack::PushL(scrBitmap);
	User::LeaveIfError(scrBitmap->Create(size, iEikonEnv->DefaultDisplayMode()) );
	User::LeaveIfError( iEikonEnv->ScreenDevice()->CopyScreenToBitmap(scrBitmap,rect) );
	
	TBool ret=CompareBitmapsL(testBitmap,scrBitmap);	

	CleanupStack::PopAndDestroy(4);	//scrBitmap, bitmapGc, bitmapDevice, testBitmap
	return ret;
	}
Esempio n. 9
0
static CFbsBitmap* createBlitCopy(CFbsBitmap* bitmap)
{
      CFbsBitmap *copy = q_check_ptr(new CFbsBitmap);
      if(!copy)
        return 0;

      if (copy->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) {
          delete copy;
          copy = 0;

          return 0;
      }

      CFbsBitmapDevice* bitmapDevice = 0;
      CFbsBitGc *bitmapGc = 0;
      QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(copy));
      QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL());
      bitmapGc->Activate(bitmapDevice);

      bitmapGc->BitBlt(TPoint(), bitmap);

      delete bitmapGc;
      delete bitmapDevice;

      return copy;
}
void WindowSurfaceImpl::handleSymbianWindowVisibilityChange(bool aVisible)
{
    if(mPaintingStarted)
    {
        // TODO window getting invisible in the middle of paint
        return;
    }
    
    if (!aVisible)
    {
        // Switch to sw rendering
        if(!isLocalSurfaceValid()) 
        {
            if(mMainSurface.localSurfaceInUse) 
            {
                deleteLocalSurface();
            }
            
            CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
            CleanupStack::PushL(bitmap);
            int err = bitmap->Create(TSize(mMainSurface.widget->width(), mMainSurface.widget->height()), 
                CCoeEnv::Static()->ScreenDevice()->DisplayMode());
            eglCopyBuffers(mEgl.display, mEgl.readSurface, bitmap);
            mMainSurface.localSurface = new QImage(QPixmap::fromSymbianCFbsBitmap(bitmap).toImage());
            CleanupStack::Pop(bitmap);
            
            mMainSurface.qSurface = NULL;
            mMainSurface.device = mMainSurface.localSurface;
            mMainSurface.type = WsTypeQtImage;
            mMainSurface.localSurfaceInUse = true;
        }
    }
    
    // Otherwise updateSurfaceData() will switch back to hw rendering
}
void CAlfPerfAppAvkonTestCaseBasic::ConstructL( 
        CAlfEnv& aEnv, TInt aCaseId, const TRect& aVisibleArea )
    {
    CAlfPerfAppBaseTestCaseControl::ConstructL( aEnv, aCaseId, aVisibleArea );   
    
    iWinRect = aVisibleArea;
    
    iAvkonControl = new(ELeave) CAvkonTestCoeControl();
    iAvkonControl->ConstructL(iWinRect);

    iAnimTimer = CPeriodic::NewL(CActive::EPriorityStandard);
    
    TFontSpec myFontSpec(_L("Arial"), 3*120);
    CCoeEnv::Static()->ScreenDevice()->GetNearestFontInTwips(iFont, myFontSpec);
    
    // Find my private path
    TFileName pathWithoutDrive;
    TFileName driveAndPath;
    CEikonEnv::Static()->FsSession().PrivatePath( pathWithoutDrive );
    driveAndPath.Copy(CEikonEnv::Static()->EikAppUi()->Application()->AppFullName().Left(2));
    driveAndPath.Append(pathWithoutDrive);
    
    // Create pictures
    iPictureBm = new(ELeave) CFbsBitmap;
    driveAndPath.Append(_L("alfperfapp_test1.mbm"));
    User::LeaveIfError(iPictureBm->Load(driveAndPath));
    iMaskBm = new(ELeave) CFbsBitmap;
    User::LeaveIfError(iMaskBm->Create(iPictureBm->SizeInPixels(), EGray256));
 
    iTestCaseStartTime_ys.UniversalTime();
    iTestCaseFrameCount = 0;
   }
Esempio n. 12
0
void CSliderControl::LoadPicture()
	{
	
	CFbsBitmap* BitMap = new (ELeave) CFbsBitmap();
	BitMap->Create(Size(),EColor16M);
	CAknsBasicBackgroundControlContext* iContext = 
			CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgAreaMain,Rect(),ETrue);
	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(BitMap);
	CBitmapContext* bitGc = NULL;
	bitmapDevice->CreateBitmapContext(bitGc);
	///
	CleanupStack::PushL(iContext);
	CleanupStack::PushL(bitmapDevice);
	CleanupStack::PushL(bitGc);
	AknsDrawUtils::DrawBackground(AknsUtils::SkinInstance(),iContext,NULL,*bitGc,TPoint(0,0),Rect(),0);
	CleanupStack::PopAndDestroy(3);
	iIcon=BitMap;
	
	/*
	CFbsBitmap* mask;
	CFbsBitmap* icon;
	_LIT(KPath,"\\resource\\apps\\TweakS_ui.mif");
	AknIconUtils::CreateIconL(icon,mask,KPath,EMbmTweaks_uiButton_dlg_bg,EMbmTweaks_uiButton_dlg_bg_mask);
	AknIconUtils::SetSize(icon,Size(),EAspectRatioNotPreserved);
	AknIconUtils::SetSize(mask,Size(),EAspectRatioNotPreserved);
	iIcon=CGulIcon::NewL(icon,mask);
	*/
	}
static void DrawIconL(CWindowGc& aGc, CGulIcon& aIcon, const TJuikLayoutItem& aL, TBool aDoCenter=ETrue) 
{
	CALLSTACKITEMSTATIC_N(_CL(""), _CL("DrawIconL"));
	CFbsBitmap* bmp = aIcon.Bitmap();
	CFbsBitmap* mask = aIcon.Mask();
	
	aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
	// center 
	TInt bmpW = bmp->SizeInPixels().iWidth;
	TInt areaW = aL.Size().iWidth;
	
	TInt dx = 0;
	TInt dy = 0;
	if ( aDoCenter && bmpW < areaW )
		{
			dx = (areaW - bmpW) / 2;
		}


	TPoint tl = aL.TopLeft();
	tl += TPoint(dx,dy);
	TRect r(TPoint(0,0), bmp->SizeInPixels());
 	if ( mask )
 		{
 			aGc.BitBltMasked( tl, bmp, r, mask, ETrue);
 		}
 	else
 		{
			aGc.BitBlt( tl, bmp, r);
  		}
}
Esempio n. 14
0
/**
	@SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0054-0001
  
	@SYMPREQ PGM027
  
	@SYMTestCaseDesc Negative Tests RWsSpriteBase::UpdateMember API. 
   
	@SYMTestPriority 1 
  
	@SYMTestStatus Implemented
   
	@SYMTestActions This test calls RWsPointerCursor::UpdateMember
		
	@SYMTestExpectedResults Should run properly with out any Panics.

 */
void CTTSprite::SpriteUpdateMemberNegTestsL()
	{
	RWsPointerCursor iCursor1;
	
	CFbsBitmap bitmap;
	bitmap.Load(TEST_BITMAP_NAME,0);
		
	RWindow win(TheClient->iWs);
	win.Construct(*TheClient->iGroup->GroupWin(),1);
	win.Activate();

	iCursor1=RWsPointerCursor(TheClient->iWs);
	TSpriteMember member;
	SetUpMember(member);
	member.iBitmap=&bitmap;
	User::LeaveIfError(iCursor1.Construct(0));
	User::LeaveIfError(iCursor1.AppendMember(member));
	User::LeaveIfError(iCursor1.Activate());
	win.SetCustomPointerCursor(iCursor1);
	iCursor1.UpdateMember(-100);
	
	RWsPointerCursor iCursor2;
	bitmap.Load(TEST_NEW_BITMAP_NAME,0);
	iCursor2=RWsPointerCursor(TheClient->iWs);
	User::LeaveIfError(iCursor2.Construct(0));
	User::LeaveIfError(iCursor2.AppendMember(member));
	User::LeaveIfError(iCursor2.Activate());
	win.SetCustomPointerCursor(iCursor2);
	iCursor2.UpdateMember(10000);
	
	iCursor1.Close();
	iCursor2.Close();
	win.Close();
	}
void CMMABitmapWindow::SetDestinationBitmapL(CFbsBitmap* aBitmap)
{
    CFbsBitmap* bitmap = new(ELeave)CFbsBitmap();
    CleanupStack::PushL(bitmap);
    User::LeaveIfError(bitmap->Duplicate(aBitmap->Handle()));

    // create context for bitmap
    CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(aBitmap);
    CleanupStack::PushL(bitmapDevice);


    CGraphicsContext* bitmapContext = NULL;
    User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext));

    CleanupStack::Pop(bitmapDevice);   // bitmapDevice
    CleanupStack::Pop(bitmap);   // bitmap

    delete iBitmap;
    iBitmap = bitmap;
    delete iBitmapDevice;
    iBitmapDevice = bitmapDevice;
    delete iBitmapContext;
    iBitmapContext = bitmapContext;

    if (iDrawRect.IsEmpty())
    {
        iDrawRect.SetSize(iBitmap->SizeInPixels());
    }
}
Esempio n. 16
0
void tst_QVolatileImage::sharing()
{
    QVolatileImage img1(100, 100, QImage::Format_ARGB32);
    QVolatileImage img2 = img1;
    img1.beginDataAccess();
    img2.beginDataAccess();
    QVERIFY(img1.constBits() == img2.constBits());
    img2.endDataAccess();
    img1.endDataAccess();
    img1.imageRef(); // non-const call, should detach
    img1.beginDataAccess();
    img2.beginDataAccess();
    QVERIFY(img1.constBits() != img2.constBits());
    img2.endDataAccess();
    img1.endDataAccess();

    // toImage() should return a copy of the internal QImage.
    // imageRef() is a reference to the internal QImage.
    QVERIFY(img1.imageRef().constBits() != img1.toImage().constBits());

#ifdef Q_OS_SYMBIAN
    CFbsBitmap *bmp = new CFbsBitmap;
    QVERIFY(bmp->Create(TSize(100, 50), EColor16MAP) == KErrNone);
    QVolatileImage bmpimg(bmp);
    QVolatileImage bmpimg2;
    bmpimg2 = bmpimg;
    QCOMPARE(bmpimg.constBits(), (const uchar *) bmp->DataAddress());
    QCOMPARE(bmpimg2.constBits(), (const uchar *) bmp->DataAddress());
    // Now force a detach, which should copy the pixel data under-the-hood.
    bmpimg.imageRef();
    QVERIFY(bmpimg.constBits() != (const uchar *) bmp->DataAddress());
    QCOMPARE(bmpimg2.constBits(), (const uchar *) bmp->DataAddress());
    delete bmp;
#endif
}
void CUnRegisterView::Draw(const TRect& /* aRect */) const
{
	CWindowGc& gc = SystemGc();
	gc.Clear();

	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
	CleanupStack::PushL(bitmap);

	TBuf<128> path;
	path = CRippleVaultAppUi::ApplicationDriveAndPath();
	path.Append(KLogoMbmFileName);

	User::LeaveIfError(bitmap->Load(path, EMbmLogoLogo));
	TPoint pos(50,60);
	gc.BitBlt(pos, bitmap);	
	CleanupStack::PopAndDestroy();

	const CFont* fontUsed;  
	fontUsed = iEikonEnv->TitleFont();
	gc.UseFont(fontUsed);

	//TPoint pos1(50,30);
	//gc.DrawText(*(iEikonEnv->AllocReadResourceL(R_RIPPLE_VAULT)),pos1);
	TPoint pos2(30,180);
	gc.DrawText(*(iEikonEnv->AllocReadResourceL(R_PURPLEACE_WEB)),pos2);
	
    // Finished using the font
	gc.DiscardFont();

}
void QGLPixmapData::fromNativeType(void* pixmap, NativeType type)
{
    if (type == QPixmapData::SgImage && pixmap) {
#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
        RSgImage *sgImage = reinterpret_cast<RSgImage*>(pixmap);

        m_sgImage = new RSgImage;
        m_sgImage->Open(sgImage->Id());

        TSgImageInfo info;
        sgImage->GetInfo(info);

        w = info.iSizeInPixels.iWidth;
        h = info.iSizeInPixels.iHeight;
        d = symbianPixeFormatBitsPerPixel((TUidPixelFormat)info.iPixelFormat);

        m_source = QVolatileImage();
        m_hasAlpha = true;
        m_hasFillColor = false;
        m_dirty = true;
        is_null = (w <= 0 || h <= 0);
#endif
    } else if (type == QPixmapData::FbsBitmap && pixmap) {
        CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap *>(pixmap);
        QSize size(bitmap->SizeInPixels().iWidth, bitmap->SizeInPixels().iHeight);
        if (size.width() == w && size.height() == h)
            setSerialNumber(++qt_gl_pixmap_serial);
        resize(size.width(), size.height());
        m_source = QVolatileImage(bitmap);
        if (pixelType() == BitmapType) {
            m_source.ensureFormat(QImage::Format_MonoLSB);
        } else if (!knownGoodFormat(m_source.format())) {
            m_source.beginDataAccess();
            QImage::Format format = idealFormat(m_source.imageRef(), Qt::AutoColor);
            m_source.endDataAccess(true);
            m_source.ensureFormat(format);
        }
        m_hasAlpha = m_source.hasAlphaChannel();
        m_hasFillColor = false;
        m_dirty = true;
        d = m_source.depth();
    } else if (type == QPixmapData::VolatileImage && pixmap) {
        // Support QS60Style in more efficient skin graphics retrieval.
        QVolatileImage *img = static_cast<QVolatileImage *>(pixmap);
        if (img->width() == w && img->height() == h)
            setSerialNumber(++qt_gl_pixmap_serial);
        resize(img->width(), img->height());
        m_source = *img;
        m_hasAlpha = m_source.hasAlphaChannel();
        m_hasFillColor = false;
        m_dirty = true;
        d = m_source.depth();
    } else if (type == QPixmapData::NativeImageHandleProvider && pixmap) {
        destroyTexture();
        nativeImageHandleProvider = static_cast<QNativeImageHandleProvider *>(pixmap);
        // Cannot defer the retrieval, we need at least the size right away.
        createFromNativeImageHandleProvider();
    }
}
TBool CScreenCaptureUtil::VerifyBitmapFormatL(const CFbsBitmap& aBitmap)
	{
  RSurfaceManager::TInfoBuf infoBuf;
	RSurfaceManager::TSurfaceInfoV01& info = infoBuf();
  User::LeaveIfError(iSurfaceManager.SurfaceInfo(iLocalSurface, infoBuf));
    		
	return ((info.iSize == aBitmap.SizeInPixels()) && (EColor16MU == aBitmap.DisplayMode()));
	}
/**
Loads a bitmap from a file

@param aName the filename of the bitmap to load
@param aIndex the index of the bitmap to load in the file
*/
CFbsBitmap* CTe_graphicsperformanceSuiteStepBase::LoadBitmapL(const TDesC& aName, TInt aIndex)
	{
	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
	CleanupStack::PushL(bitmap);
	User::LeaveIfError(bitmap->Load(aName, aIndex));
	CleanupStack::Pop(bitmap);
	return bitmap;
	}
CFbsBitmap* AknBitmapMirrorUtils::CreateBitmapL(CFbsBitmap* aSourceBitmap, TInt aMirrorDirection)
    {
    User::LeaveIfNull(aSourceBitmap);
    CFbsBitmap* destinationBitmap = new (ELeave) CFbsBitmap();
    CleanupStack::PushL(destinationBitmap);   

    TSize sourceBitmapSize = aSourceBitmap->SizeInPixels();            
    TRect sourceRect = TRect(TPoint(0,0), sourceBitmapSize);
    TSize destinationBitmapSize(sourceRect.Width(), sourceRect.Height()); 

    User::LeaveIfError(destinationBitmap->Create(destinationBitmapSize, aSourceBitmap->DisplayMode()));

    CFbsBitmapDevice* destinationDevice = CFbsBitmapDevice::NewL( destinationBitmap );
    CleanupStack::PushL(destinationDevice);

    CFbsBitGc* destinationGc;
    User::LeaveIfError( destinationDevice->CreateContext( destinationGc ) );

    switch (aMirrorDirection)
        {
        case EAknVerticalMirroring:
            {
            TRect sourceBitmapBlittingRect( sourceRect.iTl.iX,sourceRect.iTl.iY,sourceRect.iBr.iX,sourceRect.iTl.iY + 1 );  
            for ( TInt yPos=destinationBitmapSize.iHeight-1; yPos >= 0; yPos-- )
                {
                destinationGc->BitBlt( TPoint(0,yPos), aSourceBitmap, sourceBitmapBlittingRect );
                sourceBitmapBlittingRect.iTl.iY++;
                sourceBitmapBlittingRect.iBr.iY++;
                }
            break;
            }

        case EAknHorizontalMirroring:
            {
            TRect sourceBitmapBlittingRect( sourceRect.iTl.iX,sourceRect.iTl.iY,sourceRect.iTl.iX + 1,sourceRect.iBr.iY );      
            for ( TInt xPos=destinationBitmapSize.iWidth-1; xPos >= 0; xPos-- )
                {
                destinationGc->BitBlt( TPoint(xPos,0), aSourceBitmap, sourceBitmapBlittingRect );
                sourceBitmapBlittingRect.iTl.iX++;
                sourceBitmapBlittingRect.iBr.iX++;
                }
            break;
            }

        default:
            {
            destinationGc->BitBlt( TPoint(0,0), aSourceBitmap, sourceRect );
            break;
            }
        }

    delete destinationGc;  
    CleanupStack::Pop(2); // destinationBitmap, destinationDevice
    delete destinationDevice;

    return destinationBitmap;   
    }
void CEglTest_EGL_Image_Multi_Thread_Parallel::doThreadFunctionL(TInt aIdx)
	{
	INFO_PRINTF2(_L("CEglTest_EGL_Image_Multi_Thread_Parallel::doThreadFunctionL, Thread %d"),aIdx);
	GetDisplayL();
	CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, aIdx);
	eglSess->InitializeL();	
	eglSess->OpenSgDriverL();
	
	// create a reference bitmap (we give index 7, as there's only 1 image in this test case)
	TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(KDefaultSourceFormat);
	CFbsBitmap* bitmap = eglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 7);
	CleanupStack::PushL(bitmap);

	// Create an RSgImage
	INFO_PRINTF2(_L("Thread %d, Creating a RSgImage having the reference bitmap's content"),aIdx);
	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(KDefaultSourceFormat, KPixmapSize);
    RSgImage rSgImageLocal;
	CleanupClosePushL(rSgImageLocal);
	ASSERT_EQUALS(rSgImageLocal.Create(imageInfo,bitmap->DataAddress(),bitmap->DataStride()), KErrNone);

	INFO_PRINTF2(_L("Thread %d, Creating an EGLImage from the shared RSgImage"),aIdx);
	EGLImageKHR eglImageLocal = eglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &rSgImageLocal, KEglImageAttribsPreservedTrue);
	ASSERT_EGL_TRUE(eglImageLocal != EGL_NO_IMAGE_KHR);
	CleanupStack::PopAndDestroy(&rSgImageLocal); 	//transferring ownership of the buffer to the EGLImage
	CleanupStack::PopAndDestroy(bitmap);

	INFO_PRINTF2(_L("Thread %d, Creating a Surface and a Context bound to OpenVG"),aIdx);
	TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(KDefaultSurfaceFormat);
	TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize);
	// Create a pixmap surface matching the native image pixel format
	eglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2,CTestEglSession::EResourceCloseSgImageEarly);
	
	INFO_PRINTF2(_L("Thread %d, Creating one VGImage from the EGLImage"),aIdx);
	VGImage vgImageLocal = eglSess->vgCreateImageTargetKHR((VGeglImageKHR)eglImageLocal);	
	ASSERT_VG_TRUE(vgImageLocal != VG_INVALID_HANDLE);
	ASSERT_EGL_TRUE(eglSess->DestroyEGLImage(iDisplay, eglImageLocal));
		
	// Copy the source VGImage to the surface
	vgSetPixels(0, 0, vgImageLocal, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight);
	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
	eglWaitClient();

	// destroy VGImage
	vgDestroyImage(vgImageLocal);
	ASSERT_TRUE(vgGetError()==VG_NO_ERROR);

	// we can now compare the VgImage to the one we would expect for this particular thread
	CFbsBitmap* refBitmap = eglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 7);
	CleanupStack::PushL(refBitmap);
	eglSess->CheckVgDrawingL(KDefaultSurfaceFormat, refBitmap);
	CleanupStack::PopAndDestroy(refBitmap);
	INFO_PRINTF2(_L("Drawing successful, Thread %d"),aIdx);

	// cleanup
	eglSess->CloseSgDriver();
  	CleanupStack::PopAndDestroy(eglSess);	
	}
/**
Override of base class virtual

@return - TVerdict code
*/
TVerdict CTBitBltPerfDirectGdi::doTestStepPreambleL()
	{	
	CTDirectGdiTestBase::doTestStepPreambleL();
	
	// Create a CFbsBitmap image for each source mode we are testing.
	for (TInt srcMode = 0; srcMode < iSourcePixelFormatArray.Count(); ++srcMode)
		{
		TDisplayMode bitmapDisplayMode = TDisplayModeMapping::MapPixelFormatToDisplayMode(iSourcePixelFormatArray[srcMode]);
		
		CFbsBitmap* bitmapImage = NULL;
		switch(bitmapDisplayMode)
		{
			case EColor4K:
			case EGray256:
				bitmapImage = LoadBitmapL(KBitmap12bit, 0);
				break;
			case EColor64K:
				bitmapImage = LoadBitmapL(KBitmap16bit, 0);
				break;
			case EColor16M:
				bitmapImage = LoadBitmapL(KBitmap24bit, 0);
				break;
			default:
				bitmapImage = LoadBitmapL(KBitmap32bit, 0);
				break;
		}
		if (bitmapImage && bitmapImage->DisplayMode() != bitmapDisplayMode)
			{
			CleanupStack::PushL(bitmapImage);
			CFbsBitmap* tempBitmap = CopyIntoNewBitmapL(bitmapImage, bitmapDisplayMode);
			CleanupStack::PopAndDestroy(1, bitmapImage); //bitmapImage
			bitmapImage = tempBitmap;
			}
		iBitmapImage.AppendL(bitmapImage);
		}

	// Create 8bit alpha bitmap
	CFbsBitmap* tempBitmap = LoadBitmapL(KBitmap12bit, 0);
	CleanupStack::PushL(tempBitmap);
	iAlpha8bit = CopyIntoNewBitmapL(tempBitmap, EGray256);
	CleanupStack::PopAndDestroy(tempBitmap);	// tempBitmap

	// Create CFbsBitmaps for the tile images of various pixel formats.
	// The first entry in the array is always the default pixelformat loaded from the mbm.
	// Then in the rest of the array are bitmaps converted to the source pixel formats.
	CFbsBitmap* tile = LoadBitmapL(KBitmapTile, 0);	
	iBitmapTile.AppendL(tile);
	for (TInt srcMode = 0; srcMode < iSourcePixelFormatArray.Count(); ++srcMode)
		{
		TDisplayMode bitmapDisplayMode = TDisplayModeMapping::MapPixelFormatToDisplayMode(iSourcePixelFormatArray[srcMode]);
		CFbsBitmap* tileCopy = CopyIntoNewBitmapL(tile, bitmapDisplayMode);
		iBitmapTile.AppendL(tileCopy);
		}
	
	return TestStepResult();
	}
void AConvolute64KBlurGauss( CFbsBitmap& aTarget,
                             const CFbsBitmap& aSource,
                             const TInt aBlendFactor )
    {
    TInt width  = aTarget.SizeInPixels().iWidth;
    TInt height = aTarget.SizeInPixels().iHeight;

    // CFbsBitmap::ScanLineLength returns bytes 
    TInt targetScanW  = CFbsBitmap::ScanLineLength(
                                aTarget.SizeInPixels().iWidth,
                                aTarget.DisplayMode());
    TInt sourceScanW  = CFbsBitmap::ScanLineLength(
                                aSource.SizeInPixels().iWidth,
                                aSource.DisplayMode());

    TInt combinedScanW = (targetScanW << 16) + sourceScanW;

    // Prepare the data addresses
    aTarget.LockHeap( ETrue ); // Lock the global bitmap heap
    TUint* targetAddr = reinterpret_cast<TUint*>( aTarget.DataAddress() );
    TUint* sourceAddr = reinterpret_cast<TUint*>( aSource.DataAddress() );

    ADoConvolute64KBlurGauss(targetAddr, sourceAddr, combinedScanW, width, height, aBlendFactor);

    aTarget.UnlockHeap( ETrue ); // Unlock the global bitmap heap
    }
Esempio n. 25
0
/**
 Extracts data from aFrameData, packs them and then it sends this package to the player
*/
void RBitmapAnim::SetFrameL(const CBitmapFrameData& aFrameData, TInt aOpCode)
	{
	TPckgBuf<TFrameData> dataFrameArg;
	CFbsBitmap* bitmap = aFrameData.Bitmap();
	dataFrameArg().iBitmapHandle=( (bitmap) ? bitmap->Handle() : 0 );
	CFbsBitmap* mask = aFrameData.Mask();
	dataFrameArg().iMaskBitmapHandle=( (mask) ? mask->Handle() : 0 );
	dataFrameArg().iIntervalInMilliSeconds=aFrameData.IntervalInMilliSeconds();
	dataFrameArg().iPosition=aFrameData.Position();
	User::LeaveIfError(CommandReply(aOpCode, dataFrameArg));
	}
//-----------------------------------------------------------------------------
//  CBrowserViewImagesListBox::CreatePlaceholderIconL()
//-----------------------------------------------------------------------------
//
CGulIcon* CBrowserViewImagesListBox::CreatePlaceholderIconL()
    {
    CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
    CleanupStack::PushL(bitmap);
    if(KErrNone != bitmap->Create(TSize(42,32), EColor16M))
        User::Leave(KErrNoMemory);

    // create icon
    CGulIcon* icon = CGulIcon::NewL(bitmap); // bitmap is owned, no mask used
    CleanupStack::Pop();    // bitmap
    return icon;
    }
/**
Creates and destroys bitmaps of the same size KIterationsToTest times.

@param aWidth The width of the created bitmaps.
@param aHeight  The height of the created bitmaps.
@param aDisplayMode The display mode to create bitmaps with.
@param aTestDescription The description of the test.
*/
void CTFbsBitmapHandlePerf::BitmapCreationSimpleL(const TInt aWidth, const TInt aHeight, const TDisplayMode aDisplayMode, const TDesC& aTestDescription)
	{
	iProfiler->InitResults();
	for (TInt count = KIterationsToTest; count > 0; --count)
		{
		CFbsBitmap bitmap;
		TInt err = bitmap.Create(TSize(aWidth, aHeight), aDisplayMode);
		User::LeaveIfError(err);
		iProfiler->MarkResultSetL();
		}
	iProfiler->ResultsAnalysis(aTestDescription, aDisplayMode, 0, 0, KIterationsToTest);
	}
/**
@SYMTestCaseID GRAPHICS-EGL-0157

@SYMTestPriority 1

@SYMPREQ 39

@SYMREQ See SGL.GT0386.401 document

@SYMTestCaseDesc
Check if EGL Implementation allows two threads to work in parallel.
Each thread is allowed to create a VGImage from the same EGLImage

@SYMTestActions
Main Thread: creates an RSgImage with the same content as the reference bitmap and creates an EGLImage from it; starts thread1 and thread2.
Thread1: Creates an egl context and a pixmap surface linked to it. Creates an VGImage from the EGLImage previous mentioned
Thread2: Creates an egl context and a pixmap surface linked to it. Creates an VGImage from the EGLImage previous mentioned
--------
Thread 1: Changes the content of the RSgImage by using the VGImage that has a reference to it.
--------
Thread1: Passes the VGImage into vgDestroyImage()
Thread2: Copies the VGImage to the pixmap surface and checks the contents
Thread2: Passes the VGImage into vgDestroyImage()
Main Thread: Closes the EGLImage
Main Thread: Closes the RSgImage

@SYMTestExpectedResults
No error is generated within both threads. The changes apported by the first thread affects the second thread. The content the pixmap surface will matches the one of the reference bitmap changed by the first thread.
No memory or handle leaks
*/
TVerdict CEglTest_EGL_Image_Multi_Thread_Sibling_VGImage::doTestStepL()
	{
	SetTestStepID(_L("GRAPHICS-EGL-0157"));
	INFO_PRINTF1(_L("Enter: CEglTest_EGL_Image_Multi_Thread_Sibling_VGImage::doTestStepL"));

	TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image);
	if(!ret)
		{
		// The extension is not supported
		RecordTestResultL();
		CloseTMSGraphicsStep();
		return TestStepResult();
		}

	// Create display object
	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
    GetDisplayL();
    CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, 0);
	eglSess->InitializeL();

	// Make sure the driver is ready
	eglSess->OpenSgDriverL();

	// create a reference bitmap (we give index 3, as there's only 1 image in this test case)
	TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(KDefaultSourceFormat);
	CFbsBitmap* bitmap = eglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 3);
	CleanupStack::PushL(bitmap);
	
	// Create an RSgImage (member variable as it is 'shared' in the thread funtion...) 
	INFO_PRINTF1(_L("Parent Thread, Creating the shared RSgImage"));
	TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(KDefaultSourceFormat, KPixmapSize);
	ASSERT_EQUALS(iSgImageShared.Create(imageInfo,bitmap->DataAddress(),bitmap->DataStride()), KErrNone);
	CleanupStack::PopAndDestroy(bitmap);
	
	// Create an EGLImage from the RSgImage (member variable as it is 'shared' in the thread funtion...) 
	INFO_PRINTF1(_L("Parent Thread, Creating the shared EGLImage"));
	iEGLImageShared = eglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&iSgImageShared,KEglImageAttribsPreservedTrue);
	ASSERT_EGL_TRUE(iEGLImageShared != EGL_NO_IMAGE_KHR);
	iSgImageShared.Close();

	// launch 2 threads
	Test_MultiThreadL(2, ETrue);
	
	// cleanup
	ASSERT_EGL_TRUE(eglSess->DestroyEGLImage(iDisplay, iEGLImageShared));
	CleanupStack::PopAndDestroy(eglSess);
	TerminateDisplayL();	
	INFO_PRINTF1(_L("Exit: CEglTest_EGL_Image_Multi_Thread_Sibling_VGImage::doTestStepL"));	
	RecordTestResultL();
	CloseTMSGraphicsStep();
	return TestStepResult();
	}
Esempio n. 29
0
int CAfStorageClient::getThumbnail(const TDesC &imagePath, void *userData)
{
    lastMethodCalled = CAfStorageClient::GetThumbnailMethod;
    delete lastCallThumbnailPath;
    lastCallThumbnailPath = imagePath.Alloc();
    lastCallUserData = userData;
    CFbsBitmap *bitmap = new (ELeave)CFbsBitmap();
    CleanupStack::PushL(bitmap);
    User::LeaveIfError(bitmap->Create(TSize(128, 128), EColor4K));
    mObserver.getThumbnailRequestCompleted(CAfStorageClient::expectedReturnCode, bitmap->Handle(), userData);
    CleanupStack::PopAndDestroy(bitmap);
    return CAfStorageClient::expectedReturnCode;
}
// ----------------------------------------------------------------------------
// CSysApShutdownImage::ShowShutdownImage()
// ----------------------------------------------------------------------------
CFbsBitmap* CSysApShutdownImage::ReadSVGL (TFileName aFileName)
    {
    TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL:start" ) ) );    
    TFontSpec fontspec;
    TDisplayMode mode = EColor16MA;
    TInt SIZE_X(360), SIZE_Y(360);
    TSize size(SIZE_X, SIZE_Y);

    //if ( mode >= (TDisplayMode)13 )  { mode = EColor16MA; }

    CFbsBitmap* frameBuffer = new ( ELeave ) CFbsBitmap;
    CleanupStack::PushL( frameBuffer );
    frameBuffer->Create( size, mode );
    
    CSvgEngineInterfaceImpl* svgEngine = NULL;
    svgEngine = CSvgEngineInterfaceImpl::NewL(frameBuffer, NULL, fontspec );    
    
    if (svgEngine == NULL)
        {
        TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL:SVG engine creation failed" ) ) );   
        }
    
    CleanupStack::PushL( svgEngine );
    TInt domHandle = 0;
    svgEngine->PrepareDom( aFileName, domHandle ) ;
    if (domHandle == 0)
        {
        TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL():DOM handle creation failed" ) ) );
        }

    CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;    
    CleanupStack::PushL( bitmap );
    User::LeaveIfError( bitmap->Create( size, EColor64K ) );

    svgEngine->UseDom( domHandle, bitmap, NULL ) ;
    
    MSvgError* err;
    svgEngine->Start( err );
    if (err->HasError())
        {
        TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL(): SVG Engine Start failed" ) ) );
        }

    svgEngine->DeleteDom( domHandle );
    CleanupStack::Pop( bitmap );
    CleanupStack::PopAndDestroy( svgEngine );
    CleanupStack::PopAndDestroy( frameBuffer );
    TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL:End" ) ) );   
    return bitmap;
    }