sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@test
|
sl@0
|
22 |
@internalComponent - Internal Symbian test code
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
#include "egltest_endpointtearing.h"
|
sl@0
|
27 |
#include "egltest_surface.h"
|
sl@0
|
28 |
#include <e32atomics.h>
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
/**
|
sl@0
|
32 |
@SYMTestCaseID GRAPHICS-EGL-573
|
sl@0
|
33 |
|
sl@0
|
34 |
@SYMTestPriority medium
|
sl@0
|
35 |
|
sl@0
|
36 |
@SYMPREQ 2670
|
sl@0
|
37 |
|
sl@0
|
38 |
@SYMTestCaseDesc
|
sl@0
|
39 |
Image tearing test with raw surface manager surface.
|
sl@0
|
40 |
Check that there is no buffer tearing and that locks are implemented correctly.
|
sl@0
|
41 |
|
sl@0
|
42 |
@SYMTestActions
|
sl@0
|
43 |
Create a Raw Surface Manager surface.
|
sl@0
|
44 |
1) Thread B (test application): Fill the buffers with colours mostly red, and
|
sl@0
|
45 |
mostly blue, and mostly green if triple buffered. This is done so that
|
sl@0
|
46 |
there is a value greater than zero in all colour channels.
|
sl@0
|
47 |
2) Thread A (wserve): Create an endpoint from the surface belonging to the window
|
sl@0
|
48 |
3) Thread B: Submit update.
|
sl@0
|
49 |
4) Thread A: Begin streaming block
|
sl@0
|
50 |
5) Thread A in the windows server for ten seconds, as fast as possible:
|
sl@0
|
51 |
6) Thread A: Acquire an EGLImage from this endpoint
|
sl@0
|
52 |
7) Thread A: Check that the resulting image all a solid colour. Five samples,
|
sl@0
|
53 |
one at the centre and at the four corners should be sufficient.
|
sl@0
|
54 |
8) Thread A: Release the EGLImage
|
sl@0
|
55 |
9) In thread B, whilst thread A is running: fill surface with different solid
|
sl@0
|
56 |
colours, and call Submit Update. Run this thread as fast a possible, with the
|
sl@0
|
57 |
same priority as thread A. The solid colour used should be varied for each
|
sl@0
|
58 |
iteration. Do not synchronize threads A and B, but random waits (using delay
|
sl@0
|
59 |
loops) may be used to give each thread a variation and reduce any
|
sl@0
|
60 |
synchronization in the EGL code.
|
sl@0
|
61 |
10) Thread A: End the streaming block
|
sl@0
|
62 |
11) Thread A & B: Close and delete resources.
|
sl@0
|
63 |
|
sl@0
|
64 |
@SYMTestExpectedResults
|
sl@0
|
65 |
Each acquired image from the endpoint is a solid colour,
|
sl@0
|
66 |
calculated by comparing all the corners and the center pixel.
|
sl@0
|
67 |
*/
|
sl@0
|
68 |
|
sl@0
|
69 |
|
sl@0
|
70 |
CEglTest_LocalTestStep_EndpointTearing::CEglTest_LocalTestStep_EndpointTearing() :
|
sl@0
|
71 |
CLocalTestStepBase(ETestUidEndpointTearing)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
}
|
sl@0
|
74 |
|
sl@0
|
75 |
|
sl@0
|
76 |
CEglTest_LocalTestStep_EndpointTearing::~CEglTest_LocalTestStep_EndpointTearing()
|
sl@0
|
77 |
{
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
void CEglTest_LocalTestStep_EndpointTearing::DoPreambleL()
|
sl@0
|
81 |
{
|
sl@0
|
82 |
//Register the test id.
|
sl@0
|
83 |
_LIT(KTestId, "573");
|
sl@0
|
84 |
RegisterTestIdsL(KTestId);
|
sl@0
|
85 |
SetCurrentTestIds(KTestId);
|
sl@0
|
86 |
|
sl@0
|
87 |
//If this fails, the test will fail in a round about way with EGL_NOT_INITIALIZED.
|
sl@0
|
88 |
eglInitialize(eglGetDisplay(EGL_DEFAULT_DISPLAY), NULL, NULL);
|
sl@0
|
89 |
|
sl@0
|
90 |
//Create the fast locaks used for comms between the test thread and the draw thread.
|
sl@0
|
91 |
User::LeaveIfError(iStartDraw.CreateLocal());
|
sl@0
|
92 |
User::LeaveIfError(iFirstDrawDone.CreateLocal());
|
sl@0
|
93 |
}
|
sl@0
|
94 |
|
sl@0
|
95 |
|
sl@0
|
96 |
void CEglTest_LocalTestStep_EndpointTearing::DoPostambleL()
|
sl@0
|
97 |
{
|
sl@0
|
98 |
iStartDraw.Close();
|
sl@0
|
99 |
iFirstDrawDone.Close();
|
sl@0
|
100 |
eglTerminate(eglGetDisplay(EGL_DEFAULT_DISPLAY));
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|
sl@0
|
103 |
|
sl@0
|
104 |
TVerdict CEglTest_LocalTestStep_EndpointTearing::doTestStepL()
|
sl@0
|
105 |
{
|
sl@0
|
106 |
//Acquire the start drawing lock to force the draw thread to wait until we signal.
|
sl@0
|
107 |
iStartDraw.Wait();
|
sl@0
|
108 |
|
sl@0
|
109 |
//Start drawing thread. When this returns, iSurfaceId
|
sl@0
|
110 |
//contains the surface handle for the surface the thread uses
|
sl@0
|
111 |
//and the draw thread is waiting on iStartDraw.
|
sl@0
|
112 |
StartDrawThreadL();
|
sl@0
|
113 |
|
sl@0
|
114 |
//Params for the remote test step.
|
sl@0
|
115 |
TRemoteTestParams params;
|
sl@0
|
116 |
params.iEndpointTearing.iSurfaceId = iSurfaceId;
|
sl@0
|
117 |
|
sl@0
|
118 |
//Setup the remote test step. (creates an endpoint).
|
sl@0
|
119 |
StartRemoteTestStep(params);
|
sl@0
|
120 |
|
sl@0
|
121 |
//Tell the draw thread to continously fill the surface
|
sl@0
|
122 |
//with a block colour and submit the buffer, honoring the
|
sl@0
|
123 |
//notifyWhenAvailable semantics.
|
sl@0
|
124 |
iStartDraw.Signal();
|
sl@0
|
125 |
|
sl@0
|
126 |
//Wait for the first buffer to be drawn, so that the remote side
|
sl@0
|
127 |
//is guaranteed to be able to begin streaming on the endpoint
|
sl@0
|
128 |
//when we run the remote test case. The remote side continuously
|
sl@0
|
129 |
//checks that each acquired image is a solid colour for a set time.
|
sl@0
|
130 |
iFirstDrawDone.Wait();
|
sl@0
|
131 |
RunRemoteTestCase(0, TRemoteTestParams());
|
sl@0
|
132 |
|
sl@0
|
133 |
//Stop the drawing thread, so that it does not report a 'not
|
sl@0
|
134 |
//registered' error when we end the remote test step (destroy ep).
|
sl@0
|
135 |
StopDrawThread();
|
sl@0
|
136 |
EndRemoteTestStep(TRemoteTestParams());
|
sl@0
|
137 |
|
sl@0
|
138 |
return TestStepResult();
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
|
sl@0
|
142 |
void CEglTest_LocalTestStep_EndpointTearing::StartDrawThreadL()
|
sl@0
|
143 |
{
|
sl@0
|
144 |
//Stack and heap sizes.
|
sl@0
|
145 |
static const TInt KStackSize = 0x2000; // 8KB
|
sl@0
|
146 |
static const TInt KHeapMinSize = 0x1000; // 4KB
|
sl@0
|
147 |
static const TInt KHeapMaxSize = 0x1000000; // 16MB
|
sl@0
|
148 |
|
sl@0
|
149 |
//Create draw thread and wait for rendezvous.
|
sl@0
|
150 |
User::LeaveIfError(iDrawThread.Create(KNullDesC, DrawThreadEntryPoint, KStackSize, KHeapMinSize, KHeapMaxSize, this));
|
sl@0
|
151 |
CleanupClosePushL(iDrawThread);
|
sl@0
|
152 |
iDrawThread.Resume();
|
sl@0
|
153 |
TRequestStatus rendezvous;
|
sl@0
|
154 |
iDrawThread.Rendezvous(rendezvous);
|
sl@0
|
155 |
User::WaitForRequest(rendezvous);
|
sl@0
|
156 |
User::LeaveIfError(rendezvous.Int());
|
sl@0
|
157 |
CleanupStack::Pop(&iDrawThread);
|
sl@0
|
158 |
}
|
sl@0
|
159 |
|
sl@0
|
160 |
|
sl@0
|
161 |
void CEglTest_LocalTestStep_EndpointTearing::StopDrawThread()
|
sl@0
|
162 |
{
|
sl@0
|
163 |
TRequestStatus logon;
|
sl@0
|
164 |
iDrawThread.Logon(logon);
|
sl@0
|
165 |
__e32_atomic_store_rel32(&iStopDrawing, ETrue);
|
sl@0
|
166 |
User::WaitForRequest(logon);
|
sl@0
|
167 |
iDrawThread.Close();
|
sl@0
|
168 |
}
|
sl@0
|
169 |
|
sl@0
|
170 |
|
sl@0
|
171 |
TInt CEglTest_LocalTestStep_EndpointTearing::DrawThreadEntryPoint(TAny* aSelf)
|
sl@0
|
172 |
{
|
sl@0
|
173 |
CEglTest_LocalTestStep_EndpointTearing* self = static_cast<CEglTest_LocalTestStep_EndpointTearing*>(aSelf);
|
sl@0
|
174 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
sl@0
|
175 |
|
sl@0
|
176 |
TRAPD(err,
|
sl@0
|
177 |
//Create active scheduler.
|
sl@0
|
178 |
CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
|
sl@0
|
179 |
CleanupStack::PushL(scheduler);
|
sl@0
|
180 |
CActiveScheduler::Install(scheduler);
|
sl@0
|
181 |
|
sl@0
|
182 |
//Setup the draw loop.
|
sl@0
|
183 |
self->EnterDrawLoopL();
|
sl@0
|
184 |
|
sl@0
|
185 |
//Clean up.
|
sl@0
|
186 |
CleanupStack::PopAndDestroy(scheduler);
|
sl@0
|
187 |
);
|
sl@0
|
188 |
|
sl@0
|
189 |
__ASSERT_ALWAYS(err == KErrNone, User::PanicUnexpectedLeave());
|
sl@0
|
190 |
delete cleanup;
|
sl@0
|
191 |
|
sl@0
|
192 |
return KErrNone;
|
sl@0
|
193 |
}
|
sl@0
|
194 |
|
sl@0
|
195 |
|
sl@0
|
196 |
void CEglTest_LocalTestStep_EndpointTearing::EnterDrawLoopL()
|
sl@0
|
197 |
{
|
sl@0
|
198 |
//Create a standard surface.
|
sl@0
|
199 |
CSurface* surface = CSurface::SurfaceFactoryL(ESurfTypeRaw);
|
sl@0
|
200 |
CleanupStack::PushL(surface);
|
sl@0
|
201 |
surface->CreateL(ELargeSurface);
|
sl@0
|
202 |
|
sl@0
|
203 |
TRequestStatus availableStat[2];
|
sl@0
|
204 |
TInt currentStat = 0;
|
sl@0
|
205 |
TInt currentColour = 0x88CC44;
|
sl@0
|
206 |
|
sl@0
|
207 |
//Take the FirstDrawDone fast lock, save the surfaceId then rendezvous.
|
sl@0
|
208 |
iFirstDrawDone.Wait();
|
sl@0
|
209 |
iSurfaceId = surface->SurfaceId();
|
sl@0
|
210 |
RThread().Rendezvous(KErrNone);
|
sl@0
|
211 |
|
sl@0
|
212 |
//Wait for the signal to draw the first buffer.
|
sl@0
|
213 |
iStartDraw.Wait();
|
sl@0
|
214 |
surface->DrawContentL(TRgb(currentColour, 255));
|
sl@0
|
215 |
surface->Notify(ENotifyWhenAvailable, availableStat[currentStat++ & 1], 0);
|
sl@0
|
216 |
// We must wait until the image is copied; the endpoint isn't ready until the ContentUpdated has been processed by GCE BE.
|
sl@0
|
217 |
// It isn't enough to simply call SubmitContentL; there's multiple process/thread boundaries to cross before the endpoint is 'ready'
|
sl@0
|
218 |
User::LeaveIfError(surface->SubmitContent(ETrue));
|
sl@0
|
219 |
iFirstDrawDone.Signal();
|
sl@0
|
220 |
|
sl@0
|
221 |
//Loop until we are told to stop drawing.
|
sl@0
|
222 |
while(!__e32_atomic_load_acq32(&iStopDrawing))
|
sl@0
|
223 |
{
|
sl@0
|
224 |
//Draw content, ask for notification when the buffer we have drawn to is available and submit.
|
sl@0
|
225 |
surface->DrawContentL(TRgb(currentColour, 255));
|
sl@0
|
226 |
surface->Notify(ENotifyWhenAvailable, availableStat[currentStat++ & 1], 0);
|
sl@0
|
227 |
User::LeaveIfError(surface->SubmitContent(EFalse));
|
sl@0
|
228 |
|
sl@0
|
229 |
//Wait until the other buffer is free, so we don't tear. There are 2 buffers
|
sl@0
|
230 |
//in the surface: We asked for ELargeSurface, which is double buffered.
|
sl@0
|
231 |
TUint32 dummyTimeStamp;
|
sl@0
|
232 |
TInt err = surface->WaitFor(ENotifyWhenAvailable, availableStat[currentStat & 1], 1000, dummyTimeStamp);
|
sl@0
|
233 |
User::LeaveIfError(err);
|
sl@0
|
234 |
|
sl@0
|
235 |
//Modify the colour that we draw.
|
sl@0
|
236 |
currentColour += 16;
|
sl@0
|
237 |
}
|
sl@0
|
238 |
|
sl@0
|
239 |
CleanupStack::PopAndDestroy(surface);
|
sl@0
|
240 |
}
|