graphicsdeviceinterface/screendriver/sgeneric/scdraw.inl
branchRCL_3
changeset 163 bbf46f59e123
parent 70 5e51caaeeb72
child 164 25ffed67c7ef
equal deleted inserted replaced
150:57c618273d5c 163:bbf46f59e123
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    47 	CDrawXxxBppBitmap::iScanLineWords = iHelper.BytesPerScanline() / 4;
    47 	CDrawXxxBppBitmap::iScanLineWords = iHelper.BytesPerScanline() / 4;
    48 	if (CDrawXxxBppBitmap::iScanLineWords==0)
    48 	if (CDrawXxxBppBitmap::iScanLineWords==0)
    49 		{	//Note: This will cause WServ startup to fail. WServ only accepts KErrNotSupported
    49 		{	//Note: This will cause WServ startup to fail. WServ only accepts KErrNotSupported
    50 		return KErrHardwareNotAvailable;
    50 		return KErrHardwareNotAvailable;
    51 		}
    51 		}
    52 	TInt ret = CDrawXxxBppBitmap::Construct(aSize, CDrawXxxBppBitmap::iScanLineWords << 2);
    52 	TInt ret = CDrawXxxBppBitmap::Construct(aSize, iHelper.BytesPerScanline());
    53 	if (ret == KErrNone)
    53 	if (ret == KErrNone)
    54 		{
    54 		{
    55 		CDrawXxxBppBitmap::iBits = (TUint32*)iHelper.AddressFirstPixel();
    55 		CDrawXxxBppBitmap::iBits = (TUint32*)iHelper.AddressFirstPixel();
    56 		if (CDrawXxxBppBitmap::iBits==NULL)
    56 		if (CDrawXxxBppBitmap::iBits==NULL)
    57 			{	//Note: This will cause WServ startup to fail. WServ only accepts KErrNotSupported
    57 			{	//Note: This will cause WServ startup to fail. WServ only accepts KErrNotSupported
    96 	iHelper.Update();
    96 	iHelper.Update();
    97 	}
    97 	}
    98 
    98 
    99 template <class T> void CGenericScreenDevice<T>::Update(const TRegion& aRegion)
    99 template <class T> void CGenericScreenDevice<T>::Update(const TRegion& aRegion)
   100 	{
   100 	{
   101 	iHelper.Update(aRegion);
   101     if(!aRegion.IsEmpty() && !aRegion.CheckError())
       
   102         {
       
   103         if (aRegion.Count()>KMaxUpdateRegionRectangles)
       
   104             {
       
   105             UpdateRegion(aRegion.BoundingRect());
       
   106             }
       
   107         else
       
   108             {
       
   109             TInt rcCnt = aRegion.Count();
       
   110             for (TInt ii=0; ii < rcCnt; ++ii)
       
   111                 {  
       
   112                 UpdateRegion(aRegion[ii]);  //Applies deorientate (offset, scale, rotate)
       
   113                 }
       
   114             }
       
   115         }
       
   116     Update();
   102 	}
   117 	}
   103 
   118 
   104 template <class T> void CGenericScreenDevice<T>::UpdateRegion(const TRect& aRect)
   119 template <class T> void CGenericScreenDevice<T>::UpdateRegion(const TRect& aRect)
   105 	{
   120     {
   106 	iHelper.UpdateRegion(aRect);
   121     const TRect rect = CDrawXxxBppBitmap::DeOrientate(aRect);//rect - physical coordinates
   107 	}
   122     
       
   123     iHelper.UpdateRegion(rect);
       
   124     }
   108 
   125 
   109 template <class T> TInt CGenericScreenDevice<T>::GetInterface(TInt aInterfaceId, TAny*& aInterface)
   126 template <class T> TInt CGenericScreenDevice<T>::GetInterface(TInt aInterfaceId, TAny*& aInterface)
   110 	{
   127 	{
   111 	if(aInterfaceId == KSurfaceInterfaceID)
   128 	if(aInterfaceId == KSurfaceInterfaceID)
   112 	    {
   129 	    {
   173 		{
   190 		{
   174 		return EFalse;
   191 		return EFalse;
   175 		}
   192 		}
   176 
   193 
   177 	// Need to update size, scan line size, etc.
   194 	// Need to update size, scan line size, etc.
   178 	CGenericScreenDevice::SetSize(newSize);
       
   179 	
       
   180 	// Setting iScanLineWords MUST occur after the call to SetSize because SetSize itself
       
   181 	// sets iScanLineBytes to support offscreen bitmaps and may do so incorrectly for hardware devices
       
   182 	// as it just uses the width, whereas BytesPerScanline takes into account any extra bytes needed
       
   183 	// as defined by the hardware.
       
   184 	CGenericScreenDevice::iScanLineWords = CGenericScreenDevice::iHelper.BytesPerScanline() / 4;	 //presumption here that BPS is always mod4.
   195 	CGenericScreenDevice::iScanLineWords = CGenericScreenDevice::iHelper.BytesPerScanline() / 4;	 //presumption here that BPS is always mod4.
   185 	CGenericScreenDevice::iBits = (TUint32*)CGenericScreenDevice::iHelper.AddressFirstPixel();
   196 	CGenericScreenDevice::iBits = (TUint32*)CGenericScreenDevice::iHelper.AddressFirstPixel();
   186 	__ASSERT_ALWAYS(CGenericScreenDevice::iScanLineWords && CGenericScreenDevice::iBits,Panic(EScreenDriverPanicInvalidHalValue));
   197 	__ASSERT_ALWAYS(CGenericScreenDevice::iScanLineWords && CGenericScreenDevice::iBits,Panic(EScreenDriverPanicInvalidHalValue));
       
   198 	CGenericScreenDevice::SetSize(newSize);
   187 
   199 
   188 	return ETrue;
   200 	return ETrue;
   189 	}
   201 	}
   190 
   202 
   191 	
   203 	
   219 		{
   231 		{
   220 		return EFalse;
   232 		return EFalse;
   221 		}
   233 		}
   222 
   234 
   223 	// Need to update size, scan line size, etc.
   235 	// Need to update size, scan line size, etc.
   224 	CGenericScreenDevice::SetSize(newSize);
       
   225 	
       
   226 	// Setting iScanLineWords MUST occur after the call to SetSize because SetSize itself
       
   227 	// sets iScanLineBytes to support offscreen bitmaps and may do so incorrectly for hardware devices
       
   228 	// as it just uses the width, whereas BytesPerScanline takes into account any extra bytes needed
       
   229 	// as defined by the hardware.
       
   230 	CGenericScreenDevice::iScanLineWords = CGenericScreenDevice::iHelper.BytesPerScanline() / 4;	 //presumption here that BPS is always mod4.
   236 	CGenericScreenDevice::iScanLineWords = CGenericScreenDevice::iHelper.BytesPerScanline() / 4;	 //presumption here that BPS is always mod4.
   231 	CGenericScreenDevice::iBits = (TUint32*)CGenericScreenDevice::iHelper.AddressFirstPixel();
   237 	CGenericScreenDevice::iBits = (TUint32*)CGenericScreenDevice::iHelper.AddressFirstPixel();
   232 	__ASSERT_ALWAYS(CGenericScreenDevice::iScanLineWords && CGenericScreenDevice::iBits,Panic(EScreenDriverPanicInvalidHalValue));
   238 	__ASSERT_ALWAYS(CGenericScreenDevice::iScanLineWords && CGenericScreenDevice::iBits,Panic(EScreenDriverPanicInvalidHalValue));
       
   239 	CGenericScreenDevice::SetSize(newSize);
   233 
   240 
   234 	return ETrue;
   241 	return ETrue;
   235 	}
   242 	}
   236 
   243 
   237 
   244