summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/src/video/symbian
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/sdl/src/video/symbian')
-rw-r--r--apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocevents.cpp626
-rw-r--r--apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.cpp1356
-rw-r--r--apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.h34
-rw-r--r--apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocevents.cpp521
-rw-r--r--apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocvideo.cpp594
-rw-r--r--apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocvideo.h51
-rw-r--r--apps/plugins/sdl/src/video/symbian/EKA2/dsa.cpp1505
-rw-r--r--apps/plugins/sdl/src/video/symbian/EKA2/dsa_new.cpp1443
-rw-r--r--apps/plugins/sdl/src/video/symbian/EKA2/dsa_old.cpp1075
-rw-r--r--apps/plugins/sdl/src/video/symbian/SDL_epocevents_c.h60
10 files changed, 0 insertions, 7265 deletions
diff --git a/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocevents.cpp b/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocevents.cpp
deleted file mode 100644
index 5ceed5fe3b..0000000000
--- a/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocevents.cpp
+++ /dev/null
@@ -1,626 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@devolution.com
21*/
22
23/*
24 SDL_epocevents.cpp
25 Handle the event stream, converting Epoc events into SDL events
26
27 Epoc version by Hannu Viitala (hannu.j.viitala@mbnet.fi)
28*/
29
30
31#include <stdio.h>
32#undef NULL
33extern "C" {
34//#define DEBUG_TRACE_ENABLED
35#include "SDL_error.h"
36#include "SDL_video.h"
37#include "SDL_keysym.h"
38#include "SDL_keyboard.h"
39#include "SDL_events_c.h"
40#include "SDL_timer.h"
41}; /* extern "C" */
42
43#include "SDL_epocvideo.h"
44#include "SDL_epocevents_c.h"
45
46#include<linereader.h>
47#include<bautils.h>
48
49
50#include <hal.h>
51
52extern "C" {
53/* The translation tables from a console scancode to a SDL keysym */
54static SDLKey keymap[MAX_SCANCODE];
55static SDL_keysym *TranslateKey(_THIS, int scancode, SDL_keysym *keysym);
56void DisableKeyBlocking(_THIS);
57}; /* extern "C" */
58
59TBool isCursorVisible = EFalse;
60
61int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
62{
63 int posted = 0;
64 SDL_keysym keysym;
65
66// SDL_TRACE1("hws %d", aWsEvent.Type());
67
68 switch (aWsEvent.Type())
69 {
70 case EEventPointer: /* Mouse pointer events */
71 {
72
73 const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode();
74
75 if(mode == EPointerCursorNone)
76 {
77 return 0; //TODO: Find out why events are get despite of cursor should be off
78 }
79
80 const TPointerEvent* pointerEvent = aWsEvent.Pointer();
81 TPoint mousePos = pointerEvent->iPosition;
82
83 /*!! TODO Pointer do not yet work properly
84 //SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!!
85
86 if (Private->EPOC_ShrinkedHeight) {
87 mousePos.iY <<= 1; // Scale y coordinate to shrinked screen height
88 }
89 if (Private->EPOC_ShrinkedWidth) {
90 mousePos.iX <<= 1; // Scale x coordinate to shrinked screen width
91 }
92 */
93
94 posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */
95
96 switch (pointerEvent->iType)
97 {
98 case TPointerEvent::EButton1Down:
99 posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
100 break;
101 case TPointerEvent::EButton1Up:
102 posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
103 break;
104 case TPointerEvent::EButton2Down:
105 posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
106 break;
107 case TPointerEvent::EButton2Up:
108 posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
109 break;
110 case TPointerEvent::EButton3Down:
111 posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0);
112 break;
113 case TPointerEvent::EButton3Up:
114 posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);
115 break;
116 } // switch
117 break;
118 }
119
120 case EEventKeyDown: /* Key events */
121 {
122#ifdef SYMBIAN_CRYSTAL
123 // special case: 9300/9500 rocker down, simulate left mouse button
124 if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
125 {
126 const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode();
127 if(mode != EPointerCursorNone)
128 posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
129 }
130#endif
131 (void*)TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym);
132
133#ifndef DISABLE_JOYSTICK
134 /* Special handling */
135 switch((int)keysym.sym) {
136 case SDLK_CAPSLOCK:
137 if (!isCursorVisible) {
138 /* Enable virtual cursor */
139 HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
140 }
141 else {
142 /* Disable virtual cursor */
143 HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
144 }
145 isCursorVisible = !isCursorVisible;
146 break;
147 }
148#endif
149 posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
150 break;
151 }
152
153 case EEventKeyUp: /* Key events */
154 {
155#ifdef SYMBIAN_CRYSTAL
156 // special case: 9300/9500 rocker up, simulate left mouse button
157 if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
158 {
159 posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
160 }
161#endif
162 posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym));
163 break;
164 }
165
166 case EEventFocusGained: /* SDL window got focus */
167 {
168 Private->EPOC_IsWindowFocused = ETrue;
169 posted += SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
170 /* Draw window background and screen buffer */
171 DisableKeyBlocking(_this); //Markus: guess why:-)
172
173 RedrawWindowL(_this);
174 break;
175 }
176
177 case EEventFocusLost: /* SDL window lost focus */
178 {
179/*
180 CFbsBitmap* bmp = new (ELeave) CFbsBitmap();
181 bmp->Create(Private->EPOC_ScreenSize, Private->EPOC_DisplayMode);
182 Private->EPOC_WsScreen->CopyScreenToBitmap(bmp);
183 Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow);
184 Private->EPOC_WsWindow.BeginRedraw(TRect(Private->EPOC_WsWindow.Size()));
185 Private->EPOC_WindowGc->BitBlt(TPoint(0, 0), bmp);
186 Private->EPOC_WsWindow.EndRedraw();
187 Private->EPOC_WindowGc->Deactivate();
188 bmp->Save(_L("C:\\scr.mbm"));
189 delete bmp;
190*/
191
192 Private->EPOC_IsWindowFocused = EFalse;
193
194 posted += SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
195
196 RWsSession s;
197 s.Connect();
198 RWindowGroup g(s);
199 g.Construct(TUint32(&g), EFalse);
200 g.EnableReceiptOfFocus(EFalse);
201 RWindow w(s);
202 w.Construct(g, TUint32(&w));
203 w.SetExtent(TPoint(0, 0), Private->EPOC_WsWindow.Size());
204 w.SetOrdinalPosition(0);
205 w.Activate();
206 w.Close();
207 g.Close();
208 s.Close();
209
210/*
211 Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(Private->EPOC_WsWindowGroupID, -1);
212
213
214 SDL_Delay(500);
215 TInt focus = -1;
216 while(focus < 0)
217 {
218 const TInt curr = Private->EPOC_WsSession.GetFocusWindowGroup();
219 if(curr != Private->EPOC_WsWindowGroupID)
220 focus = curr;
221 else
222 SDL_Delay(500);
223 }
224
225 if(1 < Private->EPOC_WsSession.GetWindowGroupOrdinalPriority(Private->EPOC_WsWindowGroupID))
226 {
227 Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(focus, -1);
228 SDL_Delay(500);
229 Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(focus, 0);
230 }
231*/
232 /*//and the request redraw
233 TRawEvent redrawEvent;
234 redrawEvent.Set(TRawEvent::ERedraw);
235 Private->EPOC_WsSession.SimulateRawEvent(redrawEvent);
236 Private->EPOC_WsSession.Flush();*/
237#if 0
238 //!! Not used
239 // Wait and eat events until focus is gained again
240 while (ETrue) {
241 Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
242 User::WaitForRequest(Private->EPOC_WsEventStatus);
243 Private->EPOC_WsSession.GetEvent(Private->EPOC_WsEvent);
244 TInt eventType = Private->EPOC_WsEvent.Type();
245 Private->EPOC_WsEventStatus = KRequestPending;
246 //Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
247 if (eventType == EEventFocusGained) {
248 RedrawWindowL(_this);
249 break;
250 }
251 }
252#endif
253 break;
254 }
255
256 case EEventModifiersChanged:
257 {
258 TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged();
259 TUint modstate = KMOD_NONE;
260 if (modEvent->iModifiers == EModifierLeftShift)
261 modstate |= KMOD_LSHIFT;
262 if (modEvent->iModifiers == EModifierRightShift)
263 modstate |= KMOD_RSHIFT;
264 if (modEvent->iModifiers == EModifierLeftCtrl)
265 modstate |= KMOD_LCTRL;
266 if (modEvent->iModifiers == EModifierRightCtrl)
267 modstate |= KMOD_RCTRL;
268 if (modEvent->iModifiers == EModifierLeftAlt)
269 modstate |= KMOD_LALT;
270 if (modEvent->iModifiers == EModifierRightAlt)
271 modstate |= KMOD_RALT;
272 if (modEvent->iModifiers == EModifierLeftFunc)
273 modstate |= KMOD_LMETA;
274 if (modEvent->iModifiers == EModifierRightFunc)
275 modstate |= KMOD_RMETA;
276 if (modEvent->iModifiers == EModifierCapsLock)
277 modstate |= KMOD_CAPS;
278 SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT)));
279 break;
280 }
281 default:
282 break;
283 }
284
285 return posted;
286}
287
288extern "C" {
289
290void EPOC_PumpEvents(_THIS)
291{
292 int posted = 0; // !! Do we need this?
293 //Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
294 while (Private->EPOC_WsEventStatus != KRequestPending) {
295
296 Private->EPOC_WsSession.GetEvent(Private->EPOC_WsEvent);
297 posted = EPOC_HandleWsEvent(_this, Private->EPOC_WsEvent);
298 Private->EPOC_WsEventStatus = KRequestPending;
299 Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
300 }
301}
302
303
304_LIT(KMapFileName, "C:\\sdl_info\\sdlkeymap.cfg");
305LOCAL_C void ReadL(RFs& aFs, RArray<TInt>& aArray)
306 {
307 TInt drive = -1;
308 TFileName name(KMapFileName);
309 for(TInt i = 'z'; drive < 0 && i >= 'a'; i--)
310 {
311 name[0] = (TUint16)i;
312 if(BaflUtils::FileExists(aFs, name))
313 drive = i;
314 }
315 if(drive < 0)
316 return;
317 CLineReader* reader = CLineReader::NewLC(aFs, name);
318 while(reader->NextL())
319 {
320 TPtrC ln = reader->Current();
321 TLex line(ln);
322 TInt n = 0;
323 for(;;)
324 {
325 const TPtrC token = line.NextToken();
326 if(token.Length() == 0)
327 break;
328 if((n & 1) != 0)
329 {
330 TInt value;
331 TLex lex(token);
332 User::LeaveIfError(lex.Val(value));
333 User::LeaveIfError(aArray.Append(value));
334 }
335 n++;
336 }
337 }
338 CleanupStack::PopAndDestroy();
339 }
340
341
342void EPOC_InitOSKeymap(_THIS)
343{
344 int i;
345
346 /* Initialize the key translation table */
347 for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
348 keymap[i] = SDLK_UNKNOWN;
349
350
351 /* Numbers */
352 for ( i = 0; i<32; ++i ){
353 keymap[' ' + i] = (SDLKey)(SDLK_SPACE+i);
354 }
355 /* e.g. Alphabet keys */
356 for ( i = 0; i<32; ++i ){
357 keymap['A' + i] = (SDLKey)(SDLK_a+i);
358 }
359
360 keymap[EStdKeyBackspace] = SDLK_BACKSPACE;
361 keymap[EStdKeyTab] = SDLK_TAB;
362 keymap[EStdKeyEnter] = SDLK_RETURN;
363 keymap[EStdKeyEscape] = SDLK_ESCAPE;
364 keymap[EStdKeySpace] = SDLK_SPACE;
365 keymap[EStdKeyPause] = SDLK_PAUSE;
366 keymap[EStdKeyHome] = SDLK_HOME;
367 keymap[EStdKeyEnd] = SDLK_END;
368 keymap[EStdKeyPageUp] = SDLK_PAGEUP;
369 keymap[EStdKeyPageDown] = SDLK_PAGEDOWN;
370 keymap[EStdKeyDelete] = SDLK_DELETE;
371 keymap[EStdKeyUpArrow] = SDLK_UP;
372 keymap[EStdKeyDownArrow] = SDLK_DOWN;
373 keymap[EStdKeyLeftArrow] = SDLK_LEFT;
374 keymap[EStdKeyRightArrow] = SDLK_RIGHT;
375 keymap[EStdKeyCapsLock] = SDLK_CAPSLOCK;
376 keymap[EStdKeyLeftShift] = SDLK_LSHIFT;
377 keymap[EStdKeyRightShift] = SDLK_RSHIFT;
378 keymap[EStdKeyLeftAlt] = SDLK_LALT;
379 keymap[EStdKeyRightAlt] = SDLK_RALT;
380 keymap[EStdKeyLeftCtrl] = SDLK_LCTRL;
381 keymap[EStdKeyRightCtrl] = SDLK_RCTRL;
382 keymap[EStdKeyLeftFunc] = SDLK_LMETA;
383 keymap[EStdKeyRightFunc] = SDLK_RMETA;
384 keymap[EStdKeyInsert] = SDLK_INSERT;
385 keymap[EStdKeyComma] = SDLK_COMMA;
386 keymap[EStdKeyFullStop] = SDLK_PERIOD;
387 keymap[EStdKeyForwardSlash] = SDLK_SLASH;
388 keymap[EStdKeyBackSlash] = SDLK_BACKSLASH;
389 keymap[EStdKeySemiColon] = SDLK_SEMICOLON;
390 keymap[EStdKeySingleQuote] = SDLK_QUOTE;
391 keymap[EStdKeyHash] = SDLK_HASH;
392 keymap[EStdKeySquareBracketLeft] = SDLK_LEFTBRACKET;
393 keymap[EStdKeySquareBracketRight] = SDLK_RIGHTBRACKET;
394 keymap[EStdKeyMinus] = SDLK_MINUS;
395 keymap[EStdKeyEquals] = SDLK_EQUALS;
396
397 keymap[EStdKeyF1] = SDLK_F1; /* chr + q */
398 keymap[EStdKeyF2] = SDLK_F2; /* chr + w */
399 keymap[EStdKeyF3] = SDLK_F3; /* chr + e */
400 keymap[EStdKeyF4] = SDLK_F4; /* chr + r */
401 keymap[EStdKeyF5] = SDLK_F5; /* chr + t */
402 keymap[EStdKeyF6] = SDLK_F6; /* chr + y */
403 keymap[EStdKeyF7] = SDLK_F7; /* chr + i */
404 keymap[EStdKeyF8] = SDLK_F8; /* chr + o */
405
406 keymap[EStdKeyF9] = SDLK_F9; /* chr + a */
407 keymap[EStdKeyF10] = SDLK_F10; /* chr + s */
408 keymap[EStdKeyF11] = SDLK_F11; /* chr + d */
409 keymap[EStdKeyF12] = SDLK_F12; /* chr + f */
410
411 #ifndef SYMBIAN_CRYSTAL
412 //!!7650 additions
413 #ifdef __WINS__
414 keymap[EStdKeyXXX] = SDLK_RETURN; /* "fire" key */
415 #else
416 keymap[EStdKeyDevice3] = SDLK_RETURN; /* "fire" key */
417 #endif
418 keymap[EStdKeyNkpAsterisk] = SDLK_ASTERISK;
419 keymap[EStdKeyYes] = SDLK_HOME; /* "call" key */
420 keymap[EStdKeyNo] = SDLK_END; /* "end call" key */
421 keymap[EStdKeyDevice0] = SDLK_SPACE; /* right menu key */
422 keymap[EStdKeyDevice1] = SDLK_ESCAPE; /* left menu key */
423 keymap[EStdKeyDevice2] = SDLK_POWER; /* power key */
424 #endif
425
426 #ifdef SYMBIAN_CRYSTAL
427 keymap[EStdKeyMenu] = SDLK_ESCAPE; // menu key
428 keymap[EStdKeyDevice6] = SDLK_LEFT; // Rocker (joystick) left
429 keymap[EStdKeyDevice7] = SDLK_RIGHT; // Rocker (joystick) right
430 keymap[EStdKeyDevice8] = SDLK_UP; // Rocker (joystick) up
431 keymap[EStdKeyDevice9] = SDLK_DOWN; // Rocker (joystick) down
432 keymap[EStdKeyLeftFunc] = SDLK_LALT; //chr?
433 keymap[EStdKeyRightFunc] = SDLK_RALT;
434 keymap[EStdKeyDeviceA] = SDLK_RETURN; /* "fire" key */
435#endif
436
437 ///////////////////////////////////////////////////////////
438
439 RFs fs;
440 if(KErrNone == fs.Connect())
441 {
442 RArray<TInt> array;
443 TRAPD(err, ReadL(fs, array));
444 if(err == KErrNone && array.Count() > 0)
445 {
446
447 SDLKey temp[MAX_SCANCODE];
448 Mem::Copy(temp, keymap, MAX_SCANCODE * sizeof(SDLKey));
449
450 for(TInt k = 0; k < array.Count(); k+= 2)
451 {
452 const TInt oldval = array[k];
453 const TInt newval = array[k + 1];
454 if(oldval >= 0 && oldval < MAX_SCANCODE && newval >= 0 && newval < MAX_SCANCODE)
455 {
456 keymap[oldval] = temp[newval];
457 }
458 }
459 }
460 array.Close();
461 }
462
463 fs.Close();
464 ///////////////////////////////////////////////////////////
465
466 /* !!TODO
467 EStdKeyNumLock=0x1b,
468 EStdKeyScrollLock=0x1c,
469
470 EStdKeyNkpForwardSlash=0x84,
471 EStdKeyNkpAsterisk=0x85,
472 EStdKeyNkpMinus=0x86,
473 EStdKeyNkpPlus=0x87,
474 EStdKeyNkpEnter=0x88,
475 EStdKeyNkp1=0x89,
476 EStdKeyNkp2=0x8a,
477 EStdKeyNkp3=0x8b,
478 EStdKeyNkp4=0x8c,
479 EStdKeyNkp5=0x8d,
480 EStdKeyNkp6=0x8e,
481 EStdKeyNkp7=0x8f,
482 EStdKeyNkp8=0x90,
483 EStdKeyNkp9=0x91,
484 EStdKeyNkp0=0x92,
485 EStdKeyNkpFullStop=0x93,
486 EStdKeyMenu=0x94,
487 EStdKeyBacklightOn=0x95,
488 EStdKeyBacklightOff=0x96,
489 EStdKeyBacklightToggle=0x97,
490 EStdKeyIncContrast=0x98,
491 EStdKeyDecContrast=0x99,
492 EStdKeySliderDown=0x9a,
493 EStdKeySliderUp=0x9b,
494 EStdKeyDictaphonePlay=0x9c,
495 EStdKeyDictaphoneStop=0x9d,
496 EStdKeyDictaphoneRecord=0x9e,
497 EStdKeyHelp=0x9f,
498 EStdKeyOff=0xa0,
499 EStdKeyDial=0xa1,
500 EStdKeyIncVolume=0xa2,
501 EStdKeyDecVolume=0xa3,
502 EStdKeyDevice0=0xa4,
503 EStdKeyDevice1=0xa5,
504 EStdKeyDevice2=0xa6,
505 EStdKeyDevice3=0xa7,
506 EStdKeyDevice4=0xa8,
507 EStdKeyDevice5=0xa9,
508 EStdKeyDevice6=0xaa,
509 EStdKeyDevice7=0xab,
510 EStdKeyDevice8=0xac,
511 EStdKeyDevice9=0xad,
512 EStdKeyDeviceA=0xae,
513 EStdKeyDeviceB=0xaf,
514 EStdKeyDeviceC=0xb0,
515 EStdKeyDeviceD=0xb1,
516 EStdKeyDeviceE=0xb2,
517 EStdKeyDeviceF=0xb3,
518 EStdKeyApplication0=0xb4,
519 EStdKeyApplication1=0xb5,
520 EStdKeyApplication2=0xb6,
521 EStdKeyApplication3=0xb7,
522 EStdKeyApplication4=0xb8,
523 EStdKeyApplication5=0xb9,
524 EStdKeyApplication6=0xba,
525 EStdKeyApplication7=0xbb,
526 EStdKeyApplication8=0xbc,
527 EStdKeyApplication9=0xbd,
528 EStdKeyApplicationA=0xbe,
529 EStdKeyApplicationB=0xbf,
530 EStdKeyApplicationC=0xc0,
531 EStdKeyApplicationD=0xc1,
532 EStdKeyApplicationE=0xc2,
533 EStdKeyApplicationF=0xc3,
534 EStdKeyYes=0xc4,
535 EStdKeyNo=0xc5,
536 EStdKeyIncBrightness=0xc6,
537 EStdKeyDecBrightness=0xc7,
538 EStdKeyCaseOpen=0xc8,
539 EStdKeyCaseClose=0xc9
540 */
541
542}
543
544
545
546static SDL_keysym *TranslateKey(_THIS, int scancode, SDL_keysym *keysym)
547{
548// char debug[256];
549 //SDL_TRACE1("SDL: TranslateKey, scancode=%d", scancode); //!!
550
551 /* Set the keysym information */
552
553 keysym->scancode = scancode;
554
555 if ((scancode >= MAX_SCANCODE) &&
556 ((scancode - ENonCharacterKeyBase + 0x0081) >= MAX_SCANCODE)) {
557 SDL_SetError("Too big scancode");
558 keysym->scancode = SDLK_UNKNOWN;
559 keysym->mod = KMOD_NONE;
560 return keysym;
561 }
562
563 keysym->mod = SDL_GetModState();
564
565 /* Handle function keys: F1, F2, F3 ... */
566 if (keysym->mod & KMOD_META) {
567 if (scancode >= 'A' && scancode < ('A' + 24)) { /* first 32 alphabet keys */
568 switch(scancode) {
569 case 'Q': scancode = EStdKeyF1; break;
570 case 'W': scancode = EStdKeyF2; break;
571 case 'E': scancode = EStdKeyF3; break;
572 case 'R': scancode = EStdKeyF4; break;
573 case 'T': scancode = EStdKeyF5; break;
574 case 'Y': scancode = EStdKeyF6; break;
575 case 'U': scancode = EStdKeyF7; break;
576 case 'I': scancode = EStdKeyF8; break;
577 case 'A': scancode = EStdKeyF9; break;
578 case 'S': scancode = EStdKeyF10; break;
579 case 'D': scancode = EStdKeyF11; break;
580 case 'F': scancode = EStdKeyF12; break;
581 }
582 keysym->sym = keymap[scancode];
583 }
584 }
585
586 if (scancode >= ENonCharacterKeyBase) {
587 // Non character keys
588 keysym->sym = keymap[scancode -
589 ENonCharacterKeyBase + 0x0081]; // !!hard coded
590 } else {
591 keysym->sym = keymap[scancode];
592 }
593
594 /* Remap the arrow keys if the device is rotated */
595 if (Private->EPOC_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) {
596 switch(keysym->sym) {
597 case SDLK_UP: keysym->sym = SDLK_LEFT; break;
598 case SDLK_DOWN: keysym->sym = SDLK_RIGHT; break;
599 case SDLK_LEFT: keysym->sym = SDLK_DOWN; break;
600 case SDLK_RIGHT:keysym->sym = SDLK_UP; break;
601 }
602 }
603
604 /* If UNICODE is on, get the UNICODE value for the key */
605 keysym->unicode = 0;
606
607#if 0 // !!TODO:unicode
608
609 if ( SDL_TranslateUNICODE )
610 {
611 /* Populate the unicode field with the ASCII value */
612 keysym->unicode = scancode;
613 }
614#endif
615
616 //!!
617 //sprintf(debug, "SDL: TranslateKey: keysym->scancode=%d, keysym->sym=%d, keysym->mod=%d",
618 // keysym->scancode, keysym->sym, keysym->mod);
619 //SDL_TRACE(debug); //!!
620
621 return(keysym);
622}
623
624}; /* extern "C" */
625
626
diff --git a/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.cpp b/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.cpp
deleted file mode 100644
index 06874d546c..0000000000
--- a/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.cpp
+++ /dev/null
@@ -1,1356 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@devolution.com
21*/
22
23/*
24 SDL_epocvideo.cpp
25 Epoc based SDL video driver implementation
26
27 Thanks to Peter van Sebille, the author of EMame. It is a great example of
28 low level graphics coding in Epoc.
29
30 Epoc version by Hannu Viitala (hannu.j.viitala@mbnet.fi)
31 Assembler routines by Kimmo Kinnunen
32*/
33
34
35
36#include <stdlib.h>
37#include <stdio.h>
38#include <string.h>
39
40extern "C" {
41#include "SDL_error.h"
42#include "SDL_timer.h"
43#include "SDL_video.h"
44#undef NULL
45#include "SDL_pixels_c.h"
46#include "SDL.h"
47};
48
49#include "SDL_epocvideo.h"
50#include "SDL_epocevents_c.h"
51
52#include "sdl_epocruntime.h"
53
54#include <hal.h>
55#include <coedef.h>
56#include <flogger.h>
57
58#ifdef SYMBIAN_QUARTZ
59SDL_VideoDevice* _thisDevice;
60#endif
61
62_LIT(KLibName, "SDL");
63
64/* For debugging */
65
66//if old SOS, from 7.x this is public!
67class CLockable : public CFbsBitmap
68 {
69 public:
70 static CLockable* Lockable(CFbsBitmap* aBmp) {return static_cast<CLockable*>(aBmp);}
71 void Lock() {LockHeap();}
72 void Unlock() {UnlockHeap();}
73 };
74#define LockHeap(x) CLockable::Lockable(x)->Lock()
75#define UnlockHeap(x) CLockable::Lockable(x)->Unlock()
76
77void RDebug_Print_b(char* error_str, void* param)
78 {
79 TBuf8<128> error8((TUint8*)error_str);
80 TBuf<128> error;
81 error.Copy(error8);
82
83#ifndef TRACE_TO_FILE
84 if (param) //!! Do not work if the parameter is really 0!!
85 RDebug::Print(error, param);
86 else
87 RDebug::Print(error);
88#else
89 if (param) //!! Do not work if the parameter is really 0!!
90 RFileLogger::WriteFormat(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error, param);
91 else
92 RFileLogger::Write(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error);
93#endif
94
95 }
96
97extern "C" void RDebug_Print(char* error_str, void* param)
98 {
99 RDebug_Print_b(error_str, param);
100 }
101
102
103int Debug_AvailMem2()
104 {
105 //User::CompressAllHeaps();
106 TMemoryInfoV1Buf membuf;
107 User::LeaveIfError(UserHal::MemoryInfo(membuf));
108 TMemoryInfoV1 minfo = membuf();
109 return(minfo.iFreeRamInBytes);
110 }
111
112extern "C" int Debug_AvailMem()
113 {
114 return(Debug_AvailMem2());
115 }
116
117
118extern "C" {
119
120/* Initialization/Query functions */
121
122static int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat);
123static SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
124static SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
125static int EPOC_SetColors(_THIS, int firstcolor, int ncolors,
126 SDL_Color *colors);
127static void EPOC_VideoQuit(_THIS);
128
129/* Hardware surface functions */
130
131static int EPOC_AllocHWSurface(_THIS, SDL_Surface *surface);
132static int EPOC_LockHWSurface(_THIS, SDL_Surface *surface);
133static int EPOC_FlipHWSurface(_THIS, SDL_Surface *surface);
134static void EPOC_UnlockHWSurface(_THIS, SDL_Surface *surface);
135static void EPOC_FreeHWSurface(_THIS, SDL_Surface *surface);
136static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
137
138static int EPOC_Available(void);
139static SDL_VideoDevice *EPOC_CreateDevice(int devindex);
140
141void DrawBackground(_THIS);
142void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer);
143void DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer);
144
145/* Mouse functions */
146
147static WMcursor *EPOC_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
148static void EPOC_FreeWMCursor(_THIS, WMcursor *cursor);
149static int EPOC_ShowWMCursor(_THIS, WMcursor *cursor);
150
151
152
153/* !!For 12 bit screen HW. Table for fast conversion from 8 bit to 12 bit */
154// TUint16 is enough, but using TUint32 so we can use better instruction selection on ARMI
155static TUint32 EPOC_HWPalette_256_to_Screen[256];
156
157VideoBootStrap EPOC_bootstrap = {
158 "epoc", "EPOC system",
159 EPOC_Available, EPOC_CreateDevice
160};
161
162const TUint32 WindowClientHandle = 9210; //!! const
163
164/* Epoc video driver bootstrap functions */
165
166static int EPOC_Available(void)
167{
168 return 1; /* Always available */
169}
170
171static void EPOC_DeleteDevice(SDL_VideoDevice *device)
172{
173 free(device->hidden);
174 free(device);
175}
176
177static SDL_VideoDevice *EPOC_CreateDevice(int /*devindex*/)
178{
179 SDL_VideoDevice *device;
180
181 SDL_TRACE("SDL:EPOC_CreateDevice");
182
183 /* Allocate all variables that we free on delete */
184 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
185 if ( device ) {
186 memset(device, 0, (sizeof *device));
187 device->hidden = (struct SDL_PrivateVideoData *)
188 malloc((sizeof *device->hidden));
189 }
190 if ( (device == NULL) || (device->hidden == NULL) ) {
191 SDL_OutOfMemory();
192 if ( device ) {
193 free(device);
194 }
195 return(0);
196 }
197 memset(device->hidden, 0, (sizeof *device->hidden));
198
199 /* Set the function pointers */
200 device->VideoInit = EPOC_VideoInit;
201 device->ListModes = EPOC_ListModes;
202 device->SetVideoMode = EPOC_SetVideoMode;
203 device->SetColors = EPOC_SetColors;
204 device->UpdateRects = NULL;
205 device->VideoQuit = EPOC_VideoQuit;
206 device->AllocHWSurface = EPOC_AllocHWSurface;
207 device->CheckHWBlit = NULL;
208 device->FillHWRect = NULL;
209 device->SetHWColorKey = NULL;
210 device->SetHWAlpha = NULL;
211 device->LockHWSurface = EPOC_LockHWSurface;
212 device->UnlockHWSurface = EPOC_UnlockHWSurface;
213 device->FlipHWSurface = EPOC_FlipHWSurface;
214 device->FreeHWSurface = EPOC_FreeHWSurface;
215 device->SetIcon = NULL;
216 device->SetCaption = NULL;
217 device->GetWMInfo = NULL;
218 device->FreeWMCursor = EPOC_FreeWMCursor;
219 device->CreateWMCursor = EPOC_CreateWMCursor;
220 device->ShowWMCursor = EPOC_ShowWMCursor;
221 device->WarpWMCursor = NULL;
222 device->InitOSKeymap = EPOC_InitOSKeymap;
223 device->PumpEvents = EPOC_PumpEvents;
224 device->free = EPOC_DeleteDevice;
225
226 return device;
227}
228
229
230int GetBpp(TDisplayMode displaymode)
231{
232 /*TInt numColors = TDisplayModeUtils::NumDisplayModeColors(displaymode);
233 TInt bitsPerPixel = 1;
234 for (TInt32 i = 2; i < numColors; i <<= 1, bitsPerPixel++);
235 return bitsPerPixel;*/
236 return TDisplayModeUtils::NumDisplayModeBitsPerPixel(displaymode);
237}
238
239
240void DisableKeyBlocking(_THIS)
241 {
242 // Disable key blocking
243 TRawEvent event;
244 event.Set((TRawEvent::TType)/*EDisableKeyBlock*/51); // !!EDisableKeyBlock not found in epoc32\include!
245 Private->EPOC_WsSession.SimulateRawEvent(event);
246 }
247
248void ConstructWindowL(_THIS)
249{
250 TInt error;
251
252 SDL_TRACE("SDL:ConstructWindowL");
253 error = Private->EPOC_WsSession.Connect();
254 User::LeaveIfError(error);
255 Private->EPOC_WsScreen=new(ELeave) CWsScreenDevice(Private->EPOC_WsSession);
256 User::LeaveIfError(Private->EPOC_WsScreen->Construct());
257 User::LeaveIfError(Private->EPOC_WsScreen->CreateContext(Private->EPOC_WindowGc));
258
259 Private->EPOC_WsWindowGroup=RWindowGroup(Private->EPOC_WsSession);
260 User::LeaveIfError(Private->EPOC_WsWindowGroup.Construct(WindowClientHandle));
261 Private->EPOC_WsWindowGroup.SetOrdinalPosition(0);
262
263 // Set window group name (the same as process name)) !!Gives always "EPOC" in WINS
264 RProcess thisProcess;
265 TParse exeName;
266 exeName.Set(thisProcess.FileName(), NULL, NULL);
267 TBuf<32> winGroupName;
268 winGroupName.Append(0);
269 winGroupName.Append(0);
270 winGroupName.Append(0);// uid
271 winGroupName.Append(0);
272 winGroupName.Append(exeName.Name()); // caption
273 winGroupName.Append(0);
274 winGroupName.Append(0); //doc name
275 Private->EPOC_WsWindowGroup.SetName(winGroupName);
276
277 Private->EPOC_WsWindow=RWindow(Private->EPOC_WsSession);
278 // Markus, it was:
279 // User::LeaveIfError(Private->EPOC_WsWindow.Construct(Private->EPOC_WsWindowGroup,WindowClientHandle ));
280 // but SOS 7.0s debug does not accept same window handle twice
281 User::LeaveIfError(Private->EPOC_WsWindow.Construct(Private->EPOC_WsWindowGroup,WindowClientHandle - 1));
282 Private->EPOC_WsWindow.SetBackgroundColor(KRgbWhite);
283 Private->EPOC_WsWindow.Activate();
284 Private->EPOC_WsWindow.SetSize(Private->EPOC_WsScreen->SizeInPixels());
285 Private->EPOC_WsWindow.SetVisible(ETrue);
286
287 Private->EPOC_WsWindowGroupID = Private->EPOC_WsWindowGroup.Identifier();
288 Private->EPOC_IsWindowFocused = EFalse;
289
290 DisableKeyBlocking(_this); //disable key blocking
291}
292
293int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat)
294{
295 // !!TODO:handle leave functions!
296
297 int i;
298
299 SDL_TRACE("SDL:EPOC_VideoInit");
300
301 /* Initialize all variables that we clean on shutdown */
302
303 for ( i=0; i<SDL_NUMMODES; ++i ) {
304 Private->SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
305 Private->SDL_modelist[i]->x = Private->SDL_modelist[i]->y = 0;
306 }
307
308 /* Modes sorted largest to smallest */
309 Private->SDL_modelist[0]->w = 800; Private->SDL_modelist[0]->h = 250;
310 Private->SDL_modelist[1]->w = 640; Private->SDL_modelist[1]->h = 480;
311 Private->SDL_modelist[2]->w = 480; Private->SDL_modelist[2]->h = 600;
312 Private->SDL_modelist[3]->w = 640; Private->SDL_modelist[3]->h = 400;
313 Private->SDL_modelist[4]->w = 352; Private->SDL_modelist[4]->h = 416;
314 Private->SDL_modelist[5]->w = 416; Private->SDL_modelist[5]->h = 352;
315 Private->SDL_modelist[6]->w = 416; Private->SDL_modelist[6]->h = 312;
316 Private->SDL_modelist[7]->w = 352; Private->SDL_modelist[7]->h = 264;
317 Private->SDL_modelist[8]->w = 800; Private->SDL_modelist[8]->h = 240; //for doom all these..
318 Private->SDL_modelist[9]->w = 640; Private->SDL_modelist[9]->h = 240;
319 Private->SDL_modelist[10]->w = 480; Private->SDL_modelist[10]->h = 240;
320 Private->SDL_modelist[11]->w = 640; Private->SDL_modelist[11]->h = 240;
321 Private->SDL_modelist[12]->w = 352; Private->SDL_modelist[12]->h = 240;
322 Private->SDL_modelist[13]->w = 416; Private->SDL_modelist[13]->h = 240;
323 Private->SDL_modelist[14]->w = 416; Private->SDL_modelist[14]->h = 240;
324 Private->SDL_modelist[15]->w = 352; Private->SDL_modelist[15]->h = 240;
325 Private->SDL_modelist[16]->w = 640; Private->SDL_modelist[16]->h = 200;
326 Private->SDL_modelist[17]->w = 320; Private->SDL_modelist[17]->h = 240; //...for doom, currently engine renders no-higher windows :-(, propably should get fixed
327 Private->SDL_modelist[18]->w = 320; Private->SDL_modelist[18]->h = 200;
328 Private->SDL_modelist[19]->w = 256; Private->SDL_modelist[19]->h = 192;
329 Private->SDL_modelist[20]->w = 176; Private->SDL_modelist[20]->h = 208;
330 Private->SDL_modelist[21]->w = 208; Private->SDL_modelist[21]->h = 176; // Rotated
331 Private->SDL_modelist[22]->w = 160; Private->SDL_modelist[22]->h = 144;
332
333 Private->SDL_modelist[23]->w = 640; Private->SDL_modelist[2]->h = 200; //s80 some new modes
334 Private->SDL_modelist[24]->w = 640; Private->SDL_modelist[2]->h = 320; //s90 modes are added
335 Private->SDL_modelist[25]->w = 640; Private->SDL_modelist[2]->h = 240; //here
336 Private->SDL_modelist[26]->w = 640; Private->SDL_modelist[4]->h = 200; //now
337
338 Private->SDL_modelist[27] = NULL;
339
340 /* Construct Epoc window */
341
342 ConstructWindowL(_this);
343
344 /* Initialise Epoc frame buffer */
345
346 TDisplayMode displayMode = Private->EPOC_WsScreen->DisplayMode();
347
348#if !defined(__WINS__) && !defined(TEST_BM_DRAW)
349
350 TScreenInfoV01 screenInfo;
351 TPckg<TScreenInfoV01> sInfo(screenInfo);
352 UserSvr::ScreenInfo(sInfo);
353
354 Private->EPOC_ScreenSize = screenInfo.iScreenSize;
355 Private->EPOC_DisplayMode = displayMode;
356 Private->EPOC_HasFrameBuffer = screenInfo.iScreenAddressValid;
357 Private->EPOC_FrameBuffer = Private->EPOC_HasFrameBuffer ? (TUint8*) screenInfo.iScreenAddress : NULL;
358 Private->EPOC_BytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1;
359
360 Private->EPOC_BytesPerScanLine = screenInfo.iScreenSize.iWidth * Private->EPOC_BytesPerPixel;
361 Private->EPOC_BytesPerScreen = Private->EPOC_BytesPerScanLine * Private->EPOC_ScreenSize.iHeight;
362
363 SDL_TRACE1("Screen width %d", screenInfo.iScreenSize.iWidth);
364 SDL_TRACE1("Screen height %d", screenInfo.iScreenSize.iHeight);
365 SDL_TRACE1("Screen dmode %d", displayMode);
366 SDL_TRACE1("Screen valid %d", screenInfo.iScreenAddressValid);
367
368 SDL_TRACE1("bpp %d", Private->EPOC_BytesPerPixel);
369 SDL_TRACE1("bpsl %d", Private->EPOC_BytesPerScanLine);
370 SDL_TRACE1("bps %d", Private->EPOC_BytesPerScreen);
371
372
373 /* It seems that in SA1100 machines for 8bpp displays there is a 512 palette table at the
374 * beginning of the frame buffer. E.g. Series 7 and Netbook.
375 * In 12 bpp machines the table has 16 entries.
376 */
377 if (Private->EPOC_HasFrameBuffer && GetBpp(displayMode) == 8)
378 {
379 Private->EPOC_FrameBuffer += 512;
380 }
381 else
382 {
383 Private->EPOC_FrameBuffer += 32;
384 }
385 /*if (Private->EPOC_HasFrameBuffer && GetBpp(displayMode) == 12)
386 Private->EPOC_FrameBuffer += 16 * 2;
387 if (Private->EPOC_HasFrameBuffer && GetBpp(displayMode) == 16)
388 Private->EPOC_FrameBuffer += 16 * 2;
389 */
390#else /* defined __WINS__ */
391
392 /* Create bitmap, device and context for screen drawing */
393 Private->EPOC_ScreenSize = Private->EPOC_WsScreen->SizeInPixels();
394
395 Private->EPOC_Bitmap = new (ELeave) CWsBitmap(Private->EPOC_WsSession);
396 Private->EPOC_Bitmap->Create(Private->EPOC_ScreenSize, displayMode);
397
398 Private->EPOC_DisplayMode = displayMode;
399 Private->EPOC_HasFrameBuffer = ETrue;
400 Private->EPOC_FrameBuffer = NULL; /* Private->EPOC_Bitmap->DataAddress() can change any time */
401 Private->EPOC_BytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1;
402 Private->EPOC_BytesPerScanLine = Private->EPOC_WsScreen->SizeInPixels().iWidth * Private->EPOC_BytesPerPixel;
403
404#endif /* __WINS__ */
405
406#ifndef SYMBIAN_CRYSTAL
407 // Get draw device for updating the screen
408 TScreenInfoV01 screenInfo2;
409
410 Epoc_Runtime::GetScreenInfo(screenInfo2);
411
412 TRAPD(status, Private->EPOC_DrawDevice = CFbsDrawDevice::NewScreenDeviceL(screenInfo2, displayMode));
413 User::LeaveIfError(status);
414#endif
415
416 /* The "best" video format should be returned to caller. */
417
418 vformat->BitsPerPixel = /*!!GetBpp(displayMode) */ 8;
419 vformat->BytesPerPixel = /*!!Private->EPOC_BytesPerPixel*/ 1;
420
421 /* Activate events for me */
422
423 Private->EPOC_WsEventStatus = KRequestPending;
424 Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
425
426 SDL_TRACE("SDL:WsEventStatus");
427 User::WaitForRequest(Private->EPOC_WsEventStatus); //Markus: I added this and ...
428
429 Private->EPOC_RedrawEventStatus = KRequestPending;
430 Private->EPOC_WsSession.RedrawReady(&Private->EPOC_RedrawEventStatus);
431
432 SDL_TRACE("SDL:RedrawEventStatus");
433 User::WaitForRequest(Private->EPOC_RedrawEventStatus); //...this, if not catches a stray event is risen
434 //if there are active objects used, or confucing
435 //actions with User::WaitForAnyRequest
436 Private->EPOC_WsWindow.PointerFilter(EPointerFilterDrag, 0);
437
438 Private->EPOC_ScreenOffset = TPoint(0, 0);
439
440#if defined(__WINS__) || defined(TEST_BM_DRAW)
441 LockHeap(Private->EPOC_Bitmap); // Lock bitmap heap
442#endif
443
444 SDL_TRACE("SDL:DrawBackground");
445 DrawBackground(_this); // Clear screen
446
447#if defined(__WINS__) || defined(TEST_BM_DRAW)
448 UnlockHeap(Private->EPOC_Bitmap); // Unlock bitmap heap
449#endif
450 //!! TODO: error handling
451 //if (ret != KErrNone)
452 // return(-1);
453 //else
454 return(0);
455}
456
457
458SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 /*flags*/)
459{
460 if (format->BitsPerPixel == 12 || format->BitsPerPixel == 8)
461 return Private->SDL_modelist;
462 return NULL;
463}
464
465int EPOC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
466{
467 if ((firstcolor+ncolors) > 256)
468 return -1;
469// SDL_TRACE1("colors %d", (TDisplayModeUtils::NumDisplayModeColors(Private->EPOC_DisplayMode)));
470 if(TDisplayModeUtils::NumDisplayModeColors(Private->EPOC_DisplayMode) == 4096)
471 {
472 // Set 12 bit palette
473 for(int i = firstcolor; i < ncolors; i++)
474 {
475 // 4k value: 0000 rrrr gggg bbbb
476 TUint32 color4K = (colors[i].r & 0x0000f0) << 4;
477 color4K |= (colors[i].g & 0x0000f0);
478 color4K |= (colors[i].b & 0x0000f0) >> 4;
479 EPOC_HWPalette_256_to_Screen[i] = color4K;
480 }
481 }
482 else if(TDisplayModeUtils::NumDisplayModeColors(Private->EPOC_DisplayMode) == 65536)
483 {
484 for(int i = firstcolor; i < ncolors; i++)
485 {
486 // 64k-colour displays effectively support RGB values
487 // with 5 bits allocated to red, 6 to green and 5 to blue
488 // 64k value: rrrr rggg gggb bbbb
489 TUint32 color64K = (colors[i].r & 0x0000f8) << 8;
490 color64K |= (colors[i].g & 0x0000fc) << 3;
491 color64K |= (colors[i].b & 0x0000f8) >> 3;
492 EPOC_HWPalette_256_to_Screen[i] = color64K;
493 }
494 }
495 else if(TDisplayModeUtils::NumDisplayModeColors(Private->EPOC_DisplayMode) == 16777216)
496 {
497 for(int i = firstcolor; i < ncolors; i++)
498 {
499 // 16M-colour
500 //0000 0000 rrrr rrrr gggg gggg bbbb bbbb
501 TUint32 color16M = colors[i].r << 16;
502 color16M |= colors[i].g << 8;
503 color16M |= colors[i].b;
504 EPOC_HWPalette_256_to_Screen[i] = color16M;
505 }
506 }
507 else
508 {
509 return -2;
510 }
511 return(0);
512}
513
514
515SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current,
516 int width, int height, int bpp, Uint32 /*flags*/)
517{
518 SDL_TRACE("SDL:EPOC_SetVideoMode");
519 /* Check parameters */
520#ifdef SYMBIAN_CRYSTAL
521 if (! (bpp == 8 || bpp == 12 || bpp == 16) &&
522 (
523 (width == 640 && height == 200) ||
524 (width == 640 && height == 400) ||
525 (width == 640 && height == 480) ||
526 (width == 320 && height == 200) ||
527 (width == 320 && height == 240)
528 )) {
529 SDL_SetError("Requested video mode is not supported");
530 return NULL;
531 }
532#else // SYMBIAN_SERIES60
533 if (! (bpp == 8 || bpp == 12 || bpp == 16) &&
534 (
535 (width == 320 && height == 200) ||
536 (width == 320 && height == 240) ||
537 (width == 256 && height == 192) ||
538 (width == 176 && height == 208) ||
539 (width == 208 && height == 176) || // Rotated
540 (width == 160 && height == 144)
541 )) {
542 SDL_SetError("Requested video mode is not supported");
543 return NULL;
544 }
545#endif
546
547 if (current && current->pixels) {
548 free(current->pixels);
549 current->pixels = NULL;
550 }
551 if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
552 return(NULL);
553 }
554
555 /* Set up the new mode framebuffer */
556 if (bpp == 8)
557 current->flags = (SDL_FULLSCREEN|SDL_SWSURFACE|SDL_PREALLOC|SDL_HWPALETTE);
558 else // 12 bpp, 16 bpp
559 current->flags = (SDL_FULLSCREEN|SDL_SWSURFACE|SDL_PREALLOC);
560 current->w = width;
561 current->h = height;
562 int numBytesPerPixel = ((bpp-1)>>3) + 1;
563 current->pitch = numBytesPerPixel * width; // Number of bytes in scanline
564 current->pixels = malloc(width * height * numBytesPerPixel);
565 memset(current->pixels, 0, width * height * numBytesPerPixel);
566
567 /* Set the blit function */
568 _this->UpdateRects = EPOC_DirectUpdate;
569
570 /*
571 * Logic for getting suitable screen dimensions, offset, scaling and orientation
572 */
573
574 int w = current->w;
575 int h = current->h;
576
577 // Rotate, if the screen does not fit horizontally and it is landscape screen
578/*
579 if ((width>Private->EPOC_ScreenSize.iWidth) && (width>height)) {
580 Private->EPOC_ScreenOrientation = CFbsBitGc::EGraphicsOrientationRotated270;
581 w = current->h;
582 h = current->w;
583 }
584*/
585 // Get nearest stepwise scale values for width and height. The smallest supported scaled screen is 1/2.
586 TInt scaleValue = 0;
587 Private->EPOC_ScreenXScaleValue = 1;
588 Private->EPOC_ScreenYScaleValue = 1;
589 if (w > Private->EPOC_ScreenSize.iWidth) {
590 // Find the biggest scale value that result the width that fits in the screen HW
591 for (scaleValue = 2; scaleValue++;) {
592 TInt scaledWidth = (w * (scaleValue-1))/scaleValue;
593 if (scaledWidth > Private->EPOC_ScreenSize.iWidth)
594 break;
595 }
596 Private->EPOC_ScreenXScaleValue = Max(2, scaleValue - 1);
597 w = (w * (Private->EPOC_ScreenXScaleValue-1))/Private->EPOC_ScreenXScaleValue;
598 }
599 if (h > Private->EPOC_ScreenSize.iHeight) {
600 // Find the biggest scale value that result the height that fits in the screen HW
601 for (scaleValue = 2; scaleValue++;) {
602 TInt scaledHeight = (h * (scaleValue-1))/scaleValue;
603 if (scaledHeight > Private->EPOC_ScreenSize.iHeight)
604 break;
605 }
606 Private->EPOC_ScreenYScaleValue = Max(2, scaleValue - 1);
607 h = (h * (Private->EPOC_ScreenYScaleValue-1))/Private->EPOC_ScreenYScaleValue;
608 }
609
610 /* Centralize game window on device screen */
611 Private->EPOC_ScreenOffset.iX = (Private->EPOC_ScreenSize.iWidth - w) / 2;
612 if (Private->EPOC_ScreenOffset.iX < 0)
613 Private->EPOC_ScreenOffset.iX = 0;
614 Private->EPOC_ScreenOffset.iY = (Private->EPOC_ScreenSize.iHeight - h) / 2;
615 if (Private->EPOC_ScreenOffset.iY < 0)
616 Private->EPOC_ScreenOffset.iY = 0;
617
618
619 SDL_TRACE1("View width %d", w);
620 SDL_TRACE1("View height %d", h);
621 SDL_TRACE1("View bmode %d", bpp);
622 SDL_TRACE1("View s %d", scaleValue);
623 SDL_TRACE1("View x %d", Private->EPOC_ScreenOffset.iX);
624 SDL_TRACE1("View y %d", Private->EPOC_ScreenOffset.iY);
625
626 /* We're done */
627 return(current);
628}
629
630
631void RedrawWindowL(_THIS)
632{
633
634#if defined(__WINS__) || defined(TEST_BM_DRAW)
635 LockHeap(Private->EPOC_Bitmap); // Lock bitmap heap
636 Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow);
637#endif
638
639 int w = _this->screen->w;
640 int h = _this->screen->h;
641 if (Private->EPOC_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) {
642 w = _this->screen->h;
643 h = _this->screen->w;
644 }
645 if ((w < Private->EPOC_ScreenSize.iWidth)
646 || (h < Private->EPOC_ScreenSize.iHeight)) {
647 DrawBackground(_this);
648 }
649
650 /* Tell the system that something has been drawn */
651 TRect rect = TRect(Private->EPOC_WsWindow.Size());
652 Private->EPOC_WsWindow.Invalidate(rect);
653
654#if defined(__WINS__) || defined(TEST_BM_DRAW)
655 Private->EPOC_WsWindow.BeginRedraw(rect);
656 Private->EPOC_WindowGc->BitBlt(TPoint(), Private->EPOC_Bitmap);
657 Private->EPOC_WsWindow.EndRedraw();
658 Private->EPOC_WindowGc->Deactivate();
659 UnlockHeap(Private->EPOC_Bitmap);; // Unlock bitmap heap
660 Private->EPOC_WsSession.Flush();
661#endif
662
663 /* Draw current buffer */
664 SDL_Rect fullScreen;
665 fullScreen.x = 0;
666 fullScreen.y = 0;
667 fullScreen.w = _this->screen->w;
668 fullScreen.h = _this->screen->h;
669 EPOC_DirectUpdate(_this, 1, &fullScreen);
670}
671
672
673void DrawBackground(_THIS)
674{
675 /* Draw background */
676#if defined(__WINS__) || defined(TEST_BM_DRAW)
677 //warning heap is not locked! - a function calling must ensure that it's ok
678 TUint16* screenBuffer = (TUint16*)Private->EPOC_Bitmap->DataAddress();
679#else
680 TUint16* screenBuffer = (TUint16*)Private->EPOC_FrameBuffer;
681#endif
682 // Draw black background
683 Mem::FillZ(screenBuffer, Private->EPOC_BytesPerScreen);
684
685#if 0
686 for (int y = 0; y < Private->EPOC_ScreenSize.iHeight; y++) {
687 for (int x = 0; x < Private->EPOC_ScreenSize.iWidth; x++) {
688#ifdef SYMBIAN_CRYSTAL
689 const TUint16 color = 0; // ((x+y)>>1) & 0xf; /* Draw blue stripes pattern, because in e.g. 320x200 mode there is a big background area*/
690#else // SYMBIAN_SERIES60
691 const TUint16 color = 0; /* Draw black background */
692#endif
693 *screenBuffer++ = color;
694 }
695 }
696#endif
697}
698
699
700/* We don't actually allow hardware surfaces other than the main one */
701static int EPOC_AllocHWSurface(_THIS, SDL_Surface* /*surface*/)
702{
703 return(-1);
704}
705static void EPOC_FreeHWSurface(_THIS, SDL_Surface* /*surface*/)
706{
707 return;
708}
709
710static int EPOC_LockHWSurface(_THIS, SDL_Surface* /*surface*/)
711{
712 return(0);
713}
714static void EPOC_UnlockHWSurface(_THIS, SDL_Surface* /*surface*/)
715{
716 return;
717}
718
719static int EPOC_FlipHWSurface(_THIS, SDL_Surface* /*surface*/)
720{
721 return(0);
722}
723
724static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
725{
726 //TInt focusWindowGroupId = Private->EPOC_WsSession.GetFocusWindowGroup();//these are async services
727 // if (focusWindowGroupId != Private->EPOC_WsWindowGroupID) { //for that cannot be called from
728 //SDL threads ???
729 if (!Private->EPOC_IsWindowFocused)
730 {
731 /* Force focus window to redraw again for cleaning away SDL screen graphics */
732/*
733 TInt pos = Private->EPOC_WsWindowGroup.OrdinalPosition();
734 Private->EPOC_WsWindowGroup.SetOrdinalPosition(0, KMaxTInt);
735 TRect rect = TRect(Private->EPOC_WsWindow.Size());
736 Private->EPOC_WsWindow.Invalidate(rect);
737 Private->EPOC_WsWindowGroup.SetOrdinalPosition(pos, ECoeWinPriorityNormal);
738 */ /* If this is not the topmost window, wait here! Sleep for 1 second to give cpu time to
739 multitasking and poll for being the topmost window.
740 */
741 // if (Private->EPOC_WsSession.GetFocusWindowGroup() != Private->EPOC_WsWindowGroupID) {
742
743 /* !!TODO: Could call GetRedraw() etc. for WsSession and redraw the screen if needed. That might be
744 needed if a small dialog comes in front of Game screen.
745 */
746 // while (Private->EPOC_WsSession.GetFocusWindowGroup() != Private->EPOC_WsWindowGroupID)
747
748 SDL_PauseAudio(1);
749 SDL_Delay(1000);
750 return;
751 // }
752
753 // RedrawWindowL(_this);
754 }
755
756 SDL_PauseAudio(0);
757
758 // if we are not focused, do not draw
759// if (!Private->EPOC_IsWindowFocused)
760// return;
761#if defined(__WINS__) || defined(TEST_BM_DRAW)
762 TBitmapUtil lock(Private->EPOC_Bitmap);
763 lock.Begin(TPoint(0,0)); // Lock bitmap heap
764 Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow);
765 TUint16* screenBuffer = (TUint16*)Private->EPOC_Bitmap->DataAddress();
766#else
767 TUint16* screenBuffer = (TUint16*)Private->EPOC_FrameBuffer;
768#endif
769
770 if (Private->EPOC_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270)
771 DirectDrawRotated(_this, numrects, rects, screenBuffer);
772 else
773 DirectDraw(_this, numrects, rects, screenBuffer);
774
775
776#if defined(__WINS__) || defined(TEST_BM_DRAW)
777
778 TRect rect = TRect(Private->EPOC_WsWindow.Size());
779 Private->EPOC_WsWindow.Invalidate(rect);
780 Private->EPOC_WsWindow.BeginRedraw(rect);
781 Private->EPOC_WindowGc->BitBlt(TPoint(), Private->EPOC_Bitmap);
782 Private->EPOC_WsWindow.EndRedraw();
783 Private->EPOC_WindowGc->Deactivate();
784 lock.End(); // Unlock bitmap heap
785 Private->EPOC_WsSession.Flush();
786#else
787#ifndef SYMBIAN_CRYSTAL
788 // This is not needed in Crystal. What is the performance penalty in SERIES60?
789 TRect rect2 = TRect(Private->EPOC_WsWindow.Size());
790
791 Private->EPOC_DrawDevice->UpdateRegion(rect2); // Should we update rects parameter area only??
792 Private->EPOC_DrawDevice->Update();
793#endif
794#endif
795
796 /* Update virtual cursor. !!Do not yet work properly
797 Private->EPOC_WsSession.SetPointerCursorPosition(Private->EPOC_WsSession.PointerCursorPosition());
798 */
799
800 /*static int foo = 1;
801
802 for ( int i=0; i < numrects; ++i ) {
803 const SDL_Rect& currentRect = rects[i];
804 SDL_Rect rect2;
805 rect2.x = currentRect.x;
806 rect2.y = currentRect.y;
807 rect2.w = currentRect.w;
808 rect2.h = currentRect.h;
809
810 if (rect2.w <= 0 || rect2.h <= 0)
811 continue;
812
813
814 foo++;
815 if((foo % 200) == 0)
816 {
817 SDL_TRACE1("foo %d", foo);
818 CFbsBitmap* b = new (ELeave) CFbsBitmap;
819 SDL_TRACE1("bee %d", (int)b);
820 int e = b->Create(TSize(currentRect.w, currentRect.h), Private->EPOC_DisplayMode);
821
822 SDL_TRACE1("err %d", e);
823 if(e != KErrNone)
824 User::Panic(_L("damn"), e);
825
826 TBitmapUtil u(b);
827 u.Begin(TPoint(0, 0));
828 TUint32* d = b->DataAddress();
829
830 SDL_TRACE1("addr %d", (int)d);
831
832 for(TInt o = 0; o < currentRect.h; o++)
833 for(TInt p = 0; p < currentRect.w; p++)
834 {
835 u.SetPos(TPoint(p, o));
836 u.SetPixel(0xFFFF);
837 }
838
839 SDL_TRACE1("w %d", (int)currentRect.w);
840 SDL_TRACE1("h %d", (int)currentRect.h);
841
842 SDL_TRACE1("addr %d", (int)Private->EPOC_DisplayMode);
843
844
845 const TUint f = (TUint)Private->EPOC_FrameBuffer;
846 const TUint y = (TUint)Private->EPOC_BytesPerScreen;
847
848
849 SDL_TRACE1("frame %u", f);
850 SDL_TRACE1("bytes %u", y);
851
852 Mem::Copy(d, Private->EPOC_FrameBuffer, Private->EPOC_BytesPerScreen);
853
854 SDL_TRACE("kopied");
855
856 u.End();
857 TBuf<32> name;
858 name.Format(_L("C:\\nokia\\images\\doom%d.mbm"), (foo / 200));
859 e= b->Save(name);
860 if(e != KErrNone)
861 User::Panic(_L("damned"), e);
862 delete b;
863 }}*/
864}
865
866
867void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
868{
869 TInt i;
870
871 const TInt sourceNumBytesPerPixel = ((_this->screen->format->BitsPerPixel-1)>>3) + 1;
872 const TPoint fixedOffset = Private->EPOC_ScreenOffset;
873 const TInt screenW = _this->screen->w;
874 const TInt screenH = _this->screen->h;
875 const TInt sourceScanlineLength = screenW;
876 const TInt targetScanlineLength = Private->EPOC_ScreenSize.iWidth;
877
878 /* Render the rectangles in the list */
879
880 for ( i=0; i < numrects; ++i ) {
881 const SDL_Rect& currentRect = rects[i];
882 SDL_Rect rect2;
883 rect2.x = currentRect.x;
884 rect2.y = currentRect.y;
885 rect2.w = currentRect.w;
886 rect2.h = currentRect.h;
887
888 if (rect2.w <= 0 || rect2.h <= 0) /* sanity check */
889 continue;
890
891 /* All variables are measured in pixels */
892
893 /* Check rects validity, i.e. upper and lower bounds */
894 TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1);
895 TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1);
896 if (maxX < 0 || maxY < 0) /* sanity check */
897 continue;
898 /* Clip from bottom */
899 maxY = Min(maxY, Private->EPOC_ScreenSize.iHeight-1);
900 /* TODO: Clip from the right side */
901
902 const TInt sourceRectWidth = maxX - rect2.x + 1;
903 const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel;
904 const TInt sourceRectHeight = maxY - rect2.y + 1;
905 const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength;
906 const TUint skipValue = 1; // no skip
907
908 TInt targetStartOffset = fixedOffset.iX + rect2.x + (fixedOffset.iY +rect2.y) * targetScanlineLength;
909
910 // Nokia7650 native mode: 12 bpp --> 12 bpp
911 //
912
913 switch (_this->screen->format->BitsPerPixel)
914 {
915 case 12:
916 {
917 TUint16* bitmapLine = (TUint16*)_this->screen->pixels + sourceStartOffset;
918 TUint16* screenMemory = screenBuffer + targetStartOffset;
919 if (skipValue == 1)
920 {
921 for(TInt y = 0 ; y < sourceRectHeight ; y++)
922 {
923 Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes);
924 }
925 bitmapLine += sourceScanlineLength;
926 screenMemory += targetScanlineLength;
927 }
928 else
929 {
930 for(TInt y = 0 ; y < sourceRectHeight ; y++)
931 {
932 //TODO: optimize: separate loops for 1, 2 and n skip. Mem::Copy() can be used in unscaled case.
933 TUint16* bitmapPos = bitmapLine; /* 2 bytes per pixel */
934 TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
935 for(TInt x = 0 ; x < sourceRectWidth ; x++)
936 {
937 __ASSERT_DEBUG(screenMemory < (screenBuffer + Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight), User::Panic(_L("SDL"), KErrCorrupt));
938 __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt));
939 __ASSERT_DEBUG(bitmapLine < ((TUint16*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
940 __ASSERT_DEBUG(bitmapLine >= (TUint16*)_this->screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
941
942 *screenMemoryLinePos++ = *bitmapPos;
943 bitmapPos+=skipValue;
944 }
945 bitmapLine += sourceScanlineLength;
946 screenMemory += targetScanlineLength;
947 }
948 }
949 }
950 break;
951 // 256 color paletted mode: 8 bpp --> 12 bpp
952 //
953 default:
954 {
955 if(Private->EPOC_BytesPerPixel <= 2)
956 {
957 TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset;
958 TUint16* screenMemory = screenBuffer + targetStartOffset;
959 for(TInt y = 0 ; y < sourceRectHeight ; y++)
960 {
961 TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
962 TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
963 /* Convert each pixel from 256 palette to 4k color values */
964 for(TInt x = 0 ; x < sourceRectWidth ; x++)
965 {
966 __ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt));
967 __ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt));
968 __ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
969 __ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
970 *screenMemoryLinePos++ = EPOC_HWPalette_256_to_Screen[*bitmapPos++];
971 // bitmapPos+=skipValue; //TODO: optimize: separate loops for 1, 2 and n skip
972 }
973 bitmapLine += sourceScanlineLength;
974 screenMemory += targetScanlineLength;
975 }
976 }
977 else
978 {
979 TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset;
980 TUint32* screenMemory = reinterpret_cast<TUint32*>(screenBuffer + targetStartOffset);
981 for(TInt y = 0 ; y < sourceRectHeight ; y++)
982 {
983 TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
984 TUint32* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
985 /* Convert each pixel from 256 palette to 4k color values */
986 for(TInt x = 0 ; x < sourceRectWidth ; x++)
987 {
988 __ASSERT_DEBUG(screenMemoryLinePos < (reinterpret_cast<TUint32*>(screenBuffer) + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt));
989 __ASSERT_DEBUG(screenMemoryLinePos >= reinterpret_cast<TUint32*>(screenBuffer), User::Panic(_L("SDL"), KErrCorrupt));
990 __ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
991 __ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
992 *screenMemoryLinePos++ = EPOC_HWPalette_256_to_Screen[*bitmapPos++];
993 // bitmapPos+=skipValue; //TODO: optimize: separate loops for 1, 2 and n skip
994 }
995 bitmapLine += sourceScanlineLength;
996 screenMemory += targetScanlineLength;
997 }
998 }
999 }
1000 } // switch
1001 } // for
1002}
1003
1004/*
1005void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
1006{
1007 TInt i;
1008 const TInt sourceNumBytesPerPixel = ((_this->screen->format->BitsPerPixel-1)>>3) + 1;
1009 const TPoint fixedOffset = Private->EPOC_ScreenOffset;
1010 const TInt screenW = _this->screen->w;
1011 const TInt screenH = _this->screen->h;
1012 const TInt sourceScanlineLength = screenW;
1013 const TInt targetScanlineLength = Private->EPOC_ScreenSize.iWidth;
1014
1015 /* Render the rectangles in the list */
1016
1017/* for ( i=0; i < numrects; ++i ) {
1018 const SDL_Rect& currentRect = rects[i];
1019 SDL_Rect rect2;
1020 rect2.x = currentRect.x;
1021 rect2.y = currentRect.y;
1022 rect2.w = currentRect.w;
1023 rect2.h = currentRect.h;
1024
1025 if (rect2.w <= 0 || rect2.h <= 0) /* sanity check */
1026/* continue;
1027
1028 /* All variables are measured in pixels */
1029
1030 /* Check rects validity, i.e. upper and lower bounds */
1031/* TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1);
1032 TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1);
1033 if (maxX < 0 || maxY < 0) /* sanity check */
1034/* continue;
1035 /* Clip from bottom */
1036/* maxY = Min(maxY, Private->EPOC_ScreenSize.iHeight-1);
1037 /* TODO: Clip from the right side */
1038
1039/* TInt sourceRectWidth = maxX - rect2.x + 1;
1040 const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel;
1041 const TInt sourceRectHeight = maxY - rect2.y + 1;
1042 const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength;
1043 const TUint skipValue = Private->EPOC_ScreenXScaleValue; //1; // no skip
1044
1045 const TInt targetStartOffset = // = (fixedOffset.iX + (rect2.x / skipValue) + (fixedOffset.iY + rect2.y) * targetScanlineLength ) ;
1046 (skipValue > 1 ?
1047 (fixedOffset.iX + (rect2.x / skipValue) + (fixedOffset.iY + rect2.y) * targetScanlineLength ) :
1048 (fixedOffset.iX + rect2.x + (fixedOffset.iY + rect2.y) * targetScanlineLength ));
1049
1050 __ASSERT_DEBUG(skipValue >= 1, User::Panic(KLibName, KErrArgument));
1051
1052 // Nokia7650 native mode: 12 bpp --> 12 bpp
1053 //
1054 switch (_this->screen->format->BitsPerPixel)
1055 {
1056 case 12:
1057 {
1058 TUint16* bitmapLine = (TUint16*)_this->screen->pixels + sourceStartOffset;
1059 TUint16* screenMemory = screenBuffer + targetStartOffset;
1060 if (skipValue == 1)
1061 {
1062 for(TInt y = 0 ; y < sourceRectHeight ; y++)
1063 {
1064 Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes);
1065 }
1066 bitmapLine += sourceScanlineLength;
1067 screenMemory += targetScanlineLength;
1068 }
1069 else
1070 {
1071 for(TInt y = 0 ; y < sourceRectHeight ; y++)
1072 {
1073 //TODO: optimize: separate loops for 1, 2 and n skip. Mem::Copy() can be used in unscaled case.
1074 TUint16* bitmapPos = bitmapLine; /* 2 bytes per pixel */
1075/* TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
1076/* for(TInt x = 0 ; x < sourceRectWidth ; x++)
1077 {
1078 __ASSERT_DEBUG(screenMemory < (screenBuffer + Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight), User::Panic(KLibName, KErrCorrupt));
1079 __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(KLibName, KErrCorrupt));
1080 __ASSERT_DEBUG(bitmapLine < ((TUint16*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt));
1081 __ASSERT_DEBUG(bitmapLine >= (TUint16*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt));
1082
1083 *screenMemoryLinePos++ = *bitmapPos;
1084 bitmapPos+=skipValue;
1085 }
1086 bitmapLine += sourceScanlineLength;
1087 screenMemory += targetScanlineLength;
1088 }
1089 }
1090 }
1091 break;
1092 // 256 color paletted mode: 8 bpp --> 12 bpp
1093 //
1094 default:
1095 {
1096 TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset;
1097 TUint16* screenMemory = screenBuffer + targetStartOffset;
1098 if (skipValue > 1)
1099 sourceRectWidth /= skipValue;
1100#if defined __MARM_ARMI__
1101 __asm volatile("
1102 mov %4, %4, lsl #1 @ targetScanLineLength is in pixels, we need it in bytes
1103 1:
1104 mov r6, %0 @ bitmapLine
1105 mov r7, %2 @ screenMemory
1106 mov r8, %6 @ sourceRectWidth
1107 2:
1108 ldrb r4, [%0], %7 @ r4 = *bitmapPos; bitmapPos += skipValue
1109 ldr r5, [%1, r4, lsl #2] @ only 16 lower bits actually used
1110 subs r8, r8, #1 @ x--
1111 strh r5, [%2], #2 @ *screenMemoryLinePos++ = r4
1112 bne 2b
1113
1114 add %0, r6, %3 @ bitmapLine += sourceScanlineLength
1115 add %2, r7, %4 @ screenMemory += targetScanlineLength
1116 subs %5, %5, #1 @ sourceRectHeight--
1117 bne 1b
1118 "
1119 : // no output
1120 // %0 %1 %2 %3 %4 %5 %6 %7
1121 : "r" (bitmapLine), "r" (&EPOC_HWPalette_256_to_Screen[0]), "r" (screenMemory), "r" (sourceScanlineLength), "r" (targetScanlineLength), "r" (sourceRectHeight), "r" (sourceRectWidth), "r" (skipValue)
1122 : "r4", "r5", "r6", "r7", "r8"
1123 );
1124#else
1125 for(TInt y = 0 ; y < sourceRectHeight ; y++)
1126 {
1127 TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
1128/* TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
1129 /* Convert each pixel from 256 palette to 4k color values */
1130/* for (TInt x = 0 ; x < sourceRectWidth ; x++)
1131 {
1132 //__ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(KLibName, KErrCorrupt));
1133 //__ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(KLibName, KErrCorrupt));
1134 //__ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt));
1135 //__ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt));
1136
1137 *screenMemoryLinePos++ = EPOC_HWPalette_256_to_Screen[*bitmapPos];
1138 bitmapPos += skipValue;
1139 }
1140 bitmapLine += sourceScanlineLength;
1141 screenMemory += targetScanlineLength;
1142 }
1143//#endif
1144 }
1145 } // switch
1146 } // for
1147}
1148*/
1149
1150void DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
1151{
1152 TInt i;
1153// TInt sourceNumBytesPerPixel = ((_this->screen->format->BitsPerPixel-1)>>3) + 1;
1154 TPoint fixedScreenOffset = Private->EPOC_ScreenOffset;
1155 TInt bufferW = _this->screen->w;
1156 TInt bufferH = _this->screen->h;
1157 TInt ScreenW = Private->EPOC_ScreenSize.iWidth;
1158// TInt ScreenH = Private->EPOC_ScreenSize.iWidth;
1159 TInt sourceW = bufferW;
1160 TInt sourceH = bufferH;
1161 TInt targetW = ScreenW - fixedScreenOffset.iX * 2;
1162// TInt targetH = ScreenH - fixedScreenOffset.iY * 2;
1163 TInt sourceScanlineLength = bufferW;
1164 TInt targetScanlineLength = Private->EPOC_ScreenSize.iWidth;
1165
1166 /* Render the rectangles in the list */
1167
1168 for ( i=0; i < numrects; ++i ) {
1169 SDL_Rect rect2;
1170 const SDL_Rect& currentRect = rects[i];
1171 rect2.x = currentRect.x;
1172 rect2.y = currentRect.y;
1173 rect2.w = currentRect.w;
1174 rect2.h = currentRect.h;
1175
1176 if (rect2.w <= 0 || rect2.h <= 0) /* sanity check */
1177 continue;
1178
1179 /* All variables are measured in pixels */
1180
1181 /* Check rects validity, i.e. upper and lower bounds */
1182 TInt maxX = Min(sourceW - 1, rect2.x + rect2.w - 1);
1183 TInt maxY = Min(sourceH - 1, rect2.y + rect2.h - 1);
1184 if (maxX < 0 || maxY < 0) /* sanity check */
1185 continue;
1186 /* Clip from bottom */
1187 //maxX = Min(maxX, Private->EPOC_ScreenSize.iHeight-1);
1188 /* TODO: Clip from the right side */
1189
1190 TInt sourceRectWidth = maxX - rect2.x + 1;
1191// TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel;
1192 TInt sourceRectHeight = maxY - rect2.y + 1;
1193 TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength;
1194 TInt targetStartOffset = fixedScreenOffset.iX + (targetW-1 - rect2.y) + (fixedScreenOffset.iY +rect2.x) * targetScanlineLength;
1195
1196 // Nokia7650 native mode: 12 bpp --> 12 bpp
1197 if (_this->screen->format->BitsPerPixel == 12) {
1198
1199 /* !!TODO: not yet implemented
1200
1201 TUint16* bitmapLine = (TUint16*)_this->screen->pixels + sourceStartOffset;
1202 TUint16* screenMemory = screenBuffer + targetStartOffset;
1203 for(TInt y = 0 ; y < sourceRectHeight ; y++) {
1204 //TODO: optimize: separate loops for 1, 2 and n skip
1205 //Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes);
1206 TUint16* bitmapPos = bitmapLine; // 2 bytes per pixel
1207 TUint16* screenMemoryLinePos = screenMemory; // 2 bytes per pixel
1208 for(TInt x = 0 ; x < sourceRectWidth ; x++) {
1209
1210 __ASSERT_DEBUG(screenMemory < (screenBuffer + Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight), User::Panic(KLibName, KErrCorrupt));
1211 __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(KLibName, KErrCorrupt));
1212 __ASSERT_DEBUG(bitmapLine < ((TUint16*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt));
1213 __ASSERT_DEBUG(bitmapLine >= (TUint16*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt));
1214
1215 *screenMemoryLinePos = *bitmapPos;
1216 bitmapPos++;
1217 screenMemoryLinePos += targetScanlineLength;
1218 }
1219 bitmapLine += sourceScanlineLength;
1220 screenMemory--;
1221 }
1222
1223 */
1224 }
1225 // 256 color paletted mode: 8 bpp --> 12 bpp
1226 else {
1227 TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset;
1228 TUint16* screenMemory = screenBuffer + targetStartOffset;
1229 TInt screenXScaleValue = Private->EPOC_ScreenXScaleValue;
1230 TInt debug_ycount=0;
1231 for(TInt y = 0 ; y < sourceRectHeight ; y++) {
1232 if(--screenXScaleValue) {
1233 TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
1234 TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
1235 TInt screenYScaleValue = Private->EPOC_ScreenYScaleValue;
1236 TInt debug_xcount=0;
1237 /* Convert each pixel from 256 palette to 4k color values */
1238 for(TInt x = 0 ; x < sourceRectWidth ; x++) {
1239 if(--screenYScaleValue) {
1240
1241 __ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(KLibName, KErrCorrupt));
1242 __ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(KLibName, KErrCorrupt));
1243 __ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt));
1244 __ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt));
1245
1246 *screenMemoryLinePos = TUint16(EPOC_HWPalette_256_to_Screen[*bitmapPos]);
1247 screenMemoryLinePos += targetScanlineLength; debug_xcount++;
1248 }
1249 else
1250 screenYScaleValue = Private->EPOC_ScreenYScaleValue;
1251 bitmapPos++;
1252 }
1253 screenMemory--; debug_ycount++;
1254 } // endif
1255 else
1256 screenXScaleValue = Private->EPOC_ScreenXScaleValue;
1257 bitmapLine += sourceScanlineLength;
1258 }
1259 }
1260 }
1261}
1262
1263
1264/* Note: If we are terminated, this could be called in the middle of
1265 another SDL video routine -- notably UpdateRects.
1266*/
1267void EPOC_VideoQuit(_THIS)
1268{
1269 int i;
1270
1271 /* Free video mode lists */
1272 for ( i=0; i<SDL_NUMMODES; ++i ) {
1273 if ( Private->SDL_modelist[i] != NULL ) {
1274 free(Private->SDL_modelist[i]);
1275 Private->SDL_modelist[i] = NULL;
1276 }
1277 }
1278
1279 if ( _this->screen && (_this->screen->flags & SDL_HWSURFACE) ) {
1280 /* Direct screen access, no memory buffer */
1281 _this->screen->pixels = NULL;
1282 }
1283
1284 if (_this->screen && _this->screen->pixels) {
1285 free(_this->screen->pixels);
1286 _this->screen->pixels = NULL;
1287 }
1288
1289 /* Free Epoc resources */
1290
1291 /* Disable events for me */
1292 if (Private->EPOC_WsEventStatus != KRequestPending)
1293 Private->EPOC_WsSession.EventReadyCancel();
1294 if (Private->EPOC_RedrawEventStatus != KRequestPending)
1295 Private->EPOC_WsSession.RedrawReadyCancel();
1296
1297 #if defined(__WINS__) || defined(TEST_BM_DRAW)
1298 delete Private->EPOC_Bitmap;
1299 Private->EPOC_Bitmap = NULL;
1300 #else
1301 #endif
1302
1303#ifndef SYMBIAN_CRYSTAL
1304 free(Private->EPOC_DrawDevice);
1305#endif
1306
1307 if (Private->EPOC_WsWindow.WsHandle())
1308 Private->EPOC_WsWindow.Close();
1309
1310 if (Private->EPOC_WsWindowGroup.WsHandle())
1311 Private->EPOC_WsWindowGroup.Close();
1312
1313 delete Private->EPOC_WindowGc;
1314 Private->EPOC_WindowGc = NULL;
1315
1316 delete Private->EPOC_WsScreen;
1317 Private->EPOC_WsScreen = NULL;
1318
1319 if (Private->EPOC_WsSession.WsHandle())
1320 Private->EPOC_WsSession.Close();
1321}
1322
1323
1324WMcursor *EPOC_CreateWMCursor(_THIS, Uint8* /*data*/, Uint8* /*mask*/, int /*w*/, int /*h*/, int /*hot_x*/, int /*hot_y*/)
1325{
1326 return (WMcursor *) 9210; // it's ok to return something unuseful but true
1327}
1328
1329void EPOC_FreeWMCursor(_THIS, WMcursor* /*cursor*/)
1330{
1331 /* Disable virtual cursor */
1332 HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
1333 Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone);
1334}
1335
1336int EPOC_ShowWMCursor(_THIS, WMcursor *cursor)
1337{
1338
1339 if (cursor == (WMcursor *)9210) {
1340 /* Enable virtual cursor */
1341 Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNormal);
1342 if (isCursorVisible)
1343 HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
1344 else
1345 Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone);
1346 }
1347 else {
1348 /* Disable virtual cursor */
1349 HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
1350 Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone);
1351 }
1352
1353 return(1);
1354}
1355
1356}; // extern "C"
diff --git a/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.h b/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.h
deleted file mode 100644
index bd0b0e29c5..0000000000
--- a/apps/plugins/sdl/src/video/symbian/EKA1/SDL_epocvideo.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@devolution.com
21*/
22
23#ifndef _SDL_epocvideo_h
24#define _SDL_epocvideo_h
25
26#ifndef EKA2
27#include"SDL_epocvideo_org.h"
28#else
29#include"SDL_epocvideo2.h"
30#endif
31
32
33#endif
34
diff --git a/apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocevents.cpp b/apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocevents.cpp
deleted file mode 100644
index 2452daed6f..0000000000
--- a/apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocevents.cpp
+++ /dev/null
@@ -1,521 +0,0 @@
1#include "epoc_sdl.h"
2
3#include <stdio.h>
4#undef NULL
5extern "C" {
6//#define DEBUG_TRACE_ENABLED
7#include "SDL_error.h"
8#include "SDL_video.h"
9#include "SDL_keysym.h"
10#include "SDL_keyboard.h"
11#include "SDL_events_c.h"
12#include "SDL_timer.h"
13} /* extern "C" */
14
15#include "SDL_epocvideo.h"
16#include "SDL_epocevents_c.h"
17
18#include "sdlepocapi.h"
19
20#include <eikenv.h>
21
22#include<bautils.h>
23
24
25extern "C"
26 {
27 static SDL_keysym *TranslateKey(_THIS, int scancode, SDL_keysym *keysym);
28 }
29
30//extern "C" {
31/* The translation tables from a console scancode to a SDL keysym */
32static SDLKey keymap[MAX_SCANCODE];
33static SDL_keysym *TranslateKey(_THIS, int scancode, SDL_keysym *keysym);
34void DisableKeyBlocking(_THIS);
35//} /* extern "C" */
36
37SDLKey* KeyMap()
38 {
39 return keymap;
40 }
41
42TBool isCursorVisible = EFalse;
43
44void ResetKeyMap()
45 {
46 int i;
47
48 /* Initialize the key translation table */
49 for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
50 keymap[i] = SDLK_UNKNOWN;
51
52
53 /* Numbers */
54 for ( i = 0; i<32; ++i ){
55 keymap[' ' + i] = (SDLKey)(SDLK_SPACE+i);
56 }
57 /* e.g. Alphabet keys */
58 for ( i = 0; i<32; ++i ){
59 keymap['A' + i] = (SDLKey)(SDLK_a+i);
60 }
61
62 keymap[EStdKeyBackspace] = SDLK_BACKSPACE;
63 keymap[EStdKeyTab] = SDLK_TAB;
64 keymap[EStdKeyEnter] = SDLK_RETURN;
65 keymap[EStdKeyEscape] = SDLK_ESCAPE;
66 keymap[EStdKeySpace] = SDLK_SPACE;
67 keymap[EStdKeyPause] = SDLK_PAUSE;
68 keymap[EStdKeyHome] = SDLK_HOME;
69 keymap[EStdKeyEnd] = SDLK_END;
70 keymap[EStdKeyPageUp] = SDLK_PAGEUP;
71 keymap[EStdKeyPageDown] = SDLK_PAGEDOWN;
72 keymap[EStdKeyDelete] = SDLK_DELETE;
73 keymap[EStdKeyUpArrow] = SDLK_UP;
74 keymap[EStdKeyDownArrow] = SDLK_DOWN;
75 keymap[EStdKeyLeftArrow] = SDLK_LEFT;
76 keymap[EStdKeyRightArrow] = SDLK_RIGHT;
77 keymap[EStdKeyCapsLock] = SDLK_CAPSLOCK;
78 keymap[EStdKeyLeftShift] = SDLK_LSHIFT;
79 keymap[EStdKeyRightShift] = SDLK_RSHIFT;
80 keymap[EStdKeyLeftAlt] = SDLK_LALT;
81 keymap[EStdKeyRightAlt] = SDLK_RALT;
82 keymap[EStdKeyLeftCtrl] = SDLK_LCTRL;
83 keymap[EStdKeyRightCtrl] = SDLK_RCTRL;
84 keymap[EStdKeyLeftFunc] = SDLK_LMETA;
85 keymap[EStdKeyRightFunc] = SDLK_RMETA;
86 keymap[EStdKeyInsert] = SDLK_INSERT;
87 keymap[EStdKeyComma] = SDLK_COMMA;
88 keymap[EStdKeyFullStop] = SDLK_PERIOD;
89 keymap[EStdKeyForwardSlash] = SDLK_SLASH;
90 keymap[EStdKeyBackSlash] = SDLK_BACKSLASH;
91 keymap[EStdKeySemiColon] = SDLK_SEMICOLON;
92 keymap[EStdKeySingleQuote] = SDLK_QUOTE;
93 keymap[EStdKeyHash] = SDLK_HASH;
94 keymap[EStdKeySquareBracketLeft] = SDLK_LEFTBRACKET;
95 keymap[EStdKeySquareBracketRight] = SDLK_RIGHTBRACKET;
96 keymap[EStdKeyMinus] = SDLK_MINUS;
97 keymap[EStdKeyEquals] = SDLK_EQUALS;
98
99 keymap[EStdKeyF1] = SDLK_F1;
100 keymap[EStdKeyF2] = SDLK_F2;
101 keymap[EStdKeyF3] = SDLK_F3;
102 keymap[EStdKeyF4] = SDLK_F4;
103 keymap[EStdKeyF5] = SDLK_F5;
104 keymap[EStdKeyF6] = SDLK_F6;
105 keymap[EStdKeyF7] = SDLK_F7;
106 keymap[EStdKeyF8] = SDLK_F8;
107
108 keymap[EStdKeyF9] = SDLK_F9;
109 keymap[EStdKeyF10] = SDLK_F10;
110 keymap[EStdKeyF11] = SDLK_F11;
111 keymap[EStdKeyF12] = SDLK_F12;
112
113
114 keymap[EStdKeyXXX] = SDLK_RETURN; /* "fire" key */
115
116 keymap[EStdKeyDevice3] = SDLK_RETURN; /* "fire" key */
117 keymap[EStdKeyNkpAsterisk] = SDLK_ASTERISK;
118 keymap[EStdKeyYes] = SDLK_HOME; /* "call" key */
119 keymap[EStdKeyNo] = SDLK_END; /* "end call" key */
120 keymap[EStdKeyDevice0] = SDLK_SPACE; /* right menu key */
121 keymap[EStdKeyDevice1] = SDLK_ESCAPE; /* left menu key */
122 keymap[EStdKeyDevice2] = SDLK_POWER; /* power key */
123
124 keymap[EStdKeyMenu] = SDLK_MENU; // menu key
125 keymap[EStdKeyDevice6] = SDLK_LEFT; // Rocker (joystick) left
126 keymap[EStdKeyDevice7] = SDLK_RIGHT; // Rocker (joystick) right
127 keymap[EStdKeyDevice8] = SDLK_UP; // Rocker (joystick) up
128 keymap[EStdKeyDevice9] = SDLK_DOWN; // Rocker (joystick) down
129 keymap[EStdKeyLeftFunc] = SDLK_LALT; //chr?
130 keymap[EStdKeyRightFunc] = SDLK_RALT;
131 keymap[EStdKeyDeviceA] = SDLK_RETURN; /* "fire" key */
132
133
134
135
136
137 ///////////////////////////////////////////////////////////
138 /*
139 RFs fs;
140 if(KErrNone == fs.Connect())
141 {
142 RArray<TInt> array;
143 TRAPD(err, ReadL(fs, array));
144 if(err == KErrNone && array.Count() > 0)
145 {
146
147 SDLKey temp[MAX_SCANCODE];
148 Mem::Copy(temp, keymap, MAX_SCANCODE * sizeof(SDLKey));
149
150 for(TInt k = 0; k < array.Count(); k+= 2)
151 {
152 const TInt oldval = array[k];
153 const TInt newval = array[k + 1];
154 if(oldval >= 0 && oldval < MAX_SCANCODE && newval >= 0 && newval < MAX_SCANCODE)
155 {
156 keymap[oldval] = temp[newval];
157 }
158 }
159 }
160 array.Close();
161 }
162
163 fs.Close();*/
164 ///////////////////////////////////////////////////////////
165
166
167 keymap[EStdKeyNumLock] = SDLK_NUMLOCK;
168 keymap[EStdKeyScrollLock] = SDLK_SCROLLOCK;
169
170 keymap[EStdKeyNkpForwardSlash] = SDLK_KP_DIVIDE;
171 keymap[EStdKeyNkpAsterisk] = SDLK_KP_MULTIPLY;
172 keymap[EStdKeyNkpMinus] = SDLK_KP_MINUS;
173 keymap[EStdKeyNkpPlus] = SDLK_KP_PLUS;
174 keymap[EStdKeyNkpEnter] = SDLK_KP_ENTER;
175 keymap[EStdKeyNkp1] = SDLK_KP1;
176 keymap[EStdKeyNkp2] = SDLK_KP2;
177 keymap[EStdKeyNkp3] = SDLK_KP3;
178 keymap[EStdKeyNkp4] = SDLK_KP4;
179 keymap[EStdKeyNkp5] = SDLK_KP5;
180 keymap[EStdKeyNkp6] = SDLK_KP6;
181 keymap[EStdKeyNkp7] = SDLK_KP7;
182 keymap[EStdKeyNkp8] = SDLK_KP8;
183 keymap[EStdKeyNkp9] = SDLK_KP9;
184 keymap[EStdKeyNkp0] = SDLK_KP0;
185 keymap[EStdKeyNkpFullStop] = SDLK_KP_PERIOD;
186 /*
187 keymap[EStdKeyMenu] = SDLK_MENU; should be, but not yet
188 keymap[EStdKeyBacklightOn] =
189 keymap[EStdKeyBacklightOff] =
190 keymap[EStdKeyBacklightToggle] =
191 keymap[EStdKeyIncContrast] =
192 keymap[EStdKeyDecContrast] =
193 keymap[EStdKeySliderDown] =
194 keymap[EStdKeySliderUp] =
195 keymap[EStdKeyDictaphonePlay] =
196 keymap[EStdKeyDictaphoneStop] =
197 keymap[EStdKeyDictaphoneRecord] =
198 keymap[EStdKeyHelp] =
199 keymap[EStdKeyOff] =
200 keymap[EStdKeyDial] =
201 keymap[EStdKeyIncVolume] =
202 keymap[EStdKeyDecVolume] =
203 keymap[EStdKeyDevice0] =
204 keymap[EStdKeyDevice1] =
205 keymap[EStdKeyDevice2] =
206 keymap[EStdKeyDevice3] =
207 keymap[EStdKeyDevice4] =
208 keymap[EStdKeyDevice5] =
209 keymap[EStdKeyDevice6] =
210 keymap[EStdKeyDevice7] =
211 keymap[EStdKeyDevice8] =
212 keymap[EStdKeyDevice9] =
213 keymap[EStdKeyDeviceA] =
214 keymap[EStdKeyDeviceB] =
215 keymap[EStdKeyDeviceC] =
216 keymap[EStdKeyDeviceD] =
217 keymap[EStdKeyDeviceE] =
218 keymap[EStdKeyDeviceF] =
219 keymap[EStdKeyApplication0] =
220 keymap[EStdKeyApplication1] =
221 keymap[EStdKeyApplication2] =
222 keymap[EStdKeyApplication3] =
223 keymap[EStdKeyApplication4] =
224 keymap[EStdKeyApplication5] =
225 keymap[EStdKeyApplication6] =
226 keymap[EStdKeyApplication7] =
227 keymap[EStdKeyApplication8] =
228 keymap[EStdKeyApplication9] =
229 keymap[EStdKeyApplicationA] =
230 keymap[EStdKeyApplicationB] =
231 keymap[EStdKeyApplicationC] =
232 keymap[EStdKeyApplicationD] =
233 keymap[EStdKeyApplicationE] =
234 keymap[EStdKeyApplicationF] =
235 keymap[EStdKeyYes] =
236 keymap[EStdKeyNo] =
237 keymap[EStdKeyIncBrightness] =
238 keymap[EStdKeyDecBrightness] =
239 keymap[EStdKeyCaseOpen] =
240 keymap[EStdKeyCaseClose] = */
241
242
243
244}
245
246
247int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
248{
249 int posted = 0;
250 SDL_keysym keysym;
251
252// SDL_TRACE1("hws %d", aWsEvent.Type());
253
254 switch (aWsEvent.Type())
255 {
256 case EEventPointer: /* Mouse pointer events */
257 {
258/* const TPointerCursorMode mode = EpocSdlEnv::PointerMode();
259
260
261 if(mode == EPointerCursorNone)
262 {
263 return 0; //TODO: Find out why events are get despite of cursor should be off
264 }
265*/
266 const TPointerEvent* pointerEvent = aWsEvent.Pointer();
267 const TPoint mousePos = EpocSdlEnv::WindowCoordinates(pointerEvent->iPosition);
268
269 /*!! TODO Pointer do not yet work properly
270 //SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!!
271
272 if (Private->EPOC_ShrinkedHeight) {
273 mousePos.iY <<= 1; // Scale y coordinate to shrinked screen height
274 }
275 if (Private->EPOC_ShrinkedWidth) {
276 mousePos.iX <<= 1; // Scale x coordinate to shrinked screen width
277 }
278 */
279
280 posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */
281
282 switch (pointerEvent->iType)
283 {
284 case TPointerEvent::EButton1Down:
285 posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
286 break;
287 case TPointerEvent::EButton1Up:
288 posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
289 break;
290 case TPointerEvent::EButton2Down:
291 posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
292 break;
293 case TPointerEvent::EButton2Up:
294 posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
295 break;
296 case TPointerEvent::EButton3Down:
297 posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0);
298 break;
299 case TPointerEvent::EButton3Up:
300 posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);
301 break;
302 } // switch
303 break;
304 }
305
306 case EEventKeyDown: /* Key events */
307 {
308#ifdef SYMBIAN_CRYSTAL
309 // special case: 9300/9500 rocker down, simulate left mouse button
310 if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
311 {
312 const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode();
313 if(mode != EPointerCursorNone)
314 posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
315 }
316#endif
317 (void*)TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym);
318
319#ifndef DISABLE_JOYSTICK
320 /* Special handling */
321 switch((int)keysym.sym) {
322 case SDLK_CAPSLOCK:
323 if (!isCursorVisible) {
324 /* Enable virtual cursor */
325 HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
326 }
327 else {
328 /* Disable virtual cursor */
329 HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
330 }
331 isCursorVisible = !isCursorVisible;
332 break;
333 }
334#endif
335 posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
336 break;
337 }
338
339 case EEventKeyUp: /* Key events */
340 {
341#ifdef SYMBIAN_CRYSTAL
342 // special case: 9300/9500 rocker up, simulate left mouse button
343 if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
344 {
345 posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
346 }
347#endif
348 posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym));
349 break;
350 }
351
352 case EEventFocusGained: /* SDL window got focus */
353 {
354 Private->iIsWindowFocused = ETrue;
355 posted += SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
356 /* Draw window background and screen buffer */
357 DisableKeyBlocking(_this); //Markus: guess why:-)
358
359 //RedrawWindowL(_this);
360 break;
361 }
362
363 case EEventFocusLost: /* SDL window lost focus */
364 {
365
366 Private->iIsWindowFocused = EFalse;
367
368 posted += SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
369
370
371 break;
372 }
373
374 case EEventModifiersChanged:
375 {
376 TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged();
377 TUint modstate = KMOD_NONE;
378 if (modEvent->iModifiers == EModifierLeftShift)
379 modstate |= KMOD_LSHIFT;
380 if (modEvent->iModifiers == EModifierRightShift)
381 modstate |= KMOD_RSHIFT;
382 if (modEvent->iModifiers == EModifierLeftCtrl)
383 modstate |= KMOD_LCTRL;
384 if (modEvent->iModifiers == EModifierRightCtrl)
385 modstate |= KMOD_RCTRL;
386 if (modEvent->iModifiers == EModifierLeftAlt)
387 modstate |= KMOD_LALT;
388 if (modEvent->iModifiers == EModifierRightAlt)
389 modstate |= KMOD_RALT;
390 if (modEvent->iModifiers == EModifierLeftFunc)
391 modstate |= KMOD_LMETA;
392 if (modEvent->iModifiers == EModifierRightFunc)
393 modstate |= KMOD_RMETA;
394 if (modEvent->iModifiers == EModifierCapsLock)
395 modstate |= KMOD_CAPS;
396 SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT)));
397 break;
398 }
399 case EEventScreenDeviceChanged:
400 {
401 EpocSdlEnv::WaitDeviceChange();
402 }
403 break;
404 default:
405 break;
406 }
407
408 return posted;
409}
410
411extern "C" {
412
413void EPOC_PumpEvents(_THIS)
414 {
415 MEventQueue& events = EpocSdlEnv::EventQueue();
416 while(events.HasData())
417 {
418 events.Lock();
419
420 //there have to be a copy, so we can release
421 //lock immediately. HandleWsEvent may cause
422 //deadlock otherwise.
423
424 const TWsEvent event = events.Shift();
425 events.Unlock();
426// const TWsEvent& event = events.Top();
427 EPOC_HandleWsEvent(_this, event);
428// events.Shift();
429 }
430 }
431
432
433
434void EPOC_InitOSKeymap(_THIS)
435 {
436 ResetKeyMap();
437 EpocSdlEnv::ObserverEvent(MSDLObserver::EEventKeyMapInit ,0);
438 }
439
440static SDL_keysym *TranslateKey(_THIS, int scancode, SDL_keysym *keysym)
441{
442// char debug[256];
443 //SDL_TRACE1("SDL: TranslateKey, scancode=%d", scancode); //!!
444
445 /* Set the keysym information */
446
447 keysym->scancode = scancode;
448
449 if ((scancode >= MAX_SCANCODE) &&
450 ((scancode - ENonCharacterKeyBase + 0x0081) >= MAX_SCANCODE)) {
451 SDL_SetError("Too big scancode");
452 keysym->scancode = SDLK_UNKNOWN;
453 keysym->mod = KMOD_NONE;
454 return keysym;
455 }
456
457 keysym->mod = SDL_GetModState();
458
459 /* Handle function keys: F1, F2, F3 ... */
460 if (keysym->mod & KMOD_META) {
461 if (scancode >= 'A' && scancode < ('A' + 24)) { /* first 32 alphabet keys */
462 switch(scancode) {
463 case 'Q': scancode = EStdKeyF1; break;
464 case 'W': scancode = EStdKeyF2; break;
465 case 'E': scancode = EStdKeyF3; break;
466 case 'R': scancode = EStdKeyF4; break;
467 case 'T': scancode = EStdKeyF5; break;
468 case 'Y': scancode = EStdKeyF6; break;
469 case 'U': scancode = EStdKeyF7; break;
470 case 'I': scancode = EStdKeyF8; break;
471 case 'A': scancode = EStdKeyF9; break;
472 case 'S': scancode = EStdKeyF10; break;
473 case 'D': scancode = EStdKeyF11; break;
474 case 'F': scancode = EStdKeyF12; break;
475 }
476 keysym->sym = keymap[scancode];
477 }
478 }
479
480 if (scancode >= ENonCharacterKeyBase) {
481 // Non character keys
482 keysym->sym = keymap[scancode -
483 ENonCharacterKeyBase + 0x0081]; // !!hard coded
484 } else {
485 keysym->sym = keymap[scancode];
486 }
487
488 /* Remap the arrow keys if the device is rotated */
489/*
490 if (Private->EPOC_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) {
491 switch(keysym->sym) {
492 case SDLK_UP: keysym->sym = SDLK_LEFT; break;
493 case SDLK_DOWN: keysym->sym = SDLK_RIGHT; break;
494 case SDLK_LEFT: keysym->sym = SDLK_DOWN; break;
495 case SDLK_RIGHT:keysym->sym = SDLK_UP; break;
496 }
497 }
498*/
499 /* If UNICODE is on, get the UNICODE value for the key */
500 keysym->unicode = 0;
501
502#if 0 // !!TODO:unicode
503
504 if ( SDL_TranslateUNICODE )
505 {
506 /* Populate the unicode field with the ASCII value */
507 keysym->unicode = scancode;
508 }
509#endif
510
511 //!!
512 //sprintf(debug, "SDL: TranslateKey: keysym->scancode=%d, keysym->sym=%d, keysym->mod=%d",
513 // keysym->scancode, keysym->sym, keysym->mod);
514 //SDL_TRACE(debug); //!!
515
516 return(keysym);
517}
518
519} /* extern "C" */
520
521
diff --git a/apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocvideo.cpp b/apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocvideo.cpp
deleted file mode 100644
index c15506ddc0..0000000000
--- a/apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocvideo.cpp
+++ /dev/null
@@ -1,594 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@devolution.com
21*/
22
23/*
24 SDL_epocvideo.cpp
25 Epoc based SDL video driver implementation
26
27 Markus Mertama
28*/
29
30
31
32#include "epoc_sdl.h"
33
34#include <stdlib.h>
35#include <stdio.h>
36#include <string.h>
37
38extern "C" {
39#include "SDL_error.h"
40#include "SDL_timer.h"
41#include "SDL_video.h"
42#undef NULL
43#include "SDL_pixels_c.h"
44#include "SDL.h"
45#include "SDL_mouse.h"
46}
47
48#include "SDL_epocvideo.h"
49#include "SDL_epocevents_c.h"
50
51
52
53#include <coedef.h>
54#include <flogger.h>
55
56#include <eikenv.h>
57#include <eikappui.h>
58#include <eikapp.h>
59#include "sdlepocapi.h"
60
61
62////////////////////////////////////////////////////////////////
63
64
65
66
67_LIT(KLibName, "SDL");
68
69void RDebug_Print_b(char* error_str, void* param)
70 {
71 TBuf8<128> error8((TUint8*)error_str);
72 TBuf<128> error;
73 error.Copy(error8);
74
75#ifndef TRACE_TO_FILE
76 if (param) //!! Do not work if the parameter is really 0!!
77 RDebug::Print(error, param);
78 else
79 RDebug::Print(error);
80#else
81 if (param) //!! Do not work if the parameter is really 0!!
82 RFileLogger::WriteFormat(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error, param);
83 else
84 RFileLogger::Write(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error);
85#endif
86
87 }
88
89extern "C" void RDebug_Print(char* error_str, void* param)
90 {
91 RDebug_Print_b(error_str, param);
92 }
93
94/*
95int Debug_AvailMem2()
96 {
97 //User::CompressAllHeaps();
98 TMemoryInfoV1Buf membuf;
99 User::LeaveIfError(UserHal::MemoryInfo(membuf));
100 TMemoryInfoV1 minfo = membuf();
101 return(minfo.iFreeRamInBytes);
102 }
103
104extern "C" int Debug_AvailMem()
105 {
106 return(Debug_AvailMem2());
107 }
108
109*/
110
111extern "C" {
112
113/* Initialization/Query functions */
114
115static int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat);
116static SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
117static SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
118static int EPOC_SetColors(_THIS, int firstcolor, int ncolors,
119 SDL_Color *colors);
120static void EPOC_VideoQuit(_THIS);
121
122/* Hardware surface functions */
123
124static int EPOC_AllocHWSurface(_THIS, SDL_Surface *surface);
125static int EPOC_LockHWSurface(_THIS, SDL_Surface *surface);
126static int EPOC_FlipHWSurface(_THIS, SDL_Surface *surface);
127static void EPOC_UnlockHWSurface(_THIS, SDL_Surface *surface);
128static void EPOC_FreeHWSurface(_THIS, SDL_Surface *surface);
129static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
130
131static int EPOC_Available(void);
132static SDL_VideoDevice *EPOC_CreateDevice(int devindex);
133
134void DrawBackground(_THIS);
135void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer);
136void DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer);
137
138/* Mouse functions */
139
140static WMcursor *EPOC_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
141static void EPOC_FreeWMCursor(_THIS, WMcursor *cursor);
142static int EPOC_ShowWMCursor(_THIS, WMcursor *cursor);
143}
144
145
146extern "C"
147 {
148 struct WMcursor
149 {
150 };
151 }
152
153/* Epoc video driver bootstrap functions */
154
155
156static int EPOC_Available(void)
157 {
158 return 1; /* Always available */
159 }
160
161static void EPOC_DeleteDevice(SDL_VideoDevice *device)
162 {
163 User::Free(device->hidden);
164 User::Free(device);
165 }
166
167static SDL_VideoDevice *EPOC_CreateDevice(int /*devindex*/)
168 {
169 SDL_VideoDevice *device;
170
171 SDL_TRACE("SDL:EPOC_CreateDevice");
172
173 /* Allocate all variables that we free on delete */
174 device = static_cast<SDL_VideoDevice*>(User::Alloc(sizeof(SDL_VideoDevice)));
175 if ( device )
176 {
177 Mem::FillZ(device, (sizeof *device));
178 device->hidden = static_cast<struct SDL_PrivateVideoData*>
179 (User::Alloc((sizeof *device->hidden)));
180 }
181 if ( (device == NULL) || (device->hidden == NULL) )
182 {
183 SDL_OutOfMemory();
184 if ( device ) {
185 User::Free(device);
186 }
187 return(0);
188 }
189 Mem::FillZ(device->hidden, (sizeof *device->hidden));
190
191 /* Set the function pointers */
192 device->VideoInit = EPOC_VideoInit;
193 device->ListModes = EPOC_ListModes;
194 device->SetVideoMode = EPOC_SetVideoMode;
195 device->SetColors = EPOC_SetColors;
196 device->UpdateRects = NULL;
197 device->VideoQuit = EPOC_VideoQuit;
198 device->AllocHWSurface = EPOC_AllocHWSurface;
199 device->CheckHWBlit = NULL;
200 device->FillHWRect = NULL;
201 device->SetHWColorKey = NULL;
202 device->SetHWAlpha = NULL;
203 device->LockHWSurface = EPOC_LockHWSurface;
204 device->UnlockHWSurface = EPOC_UnlockHWSurface;
205 device->FlipHWSurface = EPOC_FlipHWSurface;
206 device->FreeHWSurface = EPOC_FreeHWSurface;
207 device->SetIcon = NULL;
208 device->SetCaption = NULL;
209 device->GetWMInfo = NULL;
210 device->FreeWMCursor = EPOC_FreeWMCursor;
211 device->CreateWMCursor = EPOC_CreateWMCursor;
212 device->ShowWMCursor = EPOC_ShowWMCursor;
213 device->WarpWMCursor = NULL;
214 device->InitOSKeymap = EPOC_InitOSKeymap;
215 device->PumpEvents = EPOC_PumpEvents;
216 device->free = EPOC_DeleteDevice;
217
218 return device;
219}
220
221
222VideoBootStrap EPOC_bootstrap = {
223 "epoc\0\0\0", "EPOC system",
224 EPOC_Available, EPOC_CreateDevice
225};
226
227
228
229void DisableKeyBlocking(_THIS)
230 {
231 EpocSdlEnv::Request(EpocSdlEnv::EDisableKeyBlocking);
232 }
233
234void ConstructWindowL(_THIS)
235 {
236 SDL_TRACE("SDL:ConstructWindowL");
237 DisableKeyBlocking(_this); //disable key blocking
238 }
239
240
241int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat)
242 {
243 /* Construct Epoc window */
244
245 ConstructWindowL(_this);
246
247 /* Initialise Epoc frame buffer */
248
249
250 const TDisplayMode displayMode = EpocSdlEnv::DisplayMode();
251
252 /* The "best" video format should be returned to caller. */
253
254 vformat->BitsPerPixel = TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode);
255 vformat->BytesPerPixel = TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode) / 8;
256
257
258 //?? Private->iWindow->PointerFilter(EPointerFilterDrag, 0);
259
260 Private->iScreenPos = TPoint(0, 0);
261
262 Private->iRect.x = Private->iScreenPos.iX;
263 Private->iRect.y = Private->iScreenPos.iY;
264
265 const TSize sz = EpocSdlEnv::WindowSize();
266
267 Private->iRect.w = sz.iWidth;
268 Private->iRect.h = sz.iHeight;
269 Private->iRectPtr = &Private->iRect;
270
271 return(0);
272 }
273
274
275SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
276 {
277 if(flags & SDL_HWSURFACE)
278 {
279 if(format->BytesPerPixel != 4) //in HW only full color is supported
280 return NULL;
281 }
282 if(flags & SDL_FULLSCREEN)
283 {
284 return &Private->iRectPtr;
285 }
286 return (SDL_Rect **)(-1); //everythingisok, unless too small shoes
287 }
288
289
290int EPOC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
291 {
292 if ((firstcolor+ncolors) > 256)
293 return -1;
294 TUint32 palette[256];
295 const TDisplayMode mode = EpocSdlEnv::DisplayMode();
296 if(TDisplayModeUtils::NumDisplayModeColors(mode) == 4096)
297 {
298 // Set 12 bit palette
299 for(int i = firstcolor; i < ncolors; i++)
300 {
301 // 4k value: 0000 rrrr gggg bbbb
302 TUint32 color4K = (colors[i].r & 0x0000f0) << 4;
303 color4K |= (colors[i].g & 0x0000f0);
304 color4K |= (colors[i].b & 0x0000f0) >> 4;
305 palette[i] = color4K;
306 }
307 }
308 else if(TDisplayModeUtils::NumDisplayModeColors(mode) == 65536)
309 {
310 for(int i = firstcolor; i < ncolors; i++)
311 {
312 // 64k-colour displays effectively support RGB values
313 // with 5 bits allocated to red, 6 to green and 5 to blue
314 // 64k value: rrrr rggg gggb bbbb
315 TUint32 color64K = (colors[i].r & 0x0000f8) << 8;
316 color64K |= (colors[i].g & 0x0000fc) << 3;
317 color64K |= (colors[i].b & 0x0000f8) >> 3;
318 palette[i] = color64K;
319 }
320 }
321 else if(TDisplayModeUtils::NumDisplayModeColors(mode) == 16777216)
322 {
323 for(int i = firstcolor; i < ncolors; i++)
324 {
325 // 16M-colour
326 //0000 0000 rrrr rrrr gggg gggg bbbb bbbb
327 TUint32 color16M = colors[i].r << 16;
328 color16M |= colors[i].g << 8;
329 color16M |= colors[i].b;
330 palette[i] = color16M;
331 }
332 }
333 else
334 {
335 return -2;
336 }
337 if(EpocSdlEnv::SetPalette(firstcolor, ncolors, palette) == KErrNone)
338 return 0;
339 return -1;
340 }
341
342
343/*
344void AllocHWSurfaceL(CFbsBitmap*& aBitmap, const TDisplayMode& aMode, const TSize& aSize)
345 {
346 aBitmap = new (ELeave) CFbsBitmap();
347 if(KErrNone != aBitmap->CreateHardwareBitmap(aSize, aMode,
348 EpocSdlEnv::EikonEnv().EikAppUi()->Application()->AppDllUid()))
349 //...if it fails - should we use wsbitmaps???
350 {//the good reason to use hw bitmaps is that they wont need lock heap
351 PANIC_IF_ERROR(aBitmap->Create(aSize, aMode));
352 }
353 }
354
355int CreateSurfaceL(_THIS, SDL_Surface* surface)
356 {
357 __ASSERT_ALWAYS(Private->iFrame == NULL, PANIC(KErrAlreadyExists));
358;
359 TInt dmode = EColorLast;
360
361 TDisplayMode displayMode;
362 EpocSdlEnv::GetDiplayMode(displayMode);
363
364 if(
365 TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode)
366 == surface->format->BitsPerPixel)
367 {
368 dmode = displayMode;
369 }
370 else
371 {
372 --dmode;
373 while(TDisplayModeUtils::IsDisplayModeColor(TDisplayMode(dmode)) &&
374 TDisplayModeUtils::NumDisplayModeBitsPerPixel(TDisplayMode(dmode)) !=
375 surface->format->BitsPerPixel)
376 --dmode;
377 }
378
379 __ASSERT_ALWAYS(TDisplayModeUtils::IsDisplayModeColor(TDisplayMode(dmode)), PANIC(KErrNotSupported));
380 TRAPD(err, AllocHWSurfaceL(Private->iFrame, TDisplayMode(dmode), TSize(surface->w, surface->h)));
381 return err == KErrNone ? 0 : -1;
382 }
383*/
384
385TDisplayMode GetDisplayMode(TInt aBitsPerPixel)
386 {
387 const TDisplayMode displayMode = EpocSdlEnv::DisplayMode();
388 TInt dmode = EColorLast;
389 if(
390 TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode)
391 == aBitsPerPixel)
392 {
393 dmode = displayMode;
394 }
395 else
396 {
397 --dmode;
398 while(TDisplayModeUtils::IsDisplayModeColor(TDisplayMode(dmode)) &&
399 TDisplayModeUtils::NumDisplayModeBitsPerPixel(TDisplayMode(dmode)) !=
400 aBitsPerPixel)
401 --dmode;
402 }
403 return TDisplayMode(dmode);
404 }
405
406SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current,
407 int width, int height, int bpp, Uint32 flags)
408 {
409 const TSize screenSize = EpocSdlEnv::WindowSize(TSize(width, height));
410 if(width > screenSize.iWidth || height > screenSize.iHeight)
411 {
412 if(flags & SDL_FULLSCREEN)
413 {
414 width = screenSize.iWidth;
415 height = screenSize.iHeight;
416 }
417 else
418 return NULL;
419 }
420
421 if(current && current->pixels)
422 {
423 // free(current->pixels);
424 current->pixels = NULL;
425 }
426
427 if(!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0))
428 {
429 return(NULL);
430 }
431
432 current->flags = 0;
433 if(width == screenSize.iWidth && height == screenSize.iHeight)
434 current->flags |= SDL_FULLSCREEN;
435
436 const int numBytesPerPixel = ((bpp-1)>>3) + 1;
437 current->pitch = numBytesPerPixel * width; // Number of bytes in scanline
438
439 /* Set up the new mode framebuffer */
440 current->flags |= SDL_PREALLOC;
441
442 if(bpp <= 8)
443 current->flags |= SDL_HWPALETTE;
444
445 User::Free(Private->iSwSurface);
446 current->pixels = NULL;
447 Private->iSwSurface = NULL;
448
449 if(flags & SDL_HWSURFACE)
450 {
451 current->flags |= SDL_HWSURFACE;
452 // current->pixels = NULL;
453 // Private->iSwSurface = NULL;
454 }
455 else
456 {
457 current->flags |= SDL_SWSURFACE;
458 const TInt surfacesize = width * height * numBytesPerPixel;
459 Private->iSwSurfaceSize = TSize(width, height);
460 delete Private->iSwSurface;
461 Private->iSwSurface = NULL;
462 current->pixels = (TUint8*) User::AllocL(surfacesize);
463 Private->iSwSurface = (TUint8*) current->pixels;
464 const TInt err = EpocSdlEnv::AllocSwSurface
465 (TSize(width, height), GetDisplayMode(current->format->BitsPerPixel));
466 if(err != KErrNone)
467 return NULL;
468 }
469
470 current->w = width;
471 current->h = height;
472
473
474
475 /* Set the blit function */
476 _this->UpdateRects = EPOC_DirectUpdate;
477
478 /*
479 * Logic for getting suitable screen dimensions, offset, scaling and orientation
480 */
481
482
483 /* Centralize game window on device screen */
484
485
486 Private->iScreenPos.iX = Max(0, (screenSize.iWidth - width) / 2);
487 Private->iScreenPos.iY = Max(0, (screenSize.iHeight - height) / 2);
488
489 // delete (Private->iFrame);
490// Private->iFrame = NULL;
491
492 // TRAPD(err, CreateSurfaceL(_this, current));
493 // PANIC_IF_ERROR(err);
494
495 SDL_TRACE1("View width %d", width);
496 SDL_TRACE1("View height %d", height);
497 SDL_TRACE1("View bmode %d", bpp);
498 SDL_TRACE1("View x %d", Private->iScreenPos.iX);
499 SDL_TRACE1("View y %d", Private->iScreenPos.iY);
500
501 EpocSdlEnv::LockPalette(EFalse);
502 /* We're done */
503 return(current);
504}
505
506
507
508static int EPOC_AllocHWSurface(_THIS, SDL_Surface* surface)
509 {
510 return KErrNone == EpocSdlEnv::AllocHwSurface(TSize(surface->w, surface->h), GetDisplayMode(surface->format->BitsPerPixel));
511 }
512
513static void EPOC_FreeHWSurface(_THIS, SDL_Surface* /*surface*/)
514 {
515 }
516
517static int EPOC_LockHWSurface(_THIS, SDL_Surface* surface)
518 {
519 if(EpocSdlEnv::IsDsaAvailable())
520 {
521 TUint8* address = EpocSdlEnv::LockHwSurface();
522 if(address != NULL)
523 {
524 surface->pixels = address;
525 return 1;
526 }
527 }
528 return 0;
529 }
530static void EPOC_UnlockHWSurface(_THIS, SDL_Surface* /*surface*/)
531 {
532 EpocSdlEnv::UnlockHwSurface();
533 }
534
535static int EPOC_FlipHWSurface(_THIS, SDL_Surface* /*surface*/)
536 {
537 return(0);
538 }
539
540static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
541 {
542 if(EpocSdlEnv::IsDsaAvailable())
543 {
544 if(Private->iSwSurface)
545 {
546 const TRect target(Private->iScreenPos, Private->iSwSurfaceSize);
547 for(TInt i = 0; i < numrects ;i++)
548 {
549 const TRect rect(TPoint(rects[i].x, rects[i].y),
550 TSize(rects[i].w, rects[i].h));
551 if(!EpocSdlEnv::AddUpdateRect(Private->iSwSurface, rect, target))
552 return; //not succesful
553 }
554 EpocSdlEnv::UpdateSwSurface();
555 }
556 SDL_PauseAudio(0);
557 }
558 else
559 {
560 SDL_PauseAudio(1);
561 EpocSdlEnv::WaitDsaAvailable();
562 }
563 }
564
565
566/* Note: If we are terminated, this could be called in the middle of
567 another SDL video routine -- notably UpdateRects.
568*/
569void EPOC_VideoQuit(_THIS)
570 {
571// delete Private->iFrame;
572// Private->iFrame = NULL;
573 User::Free(Private->iSwSurface);
574 Private->iSwSurface = NULL;
575 EpocSdlEnv::FreeSurface();
576 }
577
578
579
580
581WMcursor *EPOC_CreateWMCursor(_THIS, Uint8* /*data*/, Uint8* /*mask*/, int /*w*/, int /*h*/, int /*hot_x*/, int /*hot_y*/)
582 {
583 return (WMcursor*) 1; //hii! prevents SDL to view a std cursor
584 }
585
586void EPOC_FreeWMCursor(_THIS, WMcursor* /*cursor*/)
587 {
588 }
589
590int EPOC_ShowWMCursor(_THIS, WMcursor *cursor)
591 {
592 return true;
593 }
594
diff --git a/apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocvideo.h b/apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocvideo.h
deleted file mode 100644
index 5aa3a20248..0000000000
--- a/apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocvideo.h
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@devolution.com
21*/
22
23#ifndef EPOCVIDEO_H
24#define EPOCVIDEO_H
25
26#include<w32std.h>
27
28/* Hidden "this" pointer for the video functions */
29#define _THIS SDL_VideoDevice *_this
30#define Private _this->hidden
31
32class CFbsBitmap;
33
34struct SDL_VideoDevice;
35void DisableKeyBlocking(SDL_VideoDevice*);
36
37struct SDL_PrivateVideoData
38 {
39 TPoint iScreenPos;
40 TBool iIsWindowFocused;
41 TSize iSwSurfaceSize;
42 TUint8* iSwSurface;
43 SDL_Rect iRect; //same info in SDL format
44 SDL_Rect* iRectPtr;
45 };
46
47#endif
48
49
50
51
diff --git a/apps/plugins/sdl/src/video/symbian/EKA2/dsa.cpp b/apps/plugins/sdl/src/video/symbian/EKA2/dsa.cpp
deleted file mode 100644
index 07b1ab4137..0000000000
--- a/apps/plugins/sdl/src/video/symbian/EKA2/dsa.cpp
+++ /dev/null
@@ -1,1505 +0,0 @@
1#include "dsa.h"
2#include "sdlepocapi.h"
3#include <cdsb.h>
4
5
6LOCAL_C TInt BytesPerPixel(TDisplayMode aMode)
7 {
8 return ((TDisplayModeUtils::NumDisplayModeBitsPerPixel(aMode) - 1) >> 3) + 1;
9 }
10
11
12
13
14template<class T>
15NONSHARABLE_CLASS(CBitmapSurface) : public T
16 {
17public:
18 CBitmapSurface(RWsSession& aSession);
19private:
20 void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice);
21 ~CBitmapSurface();
22 TUint8* LockSurface();
23 void UnlockHwSurface();
24 void CreateSurfaceL();
25 void Wipe(TInt aLength);
26 void Free();
27 void Update(CFbsBitmap& aBmp);
28 TInt ExternalUpdate();
29private:
30 CFbsBitmap* iBmp;
31 CFbsBitmap* iCopyBmp;
32 };
33
34
35template<class T>
36void CBitmapSurface<T>::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
37 {
38 delete iCopyBmp;
39 iCopyBmp = NULL;
40 iCopyBmp = new (ELeave) CFbsBitmap();
41 T::ConstructL(aWindow, aDevice);
42 }
43
44template<class T>
45CBitmapSurface<T>::CBitmapSurface(RWsSession& aSession) : T(aSession)
46 {
47 }
48
49template<class T>
50void CBitmapSurface<T>::Free()
51 {
52 delete iBmp;
53 iBmp = NULL;
54 T::Free();
55 }
56
57template<class T>
58CBitmapSurface<T>::~CBitmapSurface()
59 {
60 __ASSERT_DEBUG(iBmp == NULL, PANIC(KErrNotReady));
61 delete iCopyBmp;
62 }
63
64template<class T>
65TUint8* CBitmapSurface<T>::LockSurface()
66 {
67 iBmp->LockHeap();
68 return reinterpret_cast<TUint8*>(iBmp->DataAddress());
69 }
70
71
72template<class T>
73void CBitmapSurface<T>::UnlockHwSurface()
74 {
75 iBmp->UnlockHeap();
76 T::SetUpdating(EFalse);
77 Update(*iBmp);
78 }
79
80
81template<class T>
82void CBitmapSurface<T>::Update(CFbsBitmap& aBmp)
83 {
84 if(!T::Blitter(aBmp))
85 {
86 if(T::SwSize() == T::HwRect().Size())
87 T::Gc().BitBlt(T::HwRect().iTl, &aBmp);
88 else
89 T::Gc().DrawBitmap(T::HwRect(), &aBmp);
90 }
91 T::DrawOverlays();
92 T::CompleteUpdate();
93 }
94
95template<class T>
96void CBitmapSurface<T>::CreateSurfaceL()
97 {
98 Free();
99 iBmp = new (ELeave) CFbsBitmap();
100 User::LeaveIfError(iBmp->Create(T::SwSize(), T::DisplayMode()));
101 T::CreateSurfaceL(*iBmp);
102 }
103
104template<class T>
105void CBitmapSurface<T>::Wipe(TInt aLength) //dont call in drawing
106 {
107 iBmp->LockHeap();
108 Mem::FillZ(iBmp->DataAddress(), aLength);
109 iBmp->UnlockHeap();
110 }
111
112template<class T>
113TInt CBitmapSurface<T>::ExternalUpdate()
114 {
115 if(iCopyBmp->Handle() == 0)
116 {
117 const TInt err = iCopyBmp->Duplicate(iBmp->Handle());
118 if(err != KErrNone)
119 return err;
120 }
121 Update(*iCopyBmp);
122 return KErrNone;
123 }
124
125
126//////////////////////////////////////////////////////////////////////
127
128
129
130NONSHARABLE_CLASS(CDsaBitgdi) : public CDsa
131 {
132public:
133 CDsaBitgdi(RWsSession& aSession);
134protected:
135 void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice);
136 CBitmapContext& Gc();
137 void CompleteUpdate();
138 ~CDsaBitgdi();
139 void CreateSurfaceL(CFbsBitmap& aBmp);
140 void Free();
141 void UnlockHWSurfaceRequestComplete();
142private:
143 void Resume();
144
145 CFbsBitGc* iGc;
146 CFbsDevice* iDevice;
147 CFbsBitmap* iBitGdiBmp;
148 CWindowGc* iWinGc;
149 RWindow* iWindow;
150 TInt iHandle;
151 };
152
153
154CDsaBitgdi::CDsaBitgdi(RWsSession& aSession) : CDsa(aSession)
155 {
156 }
157
158CDsaBitgdi::~CDsaBitgdi()
159 {
160 delete iWinGc;
161 delete iBitGdiBmp;
162 }
163
164void CDsaBitgdi::CompleteUpdate()
165 {
166 EpocSdlEnv::Request(CDsa::ERequestUpdate);
167 }
168
169
170void CDsaBitgdi::UnlockHWSurfaceRequestComplete()
171 {
172 if(iHandle == 0)
173 return;
174
175 if(iBitGdiBmp == NULL)
176 {
177 iBitGdiBmp = new CFbsBitmap();
178 if(iBitGdiBmp == NULL)
179 return;
180 iBitGdiBmp->Duplicate(iHandle);
181 }
182
183 iWindow->Invalidate();
184
185 iWindow->BeginRedraw();
186 iWinGc->Activate(*iWindow);
187 iWinGc->BitBlt(TPoint(0, 0), iBitGdiBmp);
188 iWinGc->Deactivate();
189 iWindow->EndRedraw();
190 }
191
192void CDsaBitgdi::Resume()
193 {
194 Start();
195 }
196
197CBitmapContext& CDsaBitgdi::Gc()
198 {
199 return *iGc;
200 }
201
202 void CDsaBitgdi::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
203 {
204
205 delete iBitGdiBmp;
206 iBitGdiBmp = NULL;
207 delete iWinGc;
208 iWinGc = NULL;
209 iHandle = 0;
210
211 iWindow = &aWindow;
212 User::LeaveIfError(aDevice.CreateContext(iWinGc));
213 CDsa::ConstructL(aWindow, aDevice);
214 Start();
215 }
216
217void CDsaBitgdi::CreateSurfaceL(CFbsBitmap& aBmp)
218 {
219 iDevice = CFbsBitmapDevice::NewL(&aBmp);
220 User::LeaveIfError(iDevice->CreateContext(iGc));
221 iHandle = aBmp.Handle();
222 }
223
224void CDsaBitgdi::Free()
225 {
226 delete iGc;
227 iGc = NULL;
228 delete iDevice;
229 iDevice = NULL;
230 }
231
232////////////////////////////////////////////////////////////////////////
233///////////////////////////////////////////////////////////////////////
234
235NONSHARABLE_CLASS(CDsaBase) : public CDsa, public MDirectScreenAccess
236 {
237protected:
238 inline CDirectScreenAccess& Dsa() const;
239 CDsaBase(RWsSession& aSession);
240 ~CDsaBase();
241 void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice);
242 void Stop();
243 void Resume();
244 CBitmapContext& Gc();
245protected:
246 CDirectScreenAccess* iDsa;
247private:
248 void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
249 void Restart(RDirectScreenAccess::TTerminationReasons aReason);
250private:
251 void RestartL();
252 };
253
254
255inline CDirectScreenAccess& CDsaBase::Dsa() const
256 {
257 return *iDsa;
258 }
259
260
261CDsaBase::CDsaBase(RWsSession& aSession) : CDsa(aSession)
262 {
263 }
264
265CBitmapContext& CDsaBase::Gc()
266 {
267 return *Dsa().Gc();
268 }
269
270void CDsaBase::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
271 {
272 CDsa::ConstructL(aWindow, aDevice);
273 if(iDsa != NULL)
274 {
275 iDsa->Cancel();
276 delete iDsa;
277 iDsa = NULL;
278 }
279
280 iDsa = CDirectScreenAccess::NewL(
281 Session(),
282 aDevice,
283 aWindow,
284 *this);
285 RestartL();
286 }
287
288void CDsaBase::Resume()
289 {
290 if(Stopped())
291 Restart(RDirectScreenAccess::ETerminateRegion);
292 }
293
294CDsaBase::~CDsaBase()
295 {
296 if(iDsa != NULL)
297 {
298 iDsa->Cancel();
299 }
300 delete iDsa;
301 }
302
303
304void CDsaBase::RestartL()
305 {
306
307
308 iDsa->StartL();
309
310 const RRegion* r = iDsa->DrawingRegion();
311 const TRect rect = r->BoundingRect();
312 iDsa->Gc()->SetClippingRegion(r);
313
314 if(rect != ScreenRect())
315 {
316 return ;
317 }
318
319
320 SetTargetRect();
321 RecreateL();
322
323 Start();
324
325
326 }
327
328void CDsaBase::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
329 {
330 Stop();
331 }
332
333void CDsaBase::Restart(RDirectScreenAccess::TTerminationReasons aReason)
334 {
335 if(aReason == RDirectScreenAccess::ETerminateRegion) //auto restart
336 {
337 TRAPD(err, RestartL());
338 PANIC_IF_ERROR(err);
339 }
340 }
341
342
343void CDsaBase::Stop()
344 {
345 CDsa::Stop();
346 iDsa->Cancel();
347 }
348
349
350 ///////////////////////////////////////////////////////////////////////
351 ///////////////////////////////////////////////////////////////////////
352NONSHARABLE_CLASS(TDsa)
353 {
354 public:
355 inline TDsa(const CDsa& aDsa);
356 inline TBool IsFlip() const;
357 inline TBool IsTurn() const;
358 inline const TSize& SwSize() const;
359 inline void Copy(TUint32* aTarget, const TUint8* aSrc, TInt aBytes, TInt aHeight) const;
360 private:
361 const CDsa& iDsa;
362 };
363
364
365
366
367inline TDsa::TDsa(const CDsa& aDsa) : iDsa(aDsa)
368 {
369 }
370
371inline TBool TDsa::IsTurn() const
372 {
373 return iDsa.iStateFlags & CDsa::EOrientation90;
374 }
375
376inline TBool TDsa::IsFlip() const
377 {
378 return iDsa.iStateFlags & CDsa::EOrientation180;
379 }
380
381inline const TSize& TDsa::SwSize() const
382 {
383 return iDsa.SwSize();
384 }
385
386inline void TDsa::Copy(TUint32* aTarget, const TUint8* aSrc, TInt aBytes, TInt aHeight) const
387 {
388 iDsa.iCopyFunction(iDsa, aTarget, aSrc, aBytes, aHeight);
389 }
390
391template<class T, class S>
392void ClipCopy(const TDsa& iDsa, TUint8* aTarget,
393 const TUint8* aSource,
394 const TRect& aUpdateRect,
395 const TRect& aSourceRect)
396 {
397 const S* source = reinterpret_cast<const S*>(aSource);
398 const TInt lineWidth = aSourceRect.Width();
399
400 source += (aUpdateRect.iTl.iY * lineWidth);
401 const TInt sourceStartOffset = aUpdateRect.iTl.iX;
402 source += sourceStartOffset;
403
404 T* targetPtr = reinterpret_cast<T*>(aTarget);
405
406 const TInt scanLineWidth = iDsa.SwSize().iWidth;
407
408 targetPtr += (aSourceRect.iTl.iY + aUpdateRect.iTl.iY ) * scanLineWidth;
409 const TInt targetStartOffset = (aUpdateRect.iTl.iX + aSourceRect.iTl.iX);
410
411 targetPtr += targetStartOffset;
412
413
414 const TInt height = aUpdateRect.Height();
415
416 const TInt lineMove = iDsa.IsTurn() ? 1 : lineWidth;
417 const TInt copyLen = aUpdateRect.Width();
418
419
420 if(iDsa.IsFlip())
421 {
422
423 targetPtr += scanLineWidth * (height - 1);
424
425 for(TInt i = 0; i < height; i++) //source is always smaller
426 {
427 iDsa.Copy(reinterpret_cast<TUint32*>(targetPtr), reinterpret_cast<const TUint8*>(source), copyLen, height);
428 source += lineMove;
429 targetPtr -= scanLineWidth;
430 }
431 }
432 else
433 {
434
435
436 for(TInt i = 0; i < height; i++) //source is always smaller
437 {
438 iDsa.Copy(reinterpret_cast<TUint32*>(targetPtr), reinterpret_cast<const TUint8*>(source), copyLen, height);
439 source += lineMove;
440 targetPtr += scanLineWidth; // >> 2;
441 }
442 }
443
444 }
445
446
447
448NONSHARABLE_CLASS(CDsaA) : public CDsaBase
449 {
450 public:
451 CDsaA(RWsSession& aSession);
452 protected:
453 void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice);
454 void CompleteUpdate();
455 void CreateSurfaceL(CFbsBitmap& aBmp);
456 void Free();
457 void UnlockHWSurfaceRequestComplete();
458 };
459
460
461CDsaA::CDsaA(RWsSession& aSession) : CDsaBase(aSession)
462 {
463 }
464
465
466void CDsaA::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
467 {
468 CDsaBase::ConstructL(aWindow, aDevice);
469 }
470
471void CDsaA::CompleteUpdate()
472 {
473 iDsa->ScreenDevice()->Update();
474 }
475
476void CDsaA::CreateSurfaceL(CFbsBitmap& /*aBmp*/)
477 {
478 }
479
480void CDsaA::Free()
481 {
482
483 }
484
485void CDsaA::UnlockHWSurfaceRequestComplete()
486 {
487 PANIC(KErrNotSupported);
488 }
489
490
491
492//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
493
494NONSHARABLE_CLASS(MDsbObs)
495 {
496 public:
497 virtual void SurfaceReady() = 0;
498 virtual CDirectScreenBitmap& Dsb() = 0;
499 };
500
501NONSHARABLE_CLASS(CDsbSurface) : public CActive
502 {
503 public:
504 CDsbSurface(MDsbObs& aDsb);
505 TUint8* Address();
506 void Complete();
507 ~CDsbSurface();
508 private:
509 void RunL();
510 void DoCancel();
511 private:
512 MDsbObs& iDsb;
513 TUint8* iAddress;
514 };
515
516CDsbSurface::CDsbSurface(MDsbObs& aDsb) : CActive(CActive::EPriorityHigh) , iDsb(aDsb)
517 {
518 CActiveScheduler::Add(this);
519 }
520
521CDsbSurface::~CDsbSurface()
522 {
523 Cancel();
524 }
525
526void CDsbSurface::Complete()
527 {
528 if(iAddress != NULL && !IsActive())
529 {
530 iAddress = NULL;
531 SetActive();
532 iDsb.Dsb().EndUpdate(iStatus);
533 }
534 }
535
536TUint8* CDsbSurface::Address()
537 {
538 if(iAddress == NULL && !IsActive())
539 {
540 TAcceleratedBitmapInfo info;
541 if(KErrNone == iDsb.Dsb().BeginUpdate(info))
542 iAddress = info.iAddress;
543 }
544 return iAddress;
545 }
546
547void CDsbSurface::RunL()
548 {
549 iDsb.SurfaceReady();
550 }
551
552void CDsbSurface::DoCancel()
553 {
554 //empty
555 }
556
557NONSHARABLE_CLASS(CDsaB) : public CDsaBase,
558 public MDsbObs
559 {
560 public:
561 CDsaB(RWsSession& aSession, TInt aFlags);
562 private:
563 ~CDsaB();
564 TUint8* LockSurface();
565 void UnlockHWSurfaceRequestComplete();
566 void UnlockHwSurface();
567 void CreateSurfaceL();
568 void Wipe(TInt aLength);
569 void RecreateL();
570 void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice);
571 CDirectScreenBitmap& Dsb();
572 void SurfaceReady();
573 TInt ExternalUpdate();
574 private:
575 CDsbSurface* iSurface1;
576 CDsbSurface* iSurface2;
577 CDirectScreenBitmap* iDsb;
578 TInt iType;
579 };
580
581CDsaB::CDsaB(RWsSession& aSession, TInt aFlags) : CDsaBase(aSession), iType(aFlags)
582 {
583 }
584
585
586
587void CDsaB::UnlockHWSurfaceRequestComplete()
588 {
589 iSurface1->Complete();
590 if(iSurface2 != NULL)
591 iSurface2->Complete();
592 }
593
594void CDsaB::CreateSurfaceL()
595 {
596 __ASSERT_ALWAYS(SwSize() == HwRect().Size(), PANIC(KErrNotSupported));
597 }
598
599void CDsaB::Wipe(TInt aLength) //dont call in drawing
600 {
601 TUint8* addr = LockSurface();
602 if(addr != NULL)
603 {
604 Mem::FillZ(addr, aLength);
605 UnlockHwSurface();
606 }
607 }
608
609
610void CDsaB::UnlockHwSurface()
611 {
612 EpocSdlEnv::Request(CDsa::ERequestUpdate);
613 }
614
615TUint8* CDsaB::LockSurface()
616 {
617 TUint8* addr = iSurface1->Address();
618 if(addr == NULL && iSurface2 != NULL)
619 addr = iSurface2->Address();
620 SetUpdating(addr == NULL);
621 return addr;
622 }
623
624void CDsaB::SurfaceReady()
625 {
626 SetUpdating(EFalse);
627 }
628
629CDirectScreenBitmap& CDsaB::Dsb()
630 {
631 return *iDsb;
632 }
633
634void CDsaB::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
635 {
636 if(iDsb == NULL)
637 iDsb = CDirectScreenBitmap::NewL();
638 CDsaBase::ConstructL(aWindow, aDevice);
639 if(iSurface1 == NULL)
640 iSurface1 = new (ELeave) CDsbSurface(*this);
641 if(iSurface2 == NULL && iType & CDirectScreenBitmap::EDoubleBuffer)
642 iSurface2 = new (ELeave) CDsbSurface(*this);
643 }
644
645CDsaB::~CDsaB()
646 {
647 delete iSurface1;
648 delete iSurface2;
649 delete iDsb;
650 }
651
652void CDsaB::RecreateL()
653 {
654 iDsb->Close();
655 iDsb->Create(HwRect(), CDirectScreenBitmap::TSettingsFlags(iType));
656 }
657
658TInt CDsaB::ExternalUpdate()
659 {
660 if(LockSurface())
661 {
662 UnlockHWSurfaceRequestComplete();
663 return KErrNone;
664 }
665 return KErrNotReady;
666 }
667
668
669/////////////////////////////////////////////////////////////////////////////////////////////////////
670
671
672
673CDsa* CDsa::CreateL(RWsSession& aSession)
674 {
675 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSB))
676 {
677 TInt flags = CDirectScreenBitmap::ENone;
678 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBDoubleBuffer))
679 flags |= CDirectScreenBitmap::EDoubleBuffer;
680 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBIncrementalUpdate))
681 flags |= CDirectScreenBitmap::EIncrementalUpdate;
682 return new (ELeave) CDsaB(aSession, flags);
683 }
684 else if(EpocSdlEnv::Flags(CSDL::EDrawModeGdi))
685 {
686 return new (ELeave) CBitmapSurface<CDsaBitgdi>(aSession);
687 }
688 else
689 {
690 return new (ELeave) CBitmapSurface<CDsaA>(aSession);
691 }
692 }
693
694
695void CDsa::RecreateL()
696 {
697 }
698
699void CDsa::Free()
700 {
701 }
702
703TSize CDsa::WindowSize() const
704 {
705 TSize size = iSwSize;
706 if(iStateFlags & EOrientation90)
707 {
708 const TInt tmp = size.iWidth;
709 size.iWidth = size.iHeight;
710 size.iHeight = tmp;
711 }
712 return size;
713 }
714
715void CDsa::SetSuspend()
716 {
717 iStateFlags |= ESdlThreadSuspend;
718 }
719
720
721void CDsa::SetUpdating(TBool aUpdate)
722 {
723 if(aUpdate)
724 iStateFlags |= EUpdating;
725 else
726 iStateFlags &= ~EUpdating;
727 }
728
729
730TBool CDsa::Stopped() const
731 {
732 return (iStateFlags & ESdlThreadExplicitStop);
733 }
734
735void CDsa::SetOrientation(CSDL::TOrientationMode aOrientation)
736 {
737 TInt flags = 0;
738 switch(aOrientation)
739 {
740 case CSDL::EOrientation90:
741 flags = EOrientation90;
742 break;
743 case CSDL::EOrientation180:
744 flags = EOrientation180;
745 break;
746 case CSDL::EOrientation270:
747 flags = EOrientation90 | EOrientation180;
748 break;
749 case CSDL::EOrientation0:
750 flags = 0;
751 break;
752 }
753 if(flags != (iStateFlags & EOrientationFlags))
754 {
755 iStateFlags |= EOrientationChanged;
756 iNewFlags = flags; //cannot be set during drawing...
757 }
758 }
759
760CDsa::~CDsa()
761 {
762 iOverlays.Close();
763 User::Free(iLut256);
764 }
765
766void CDsa::ConstructL(RWindow& aWindow, CWsScreenDevice& /*aDevice*/)
767 {
768 if(iLut256 == NULL)
769 iLut256 = (TUint32*) User::AllocL(256 * sizeof(TUint32));
770 iTargetMode = aWindow.DisplayMode();
771 iTargetBpp = BytesPerPixel(DisplayMode());
772 iScreenRect = TRect(aWindow.Position(), aWindow.Size());
773 SetTargetRect();
774 }
775
776void CDsa::DrawOverlays()
777 {
778 const TInt last = iOverlays.Count() - 1;
779 for(TInt i = last; i >= 0 ; i--)
780 iOverlays[i].iOverlay->Draw(Gc(), HwRect(), SwSize());
781 }
782
783TInt CDsa::AppendOverlay(MOverlay& aOverlay, TInt aPriority)
784 {
785 TInt i;
786 for(i = 0; i < iOverlays.Count() && iOverlays[i].iPriority < aPriority; i++)
787 {}
788 const TOverlay overlay = {&aOverlay, aPriority};
789 return iOverlays.Insert(overlay, i);
790 }
791
792TInt CDsa::RemoveOverlay(MOverlay& aOverlay)
793 {
794 for(TInt i = 0; i < iOverlays.Count(); i++)
795 {
796 if(iOverlays[i].iOverlay == &aOverlay)
797 {
798 iOverlays.Remove(i);
799 return KErrNone;
800 }
801 }
802 return KErrNotFound;
803 }
804
805void CDsa::LockPalette(TBool aLock)
806 {
807 if(aLock)
808 iStateFlags |= EPaletteLocked;
809 else
810 iStateFlags &= ~EPaletteLocked;
811 }
812TInt CDsa::SetPalette(TInt aFirst, TInt aCount, TUint32* aPalette)
813 {
814 if(iLut256 == NULL)
815 return KErrNotFound;
816 const TInt count = aCount - aFirst;
817 if(count > 256)
818 return KErrArgument;
819 if(iStateFlags & EPaletteLocked)
820 return KErrNone;
821 for(TInt i = aFirst; i < count; i++) //not so busy here:-)
822 {
823 iLut256[i] = aPalette[i];
824 }
825 return KErrNone;
826 }
827
828
829
830
831
832CDsa::CDsa(RWsSession& aSession) :
833 iStateFlags(0),
834 iSession(aSession)
835
836 {
837// CActiveScheduler::Add(this);
838 iCFTable[0] = CopyMem;
839 iCFTable[1] = CopyMemFlipReversed;
840 iCFTable[2] = CopyMemReversed;
841 iCFTable[3] = CopyMemFlip;
842
843 iCFTable[4] = Copy256;
844 iCFTable[5] = Copy256FlipReversed;
845 iCFTable[6] = Copy256Reversed;
846 iCFTable[7] = Copy256Flip;
847
848
849 iCFTable[8] = CopySlow;
850 iCFTable[9] = CopySlowFlipReversed;
851 iCFTable[10] = CopySlowReversed;
852 iCFTable[11] = CopySlowFlip;
853 }
854
855RWsSession& CDsa::Session()
856 {
857 return iSession;
858 }
859
860TInt CDsa::RedrawRequest()
861 {
862 if(!(iStateFlags & (EUpdating) && (iStateFlags & ERunning)))
863 {
864 return ExternalUpdate();
865 }
866 return KErrNotReady;
867 }
868
869TUint8* CDsa::LockHwSurface()
870 {
871 if((iStateFlags & EUpdating) == 0) //else frame is skipped
872 {
873 return LockSurface();
874 }
875 return NULL;
876 }
877
878/*
879void CDsa::RunL()
880 {
881 iStateFlags &= ~EUpdating;
882 }
883
884
885void CDsa::DoCancel()
886 {
887 iStateFlags &= ~EUpdating;
888 //nothing can do, just wait?
889 }
890*/
891
892
893TInt CDsa::AllocSurface(TBool aHwSurface, const TSize& aSize, TDisplayMode aMode)
894 {
895 if(aHwSurface && aMode != DisplayMode())
896 return KErrArgument;
897
898 iSourceMode = aMode;
899
900 iSourceBpp = BytesPerPixel(aMode);
901
902 const TSize size = WindowSize();
903 if(aSize.iWidth > size.iWidth)
904 return KErrTooBig;
905 if(aSize.iHeight > size.iHeight)
906 return KErrTooBig;
907
908 TRAPD(err, CreateSurfaceL());
909 if(err != KErrNone)
910 return err;
911
912 SetCopyFunction();
913
914 return KErrNone;
915 }
916
917
918void CDsa::CreateZoomerL(const TSize& aSize)
919 {
920 iSwSize = aSize;
921 iStateFlags |= EResizeRequest;
922 CreateSurfaceL();
923 SetTargetRect();
924 }
925
926
927/*
928void SaveBmp(const TDesC& aName, const TAny* aData, TInt aLength, const TSize& aSz, TDisplayMode aMode)
929 {
930 CFbsBitmap* s = new CFbsBitmap();
931 s->Create(aSz, aMode);
932 s->LockHeap();
933 TUint32* addr = s->DataAddress();
934 Mem::Copy(addr, aData, aLength);
935 s->UnlockHeap();
936 s->Save(aName);
937 s->Reset();
938 delete s;
939 }
940
941void SaveBmp(const TDesC& aName, const TUint32* aData, const TSize& aSz)
942 {
943 CFbsBitmap* s = new CFbsBitmap();
944 s->Create(aSz, EColor64K);
945 TBitmapUtil bmp(s);
946 bmp.Begin(TPoint(0, 0));
947 for(TInt j = 0; j < aSz.iHeight; j++)
948 {
949 bmp.SetPos(TPoint(0, j));
950 for(TInt i = 0; i < aSz.iWidth; i++)
951 {
952 bmp.SetPixel(*aData);
953 aData++;
954 bmp.IncXPos();
955 }
956 }
957 bmp.End();
958 s->Save(aName);
959 s->Reset();
960 delete s;
961 }
962
963TBuf<16> FooName(TInt aFoo)
964 {
965 TBuf<16> b;
966 b.Format(_L("C:\\pic%d.mbm"), aFoo);
967 return b;
968 }
969
970*/
971
972
973void CDsa::ClipCopy(TUint8* aTarget,
974 const TUint8* aSource,
975 const TRect& aUpdateRect,
976 const TRect& aSourceRect) const
977 {
978 const TDsa dsa(*this);
979 switch(iSourceBpp)
980 {
981 case 1:
982 ::ClipCopy<TUint32, TUint8>(dsa, aTarget, aSource, aUpdateRect, aSourceRect);
983 break;
984 case 2:
985 ::ClipCopy<TUint32, TUint16>(dsa, aTarget, aSource, aUpdateRect, aSourceRect);
986 break;
987 case 4:
988 ::ClipCopy<TUint32, TUint32>(dsa, aTarget, aSource, aUpdateRect, aSourceRect);
989 break;
990 }
991 }
992
993
994void CDsa::Wipe() //dont call in drawing
995 {
996 if(IsDsaAvailable())
997 Wipe(iTargetBpp * SwSize().iWidth * SwSize().iHeight);
998 }
999
1000void CDsa::SetCopyFunction()
1001 {
1002 //calculate offset to correct function in iCFTable according to given parameters
1003 TInt function = 0;
1004 const TInt KCopyFunctions = 4;
1005 const TInt KOffsetToNative = 0;
1006 const TInt KOffsetTo256 = KOffsetToNative + KCopyFunctions;
1007 const TInt KOffsetToOtherModes = KOffsetTo256 + KCopyFunctions;
1008 const TInt KOffsetTo90Functions = 1;
1009 const TInt KOffsetTo180Functions = 2;
1010
1011 if(iSourceMode == DisplayMode())
1012 function = KOffsetToNative; //0
1013 else if(iSourceMode == EColor256)
1014 function = KOffsetTo256; //4
1015 else
1016 function = KOffsetToOtherModes; //8
1017
1018 if(iStateFlags & EOrientation90)
1019 function += KOffsetTo90Functions; // + 1
1020 if(iStateFlags & EOrientation180)
1021 function += KOffsetTo180Functions; //+ 2
1022
1023 iCopyFunction = iCFTable[function];
1024
1025 Wipe();
1026 }
1027
1028inline void Rotate(TRect& aRect)
1029 {
1030 const TInt dx = aRect.iBr.iX - aRect.iTl.iX;
1031 const TInt dy = aRect.iBr.iY - aRect.iTl.iY;
1032
1033 aRect.iBr.iX = aRect.iTl.iX + dy;
1034 aRect.iBr.iY = aRect.iTl.iY + dx;
1035
1036 const TInt tmp = aRect.iTl.iX;
1037 aRect.iTl.iX = aRect.iTl.iY;
1038 aRect.iTl.iY = tmp;
1039 }
1040
1041/*
1042int bar = 0;
1043*/
1044
1045TBool CDsa::AddUpdateRect(const TUint8* aBits, const TRect& aUpdateRect, const TRect& aRect)
1046 {
1047
1048 if(iStateFlags & EOrientationChanged)
1049 {
1050 iStateFlags &= ~EOrientationFlags;
1051 iStateFlags |= iNewFlags;
1052 SetCopyFunction();
1053 iStateFlags &= ~EOrientationChanged;
1054 EpocSdlEnv::WaitDeviceChange();
1055 return EFalse; //skip this frame as data is may be changed
1056 }
1057
1058 if(iTargetAddr == NULL)
1059 {
1060 iTargetAddr = LockHwSurface();
1061 }
1062
1063 TUint8* target = iTargetAddr;
1064 if(target == NULL)
1065 return EFalse;
1066
1067
1068 TRect targetRect = TRect(TPoint(0, 0), SwSize());
1069
1070 TRect sourceRect = aRect;
1071 TRect updateRect = aUpdateRect;
1072
1073// TPoint move(0, 0);
1074
1075
1076 if(iStateFlags & EOrientation90)
1077 {
1078 Rotate(sourceRect);
1079 Rotate(updateRect);
1080 }
1081
1082 if(iSourceMode != DisplayMode() || targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0))
1083 {
1084 sourceRect.Intersection(targetRect); //so source always smaller or equal than target
1085 //updateRect.Intersection(targetRect);
1086 ClipCopy(target, aBits, updateRect, sourceRect);
1087 }
1088 else
1089 {
1090 const TInt byteCount = aRect.Width() * aRect.Height() * iSourceBpp; //this could be stored
1091 Mem::Copy(target, aBits, byteCount);
1092 }
1093
1094 return ETrue;
1095 }
1096
1097
1098void CDsa::UpdateSwSurface()
1099 {
1100 iTargetAddr = NULL;
1101 UnlockHwSurface(); //could be faster if does not use AO, but only check status before redraw, then no context switch needed
1102 }
1103
1104
1105
1106
1107void CDsa::DoStop()
1108 {
1109 if(IsDsaAvailable())
1110 iStateFlags |= ESdlThreadExplicitStop;
1111 Stop();
1112 }
1113
1114
1115void CDsa::Stop()
1116 {
1117 iStateFlags &= ~ERunning;
1118 }
1119
1120void CDsa::Start()
1121 {
1122 iStateFlags |= ERunning;
1123
1124 iStateFlags &= ~ESdlThreadExplicitStop;
1125
1126 if(iStateFlags & ESdlThreadSuspend)
1127 {
1128 EpocSdlEnv::Resume();
1129 iStateFlags &= ~ ESdlThreadSuspend;
1130 }
1131 EpocSdlEnv::ObserverEvent(MSDLObserver::EEventWindowReserved);
1132 }
1133
1134
1135TBool CDsa::Blitter(CFbsBitmap& aBmp)
1136 {
1137 return iBlitter && iBlitter->BitBlt(Gc(), aBmp, HwRect(), SwSize());
1138 }
1139
1140void CDsa::SetBlitter(MBlitter* aBlitter)
1141 {
1142 iBlitter = aBlitter;
1143 }
1144
1145
1146TPoint CDsa::WindowCoordinates(const TPoint& aPoint) const
1147 {
1148 TPoint pos = aPoint - iScreenRect.iTl;
1149 const TSize asz = iScreenRect.Size();
1150 if(iStateFlags & EOrientation180)
1151 {
1152 pos.iX = asz.iWidth - pos.iX;
1153 pos.iY = asz.iHeight - pos.iY;
1154 }
1155 if(iStateFlags & EOrientation90)
1156 {
1157 pos.iX = aPoint.iY;
1158 pos.iY = aPoint.iX;
1159 }
1160 pos.iX <<= 16;
1161 pos.iY <<= 16;
1162 pos.iX /= asz.iWidth;
1163 pos.iY /= asz.iHeight;
1164 pos.iX *= iSwSize.iWidth;
1165 pos.iY *= iSwSize.iHeight;
1166 pos.iX >>= 16;
1167 pos.iY >>= 16;
1168 return pos;
1169 }
1170
1171void CDsa::SetTargetRect()
1172 {
1173 iTargetRect = iScreenRect;
1174 if(iStateFlags & EResizeRequest && EpocSdlEnv::Flags(CSDL::EAllowImageResizeKeepRatio))
1175 {
1176 const TSize asz = iScreenRect.Size();
1177 const TSize sz = iSwSize;
1178
1179 TRect rect;
1180
1181 const TInt dh = (sz.iHeight << 16) / sz.iWidth;
1182
1183 if((asz.iWidth * dh ) >> 16 <= asz.iHeight)
1184 {
1185 rect.SetRect(TPoint(0, 0), TSize(asz.iWidth, (asz.iWidth * dh) >> 16));
1186 }
1187 else
1188 {
1189 const TInt dw = (sz.iWidth << 16) / sz.iHeight;
1190 rect.SetRect(TPoint(0, 0), TSize((asz.iHeight * dw) >> 16, asz.iHeight));
1191 }
1192 rect.Move((asz.iWidth - rect.Size().iWidth) >> 1, (asz.iHeight - rect.Size().iHeight) >> 1);
1193
1194 iTargetRect = rect;
1195 iTargetRect.Move(iScreenRect.iTl);
1196
1197 }
1198 if(!(iStateFlags & EResizeRequest))
1199 iSwSize = iScreenRect.Size();
1200
1201 }
1202
1203
1204/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1205
1206void CDsa::Copy256(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1207 {
1208 TUint32* target = aTarget;
1209 const TUint32* endt = target + aBytes;
1210 const TUint8* source = aSource;
1211 while(target < endt)
1212 {
1213 *target++ = aDsa.iLut256[*source++];
1214 }
1215 }
1216
1217void CDsa::Copy256Reversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1218 {
1219 const TUint32* target = aTarget;
1220 TUint32* endt = aTarget + aBytes;
1221 const TUint8* source = aSource;
1222 while(target < endt)
1223 {
1224 *(--endt) = aDsa.iLut256[*source++];
1225 }
1226 }
1227
1228void CDsa::Copy256Flip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1229 {
1230 TUint32* target = aTarget;
1231 const TUint32* endt = target + aBytes;
1232 const TUint8* column = aSource;
1233
1234 while(target < endt)
1235 {
1236 *target++ = aDsa.iLut256[*column];
1237 column += aLineLen;
1238 }
1239 }
1240
1241void CDsa::Copy256FlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1242 {
1243 const TUint32* target = aTarget;
1244 TUint32* endt = aTarget + aBytes;
1245 const TUint8* column = aSource;
1246
1247 while(target < endt)
1248 {
1249 *(--endt) = aDsa.iLut256[*column];
1250 column += aLineLen;
1251 }
1252 }
1253
1254void CDsa::CopyMem(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1255 {
1256 const TUint32* src = reinterpret_cast<const TUint32*>(aSource);
1257 Mem::Copy(aTarget, src, aBytes << 2);
1258 }
1259
1260void CDsa::CopyMemFlip(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1261 {
1262 TUint32* target = aTarget;
1263 const TUint32* endt = target + aBytes;
1264 const TUint32* column = reinterpret_cast<const TUint32*>(aSource);
1265
1266 while(target < endt)
1267 {
1268 *target++ = *column;
1269 column += aLineLen;
1270 }
1271 }
1272
1273void CDsa::CopyMemReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1274 {
1275 const TUint32* target = aTarget;
1276 TUint32* endt = aTarget + aBytes;
1277 const TUint32* source = reinterpret_cast<const TUint32*>(aSource);
1278 while(target < endt)
1279 {
1280 *(--endt) = *source++;
1281 }
1282 }
1283
1284
1285void CDsa::CopyMemFlipReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1286 {
1287 const TUint32* target = aTarget;
1288 TUint32* endt = aTarget + aBytes;
1289 const TUint32* column = reinterpret_cast<const TUint32*>(aSource);
1290
1291 while(target < endt)
1292 {
1293 *(--endt) = *column;
1294 column += aLineLen;
1295 }
1296 }
1297
1298/*
1299
1300LOCAL_C TRgb rgb16MA(TInt aValue)
1301 {
1302 return TRgb::Color16MA(aValue);
1303 }
1304*/
1305NONSHARABLE_CLASS(MRgbCopy)
1306 {
1307 public:
1308 virtual void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed) = 0;
1309 virtual void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed) = 0;
1310 };
1311
1312template <class T>
1313NONSHARABLE_CLASS(TRgbCopy) : public MRgbCopy
1314 {
1315 public:
1316 TRgbCopy(TDisplayMode aMode);
1317 void* operator new(TUint aBytes, TAny* aMem);
1318 void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed);
1319 void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed);
1320 static TUint32 Gray256(const TUint8& aPixel);
1321 static TUint32 Color256(const TUint8& aPixel);
1322 static TUint32 Color4K(const TUint16& aPixel);
1323 static TUint32 Color64K(const TUint16& aPixel);
1324 static TUint32 Color16M(const TUint32& aPixel);
1325 static TUint32 Color16MU(const TUint32& aPixel);
1326 static TUint32 Color16MA(const TUint32& aPixel);
1327 private:
1328 typedef TUint32 (*TRgbFunc) (const T& aValue);
1329 TRgbFunc iFunc;
1330 };
1331
1332
1333template <class T>
1334void* TRgbCopy<T>::operator new(TUint /*aBytes*/, TAny* aMem)
1335 {
1336 return aMem;
1337 }
1338
1339template <class T>
1340TRgbCopy<T>::TRgbCopy(TDisplayMode aMode)
1341 {
1342 switch(aMode)
1343 {
1344 case EGray256 : iFunc = (TRgbFunc) Gray256; break;
1345 case EColor256 : iFunc = (TRgbFunc) Color256; break;
1346 case EColor4K : iFunc = (TRgbFunc) Color4K; break;
1347 case EColor64K : iFunc = (TRgbFunc) Color64K; break;
1348 case EColor16M : iFunc = (TRgbFunc) Color16M; break;
1349 case EColor16MU : iFunc = (TRgbFunc) Color16MU; break;
1350 case EColor16MA : iFunc = (TRgbFunc) Color16MA; break;
1351 default:
1352 PANIC(KErrNotSupported);
1353 }
1354 }
1355
1356template <class T>
1357void TRgbCopy<T>::Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed)
1358 {
1359 const T* source = reinterpret_cast<const T*>(aSource);
1360 TUint32* target = aTarget;
1361 TUint32* endt = target + aBytes;
1362
1363 if(aReversed)
1364 {
1365 while(target < endt)
1366 {
1367 const T value = *source++;
1368 *(--endt) = iFunc(value);//iFunc(value).Value();
1369 }
1370 }
1371 else
1372 {
1373 while(target < endt)
1374 {
1375 const T value = *source++;
1376 *target++ = iFunc(value);//iFunc(value).Value();
1377 }
1378 }
1379 }
1380
1381template <class T>
1382void TRgbCopy<T>::FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed)
1383 {
1384 const T* column = reinterpret_cast<const T*>(aSource);
1385 TUint32* target = aTarget;
1386 TUint32* endt = target + aBytes;
1387
1388 if(aReversed)
1389 {
1390 while(target < endt)
1391 {
1392 *(--endt) = iFunc(*column);
1393 column += aLineLen;
1394 }
1395 }
1396 else
1397 {
1398 while(target < endt)
1399 {
1400 *target++ = iFunc(*column);
1401 column += aLineLen;
1402 }
1403 }
1404 }
1405
1406template <class T> TUint32 TRgbCopy<T>::Gray256(const TUint8& aPixel)
1407 {
1408 const TUint32 px = aPixel << 16 | aPixel << 8 | aPixel;
1409 return px;
1410 }
1411
1412template <class T> TUint32 TRgbCopy<T>::Color256(const TUint8& aPixel)
1413 {
1414 return TRgb::Color256(aPixel).Value();
1415 }
1416
1417template <class T> TUint32 TRgbCopy<T>::Color4K(const TUint16& aPixel)
1418 {
1419 TUint32 col = (aPixel & 0xF00) << 12;
1420 col |= (aPixel & 0xF00) << 8;
1421
1422 col |= (aPixel & 0x0F0) << 8;
1423 col |= (aPixel & 0x0F0);
1424
1425 col |= (aPixel & 0x00F) << 4;
1426 col |= (aPixel & 0x00F);
1427
1428 return col;
1429 }
1430
1431template <class T> TUint32 TRgbCopy<T>::Color64K(const TUint16& aPixel)
1432 {
1433 TUint32 col = (aPixel & 0xF800)<< 8;
1434 col |= (aPixel & 0xE000) << 3;
1435
1436 col |= (aPixel & 0x07E0) << 5;
1437 col |= (aPixel & 0xC0) >> 1;
1438
1439 col |= (aPixel & 0x07E0) << 3;
1440 col |= (aPixel & 0x1C) >> 2;
1441
1442 return col;
1443 }
1444
1445template <class T> TUint32 TRgbCopy<T>::Color16M(const TUint32& aPixel)
1446 {
1447 return TRgb::Color16M(aPixel).Value();
1448 }
1449
1450template <class T> TUint32 TRgbCopy<T>::Color16MU(const TUint32& aPixel)
1451 {
1452 return TRgb::Color16MU(aPixel).Value();
1453 }
1454
1455template <class T> TUint32 TRgbCopy<T>::Color16MA(const TUint32& aPixel)
1456 {
1457 return TRgb::Color16MA(aPixel).Value();
1458 }
1459
1460typedef TUint64 TStackMem;
1461
1462LOCAL_C MRgbCopy* GetCopy(TAny* mem, TDisplayMode aMode)
1463 {
1464 if(aMode == EColor256 || aMode == EGray256)
1465 {
1466 return new (mem) TRgbCopy<TUint8>(aMode);
1467 }
1468 if(aMode == EColor4K || aMode == EColor64K)
1469 {
1470 return new (mem) TRgbCopy<TUint16>(aMode);
1471 }
1472 if(aMode == EColor16M || aMode == EColor16MU || aMode == EColor16MA)
1473 {
1474 return new (mem) TRgbCopy<TUint32>(aMode);
1475 }
1476 PANIC(KErrNotSupported);
1477 return NULL;
1478 }
1479
1480
1481void CDsa::CopySlowFlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1482 {
1483 TStackMem mem = 0;
1484 GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, ETrue);
1485 }
1486
1487void CDsa::CopySlowFlip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1488 {
1489 TStackMem mem = 0;
1490 GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, EFalse);
1491 }
1492
1493void CDsa::CopySlow(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1494 {
1495 TStackMem mem = 0;
1496 GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, EFalse);
1497 }
1498
1499void CDsa::CopySlowReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1500 {
1501 TStackMem mem = 0;
1502 GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, ETrue);
1503 }
1504
1505////////////////////////////////////////////////////////////////////////////////////////////////////////////////7
diff --git a/apps/plugins/sdl/src/video/symbian/EKA2/dsa_new.cpp b/apps/plugins/sdl/src/video/symbian/EKA2/dsa_new.cpp
deleted file mode 100644
index 638fbe8c94..0000000000
--- a/apps/plugins/sdl/src/video/symbian/EKA2/dsa_new.cpp
+++ /dev/null
@@ -1,1443 +0,0 @@
1#include "dsa.h"
2#include "sdlepocapi.h"
3#include <cdsb.h>
4
5
6LOCAL_C TInt BytesPerPixel(TDisplayMode aMode)
7 {
8 return ((TDisplayModeUtils::NumDisplayModeBitsPerPixel(aMode) - 1) >> 3) + 1;
9 }
10
11
12NONSHARABLE_CLASS(TDsa)
13 {
14 public:
15 inline TDsa(const CDsa& aDsa);
16 inline TBool IsFlip() const;
17 inline TBool IsTurn() const;
18 inline const TSize& SwSize() const;
19 inline void Copy(TUint32* aTarget, const TUint8* aSrc, TInt aBytes, TInt aHeight) const;
20 private:
21 const CDsa& iDsa;
22 };
23
24
25inline TDsa::TDsa(const CDsa& aDsa) : iDsa(aDsa)
26 {
27 }
28
29inline TBool TDsa::IsTurn() const
30 {
31 return iDsa.iStateFlags & CDsa::EOrientation90;
32 }
33
34inline TBool TDsa::IsFlip() const
35 {
36 return iDsa.iStateFlags & CDsa::EOrientation180;
37 }
38
39inline const TSize& TDsa::SwSize() const
40 {
41 return iDsa.SwSize();
42 }
43
44inline void TDsa::Copy(TUint32* aTarget, const TUint8* aSrc, TInt aBytes, TInt aHeight) const
45 {
46 iDsa.iCopyFunction(iDsa, aTarget, aSrc, aBytes, aHeight);
47 }
48
49template<class T, class S>
50void ClipCopy(const TDsa& iDsa, TUint8* aTarget,
51 const TUint8* aSource,
52 const TRect& aUpdateRect,
53 const TRect& aSourceRect)
54 {
55 const S* source = reinterpret_cast<const S*>(aSource);
56 const TInt lineWidth = aSourceRect.Width();
57
58 source += (aUpdateRect.iTl.iY * lineWidth);
59 const TInt sourceStartOffset = aUpdateRect.iTl.iX;
60 source += sourceStartOffset;
61
62 T* targetPtr = reinterpret_cast<T*>(aTarget);
63
64 const TInt scanLineWidth = iDsa.SwSize().iWidth;
65
66 targetPtr += (aSourceRect.iTl.iY + aUpdateRect.iTl.iY ) * scanLineWidth;
67 const TInt targetStartOffset = (aUpdateRect.iTl.iX + aSourceRect.iTl.iX);
68
69 targetPtr += targetStartOffset;
70
71
72 const TInt height = aUpdateRect.Height();
73
74 const TInt lineMove = iDsa.IsTurn() ? 1 : lineWidth;
75 const TInt copyLen = aUpdateRect.Width();
76
77
78 if(iDsa.IsFlip())
79 {
80
81 targetPtr += scanLineWidth * (height - 1);
82
83 for(TInt i = 0; i < height; i++) //source is always smaller
84 {
85 iDsa.Copy(reinterpret_cast<TUint32*>(targetPtr), reinterpret_cast<const TUint8*>(source), copyLen, height);
86 source += lineMove;
87 targetPtr -= scanLineWidth;
88 }
89 }
90 else
91 {
92
93
94 for(TInt i = 0; i < height; i++) //source is always smaller
95 {
96 iDsa.Copy(reinterpret_cast<TUint32*>(targetPtr), reinterpret_cast<const TUint8*>(source), copyLen, height);
97 source += lineMove;
98 targetPtr += scanLineWidth; // >> 2;
99 }
100 }
101
102 }
103
104
105
106NONSHARABLE_CLASS(CDsaA) : public CDsa
107 {
108 public:
109 CDsaA(RWsSession& aSession);
110 private:
111 ~CDsaA();
112 TUint8* LockSurface();
113 void UnlockHWSurfaceRequestComplete();
114 void UnlockHwSurface();
115 void CreateSurfaceL();
116 void Wipe(TInt aLength);
117 void Free();
118 void Update(CFbsBitmap& aBmp);
119 void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice);
120 TInt ExternalUpdate();
121 // void ExternalUpdate();
122 protected:
123 CFbsBitmap* iBmp;
124 CFbsBitmap* iCopyBmp;
125 };
126
127
128CDsaA::CDsaA(RWsSession& aSession) : CDsa(aSession)
129 {
130 }
131
132
133void CDsaA::Free()
134 {
135 delete iBmp;
136 iBmp = NULL;
137 }
138
139CDsaA::~CDsaA()
140 {
141 __ASSERT_DEBUG(iBmp == NULL, PANIC(KErrNotReady));
142 delete iCopyBmp;
143 }
144
145TUint8* CDsaA::LockSurface()
146 {
147 iBmp->LockHeap();
148 return reinterpret_cast<TUint8*>(iBmp->DataAddress());
149 }
150
151void CDsaA::UnlockHWSurfaceRequestComplete()
152 {
153 PANIC(KErrNotSupported);
154 }
155
156void CDsaA::UnlockHwSurface()
157 {
158 iBmp->UnlockHeap();
159 SetUpdating(EFalse);
160 Update(*iBmp);
161 }
162
163void CDsaA::Update(CFbsBitmap& aBmp)
164 {
165 if(!Blitter(aBmp))
166 {
167 if(SwSize() == HwRect().Size())
168 Dsa().Gc()->BitBlt(HwRect().iTl, &aBmp);
169 else
170 Dsa().Gc()->DrawBitmap(HwRect(), &aBmp);
171 }
172 DrawOverlays();
173 Dsa().ScreenDevice()->Update();
174 }
175void CDsaA::CreateSurfaceL()
176 {
177 delete iBmp;
178 iBmp = NULL;
179 iBmp = new (ELeave) CFbsBitmap();
180 User::LeaveIfError(iBmp->Create(SwSize(), DisplayMode()));
181 }
182
183void CDsaA::Wipe(TInt aLength) //dont call in drawing
184 {
185 iBmp->LockHeap();
186 Mem::FillZ(iBmp->DataAddress(), aLength);
187 iBmp->UnlockHeap();
188 }
189
190
191
192TInt CDsaA::ExternalUpdate()
193 {
194 if(iCopyBmp->Handle() == 0)
195 {
196 const TInt err = iCopyBmp->Duplicate(iBmp->Handle());
197 if(err != KErrNone)
198 return err;
199 }
200 Update(*iCopyBmp);
201 return KErrNone;
202 }
203
204void CDsaA::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
205 {
206 iCopyBmp = new (ELeave) CFbsBitmap();
207 CDsa::ConstructL(aWindow, aDevice);
208 }
209
210
211//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
212
213NONSHARABLE_CLASS(MDsbObs)
214 {
215 public:
216 virtual void SurfaceReady() = 0;
217 virtual CDirectScreenBitmap& Dsb() = 0;
218 };
219
220NONSHARABLE_CLASS(CDsbSurface) : public CActive
221 {
222 public:
223 CDsbSurface(MDsbObs& aDsb);
224 TUint8* Address();
225 void Complete();
226 ~CDsbSurface();
227 private:
228 void RunL();
229 void DoCancel();
230 private:
231 MDsbObs& iDsb;
232 TUint8* iAddress;
233 };
234
235CDsbSurface::CDsbSurface(MDsbObs& aDsb) : CActive(CActive::EPriorityHigh) , iDsb(aDsb)
236 {
237 CActiveScheduler::Add(this);
238 }
239
240CDsbSurface::~CDsbSurface()
241 {
242 Cancel();
243 }
244
245void CDsbSurface::Complete()
246 {
247 if(iAddress != NULL && !IsActive())
248 {
249 iAddress = NULL;
250 SetActive();
251 iDsb.Dsb().EndUpdate(iStatus);
252 }
253 }
254
255TUint8* CDsbSurface::Address()
256 {
257 if(iAddress == NULL && !IsActive())
258 {
259 TAcceleratedBitmapInfo info;
260 if(KErrNone == iDsb.Dsb().BeginUpdate(info))
261 iAddress = info.iAddress;
262 }
263 return iAddress;
264 }
265
266void CDsbSurface::RunL()
267 {
268 iDsb.SurfaceReady();
269 }
270
271void CDsbSurface::DoCancel()
272 {
273 //empty
274 }
275
276NONSHARABLE_CLASS(CDsaB) : public CDsa, public MDsbObs
277 {
278 public:
279 CDsaB(RWsSession& aSession, TInt aFlags);
280 private:
281 ~CDsaB();
282 TUint8* LockSurface();
283 void UnlockHWSurfaceRequestComplete();
284 void UnlockHwSurface();
285 void CreateSurfaceL();
286 void Wipe(TInt aLength);
287 void RecreateL();
288 void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice);
289 CDirectScreenBitmap& Dsb();
290 void SurfaceReady();
291 TInt ExternalUpdate();
292 private:
293 CDsbSurface* iSurface1;
294 CDsbSurface* iSurface2;
295 CDirectScreenBitmap* iDsb;
296 TInt iType;
297 };
298
299CDsaB::CDsaB(RWsSession& aSession, TInt aFlags) : CDsa(aSession), iType(aFlags)
300 {
301 }
302
303
304
305void CDsaB::UnlockHWSurfaceRequestComplete()
306 {
307 iSurface1->Complete();
308 if(iSurface2 != NULL)
309 iSurface2->Complete();
310 }
311
312void CDsaB::CreateSurfaceL()
313 {
314 __ASSERT_ALWAYS(SwSize() == HwRect().Size(), PANIC(KErrNotSupported));
315 }
316
317void CDsaB::Wipe(TInt aLength) //dont call in drawing
318 {
319 TUint8* addr = LockSurface();
320 if(addr != NULL)
321 {
322 Mem::FillZ(addr, aLength);
323 UnlockHwSurface();
324 }
325 }
326
327
328void CDsaB::UnlockHwSurface()
329 {
330 EpocSdlEnv::Request(CDsa::ERequestUpdate);
331 }
332
333TUint8* CDsaB::LockSurface()
334 {
335 TUint8* addr = iSurface1->Address();
336 if(addr == NULL && iSurface2 != NULL)
337 addr = iSurface2->Address();
338 SetUpdating(addr == NULL);
339 return addr;
340 }
341
342void CDsaB::SurfaceReady()
343 {
344 SetUpdating(EFalse);
345 }
346
347CDirectScreenBitmap& CDsaB::Dsb()
348 {
349 return *iDsb;
350 }
351
352void CDsaB::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
353 {
354 if(iDsb == NULL)
355 iDsb = CDirectScreenBitmap::NewL();
356 CDsa::ConstructL(aWindow, aDevice);
357 if(iSurface1 == NULL)
358 iSurface1 = new (ELeave) CDsbSurface(*this);
359 if(iSurface2 == NULL && iType & CDirectScreenBitmap::EDoubleBuffer)
360 iSurface2 = new (ELeave) CDsbSurface(*this);
361 }
362
363CDsaB::~CDsaB()
364 {
365 delete iSurface1;
366 delete iSurface2;
367 delete iDsb;
368 }
369
370void CDsaB::RecreateL()
371 {
372 iDsb->Close();
373 iDsb->Create(HwRect(), CDirectScreenBitmap::TSettingsFlags(iType));
374 }
375
376TInt CDsaB::ExternalUpdate()
377 {
378 if(LockSurface())
379 {
380 UnlockHWSurfaceRequestComplete();
381 return KErrNone;
382 }
383 return KErrNotReady;
384 }
385
386
387/////////////////////////////////////////////////////////////////////////////////////////////////////
388
389
390CDsa* CDsa::CreateL(RWsSession& aSession)
391 {
392 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSB))
393 {
394 TInt flags = CDirectScreenBitmap::ENone;
395 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBDoubleBuffer))
396 flags |= CDirectScreenBitmap::EDoubleBuffer;
397 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBIncrentalUpdate))
398 flags |= CDirectScreenBitmap::EIncrementalUpdate;
399 return new (ELeave) CDsaB(aSession, flags);
400 }
401 else
402 return new (ELeave) CDsaA(aSession);
403 }
404
405
406void CDsa::RecreateL()
407 {
408 }
409
410void CDsa::Free()
411 {
412 }
413
414TSize CDsa::WindowSize() const
415 {
416 TSize size = iSwSize;
417 if(iStateFlags & EOrientation90)
418 {
419 const TInt tmp = size.iWidth;
420 size.iWidth = size.iHeight;
421 size.iHeight = tmp;
422 }
423 return size;
424 }
425
426void CDsa::SetSuspend()
427 {
428 iStateFlags |= ESdlThreadSuspend;
429 }
430
431void CDsa::ReleaseStop()
432 {
433 iStateFlags &= ~ESdlThreadExplicitStop;
434 }
435
436
437TBool CDsa::Stopped() const
438 {
439 return (iStateFlags & ESdlThreadExplicitStop);
440 }
441
442void CDsa::SetOrientation(CSDL::TOrientationMode aOrientation)
443 {
444 TInt flags = 0;
445 switch(aOrientation)
446 {
447 case CSDL::EOrientation90:
448 flags = EOrientation90;
449 break;
450 case CSDL::EOrientation180:
451 flags = EOrientation180;
452 break;
453 case CSDL::EOrientation270:
454 flags = EOrientation90 | EOrientation180;
455 break;
456 case CSDL::EOrientation0:
457 flags = 0;
458 break;
459 }
460 if(flags != (iStateFlags & EOrientationFlags))
461 {
462 iStateFlags |= EOrientationChanged;
463 iNewFlags = flags; //cannot be set during drawing...
464 }
465 }
466
467CDsa::~CDsa()
468 {
469 if(iDsa != NULL)
470 {
471 iDsa->Cancel();
472 }
473 iOverlays.Close();
474 delete iDsa;
475 User::Free(iLut256);
476 }
477
478void CDsa::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
479 {
480 if(iDsa != NULL)
481 {
482 iDsa->Cancel();
483 delete iDsa;
484 iDsa = NULL;
485 }
486
487 iDsa = CDirectScreenAccess::NewL(
488 iSession,
489 aDevice,
490 aWindow,
491 *this);
492
493 if(iLut256 == NULL)
494 iLut256 = (TUint32*) User::AllocL(256 * sizeof(TUint32));
495 iTargetMode = aWindow.DisplayMode();
496 iTargetBpp = BytesPerPixel(DisplayMode());
497 iScreenRect = TRect(aWindow.Position(), aWindow.Size());
498 SetTargetRect();
499 RestartL();
500 }
501
502void CDsa::DrawOverlays()
503 {
504 const TInt last = iOverlays.Count() - 1;
505 for(TInt i = last; i >= 0 ; i--)
506 iOverlays[i].iOverlay->Draw(*iDsa->Gc(), HwRect(), SwSize());
507 }
508
509TInt CDsa::AppendOverlay(MOverlay& aOverlay, TInt aPriority)
510 {
511 TInt i;
512 for(i = 0; i < iOverlays.Count() && iOverlays[i].iPriority < aPriority; i++)
513 {}
514 const TOverlay overlay = {&aOverlay, aPriority};
515 return iOverlays.Insert(overlay, i);
516 }
517
518TInt CDsa::RemoveOverlay(MOverlay& aOverlay)
519 {
520 for(TInt i = 0; i < iOverlays.Count(); i++)
521 {
522 if(iOverlays[i].iOverlay == &aOverlay)
523 {
524 iOverlays.Remove(i);
525 return KErrNone;
526 }
527 }
528 return KErrNotFound;
529 }
530
531void CDsa::LockPalette(TBool aLock)
532 {
533 if(aLock)
534 iStateFlags |= EPaletteLocked;
535 else
536 iStateFlags &= ~EPaletteLocked;
537 }
538TInt CDsa::SetPalette(TInt aFirst, TInt aCount, TUint32* aPalette)
539 {
540 if(iLut256 == NULL)
541 return KErrNotFound;
542 const TInt count = aCount - aFirst;
543 if(count > 256)
544 return KErrArgument;
545 if(iStateFlags & EPaletteLocked)
546 return KErrNone;
547 for(TInt i = aFirst; i < count; i++) //not so busy here:-)
548 {
549 iLut256[i] = aPalette[i];
550 }
551 return KErrNone;
552 }
553
554
555
556void CDsa::RestartL()
557 {
558 //const TBool active = iDsa->IsActive();
559
560 //if(!active)
561
562 iDsa->StartL();
563
564 const RRegion* r = iDsa->DrawingRegion();
565 const TRect rect = r->BoundingRect();
566 iDsa->Gc()->SetClippingRegion(r);
567
568 if(rect != iScreenRect)
569 {
570 // iDsa->Cancel();
571 return ;
572 }
573
574
575
576 //iScreenRect = rect; //to ensure properly set, albeit may not(?) match to value SDL has - therefore may has to clip
577 //targetrect shall no change
578 SetTargetRect();
579 RecreateL();
580
581 iStateFlags |= ERunning;
582
583 ReleaseStop();
584 if(iStateFlags & ESdlThreadSuspend)
585 {
586 EpocSdlEnv::Resume();
587 iStateFlags &= ~ ESdlThreadSuspend;
588 }
589 EpocSdlEnv::ObserverEvent(MSDLObserver::EEventWindowReserved);
590 }
591
592CDsa::CDsa(RWsSession& aSession) :
593 iSession(aSession),
594 iStateFlags(0)
595 {
596// CActiveScheduler::Add(this);
597 iCFTable[0] = CopyMem;
598 iCFTable[1] = CopyMemFlipReversed;
599 iCFTable[2] = CopyMemReversed;
600 iCFTable[3] = CopyMemFlip;
601
602 iCFTable[4] = Copy256;
603 iCFTable[5] = Copy256FlipReversed;
604 iCFTable[6] = Copy256Reversed;
605 iCFTable[7] = Copy256Flip;
606
607
608 iCFTable[8] = CopySlow;
609 iCFTable[9] = CopySlowFlipReversed;
610 iCFTable[10] = CopySlowReversed;
611 iCFTable[11] = CopySlowFlip;
612 }
613
614RWsSession& CDsa::Session()
615 {
616 return iSession;
617 }
618
619TInt CDsa::RedrawRequest()
620 {
621 if(!(iStateFlags & (EUpdating) && (iStateFlags & ERunning)))
622 {
623 return ExternalUpdate();
624 }
625 return KErrNotReady;
626 }
627
628TUint8* CDsa::LockHwSurface()
629 {
630 if((iStateFlags & EUpdating) == 0) //else frame is skipped
631 {
632 return LockSurface();
633 }
634 return NULL;
635 }
636
637/*
638void CDsa::RunL()
639 {
640 iStateFlags &= ~EUpdating;
641 }
642
643
644void CDsa::DoCancel()
645 {
646 iStateFlags &= ~EUpdating;
647 //nothing can do, just wait?
648 }
649*/
650
651
652TInt CDsa::AllocSurface(TBool aHwSurface, const TSize& aSize, TDisplayMode aMode)
653 {
654 if(aHwSurface && aMode != DisplayMode())
655 return KErrArgument;
656
657 iSourceMode = aMode;
658
659 iSourceBpp = BytesPerPixel(aMode);
660
661 const TSize size = WindowSize();
662 if(aSize.iWidth > size.iWidth)
663 return KErrTooBig;
664 if(aSize.iHeight > size.iHeight)
665 return KErrTooBig;
666
667 TRAPD(err, CreateSurfaceL());
668 if(err != KErrNone)
669 return err;
670
671 SetCopyFunction();
672
673 return KErrNone;
674 }
675
676
677void CDsa::CreateZoomerL(const TSize& aSize)
678 {
679 iSwSize = aSize;
680 iStateFlags |= EResizeRequest;
681 CreateSurfaceL();
682 SetTargetRect();
683 }
684
685
686/*
687void SaveBmp(const TDesC& aName, const TAny* aData, TInt aLength, const TSize& aSz, TDisplayMode aMode)
688 {
689 CFbsBitmap* s = new CFbsBitmap();
690 s->Create(aSz, aMode);
691 s->LockHeap();
692 TUint32* addr = s->DataAddress();
693 Mem::Copy(addr, aData, aLength);
694 s->UnlockHeap();
695 s->Save(aName);
696 s->Reset();
697 delete s;
698 }
699
700void SaveBmp(const TDesC& aName, const TUint32* aData, const TSize& aSz)
701 {
702 CFbsBitmap* s = new CFbsBitmap();
703 s->Create(aSz, EColor64K);
704 TBitmapUtil bmp(s);
705 bmp.Begin(TPoint(0, 0));
706 for(TInt j = 0; j < aSz.iHeight; j++)
707 {
708 bmp.SetPos(TPoint(0, j));
709 for(TInt i = 0; i < aSz.iWidth; i++)
710 {
711 bmp.SetPixel(*aData);
712 aData++;
713 bmp.IncXPos();
714 }
715 }
716 bmp.End();
717 s->Save(aName);
718 s->Reset();
719 delete s;
720 }
721
722TBuf<16> FooName(TInt aFoo)
723 {
724 TBuf<16> b;
725 b.Format(_L("C:\\pic%d.mbm"), aFoo);
726 return b;
727 }
728
729void ClipCopy(TUint8* aTarget, const TUint8* aSource, const TRect& aRect, const TPoint& aTargetPos)
730 {
731 const TInt iSourceBpp = 1;
732 const TInt iTargetBpp = 4;
733 const TInt iScanLineWidth = 800;
734
735 TUint8* target = aTarget;
736 const TUint8* source = aSource;
737 const TInt lineWidth = aRect.Width();
738 source += iSourceBpp * (aRect.iTl.iY * lineWidth);
739 const TInt sourceStartOffset = iSourceBpp * aRect.iTl.iX;
740 source += sourceStartOffset;
741 target += iTargetBpp * ((aTargetPos.iY + aRect.iTl.iY ) * lineWidth);
742 const TInt targetStartOffset = iTargetBpp * (aRect.iTl.iX + aTargetPos.iX);
743 target += targetStartOffset;
744 TUint32* targetPtr = reinterpret_cast<TUint32*>(target);
745 const TInt targetWidth = iScanLineWidth >> 2;
746 const TInt height = aRect.Height();
747 }
748*/
749/*
750void CDsa::ClipCopy(TUint8* aTarget,
751 const TUint8* aSource,
752 const TRect& aUpdateRect,
753 const TRect& aSourceRect) const
754 {
755 //TUint8* target = aTarget;
756 const TUint32* source = (const TUint32*) aSource;
757 const TInt lineWidth = aSourceRect.Width();
758
759 source += (aUpdateRect.iTl.iY * lineWidth);
760 const TInt sourceStartOffset = aUpdateRect.iTl.iX;
761 source += sourceStartOffset;
762
763 TUint32* targetPtr = reinterpret_cast<TUint32*>(aTarget);
764
765 targetPtr += (aSourceRect.iTl.iY + aUpdateRect.iTl.iY ) * SwSize().iWidth;
766 const TInt targetStartOffset = (aUpdateRect.iTl.iX + aSourceRect.iTl.iX);
767
768 targetPtr += targetStartOffset;
769
770// TUint32* targetPtr = reinterpret_cast<TUint32*>(target);
771
772 const TInt targetWidth32 = SwSize().iWidth;
773
774 const TInt height = aUpdateRect.Height();
775
776 const TInt lineMove = iStateFlags & EOrientation90 ? 1 : lineWidth;
777 const TInt copyLen = aUpdateRect.Width();
778
779
780 if(iStateFlags & EOrientation180)
781 {
782
783 targetPtr += targetWidth32 * (height - 1);
784
785 for(TInt i = 0; i < height; i++) //source is always smaller
786 {
787 iCopyFunction(*this, targetPtr, (TUint8*)source, copyLen, height);
788 source += lineMove;
789 targetPtr -= targetWidth32;
790 }
791 }
792 else
793 {
794
795
796 for(TInt i = 0; i < height; i++) //source is always smaller
797 {
798 iCopyFunction(*this, targetPtr, (TUint8*)source, copyLen, height);
799 source += lineMove;
800 targetPtr += targetWidth32; // >> 2;
801 }
802 }
803
804 }
805
806*/
807
808void CDsa::ClipCopy(TUint8* aTarget, const TUint8* aSource, const TRect& aRect, const TPoint& aTargetPos) const
809 {
810 TUint8* target = aTarget;
811 const TUint8* source = aSource;
812 const TInt lineWidth = aRect.Width();
813 source += iSourceBpp * (aRect.iTl.iY * lineWidth);
814 TInt sourceStartOffset = iSourceBpp * aRect.iTl.iX;
815 source += sourceStartOffset;
816 target += iTargetBpp * ((aTargetPos.iY + aRect.iTl.iY ) * lineWidth);
817 TInt targetStartOffset = iTargetBpp * (aRect.iTl.iX + aTargetPos.iX);
818 target += targetStartOffset;
819 TUint32* targetPtr = reinterpret_cast<TUint32*>(target);
820 const TInt targetWidth = iScanLineWidth >> 2;
821 const TInt height = aRect.Height();
822
823 TInt lineMove = iStateFlags & EOrientation90 ? 1 : lineWidth;
824
825 if(iStateFlags & EOrientation180)
826 {
827
828 targetPtr += targetWidth * (height - 1);
829
830 for(TInt i = 0; i < height; i++) //source is always smaller
831 {
832 iCopyFunction(*this, targetPtr, source, lineWidth, height);
833 source += lineMove;
834 targetPtr -= targetWidth;
835 }
836 }
837 else
838 {
839
840
841 for(TInt i = 0; i < height; i++) //source is always smaller
842 {
843 iCopyFunction(*this, targetPtr, source, lineWidth, height);
844 source += lineMove;
845 targetPtr += targetWidth;
846 }
847 }
848
849 }
850
851
852
853 /*
854void CDsa::ClipCopy(TUint8* aTarget,
855 const TUint8* aSource,
856 const TRect& aUpdateRect,
857 const TRect& aSourceRect) const
858 {
859 const TDsa dsa(*this);
860 switch(iSourceBpp)
861 {
862 case 1:
863 ::ClipCopy<TUint32, TUint8>(dsa, aTarget, aSource, aUpdateRect, aSourceRect);
864 break;
865 case 2:
866 ::ClipCopy<TUint32, TUint16>(dsa, aTarget, aSource, aUpdateRect, aSourceRect);
867 break;
868 case 4:
869 ::ClipCopy<TUint32, TUint32>(dsa, aTarget, aSource, aUpdateRect, aSourceRect);
870 break;
871 }
872 }
873
874
875*/
876
877
878
879void CDsa::Wipe() //dont call in drawing
880 {
881 if(IsDsaAvailable())
882 Wipe(iTargetBpp * SwSize().iWidth * SwSize().iHeight);
883 }
884
885void CDsa::SetCopyFunction()
886 {
887 //calculate offset to correct function in iCFTable according to given parameters
888 TInt function = 0;
889 const TInt KCopyFunctions = 4;
890 const TInt KOffsetToNative = 0;
891 const TInt KOffsetTo256 = KOffsetToNative + KCopyFunctions;
892 const TInt KOffsetToOtherModes = KOffsetTo256 + KCopyFunctions;
893 const TInt KOffsetTo90Functions = 1;
894 const TInt KOffsetTo180Functions = 2;
895
896 if(iSourceMode == DisplayMode())
897 function = KOffsetToNative; //0
898 else if(iSourceMode == EColor256)
899 function = KOffsetTo256; //4
900 else
901 function = KOffsetToOtherModes; //8
902
903 if(iStateFlags & EOrientation90)
904 function += KOffsetTo90Functions; // + 1
905 if(iStateFlags & EOrientation180)
906 function += KOffsetTo180Functions; //+ 2
907
908 iCopyFunction = iCFTable[function];
909
910 Wipe();
911 }
912
913inline void Rotate(TRect& aRect)
914 {
915 const TInt dx = aRect.iBr.iX - aRect.iTl.iX;
916 const TInt dy = aRect.iBr.iY - aRect.iTl.iY;
917
918 aRect.iBr.iX = aRect.iTl.iX + dy;
919 aRect.iBr.iY = aRect.iTl.iY + dx;
920
921 const TInt tmp = aRect.iTl.iX;
922 aRect.iTl.iX = aRect.iTl.iY;
923 aRect.iTl.iY = tmp;
924 }
925
926/*
927int bar = 0;
928*/
929/*
930TBool CDsa::AddUpdateRect(const TUint8* aBits, const TRect& aUpdateRect, const TRect& aRect)
931 {
932
933 if(iStateFlags & EOrientationChanged)
934 {
935 iStateFlags &= ~EOrientationFlags;
936 iStateFlags |= iNewFlags;
937 SetCopyFunction();
938 iStateFlags &= ~EOrientationChanged;
939 EpocSdlEnv::WaitDeviceChange();
940 return EFalse; //skip this frame as data is may be changed
941 }
942
943 if(iTargetAddr == NULL)
944 {
945 iTargetAddr = LockHwSurface();
946 }
947
948 TUint8* target = iTargetAddr;
949 if(target == NULL)
950 return EFalse;
951
952
953 TRect targetRect = TRect(TPoint(0, 0), SwSize());
954
955 TRect sourceRect = aRect;
956 TRect updateRect = aUpdateRect;
957
958// TPoint move(0, 0);
959
960
961 if(iStateFlags & EOrientation90)
962 {
963 Rotate(sourceRect);
964 Rotate(updateRect);
965 }
966
967 if(iSourceMode != DisplayMode() || targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0))
968 {
969 sourceRect.Intersection(targetRect); //so source always smaller or equal than target
970 //updateRect.Intersection(targetRect);
971 ClipCopy(target, aBits, updateRect, sourceRect);
972 }
973 else
974 {
975 const TInt byteCount = aRect.Width() * aRect.Height() * iSourceBpp; //this could be stored
976 Mem::Copy(target, aBits, byteCount);
977 }
978
979 return ETrue;
980 }
981 */
982
983TBool CDsa::AddUpdateRect(const TUint8* aBits, const TRect& aUpdateRect, const TRect& aRect)
984 {
985
986 if(iStateFlags & EOrientationChanged)
987 {
988 iStateFlags &= ~EOrientationFlags;
989 iStateFlags |= iNewFlags;
990 SetCopyFunction();
991 iStateFlags &= ~EOrientationChanged;
992 EpocSdlEnv::WaitDeviceChange();
993 return EFalse; //skip this frame as data is may be changed
994 }
995
996 if(iTargetAddr == NULL)
997 {
998 iTargetAddr = LockHwSurface();
999 }
1000 TUint8* target = iTargetAddr;
1001 if(target == NULL)
1002 return EFalse;
1003
1004
1005 TRect targetRect = Rect();
1006 TRect sourceRect = aRect;
1007 TRect updateRect = aUpdateRect;
1008
1009 if(iStateFlags & EOrientation90)
1010 {
1011 Rotate(sourceRect);
1012 Rotate(updateRect);
1013 }
1014
1015 if(iSourceMode != DisplayMode() || targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0))
1016 {
1017 sourceRect.Intersection(targetRect); //so source always smaller or equal than target
1018 updateRect.Intersection(targetRect);
1019 ClipCopy(target, aBits, updateRect, sourceRect.iTl);
1020 }
1021 else
1022 {
1023 const TInt byteCount = aRect.Width() * aRect.Height() * iSourceBpp; //this could be stored
1024 Mem::Copy(target, aBits, byteCount);
1025 }
1026
1027 return ETrue;
1028 }
1029void CDsa::UpdateSwSurface()
1030 {
1031 iTargetAddr = NULL;
1032 UnlockHwSurface(); //could be faster if does not use AO, but only check status before redraw, then no context switch needed
1033 }
1034
1035
1036void CDsa::Resume()
1037 {
1038 if(Stopped())
1039 Restart(RDirectScreenAccess::ETerminateRegion);
1040 }
1041
1042void CDsa::DoStop()
1043 {
1044 if(IsDsaAvailable())
1045 iStateFlags |= ESdlThreadExplicitStop;
1046 Stop();
1047 }
1048
1049void CDsa::Stop()
1050 {
1051 iStateFlags &= ~ERunning;
1052// Cancel(); //can be called only from main!
1053 iDsa->Cancel();
1054 }
1055
1056void CDsa::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
1057 {
1058// iStateFlags |= EChangeNotify;
1059 Stop();
1060 }
1061
1062void CDsa::Restart(RDirectScreenAccess::TTerminationReasons aReason)
1063 {
1064 if(aReason == RDirectScreenAccess::ETerminateRegion) //auto restart
1065 {
1066 TRAPD(err, RestartL());
1067 PANIC_IF_ERROR(err);
1068 }
1069 }
1070
1071void CDsa::SetBlitter(MBlitter* aBlitter)
1072 {
1073 iBlitter = aBlitter;
1074 }
1075
1076
1077TPoint CDsa::WindowCoordinates(const TPoint& aPoint) const
1078 {
1079 TPoint pos = aPoint - iScreenRect.iTl;
1080 const TSize asz = iScreenRect.Size();
1081 if(iStateFlags & EOrientation180)
1082 {
1083 pos.iX = asz.iWidth - pos.iX;
1084 pos.iY = asz.iHeight - pos.iY;
1085 }
1086 if(iStateFlags & EOrientation90)
1087 {
1088 pos.iX = aPoint.iY;
1089 pos.iY = aPoint.iX;
1090 }
1091 pos.iX <<= 16;
1092 pos.iY <<= 16;
1093 pos.iX /= asz.iWidth;
1094 pos.iY /= asz.iHeight;
1095 pos.iX *= iSwSize.iWidth;
1096 pos.iY *= iSwSize.iHeight;
1097 pos.iX >>= 16;
1098 pos.iY >>= 16;
1099 return pos;
1100 }
1101
1102void CDsa::SetTargetRect()
1103 {
1104 iTargetRect = iScreenRect;
1105 if(iStateFlags & EResizeRequest && EpocSdlEnv::Flags(CSDL::EAllowImageResizeKeepRatio))
1106 {
1107 const TSize asz = iScreenRect.Size();
1108 const TSize sz = iSwSize;
1109
1110 TRect rect;
1111
1112 const TInt dh = (sz.iHeight << 16) / sz.iWidth;
1113
1114 if((asz.iWidth * dh ) >> 16 <= asz.iHeight)
1115 {
1116 rect.SetRect(TPoint(0, 0), TSize(asz.iWidth, (asz.iWidth * dh) >> 16));
1117 }
1118 else
1119 {
1120 const TInt dw = (sz.iWidth << 16) / sz.iHeight;
1121 rect.SetRect(TPoint(0, 0), TSize((asz.iHeight * dw) >> 16, asz.iHeight));
1122 }
1123 rect.Move((asz.iWidth - rect.Size().iWidth) >> 1, (asz.iHeight - rect.Size().iHeight) >> 1);
1124
1125 iTargetRect = rect;
1126 iTargetRect.Move(iScreenRect.iTl);
1127
1128 }
1129 if(!(iStateFlags & EResizeRequest))
1130 iSwSize = iScreenRect.Size();
1131// iScanLineWidth = /*iTargetBpp **/ SwSize().iWidth;
1132 }
1133
1134/*)
1135TBool CDsa::ChangeTrigger()
1136 {
1137 const TBool change = iStateFlags & EChangeNotify;
1138 iStateFlags &= ~EChangeNotify;
1139 return change;
1140 }
1141*/
1142/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1143
1144void CDsa::Copy256(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1145 {
1146 TUint32* target = aTarget;
1147 const TUint32* endt = target + aBytes;
1148 const TUint8* source = aSource;
1149 while(target < endt)
1150 {
1151 *target++ = aDsa.iLut256[*source++];
1152 }
1153 }
1154
1155void CDsa::Copy256Reversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1156 {
1157 const TUint32* target = aTarget;
1158 TUint32* endt = aTarget + aBytes;
1159 const TUint8* source = aSource;
1160 while(target < endt)
1161 {
1162 *(--endt) = aDsa.iLut256[*source++];
1163 }
1164 }
1165
1166void CDsa::Copy256Flip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1167 {
1168 TUint32* target = aTarget;
1169 const TUint32* endt = target + aBytes;
1170 const TUint8* column = aSource;
1171
1172 while(target < endt)
1173 {
1174 *target++ = aDsa.iLut256[*column];
1175 column += aLineLen;
1176 }
1177 }
1178
1179void CDsa::Copy256FlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1180 {
1181 const TUint32* target = aTarget;
1182 TUint32* endt = aTarget + aBytes;
1183 const TUint8* column = aSource;
1184
1185 while(target < endt)
1186 {
1187 *(--endt) = aDsa.iLut256[*column];
1188 column += aLineLen;
1189 }
1190 }
1191
1192void CDsa::CopyMem(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1193 {
1194 const TUint32* src = reinterpret_cast<const TUint32*>(aSource);
1195 Mem::Copy(aTarget, src, aBytes << 2);
1196 }
1197
1198void CDsa::CopyMemFlip(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1199 {
1200 TUint32* target = aTarget;
1201 const TUint32* endt = target + aBytes;
1202 const TUint32* column = reinterpret_cast<const TUint32*>(aSource);
1203
1204 while(target < endt)
1205 {
1206 *target++ = *column;
1207 column += aLineLen;
1208 }
1209 }
1210
1211void CDsa::CopyMemReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1212 {
1213 const TUint32* target = aTarget;
1214 TUint32* endt = aTarget + aBytes;
1215 const TUint32* source = reinterpret_cast<const TUint32*>(aSource);
1216 while(target < endt)
1217 {
1218 *(--endt) = *source++;
1219 }
1220 }
1221
1222
1223void CDsa::CopyMemFlipReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1224 {
1225 const TUint32* target = aTarget;
1226 TUint32* endt = aTarget + aBytes;
1227 const TUint32* column = reinterpret_cast<const TUint32*>(aSource);
1228
1229 while(target < endt)
1230 {
1231 *(--endt) = *column;
1232 column += aLineLen;
1233 }
1234 }
1235
1236/*
1237
1238LOCAL_C TRgb rgb16MA(TInt aValue)
1239 {
1240 return TRgb::Color16MA(aValue);
1241 }
1242*/
1243NONSHARABLE_CLASS(MRgbCopy)
1244 {
1245 public:
1246 virtual void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed) = 0;
1247 virtual void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed) = 0;
1248 };
1249
1250template <class T>
1251NONSHARABLE_CLASS(TRgbCopy) : public MRgbCopy
1252 {
1253 public:
1254 TRgbCopy(TDisplayMode aMode);
1255 void* operator new(TUint aBytes, TAny* aMem);
1256 void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed);
1257 void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed);
1258 static TUint32 Gray256(const TUint8& aPixel);
1259 static TUint32 Color256(const TUint8& aPixel);
1260 static TUint32 Color4K(const TUint16& aPixel);
1261 static TUint32 Color64K(const TUint16& aPixel);
1262 static TUint32 Color16M(const TUint32& aPixel);
1263 static TUint32 Color16MU(const TUint32& aPixel);
1264 static TUint32 Color16MA(const TUint32& aPixel);
1265 private:
1266 typedef TUint32 (*TRgbFunc) (const T& aValue);
1267 TRgbFunc iFunc;
1268 };
1269
1270
1271template <class T>
1272void* TRgbCopy<T>::operator new(TUint /*aBytes*/, TAny* aMem)
1273 {
1274 return aMem;
1275 }
1276
1277template <class T>
1278TRgbCopy<T>::TRgbCopy(TDisplayMode aMode)
1279 {
1280 switch(aMode)
1281 {
1282 case EGray256 : iFunc = (TRgbFunc) Gray256; break;
1283 case EColor256 : iFunc = (TRgbFunc) Color256; break;
1284 case EColor4K : iFunc = (TRgbFunc) Color4K; break;
1285 case EColor64K : iFunc = (TRgbFunc) Color64K; break;
1286 case EColor16M : iFunc = (TRgbFunc) Color16M; break;
1287 case EColor16MU : iFunc = (TRgbFunc) Color16MU; break;
1288 case EColor16MA : iFunc = (TRgbFunc) Color16MA; break;
1289 default:
1290 PANIC(KErrNotSupported);
1291 }
1292 }
1293
1294template <class T>
1295void TRgbCopy<T>::Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed)
1296 {
1297 const T* source = reinterpret_cast<const T*>(aSource);
1298 TUint32* target = aTarget;
1299 TUint32* endt = target + aBytes;
1300
1301 if(aReversed)
1302 {
1303 while(target < endt)
1304 {
1305 const T value = *source++;
1306 *(--endt) = iFunc(value);//iFunc(value).Value();
1307 }
1308 }
1309 else
1310 {
1311 while(target < endt)
1312 {
1313 const T value = *source++;
1314 *target++ = iFunc(value);//iFunc(value).Value();
1315 }
1316 }
1317 }
1318
1319template <class T>
1320void TRgbCopy<T>::FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed)
1321 {
1322 const T* column = reinterpret_cast<const T*>(aSource);
1323 TUint32* target = aTarget;
1324 TUint32* endt = target + aBytes;
1325
1326 if(aReversed)
1327 {
1328 while(target < endt)
1329 {
1330 *(--endt) = iFunc(*column);
1331 column += aLineLen;
1332 }
1333 }
1334 else
1335 {
1336 while(target < endt)
1337 {
1338 *target++ = iFunc(*column);
1339 column += aLineLen;
1340 }
1341 }
1342 }
1343
1344template <class T> TUint32 TRgbCopy<T>::Gray256(const TUint8& aPixel)
1345 {
1346 const TUint32 px = aPixel << 16 | aPixel << 8 | aPixel;
1347 return px;
1348 }
1349
1350template <class T> TUint32 TRgbCopy<T>::Color256(const TUint8& aPixel)
1351 {
1352 return TRgb::Color256(aPixel).Value();
1353 }
1354
1355template <class T> TUint32 TRgbCopy<T>::Color4K(const TUint16& aPixel)
1356 {
1357 TUint32 col = (aPixel & 0xF00) << 12;
1358 col |= (aPixel & 0xF00) << 8;
1359
1360 col |= (aPixel & 0x0F0) << 8;
1361 col |= (aPixel & 0x0F0);
1362
1363 col |= (aPixel & 0x00F) << 4;
1364 col |= (aPixel & 0x00F);
1365
1366 return col;
1367 }
1368
1369template <class T> TUint32 TRgbCopy<T>::Color64K(const TUint16& aPixel)
1370 {
1371 TUint32 col = (aPixel & 0xF800)<< 8;
1372 col |= (aPixel & 0xE000) << 3;
1373
1374 col |= (aPixel & 0x07E0) << 5;
1375 col |= (aPixel & 0xC0) >> 1;
1376
1377 col |= (aPixel & 0x07E0) << 3;
1378 col |= (aPixel & 0x1C) >> 2;
1379
1380 return col;
1381 }
1382
1383template <class T> TUint32 TRgbCopy<T>::Color16M(const TUint32& aPixel)
1384 {
1385 return TRgb::Color16M(aPixel).Value();
1386 }
1387
1388template <class T> TUint32 TRgbCopy<T>::Color16MU(const TUint32& aPixel)
1389 {
1390 return TRgb::Color16MU(aPixel).Value();
1391 }
1392
1393template <class T> TUint32 TRgbCopy<T>::Color16MA(const TUint32& aPixel)
1394 {
1395 return TRgb::Color16MA(aPixel).Value();
1396 }
1397
1398typedef TUint64 TStackMem;
1399
1400LOCAL_C MRgbCopy* GetCopy(TAny* mem, TDisplayMode aMode)
1401 {
1402 if(aMode == EColor256 || aMode == EGray256)
1403 {
1404 return new (mem) TRgbCopy<TUint8>(aMode);
1405 }
1406 if(aMode == EColor4K || aMode == EColor64K)
1407 {
1408 return new (mem) TRgbCopy<TUint16>(aMode);
1409 }
1410 if(aMode == EColor16M || aMode == EColor16MU || aMode == EColor16MA)
1411 {
1412 return new (mem) TRgbCopy<TUint32>(aMode);
1413 }
1414 PANIC(KErrNotSupported);
1415 return NULL;
1416 }
1417
1418
1419void CDsa::CopySlowFlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1420 {
1421 TStackMem mem = 0;
1422 GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, ETrue);
1423 }
1424
1425void CDsa::CopySlowFlip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1426 {
1427 TStackMem mem = 0;
1428 GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, EFalse);
1429 }
1430
1431void CDsa::CopySlow(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1432 {
1433 TStackMem mem = 0;
1434 GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, EFalse);
1435 }
1436
1437void CDsa::CopySlowReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1438 {
1439 TStackMem mem = 0;
1440 GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, ETrue);
1441 }
1442
1443////////////////////////////////////////////////////////////////////////////////////////////////////////////////7
diff --git a/apps/plugins/sdl/src/video/symbian/EKA2/dsa_old.cpp b/apps/plugins/sdl/src/video/symbian/EKA2/dsa_old.cpp
deleted file mode 100644
index 7e32de2cfd..0000000000
--- a/apps/plugins/sdl/src/video/symbian/EKA2/dsa_old.cpp
+++ /dev/null
@@ -1,1075 +0,0 @@
1#include "dsa.h"
2#include "sdlepocapi.h"
3#include <cdsb.h>
4
5LOCAL_C TInt BytesPerPixel(TDisplayMode aMode)
6 {
7 return ((TDisplayModeUtils::NumDisplayModeBitsPerPixel(aMode) - 1) >> 3) + 1;
8 }
9
10
11////////////////////////////////////////////////////////////////////////////////////////////////
12
13NONSHARABLE_CLASS(CDsaA) : public CDsa
14 {
15 public:
16 CDsaA(RWsSession& aSession);
17 private:
18 ~CDsaA();
19 TUint8* LockSurface();
20 void UnlockHWSurfaceRequestComplete();
21 void UnlockHwSurface();
22 void CreateSurfaceL();
23 void Wipe(TInt aLength);
24 void RecreateL();
25 void Free();
26 TInt ExternalUpdate() {return 0;}
27 private:
28 CFbsBitmap* iBmp;
29 };
30
31
32CDsaA::CDsaA(RWsSession& aSession) : CDsa(aSession)
33 {
34 }
35
36void CDsaA::Free()
37 {
38 delete iBmp;
39 iBmp = NULL;
40 }
41
42CDsaA::~CDsaA()
43 {
44 __ASSERT_DEBUG(iBmp == NULL, PANIC(KErrNotReady));
45 }
46
47TUint8* CDsaA::LockSurface()
48 {
49 iBmp->LockHeap();
50 return reinterpret_cast<TUint8*>(iBmp->DataAddress());
51 }
52
53void CDsaA::UnlockHWSurfaceRequestComplete()
54 {
55 PANIC(KErrNotSupported);
56 }
57
58void CDsaA::UnlockHwSurface()
59 {
60 iBmp->UnlockHeap();
61 SetUpdating(EFalse);
62 Dsa().Gc()->BitBlt(HwRect().iTl, iBmp);
63 Dsa().ScreenDevice()->Update();
64 }
65
66void CDsaA::CreateSurfaceL()
67 {
68 delete iBmp;
69 iBmp = NULL;
70 iBmp = new (ELeave) CFbsBitmap();
71 User::LeaveIfError(iBmp->Create(HwRect().Size(), DisplayMode()));
72 }
73
74void CDsaA::Wipe(TInt aLength) //dont call in drawing
75 {
76 iBmp->LockHeap();
77 Mem::FillZ(iBmp->DataAddress(), aLength);
78 iBmp->UnlockHeap();
79 }
80
81void CDsaA::RecreateL()
82 {
83 }
84
85//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
86
87NONSHARABLE_CLASS(MDsbObs)
88 {
89 public:
90 virtual void SurfaceReady() = 0;
91 virtual CDirectScreenBitmap& Dsb() = 0;
92 };
93
94NONSHARABLE_CLASS(CDsbSurface) : public CActive
95 {
96 public:
97 CDsbSurface(MDsbObs& aDsb);
98 TUint8* Address();
99 void Complete();
100 ~CDsbSurface();
101 private:
102 void RunL();
103 void DoCancel();
104 private:
105 MDsbObs& iDsb;
106 TUint8* iAddress;
107 };
108
109CDsbSurface::CDsbSurface(MDsbObs& aDsb) : CActive(CActive::EPriorityHigh) , iDsb(aDsb)
110 {
111 CActiveScheduler::Add(this);
112 }
113
114CDsbSurface::~CDsbSurface()
115 {
116 Cancel();
117 }
118
119void CDsbSurface::Complete()
120 {
121 if(iAddress != NULL && !IsActive())
122 {
123 iAddress = NULL;
124 SetActive();
125 iDsb.Dsb().EndUpdate(iStatus);
126 }
127 }
128
129TUint8* CDsbSurface::Address()
130 {
131 if(iAddress == NULL && !IsActive())
132 {
133 TAcceleratedBitmapInfo info;
134 if(KErrNone == iDsb.Dsb().BeginUpdate(info))
135 iAddress = info.iAddress;
136 }
137 return iAddress;
138 }
139
140void CDsbSurface::RunL()
141 {
142 iDsb.SurfaceReady();
143 }
144
145void CDsbSurface::DoCancel()
146 {
147 //empty
148 }
149
150NONSHARABLE_CLASS(CDsaB) : public CDsa, public MDsbObs
151 {
152 public:
153 CDsaB(RWsSession& aSession);
154 private:
155 ~CDsaB();
156 TUint8* LockSurface();
157 void UnlockHWSurfaceRequestComplete();
158 void UnlockHwSurface();
159 void CreateSurfaceL();
160 void Wipe(TInt aLength);
161 void RecreateL();
162 void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice);
163 void Free();
164 CDirectScreenBitmap& Dsb();
165 void SurfaceReady();
166 TInt ExternalUpdate() {return 0;}
167 private:
168 CDsbSurface* iSurface1;
169 CDsbSurface* iSurface2;
170 CDirectScreenBitmap* iDsb;
171 };
172
173CDsaB::CDsaB(RWsSession& aSession) : CDsa(aSession)
174 {
175 }
176
177void CDsaB::Free()
178 {
179 }
180
181void CDsaB::UnlockHWSurfaceRequestComplete()
182 {
183 iSurface1->Complete();
184 iSurface2->Complete();
185 }
186
187void CDsaB::CreateSurfaceL()
188 {
189 }
190
191void CDsaB::Wipe(TInt aLength) //dont call in drawing
192 {
193 TUint8* addr = LockSurface();
194 if(addr != NULL)
195 {
196 Mem::FillZ(addr, aLength);
197 UnlockHwSurface();
198 }
199 }
200
201void CDsaB::UnlockHwSurface()
202 {
203 EpocSdlEnv::Request(CDsa::ERequestUpdate);
204 }
205
206TUint8* CDsaB::LockSurface()
207 {
208 TUint8* addr = iSurface1->Address();
209 if(addr == NULL)
210 addr = iSurface2->Address();
211 SetUpdating(addr == NULL);
212 return addr;
213 }
214
215void CDsaB::SurfaceReady()
216 {
217 SetUpdating(EFalse);
218 }
219
220CDirectScreenBitmap& CDsaB::Dsb()
221 {
222 return *iDsb;
223 }
224
225void CDsaB::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
226 {
227 if(iDsb == NULL)
228 iDsb = CDirectScreenBitmap::NewL();
229 CDsa::ConstructL(aWindow, aDevice);
230 iSurface1 = new (ELeave) CDsbSurface(*this);
231 iSurface2 = new (ELeave) CDsbSurface(*this);
232 }
233
234CDsaB::~CDsaB()
235 {
236 delete iSurface1;
237 delete iSurface2;
238 delete iDsb;
239 }
240
241void CDsaB::RecreateL()
242 {
243 iDsb->Close();
244 iDsb->Create(HwRect(), CDirectScreenBitmap::EDoubleBuffer);
245 }
246
247/////////////////////////////////////////////////////////////////////////////////////////////////////
248
249
250TSize CDsa::WindowSize() const
251 {
252 TSize size = HwRect().Size();
253 if(iStateFlags & EOrientation90)
254 {
255 const TInt tmp = size.iWidth;
256 size.iWidth = size.iHeight;
257 size.iHeight = tmp;
258 }
259 return size;
260 }
261
262void CDsa::SetSuspend()
263 {
264 iStateFlags |= ESdlThreadSuspend;
265 }
266
267void CDsa::ReleaseStop()
268 {
269 iStateFlags &= ~ESdlThreadExplicitStop;
270 }
271
272
273TBool CDsa::Stopped() const
274 {
275 return (iStateFlags & ESdlThreadExplicitStop);
276 }
277
278void CDsa::SetOrientation(CSDL::TOrientationMode aOrientation)
279 {
280 TInt flags = 0;
281 switch(aOrientation)
282 {
283 case CSDL::EOrientation90:
284 flags = EOrientation90;
285 break;
286 case CSDL::EOrientation180:
287 flags = EOrientation180;
288 break;
289 case CSDL::EOrientation270:
290 flags = EOrientation90 | EOrientation180;
291 break;
292 case CSDL::EOrientation0:
293 flags = 0;
294 break;
295 }
296 if(flags != (iStateFlags & EOrientationFlags))
297 {
298 iStateFlags |= EOrientationChanged;
299 iNewFlags = flags; //cannot be set during drawing...
300 }
301 }
302
303CDsa::~CDsa()
304 {
305 if(iDsa != NULL)
306 {
307 iDsa->Cancel();
308 }
309 delete iDsa;
310 User::Free(iLut256);
311 }
312
313void CDsa::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
314 {
315 if(iDsa != NULL)
316 {
317 iDsa->Cancel();
318 delete iDsa;
319 iDsa = NULL;
320 }
321
322
323 iDsa = CDirectScreenAccess::NewL(
324 iSession,
325 aDevice,
326 aWindow,
327 *this);
328
329 if(iLut256 == NULL)
330 iLut256 = (TUint32*) User::AllocL(256 * sizeof(TUint32));
331 iTargetMode = aWindow.DisplayMode();
332 iTargetBpp = BytesPerPixel(DisplayMode());
333 iTargetRect = TRect(aWindow.Position(), aWindow.Size());
334 RestartL();
335 }
336
337void CDsa::LockPalette(TBool aLock)
338 {
339 if(aLock)
340 iStateFlags |= EPaletteLocked;
341 else
342 iStateFlags &= ~EPaletteLocked;
343 }
344TInt CDsa::SetPalette(TInt aFirst, TInt aCount, TUint32* aPalette)
345 {
346 if(iLut256 == NULL)
347 return KErrNotFound;
348 const TInt count = aCount - aFirst;
349 if(count > 256)
350 return KErrArgument;
351 if(iStateFlags & EPaletteLocked)
352 return KErrNone;
353 for(TInt i = aFirst; i < count; i++) //not so busy here:-)
354 {
355 iLut256[i] = aPalette[i];
356 }
357 return KErrNone;
358 }
359
360
361
362
363void CDsa::RestartL()
364 {
365 //const TBool active = iDsa->IsActive();
366
367 //if(!active)
368 iDsa->StartL();
369
370 RRegion* r = iDsa->DrawingRegion();
371 iDsa->Gc()->SetClippingRegion(r);
372 TRect rect = r->BoundingRect();
373
374 if(rect.IsEmpty())
375 {
376 return;
377 }
378
379 iScreenRect = rect; //to ensure properly set, albeit may not(?) match to value SDL has - therefore may has to clip
380
381 RecreateL();
382
383 iStateFlags |= ERunning;
384// iScanLineWidth = iTargetBpp * HwRect().Width();
385 ReleaseStop();
386 if(iStateFlags & ESdlThreadSuspend)
387 {
388 EpocSdlEnv::Resume();
389 iStateFlags &= ~ ESdlThreadSuspend;
390 }
391 }
392
393CDsa::CDsa(RWsSession& aSession) :
394 iSession(aSession),
395 iStateFlags(0)
396 {
397// CActiveScheduler::Add(this);
398 iCFTable[0] = CopyMem;
399 iCFTable[1] = CopyMemFlipReversed;
400 iCFTable[2] = CopyMemReversed;
401 iCFTable[3] = CopyMemFlip;
402
403 iCFTable[4] = Copy256;
404 iCFTable[5] = Copy256FlipReversed;
405 iCFTable[6] = Copy256Reversed;
406 iCFTable[7] = Copy256Flip;
407
408
409 iCFTable[8] = CopySlow;
410 iCFTable[9] = CopySlowFlipReversed;
411 iCFTable[10] = CopySlowReversed;
412 iCFTable[11] = CopySlowFlip;
413 }
414
415RWsSession& CDsa::Session()
416 {
417 return iSession;
418 }
419
420
421
422TUint8* CDsa::LockHwSurface()
423 {
424 if((iStateFlags & EUpdating) == 0) //else frame is skipped
425 {
426 return LockSurface();
427 }
428 return NULL;
429 }
430
431/*
432void CDsa::RunL()
433 {
434 iStateFlags &= ~EUpdating;
435 }
436
437
438void CDsa::DoCancel()
439 {
440 iStateFlags &= ~EUpdating;
441 //nothing can do, just wait?
442 }
443*/
444
445TInt CDsa::AllocSurface(TBool aHwSurface, const TSize& aSize, TDisplayMode aMode)
446 {
447 if(aHwSurface && aMode != DisplayMode())
448 return KErrArgument;
449
450 iSourceMode = aMode;
451
452 iSourceBpp = BytesPerPixel(aMode);
453
454 const TSize size = WindowSize();
455 if(aSize.iWidth > size.iWidth)
456 return KErrTooBig;
457 if(aSize.iHeight > size.iHeight)
458 return KErrTooBig;
459
460 TRAPD(err, CreateSurfaceL());
461 if(err != KErrNone)
462 return err;
463
464
465 SetCopyFunction();
466
467 EpocSdlEnv::ObserverEvent(MSDLObserver::EEventWindowReserved);
468
469 return KErrNone;
470 }
471
472
473/*
474void SaveBmp(const TDesC& aName, const TAny* aData, TInt aLength, const TSize& aSz, TDisplayMode aMode)
475 {
476 CFbsBitmap* s = new CFbsBitmap();
477 s->Create(aSz, aMode);
478 s->LockHeap();
479 TUint32* addr = s->DataAddress();
480 Mem::Copy(addr, aData, aLength);
481 s->UnlockHeap();
482 s->Save(aName);
483 s->Reset();
484 delete s;
485 }
486
487void SaveBmp(const TDesC& aName, const TUint32* aData, const TSize& aSz)
488 {
489 CFbsBitmap* s = new CFbsBitmap();
490 s->Create(aSz, EColor64K);
491 TBitmapUtil bmp(s);
492 bmp.Begin(TPoint(0, 0));
493 for(TInt j = 0; j < aSz.iHeight; j++)
494 {
495 bmp.SetPos(TPoint(0, j));
496 for(TInt i = 0; i < aSz.iWidth; i++)
497 {
498 bmp.SetPixel(*aData);
499 aData++;
500 bmp.IncXPos();
501 }
502 }
503 bmp.End();
504 s->Save(aName);
505 s->Reset();
506 delete s;
507 }
508
509TBuf<16> FooName(TInt aFoo)
510 {
511 TBuf<16> b;
512 b.Format(_L("C:\\pic%d.mbm"), aFoo);
513 return b;
514 }
515*/
516void CDsa::ClipCopy(TUint8* aTarget, const TUint8* aSource, const TRect& aRect, const TRect& aTargetPos) const
517 {
518 TUint8* target = aTarget;
519 const TUint8* source = aSource;
520 const TInt lineWidth = aRect.Width();
521 source += iSourceBpp * (aRect.iTl.iY * lineWidth);
522 TInt sourceStartOffset = iSourceBpp * aRect.iTl.iX;
523 source += sourceStartOffset;
524 target += iTargetBpp * ((aTargetPos.iTl.iY + aRect.iTl.iY ) * lineWidth);
525 TInt targetStartOffset = iTargetBpp * (aRect.iTl.iX + aTargetPos.iTl.iX);
526 target += targetStartOffset;
527 TUint32* targetPtr = reinterpret_cast<TUint32*>(target);
528 const TInt targetWidth = HwRect().Size().iWidth;
529 const TInt height = aRect.Height();
530
531 TInt lineMove = iStateFlags & EOrientation90 ? 1 : lineWidth;
532
533 if(iStateFlags & EOrientation180)
534 {
535
536 targetPtr += targetWidth * (height - 1);
537
538 for(TInt i = 0; i < height; i++) //source is always smaller
539 {
540 iCopyFunction(*this, targetPtr, source, lineWidth, height);
541 source += lineMove;
542 targetPtr -= targetWidth;
543 }
544 }
545 else
546 {
547
548
549 for(TInt i = 0; i < height; i++) //source is always smaller
550 {
551 iCopyFunction(*this, targetPtr, source, lineWidth, height);
552 source += lineMove;
553 targetPtr += targetWidth;
554 }
555 }
556
557 }
558
559
560
561
562void CDsa::Wipe() //dont call in drawing
563 {
564 if(IsDsaAvailable())
565 Wipe(iTargetBpp * iScreenRect.Width() * iScreenRect.Height());
566 }
567
568void CDsa::SetCopyFunction()
569 {
570 //calculate offset to correct function in iCFTable according to given parameters
571 TInt function = 0;
572 const TInt KCopyFunctions = 4;
573 const TInt KOffsetToNative = 0;
574 const TInt KOffsetTo256 = KOffsetToNative + KCopyFunctions;
575 const TInt KOffsetToOtherModes = KOffsetTo256 + KCopyFunctions;
576 const TInt KOffsetTo90Functions = 1;
577 const TInt KOffsetTo180Functions = 2;
578
579 if(iSourceMode == DisplayMode())
580 function = KOffsetToNative; //0
581 else if(iSourceMode == EColor256)
582 function = KOffsetTo256; //4
583 else
584 function = KOffsetToOtherModes; //8
585
586 if(iStateFlags & EOrientation90)
587 function += KOffsetTo90Functions; // + 1
588 if(iStateFlags & EOrientation180)
589 function += KOffsetTo180Functions; //+ 2
590
591 iCopyFunction = iCFTable[function];
592
593 Wipe();
594 }
595
596inline void Rotate(TRect& aRect)
597 {
598 const TInt dx = aRect.iBr.iX - aRect.iTl.iX;
599 const TInt dy = aRect.iBr.iY - aRect.iTl.iY;
600
601 aRect.iBr.iX = aRect.iTl.iX + dy;
602 aRect.iBr.iY = aRect.iTl.iY + dx;
603
604 const TInt tmp = aRect.iTl.iX;
605 aRect.iTl.iX = aRect.iTl.iY;
606 aRect.iTl.iY = tmp;
607 }
608
609/*
610int bar = 0;
611*/
612TBool CDsa::AddUpdateRect(const TUint8* aBits, const TRect& aUpdateRect, const TRect& aRect)
613 {
614
615 if(iStateFlags & EOrientationChanged)
616 {
617 iStateFlags &= ~EOrientationFlags;
618 iStateFlags |= iNewFlags;
619 SetCopyFunction();
620 iStateFlags &= ~EOrientationChanged;
621 EpocSdlEnv::WaitDeviceChange();
622 return EFalse; //skip this frame as data is may be changed
623 }
624
625 if(iTargetAddr == NULL)
626 {
627 iTargetAddr = LockHwSurface();
628 }
629 TUint8* target = iTargetAddr;
630 if(target == NULL)
631 return EFalse;
632
633
634 TRect targetRect = HwRect();
635 TRect sourceRect = aRect;
636 TRect updateRect = aUpdateRect;
637
638 if(iStateFlags & EOrientation90)
639 {
640 Rotate(sourceRect);
641 Rotate(updateRect);
642 }
643
644 if(iSourceMode != DisplayMode() || targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0))
645 {
646 sourceRect.Intersection(targetRect); //so source always smaller or equal than target
647 updateRect.Intersection(targetRect);
648 ClipCopy(target, aBits, updateRect, sourceRect);
649 }
650 else
651 {
652 const TInt byteCount = aRect.Width() * aRect.Height() * iSourceBpp; //this could be stored
653 Mem::Copy(target, aBits, byteCount);
654 }
655
656 return ETrue;
657 }
658
659CDsa* CDsa::CreateL(RWsSession& aSession)
660 {
661 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSB))
662 {
663 TInt flags = CDirectScreenBitmap::ENone;
664 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBDoubleBuffer))
665 flags |= CDirectScreenBitmap::EDoubleBuffer;
666 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBIncrentalUpdate))
667 flags |= CDirectScreenBitmap::EIncrementalUpdate;
668 return new (ELeave) CDsaB(aSession);
669 }
670 else
671 return new (ELeave) CDsaA(aSession);
672 }
673
674void CDsa::CreateZoomerL(const TSize& aSize)
675 {
676 iSwSize = aSize;
677 iStateFlags |= EResizeRequest;
678 CreateSurfaceL();
679 SetTargetRect();
680 }
681
682TPoint CDsa::WindowCoordinates(const TPoint& aPoint) const
683 {
684 TPoint pos = aPoint - iScreenRect.iTl;
685 const TSize asz = iScreenRect.Size();
686 if(iStateFlags & EOrientation180)
687 {
688 pos.iX = asz.iWidth - pos.iX;
689 pos.iY = asz.iHeight - pos.iY;
690 }
691 if(iStateFlags & EOrientation90)
692 {
693 pos.iX = aPoint.iY;
694 pos.iY = aPoint.iX;
695 }
696 pos.iX <<= 16;
697 pos.iY <<= 16;
698 pos.iX /= asz.iWidth;
699 pos.iY /= asz.iHeight;
700 pos.iX *= iSwSize.iWidth;
701 pos.iY *= iSwSize.iHeight;
702 pos.iX >>= 16;
703 pos.iY >>= 16;
704 return pos;
705 }
706
707void CDsa::SetTargetRect()
708 {
709 iTargetRect = iScreenRect;
710 if(iStateFlags & EResizeRequest && EpocSdlEnv::Flags(CSDL::EAllowImageResizeKeepRatio))
711 {
712 const TSize asz = iScreenRect.Size();
713 const TSize sz = iSwSize;
714
715 TRect rect;
716
717 const TInt dh = (sz.iHeight << 16) / sz.iWidth;
718
719 if((asz.iWidth * dh ) >> 16 <= asz.iHeight)
720 {
721 rect.SetRect(TPoint(0, 0), TSize(asz.iWidth, (asz.iWidth * dh) >> 16));
722 }
723 else
724 {
725 const TInt dw = (sz.iWidth << 16) / sz.iHeight;
726 rect.SetRect(TPoint(0, 0), TSize((asz.iHeight * dw) >> 16, asz.iHeight));
727 }
728 rect.Move((asz.iWidth - rect.Size().iWidth) >> 1, (asz.iHeight - rect.Size().iHeight) >> 1);
729
730 iTargetRect = rect;
731 iTargetRect.Move(iScreenRect.iTl);
732
733 }
734 if(!(iStateFlags & EResizeRequest))
735 iSwSize = iScreenRect.Size();
736// iScanLineWidth = /*iTargetBpp **/ SwSize().iWidth;
737 }
738
739void CDsa::RecreateL()
740 {
741 }
742
743void CDsa::Free()
744 {
745 }
746
747void CDsa::UpdateSwSurface()
748 {
749 iTargetAddr = NULL;
750 UnlockHwSurface(); //could be faster if does not use AO, but only check status before redraw, then no context switch needed
751 }
752
753void CDsa::SetBlitter(MBlitter* aBlitter)
754 {
755 iBlitter = aBlitter;
756 }
757
758void CDsa::DrawOverlays()
759 {
760 const TInt last = iOverlays.Count() - 1;
761 for(TInt i = last; i >= 0 ; i--)
762 iOverlays[i].iOverlay->Draw(*iDsa->Gc(), HwRect(), SwSize());
763 }
764
765TInt CDsa::AppendOverlay(MOverlay& aOverlay, TInt aPriority)
766 {
767 TInt i;
768 for(i = 0; i < iOverlays.Count() && iOverlays[i].iPriority < aPriority; i++)
769 {}
770 const TOverlay overlay = {&aOverlay, aPriority};
771 return iOverlays.Insert(overlay, i);
772 }
773
774TInt CDsa::RemoveOverlay(MOverlay& aOverlay)
775 {
776 for(TInt i = 0; i < iOverlays.Count(); i++)
777 {
778 if(iOverlays[i].iOverlay == &aOverlay)
779 {
780 iOverlays.Remove(i);
781 return KErrNone;
782 }
783 }
784 return KErrNotFound;
785 }
786
787TInt CDsa::RedrawRequest()
788 {
789 if(!(iStateFlags & (EUpdating) && (iStateFlags & ERunning)))
790 {
791 return ExternalUpdate();
792 }
793 return KErrNotReady;
794 }
795
796
797void CDsa::Resume()
798 {
799 if(Stopped())
800 Restart(RDirectScreenAccess::ETerminateRegion);
801 }
802
803void CDsa::DoStop()
804 {
805 if(IsDsaAvailable())
806 iStateFlags |= ESdlThreadExplicitStop;
807 Stop();
808 }
809
810void CDsa::Stop()
811 {
812 iStateFlags &= ~ERunning;
813// Cancel(); //can be called only from main!
814 iDsa->Cancel();
815 }
816
817void CDsa::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
818 {
819// iStateFlags |= EChangeNotify;
820 Stop();
821 }
822
823void CDsa::Restart(RDirectScreenAccess::TTerminationReasons aReason)
824 {
825 if(aReason == RDirectScreenAccess::ETerminateRegion) //auto restart
826 {
827 TRAPD(err, RestartL());
828 PANIC_IF_ERROR(err);
829 }
830 }
831/*)
832TBool CDsa::ChangeTrigger()
833 {
834 const TBool change = iStateFlags & EChangeNotify;
835 iStateFlags &= ~EChangeNotify;
836 return change;
837 }
838*/
839/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
840
841void CDsa::Copy256(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
842 {
843 TUint32* target = aTarget;
844 const TUint32* endt = target + aBytes;
845 const TUint8* source = aSource;
846 while(target < endt)
847 {
848 *target++ = aDsa.iLut256[*source++];
849 }
850 }
851
852void CDsa::Copy256Reversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
853 {
854 const TUint32* target = aTarget;
855 TUint32* endt = aTarget + aBytes;
856 const TUint8* source = aSource;
857 while(target < endt)
858 {
859 *(--endt) = aDsa.iLut256[*source++];
860 }
861 }
862
863void CDsa::Copy256Flip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
864 {
865 TUint32* target = aTarget;
866 const TUint32* endt = target + aBytes;
867 const TUint8* column = aSource;
868
869 while(target < endt)
870 {
871 *target++ = aDsa.iLut256[*column];
872 column += aLineLen;
873 }
874 }
875
876void CDsa::Copy256FlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
877 {
878 const TUint32* target = aTarget;
879 TUint32* endt = aTarget + aBytes;
880 const TUint8* column = aSource;
881
882 while(target < endt)
883 {
884 *(--endt) = aDsa.iLut256[*column];
885 column += aLineLen;
886 }
887 }
888
889void CDsa::CopyMem(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
890 {
891 Mem::Copy(aTarget, aSource, aBytes);
892 }
893
894void CDsa::CopyMemFlip(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
895 {
896 TUint32* target = aTarget;
897 const TUint32* endt = target + aBytes;
898 const TUint32* column = reinterpret_cast<const TUint32*>(aSource);
899
900 while(target < endt)
901 {
902 *target++ = *column;
903 column += aLineLen;
904 }
905 }
906
907void CDsa::CopyMemReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
908 {
909 const TUint32* target = aTarget;
910 TUint32* endt = aTarget + aBytes;
911 const TUint32* source = reinterpret_cast<const TUint32*>(aSource);
912 while(target < endt)
913 {
914 *(--endt) = *source++;
915 }
916 }
917
918
919void CDsa::CopyMemFlipReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
920 {
921 const TUint32* target = aTarget;
922 TUint32* endt = aTarget + aBytes;
923 const TUint32* column = reinterpret_cast<const TUint32*>(aSource);
924
925 while(target < endt)
926 {
927 *(--endt) = *column;
928 column += aLineLen;
929 }
930 }
931
932
933typedef TRgb (*TRgbFunc) (TInt aValue);
934
935LOCAL_C TRgb rgb16MA(TInt aValue)
936 {
937 return TRgb::Color16MA(aValue);
938 }
939
940NONSHARABLE_CLASS(MRgbCopy)
941 {
942 public:
943 virtual void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed) = 0;
944 virtual void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed) = 0;
945 };
946template <class T>
947NONSHARABLE_CLASS(TRgbCopy) : public MRgbCopy
948 {
949 public:
950 TRgbCopy(TDisplayMode aMode);
951 void* operator new(TUint aBytes, TAny* aMem);
952 void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed);
953 void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed);
954 private:
955 TRgbFunc iFunc;
956 };
957
958template <class T>
959void* TRgbCopy<T>::operator new(TUint /*aBytes*/, TAny* aMem)
960 {
961 return aMem;
962 }
963
964template <class T>
965TRgbCopy<T>::TRgbCopy(TDisplayMode aMode)
966 {
967 switch(aMode)
968 {
969 case EGray256 : iFunc = TRgb::Gray256; break;
970 case EColor256 : iFunc = TRgb::Color256; break;
971 case EColor4K : iFunc = TRgb::Color4K; break;
972 case EColor64K : iFunc = TRgb::Color64K; break;
973 case EColor16M : iFunc = TRgb::Color16M; break;
974 case EColor16MU : iFunc = TRgb::Color16MU; break;
975 case EColor16MA : iFunc = rgb16MA; break;
976 default:
977 PANIC(KErrNotSupported);
978 }
979 }
980
981template <class T>
982void TRgbCopy<T>::Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed)
983 {
984 const T* source = reinterpret_cast<const T*>(aSource);
985 TUint32* target = aTarget;
986 TUint32* endt = target + aBytes;
987
988 if(aReversed)
989 {
990 while(target < endt)
991 {
992 TUint32 value = *source++;
993 *(--endt) = iFunc(value).Value();
994 }
995 }
996 else
997 {
998 while(target < endt)
999 {
1000 TUint32 value = *source++;
1001 *target++ = iFunc(value).Value();
1002 }
1003 }
1004 }
1005
1006template <class T>
1007void TRgbCopy<T>::FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed)
1008 {
1009 const T* column = reinterpret_cast<const T*>(aSource);
1010 TUint32* target = aTarget;
1011 TUint32* endt = target + aBytes;
1012
1013 if(aReversed)
1014 {
1015 while(target < endt)
1016 {
1017 *(--endt) = iFunc(*column).Value();
1018 column += aLineLen;
1019 }
1020 }
1021 else
1022 {
1023 while(target < endt)
1024 {
1025 *target++ = iFunc(*column).Value();
1026 column += aLineLen;
1027 }
1028 }
1029 }
1030
1031
1032typedef TUint64 TStackMem;
1033
1034LOCAL_C MRgbCopy* GetCopy(TAny* mem, TDisplayMode aMode)
1035 {
1036 if(aMode == EColor256 || aMode == EGray256)
1037 {
1038 return new (mem) TRgbCopy<TUint8>(aMode);
1039 }
1040 if(aMode == EColor4K || aMode == EColor64K)
1041 {
1042 return new (mem) TRgbCopy<TUint16>(aMode);
1043 }
1044 if(aMode == EColor16M || aMode == EColor16MU || aMode == EColor16MA)
1045 {
1046 return new (mem) TRgbCopy<TUint32>(aMode);
1047 }
1048 PANIC(KErrNotSupported);
1049 return NULL;
1050 }
1051
1052
1053void CDsa::CopySlowFlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1054 {
1055 TStackMem mem = 0;
1056 GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, ETrue);
1057 }
1058
1059void CDsa::CopySlowFlip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
1060 {
1061 TStackMem mem = 0;
1062 GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, EFalse);
1063 }
1064
1065void CDsa::CopySlow(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1066 {
1067 TStackMem mem = 0;
1068 GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, EFalse);
1069 }
1070
1071void CDsa::CopySlowReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
1072 {
1073 TStackMem mem = 0;
1074 GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, ETrue);
1075 } \ No newline at end of file
diff --git a/apps/plugins/sdl/src/video/symbian/SDL_epocevents_c.h b/apps/plugins/sdl/src/video/symbian/SDL_epocevents_c.h
deleted file mode 100644
index 8e10a04293..0000000000
--- a/apps/plugins/sdl/src/video/symbian/SDL_epocevents_c.h
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@devolution.com
21*/
22
23/*
24 SDL_epocevents_c.h
25 Handle the event stream, converting Epoc events into SDL events
26
27 Epoc version by Hannu Viitala (hannu.j.viitala@mbnet.fi) and Markus Mertama
28
29*/
30
31
32#ifdef SAVE_RCSID
33static char rcsid =
34 "@(#) $Id: SDL_aaevents_c.h,v 1.1.2.2 2000/03/16 15:20:39 hercules Exp $";
35#endif
36
37extern "C" {
38#include "SDL_sysvideo.h"
39//#include "SDL_epocvideo.h"
40}
41
42
43
44#define MAX_SCANCODE 255
45
46/* Variables and functions exported by SDL_sysevents.c to other parts
47 of the native video subsystem (SDL_sysvideo.c)
48*/
49
50/* Hidden "this" pointer for the video functions */
51#define _THIS SDL_VideoDevice *_this
52#define Private _this->hidden
53
54extern "C" {
55extern void EPOC_InitOSKeymap(_THIS);
56extern void EPOC_PumpEvents(_THIS);
57}
58
59extern TBool isCursorVisible;
60