This article was originally prepared by Yang. If you need to reselect the article, please indicate the source. Thank you!
In Symbian OS, there are two ways to draw images to reduce flickering:
- Use double cache to draw images (Click here to enter related articles)
- Use the CDirectScreenAccess class to draw the screen directly.
The CDirectScreenAccess class is described as follows:
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.
In addition, CDirectScreenAccess can also intercept the pop-up events of system notification messages (such as menu pop-up, dial-in by phone, and message receipt), so as to avoid unnecessary refresh.
1. simple use of CDirectScreenAccess
CDirectScreenAccess is easy to use. The following steps describe how to use CDirectScreenAccess:
- Use the wizard in Carbide C ++ to generate a GUI application
- Create the member variable CDirectScreenAccess * iDSA in the View class;
- Create a private method void DrawGraphics () in the View class. The Code is as follows:
Void CTestDirectDrawAppView: DrawGraphics ()
{
CFbsBitGc * gc = iDSA-> Gc ();
TRgb colorRed = AKN_LAF_COLOR (35 );
Gc-> SetPenColor (colorRed );
Gc-> DrawRect (TRect (0, 0,100,100 ));
IDSA-> ScreenDevice ()-> Update ();
}
- Add the following code to the ConstructL method of the View class:
CEikonEnv * env = CEikonEnv: Static ();
IDSA = CDirectScreenAccess: NewL (env-> WsSession (), * (env-> ScreenDevice (), this-> Window (), * this );
IDSA-> StartL ();
DrawGraphics ();
- Create the following two private methods in the View class:
Void Restart (RDirectScreenAccess: TTerminationReasons aReason );
Void AbortNow (RDirectScreenAccess: TTerminationReasons aReason );
The implementation is as follows:
Void CTestDirectDrawAppView: Restart (RDirectScreenAccess: TTerminationReasons aReason)
{
IDSA-> StartL ();
DrawGraphics ();
}
Void CTestDirectDrawAppView: AbortNow (RDirectScreenAccess: TTerminationReasons aReason)
{
IDSA-> Cancel ();
}
Click here to download the source code
Ii. Analysis implementation process
1. General Drawing Process
2. Drawing Process when there is a system dialog box notification