|
1 #include <w32std.h> |
|
2 #include "profiler.h" |
|
3 |
|
4 #include <graphics/surfacemanager.h> |
|
5 #include <graphics/surfaceupdateclient.h> |
|
6 const TSize KSize(64,60); |
|
7 const TInt KRow = 4; |
|
8 const TInt KCol = 5; |
|
9 |
|
10 void MainL() |
|
11 { |
|
12 RWsSession ws; |
|
13 ws.Connect(); |
|
14 CWsScreenDevice* scr = new(ELeave) CWsScreenDevice(ws); |
|
15 scr->Construct(); |
|
16 CWindowGc* gc = new(ELeave) CWindowGc(scr); |
|
17 gc->Construct(); |
|
18 RWindowGroup grp(ws); |
|
19 grp.Construct(0xc0decafe, ETrue); |
|
20 RWindow win(ws); |
|
21 win.Construct(grp, 0xbeefcafe); |
|
22 win.SetExtent(TPoint(20,160), TSize(320,240)); |
|
23 win.Activate(); |
|
24 win.Invalidate(); |
|
25 win.BeginRedraw(); |
|
26 gc->Activate(win); |
|
27 gc->SetPenStyle(CGraphicsContext::ENullPen); |
|
28 gc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
29 TBool color = EFalse; |
|
30 |
|
31 if (Profiler::Start() == KErrNotFound) |
|
32 { |
|
33 _LIT(KProfiler,"profiler"); |
|
34 _LIT(KStart,"start -noui -drive=S"); |
|
35 RProcess p; |
|
36 if (p.Create(KProfiler,KStart) == KErrNone) |
|
37 { |
|
38 p.Resume(); |
|
39 p.Close(); |
|
40 } |
|
41 } |
|
42 |
|
43 for (TInt col=0; col<KCol; ++col) |
|
44 { |
|
45 color = !color; |
|
46 for (TInt row=0; row<KRow; ++row) |
|
47 { |
|
48 TRect rect; |
|
49 rect.iTl.iX = col * KSize.iWidth; |
|
50 rect.iTl.iY = row * KSize.iHeight; |
|
51 rect.SetSize(KSize); |
|
52 color = !color; |
|
53 gc->SetBrushColor(color? KRgbGreen : KRgbBlack); |
|
54 gc->DrawRect(rect); |
|
55 } |
|
56 } |
|
57 |
|
58 // Open the surface manager |
|
59 RSurfaceManager surfaceManager; |
|
60 User::LeaveIfError(surfaceManager.Open()); |
|
61 // Store the attributes used to create the Surface |
|
62 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
63 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
64 |
|
65 attributes.iSize = TSize(361,341); // w > 0, h > 0 |
|
66 attributes.iBuffers = 4; // > 0, <= 4 |
|
67 attributes.iPixelFormat = EUidPixelFormatYUV_422Planar; // 2bpp |
|
68 attributes.iStride = 1400; // > 0, width * bpp |
|
69 attributes.iOffsetToFirstBuffer = 184; // > 0, divisible by alignment |
|
70 attributes.iAlignment = 4; // 1 || 2 || 4 || 8 |
|
71 attributes.iContiguous = EFalse; |
|
72 attributes.iMappable = ETrue; |
|
73 |
|
74 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
75 attributes.iHintCount=2; |
|
76 hints[0].Set(TUid::Uid(0x124578), 20, ETrue); |
|
77 hints[1].Set(TUid::Uid(0x237755), 50, EFalse); |
|
78 attributes.iSurfaceHints = hints; |
|
79 |
|
80 attributes.iOffsetBetweenBuffers = 0; |
|
81 // Create a surface |
|
82 TSurfaceId surfaceId; |
|
83 User::LeaveIfError(surfaceManager.CreateSurface(buf, surfaceId)); |
|
84 |
|
85 // We have a surface, so map it in. |
|
86 RChunk chunk; |
|
87 TInt err = surfaceManager.MapSurface(surfaceId, chunk); |
|
88 if ( err == KErrNone) |
|
89 { |
|
90 // Get info about it |
|
91 RSurfaceManager::TInfoBuf buf; |
|
92 RSurfaceManager::TSurfaceInfoV01& surfaceInfo = buf(); |
|
93 |
|
94 surfaceManager.SurfaceInfo(surfaceId, buf); |
|
95 } |
|
96 |
|
97 |
|
98 win.SetBackgroundSurface(surfaceId); |
|
99 gc->Deactivate(); |
|
100 win.EndRedraw(); |
|
101 ws.Flush(); |
|
102 User::After(3000000); |
|
103 win.Close(); |
|
104 grp.Close(); |
|
105 delete gc; |
|
106 delete scr; |
|
107 ws.Close(); |
|
108 |
|
109 Profiler::Stop(); |
|
110 Profiler::Close(); |
|
111 Profiler::Unload(); |
|
112 |
|
113 } |
|
114 |
|
115 |
|
116 GLDEF_C TInt E32Main() |
|
117 { |
|
118 |
|
119 CTrapCleanup* tc = CTrapCleanup::New(); |
|
120 if (!tc) |
|
121 { |
|
122 return KErrNoMemory; |
|
123 } |
|
124 TRAPD(err, MainL()); |
|
125 delete tc; |
|
126 return err; |
|
127 } |