wsScreenDev->SetAutoUpdate(ETrue);// Sets or unsets auto-update for the screen.
gc->DrawRect(TRect(TPoint (10, 10), TSize (60, 60))); // draw a rect by DSA /* if not call SetAutoUpdate(ETrue) before, it must call Update() manually to update screen. */ // screenDev->Update();
/* skip the palette data in the beginning of frame buffer. * series 60 devices have 32 Bytes palette at the beginning. * But be careful: UIQ devices haven't. */ screenDataAddr += 16; } #endif// __WINS__
/* DSA. * when you copy bitmap data directly to video memory, it is essential to ensure * your screen mode is same as bitmap mode! */ if(screenDataAddr)
#if defined(__WINS__) screenBufBmp->UnlockHeap(); ...// bitblt the screenBufBmp to Screen
CleanupStack::PopAndDestroy(screenBufBmp); #else// device /**Once when the drawing is completed, the screen should be updated such that * the changes made to the screen memory will be reflected on the screen. * The general way of doing this is by adding a redraw event(TRawEvent::ERedraw) * to the system queue using UserSvr::AddEvent() API, which updates the screen * immediately. * * But the TRawEvent::ERedraw is a event generated by the host OS ( typically by * WM_PAINT ) which is meant for emulator environment( as per the S60 SDK help * document ). However on S60 2nd edition devices, the screen gets updated * properly by adding this event to the system queue. But S60 3rd Edition * devices does not have any immediate effect after the Redraw event is added to * the system queue. The screen is updated only after notifying the screen * device about the out of date region(s), which is a known issue. * * Also accessing the display memory with UserSvr::ScreenInfo() is deprecated * from S60 3rd Edition onwards. */ TRawEvent redraw; redraw.Set(TRawEvent::ERedraw); UserSvr::AddEvent(redraw);
/**As a workaround solution, it is still possible to use the old drawing method * and force the screen to update itself by specifying the out of date region * using CFbsScreenDevice's Update() API. The code snippet for doing the same is * as follows: */ CFbsScreenDevice* iMyScreenDev = CFbsScreenDevice::NewL(0 ,displayMode); // the screennumber will be 0 if phone supports single screen where as the // displaymode can be as per your choice RRegion iMyregion; iMyregion.AddRect(TRect(0,0,240,320)); // the out of date rect region. iMyScreenDev->Update(iMyregion); iMyregion.Close(); #endif
An active object used to start direct screen access.
Direct screen access is a way of drawing to the screen without using the window server. As this avoids client-server communication, it is much faster, and may be useful for games and video. Note that some interaction with the window server is needed in order to prevent the application from drawing over other application's data.
The object's (private) RunL() function is called by the window server in order to abort direct screen access. This might occur when another window needs to be displayed in front or when the window with direct screen access is moved. The active object's priority is RDirectScreenAccess::EPriorityVeryHigh so that direct screen access will be aborted as quickly as possible.
示例代码
头文件
#include<W32STD.H>// ws32.lib
class CMyDsaAppContainer:public CCoeControl, public MDirectScreenAccess { // new functions ++ ...// other functions public: virtual~CMyDsaAppContainer(); void Repaint(const TRect & aRect);
/** This function is called by the window server when direct screen access must * stop (for example because a dialogue is moved in front of the area where direct * screen access is taking place). * In response to this, direct screen access must stop immediately. In simple cases, * this will involve cancelling the active object that is driving the drawing to the * screen. * No attempt to call a Window Server API function can be made from * AbortNow(), because then a temporary deadlock will occur. This is because WSERV * is waiting to receive the client's acknowledgment that it has aborted, and so will * not be able to service the call. As soon as the restriction no longer applies, * the function Restart() will be called. * * @param aReason The reason why direct screen access was terminated. */ void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
/** This function is called by the window server as soon as direct screen access * can resume. * This function should call CDirectScreenAccess::StartL() within a trap harness. * If this leaves, e.g. through lack of memory, direct screen access cannot be * restarted. StartL() re-calculates the clipping region, so that if direct screen * access was aborted because another window appeared in front of it, that window * will not be overwritten when direct screen access resumes. * In this function, you can resume calls to Window Server Client Side API functions. * * @param aReason Provides the reason why direct screen access was terminated. */ void Restart(RDirectScreenAccess::TTerminationReasons aReason); // from MDirectScreenAccess --
...// other functions
private: CDirectScreenAccess * iDsa; ...// other member data };