graphicsdeviceinterface/screendriver/sbit/Cdsb.cpp
changeset 45 36b2e23a8629
parent 0 5d03bc08d59c
child 116 171fae344dd4
equal deleted inserted replaced
36:01a6848ebfd7 45:36b2e23a8629
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1998-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".
    14 //
    14 //
    15 
    15 
    16 #include <hal.h>
    16 #include <hal.h>
    17 #include <cdsb.h>
    17 #include <cdsb.h>
    18 #include <e32hal.h>
    18 #include <e32hal.h>
    19 
       
    20 
    19 
    21 #ifdef SYMBIAN_GRAPHICS_GCE
    20 #ifdef SYMBIAN_GRAPHICS_GCE
    22 #undef __WINS__
    21 #undef __WINS__
    23 #include "../sgeneric/scdraw.h"
    22 #include "../sgeneric/scdraw.h"
    24 #elif defined(__WINS__)
    23 #elif defined(__WINS__)
    71 	TInt    iVideoAddress;
    70 	TInt    iVideoAddress;
    72 #endif
    71 #endif
    73 #ifdef SYMBIAN_GRAPHICS_GCE
    72 #ifdef SYMBIAN_GRAPHICS_GCE
    74     CScreenDeviceHelper iSurfaceUpdater;
    73     CScreenDeviceHelper iSurfaceUpdater;
    75     TUidPixelFormat iPixelFormat;
    74     TUidPixelFormat iPixelFormat;
    76     TBool iDsaBufferIsBusy;
       
    77     TRequestStatus iDsaBufferAvailable;
       
    78 #endif
    75 #endif
    79 	TAcceleratedBitmapInfo iBitmapInfo;
    76 	TAcceleratedBitmapInfo iBitmapInfo;
    80 	TUint32 iSettingsFlags;
    77 	TUint32 iSettingsFlags;
    81 	TRect   iUpdateRect;
    78 	TRect   iUpdateRect;
    82 	TInt    iDisplayOffsetLines;
    79 	TInt    iDisplayOffsetLines;
   108 
   105 
   109 CGenericDirectScreenBitmap::CGenericDirectScreenBitmap() :
   106 CGenericDirectScreenBitmap::CGenericDirectScreenBitmap() :
   110 #ifndef __WINS__
   107 #ifndef __WINS__
   111 	iVideoAddress(NULL),
   108 	iVideoAddress(NULL),
   112 #endif
   109 #endif
   113 #ifdef SYMBIAN_GRAPHICS_GCE
       
   114 	iDsaBufferIsBusy(EFalse),
       
   115 #endif
       
   116 	iBitmapInfo(),
   110 	iBitmapInfo(),
   117 	iSettingsFlags(ENone),
   111 	iSettingsFlags(ENone),
   118 	iUpdateRect(),
   112 	iUpdateRect(),
   119 	iDisplayOffsetLines(0),
   113 	iDisplayOffsetLines(0),
   120 	iBytesPerPixel(0),
   114 	iBytesPerPixel(0),
   163 		{
   157 		{
   164 		return r;
   158 		return r;
   165 		}
   159 		}
   166 
   160 
   167 	__ASSERT_ALWAYS(aScreenRect.iTl.iX >= 0 &&
   161 	__ASSERT_ALWAYS(aScreenRect.iTl.iX >= 0 &&
   168 					aScreenRect.iTl.iY >= 0 &&
   162 	                aScreenRect.iTl.iY >= 0 &&
   169 					aScreenRect.Width() <= screenWidth &&
   163 	                ((aScreenRect.Width() <= screenWidth &&
   170 					aScreenRect.Height() <= screenHeight, Panic(EPanicOutOfBounds));
   164 	                aScreenRect.Height() <= screenHeight)
       
   165 	                ||
       
   166 	                (aScreenRect.Width() <= screenHeight &&
       
   167 	                aScreenRect.Height() <= screenWidth)),
       
   168 	                Panic(EPanicOutOfBounds));
   171 
   169 
   172 	__ASSERT_ALWAYS(aScreenRect.Width() > 0 &&
   170 	__ASSERT_ALWAYS(aScreenRect.Width() > 0 &&
   173 					aScreenRect.Height() > 0, Panic(EPanicInvalidRect));
   171 					aScreenRect.Height() > 0, Panic(EPanicInvalidRect));
   174 
   172 
   175 	iUpdateRect = aScreenRect;
   173 	iUpdateRect = aScreenRect;
   527 	WinsUpdate(iUpdateRect);
   525 	WinsUpdate(iUpdateRect);
   528 
   526 
   529 #else
   527 #else
   530 	TUint8* pD = (TUint8*)iVideoAddress;
   528 	TUint8* pD = (TUint8*)iVideoAddress;
   531 	const TUint dD = iDisplayOffsetLines;
   529 	const TUint dD = iDisplayOffsetLines;
   532 #ifdef SYMBIAN_GRAPHICS_GCE
   530 
   533 	if (iDsaBufferIsBusy)
       
   534 		{
       
   535 		User::WaitForRequest(iDsaBufferAvailable);
       
   536 		__ASSERT_DEBUG(iDsaBufferAvailable != KRequestPending, Panic(EPanicIncompleteRequest));
       
   537 		iDsaBufferIsBusy=EFalse;
       
   538 		}
       
   539 #endif	
       
   540 	for(TInt y=iUpdateRect.Height(); y>0; y--)
   531 	for(TInt y=iUpdateRect.Height(); y>0; y--)
   541 		{
   532 		{
   542 		Mem::Move((void *)pD, (void *)pS, dS);
   533 		Mem::Move((void *)pD, (void *)pS, dS);
   543 		pS += dS;
   534 		pS += dS;
   544 		pD += dD;
   535 		pD += dD;
   545 		}
   536 		}
   546 #endif
   537 #endif
   547 	
   538 	
   548 #ifdef SYMBIAN_GRAPHICS_GCE
   539 #ifdef SYMBIAN_GRAPHICS_GCE
   549 	iDsaBufferIsBusy=ETrue;
   540 	// update the region and complete notification on the client's TRequestStatus
       
   541 	// This means the backbuffer is held up until the surface update has completed
       
   542 	// notification.
   550 	iSurfaceUpdater.UpdateRegion(iUpdateRect);
   543 	iSurfaceUpdater.UpdateRegion(iUpdateRect);
   551 	iDsaBufferAvailable = KRequestPending;
   544 	iSurfaceUpdater.Update(aComplete);
   552 	iSurfaceUpdater.NotifyWhenAvailable(iDsaBufferAvailable);
   545 #else
   553 	iSurfaceUpdater.Update();
       
   554 #endif
       
   555 	// In the generic implementation, complete the request immediately to allow the client
   546 	// In the generic implementation, complete the request immediately to allow the client
   556     // to render to the back buffer
   547 	// to render to the back buffer
   557 	TRequestStatus* pComplete=&aComplete;
   548 	TRequestStatus* pComplete=&aComplete;
   558 
   549 	User::RequestComplete(pComplete,KErrNone);
   559     User::RequestComplete(pComplete,KErrNone);
   550 #endif
       
   551 
   560  	}
   552  	}
   561 
   553 
   562 //
   554 //
   563 // End Update - Commit changes within the given area to the Frame Buffer
   555 // End Update - Commit changes within the given area to the Frame Buffer
   564 //
   556 //
   604 	const TUint dD = iDisplayOffsetLines;
   596 	const TUint dD = iDisplayOffsetLines;
   605 
   597 
   606 	TUint8* pS = iBitmapInfo.iAddress + offX + (offY*dS);
   598 	TUint8* pS = iBitmapInfo.iAddress + offX + (offY*dS);
   607 	TUint8* pD = (TUint8*)iVideoAddress + offX + (offY*dD);
   599 	TUint8* pD = (TUint8*)iVideoAddress + offX + (offY*dD);
   608 
   600 
   609 #ifdef SYMBIAN_GRAPHICS_GCE
       
   610 	if (iDsaBufferIsBusy)
       
   611 		{
       
   612 		User::WaitForRequest(iDsaBufferAvailable);
       
   613 		__ASSERT_DEBUG(iDsaBufferAvailable != KRequestPending, Panic(EPanicIncompleteRequest));
       
   614 		iDsaBufferIsBusy=EFalse;
       
   615 		}
       
   616 #endif	
       
   617 	
       
   618 	for(TInt y=aScreenRect.Height(); y>0; y--)
   601 	for(TInt y=aScreenRect.Height(); y>0; y--)
   619 		{
   602 		{
   620 		Mem::Move((void *)pD, (void *)pS, bytesToCopy);
   603 		Mem::Move((void *)pD, (void *)pS, bytesToCopy);
   621 		pS += dS;
   604 		pS += dS;
   622 		pD += dD;
   605 		pD += dD;
   623 		}
   606 		}
   624 #endif
   607 #endif
   625 
   608 
   626 #ifdef SYMBIAN_GRAPHICS_GCE
   609 #ifdef SYMBIAN_GRAPHICS_GCE
   627 	iDsaBufferIsBusy=ETrue;
   610 	// update the region and complete notification on the client's TRequestStatus
       
   611 	// This means the backbuffer is held up until the surface update has completed
       
   612 	// notification.
   628 	iSurfaceUpdater.UpdateRegion(iUpdateRect);
   613 	iSurfaceUpdater.UpdateRegion(iUpdateRect);
   629 	iDsaBufferAvailable = KRequestPending;
   614 	iSurfaceUpdater.Update(aComplete);
   630 	iSurfaceUpdater.NotifyWhenAvailable(iDsaBufferAvailable);
   615 #else
   631 	iSurfaceUpdater.Update();
   616 	// In the generic implementation, complete the request immediately to allow the client
       
   617 	// to render to the back buffer
       
   618 	TRequestStatus* pComplete=&aComplete;
       
   619 	User::RequestComplete(pComplete,KErrNone);
   632 #endif	
   620 #endif	
   633 	// In the generic implementation, complete the request immediately.
   621 
   634 	TRequestStatus* pComplete=&aComplete;
       
   635 
       
   636 	User::RequestComplete(pComplete,KErrNone);
       
   637 	}
   622 	}
   638 
   623 
   639 #ifdef __WINS__
   624 #ifdef __WINS__
   640 //
   625 //
   641 // Extracts the RGB value of the specidied pixel from the buffer
   626 // Extracts the RGB value of the specidied pixel from the buffer
   726 		};
   711 		};
   727 	return KRgbBlack;
   712 	return KRgbBlack;
   728 	}
   713 	}
   729 #endif
   714 #endif
   730 
   715 
       
   716 
   731 //
   717 //
   732 // Close - Deallocate resources and cancel outstanding updates
   718 // Close - Deallocate resources and cancel outstanding updates
   733 //
   719 //
   734 void CGenericDirectScreenBitmap::Close()
   720 void CGenericDirectScreenBitmap::Close()
   735 	{
   721 	{
   736 	if(iCreated)
   722 	if(iCreated)
   737 		{
   723 		{
       
   724 #ifdef SYMBIAN_GRAPHICS_GCE
       
   725 		iSurfaceUpdater.CancelUpdateNotification();
       
   726 #endif
   738 		User::Free(iBitmapInfo.iAddress);
   727 		User::Free(iBitmapInfo.iAddress);
   739 		iBitmapInfo.iAddress = NULL;
   728 		iBitmapInfo.iAddress = NULL;
   740 		iCreated = EFalse;
   729 		iCreated = EFalse;
   741 		}
   730 		}
   742 	if (iHasChunk)
   731 	if (iHasChunk)