00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "CGfxDirectScreenBitmap.h"
00030 #include <coemain.h>
00031 #include <cdsb.h>
00032
00033
00034 CGfxDirectScreenBitmap::CGfxDirectScreenBitmap(RWsSession& aClient,
00035 RWindow& aWindow):
00036 CActive(CActive::EPriorityStandard),
00037 iClient(aClient),
00038 iWindow(aWindow)
00039 {
00040 }
00041
00042 void CGfxDirectScreenBitmap::ConstructL()
00043 {
00044
00045 iDSBitmap =CDirectScreenBitmap::NewL();
00046
00047
00048 iDirectScreenAccess = CDirectScreenAccess::NewL(
00049 iClient,
00050 *(CCoeEnv::Static()->ScreenDevice()),
00051 iWindow,
00052 *this
00053 );
00054
00055 CActiveScheduler::Add(this);
00056 }
00057
00058 CGfxDirectScreenBitmap::~CGfxDirectScreenBitmap()
00059 {
00060 Cancel();
00061 delete iDirectScreenAccess;
00062 delete iDSBitmap;
00063 }
00064
00065
00066
00067 void CGfxDirectScreenBitmap::Restart(RDirectScreenAccess::TTerminationReasons )
00068 {
00069
00070 }
00071
00072 void CGfxDirectScreenBitmap::AbortNow(RDirectScreenAccess::TTerminationReasons )
00073 {
00074 Cancel();
00075 }
00076
00077 void CGfxDirectScreenBitmap::RunL()
00078 {
00079 ProcessFrame();
00080 }
00081
00082 void CGfxDirectScreenBitmap::DoCancel()
00083 {
00084
00085
00086 iDirectScreenAccess->Cancel();
00087 iDSBitmap->Close();
00088 }
00089
00090 TAcceleratedBitmapInfo CGfxDirectScreenBitmap::BeginDraw()
00091 {
00092 TAcceleratedBitmapInfo bitmapInfo;
00093 iDSBitmap->BeginUpdate(bitmapInfo);
00094 return bitmapInfo;
00095 }
00096
00097
00098
00099
00100 void CGfxDirectScreenBitmap::EndDraw()
00101 {
00102 if(IsActive())
00103 {
00104 Cancel();
00105 }
00106 iDSBitmap->EndUpdate(iStatus);
00107 SetActive();
00108 }
00109
00110
00111
00112 void CGfxDirectScreenBitmap::ProcessFrame()
00113 {
00114 TAcceleratedBitmapInfo bmpInfo = BeginDraw();
00115 TUint8* screenAddress = bmpInfo.iAddress;
00116 TUint8* p = screenAddress;
00117
00118 TInt width = bmpInfo.iSize.iWidth;
00119 TInt height = bmpInfo.iSize.iHeight;
00120
00121 TInt byteShift = (1<< bmpInfo.iPixelShift)/8;
00122 if( bmpInfo.iPixelShift == 32 )
00123 byteShift = 4;
00124
00125 const TInt padding = byteShift -3;
00126 const TInt rowWidthInBytes = bmpInfo.iLinePitch;
00127
00128 TInt y=height;
00129 while(--y)
00130 {
00131 TUint8* b=p;
00132 for(TInt x=0; x<width; x++)
00133 {
00134 (*b++) = 255;
00135 (*b++) = (x+iFrameCounter)%64 * 4;
00136 (*b++) = (y+(iFrameCounter/2))%64 * 4;
00137 b+=padding;
00138 }
00139 p += rowWidthInBytes;
00140 }
00141
00142 iFrameCounter++;
00143 EndDraw();
00144
00145 }
00146
00147 void CGfxDirectScreenBitmap::StartL(TRect &aRect)
00148 {
00149 iControlScreenRect = aRect;
00150 User::LeaveIfError(
00151 iDSBitmap->Create(iControlScreenRect, CDirectScreenBitmap::EDoubleBuffer));
00152
00153
00154 iDirectScreenAccess -> StartL();
00155
00156 iGc = iDirectScreenAccess -> Gc();
00157 iGc -> SetBrushStyle(CGraphicsContext::ESolidBrush);
00158
00159 iRegion = iDirectScreenAccess -> DrawingRegion();
00160
00161 iGc -> SetClippingRegion(iRegion);
00162
00163 ProcessFrame();
00164 }
00165
00166 void CGfxDirectScreenBitmap::StopL()
00167 {
00168 Cancel();
00169 }
00170