diff options
author | Franklin Wei <git@fwei.tk> | 2018-02-07 20:04:46 -0500 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2018-03-12 20:52:01 -0400 |
commit | 6039eb05ba6d82ef56f2868c96654c552d117bf9 (patch) | |
tree | 9db7016bcbf66cfdf7b9bc998d84c6eaff9c8378 /apps/plugins/sdl/src/video/symbian/EKA2 | |
parent | ef373c03b96b0be08babca581d9f10bccfd4931f (diff) | |
download | rockbox-6039eb05ba6d82ef56f2868c96654c552d117bf9.tar.gz rockbox-6039eb05ba6d82ef56f2868c96654c552d117bf9.zip |
sdl: remove non-rockbox drivers
We never use any of these other drivers, so having them around just takes
up space.
Change-Id: Iced812162df1fef3fd55522b7e700acb6c3bcd41
Diffstat (limited to 'apps/plugins/sdl/src/video/symbian/EKA2')
-rw-r--r-- | apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocevents.cpp | 521 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocvideo.cpp | 594 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocvideo.h | 51 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/symbian/EKA2/dsa.cpp | 1505 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/symbian/EKA2/dsa_new.cpp | 1443 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/symbian/EKA2/dsa_old.cpp | 1075 |
6 files changed, 0 insertions, 5189 deletions
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 | ||
5 | extern "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 | |||
25 | extern "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 */ | ||
32 | static SDLKey keymap[MAX_SCANCODE]; | ||
33 | static SDL_keysym *TranslateKey(_THIS, int scancode, SDL_keysym *keysym); | ||
34 | void DisableKeyBlocking(_THIS); | ||
35 | //} /* extern "C" */ | ||
36 | |||
37 | SDLKey* KeyMap() | ||
38 | { | ||
39 | return keymap; | ||
40 | } | ||
41 | |||
42 | TBool isCursorVisible = EFalse; | ||
43 | |||
44 | void 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 | |||
247 | int 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 | |||
411 | extern "C" { | ||
412 | |||
413 | void 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 | |||
434 | void EPOC_InitOSKeymap(_THIS) | ||
435 | { | ||
436 | ResetKeyMap(); | ||
437 | EpocSdlEnv::ObserverEvent(MSDLObserver::EEventKeyMapInit ,0); | ||
438 | } | ||
439 | |||
440 | static 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 | |||
38 | extern "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 | |||
69 | void 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 | |||
89 | extern "C" void RDebug_Print(char* error_str, void* param) | ||
90 | { | ||
91 | RDebug_Print_b(error_str, param); | ||
92 | } | ||
93 | |||
94 | /* | ||
95 | int 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 | |||
104 | extern "C" int Debug_AvailMem() | ||
105 | { | ||
106 | return(Debug_AvailMem2()); | ||
107 | } | ||
108 | |||
109 | */ | ||
110 | |||
111 | extern "C" { | ||
112 | |||
113 | /* Initialization/Query functions */ | ||
114 | |||
115 | static int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat); | ||
116 | static SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | ||
117 | static SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | ||
118 | static int EPOC_SetColors(_THIS, int firstcolor, int ncolors, | ||
119 | SDL_Color *colors); | ||
120 | static void EPOC_VideoQuit(_THIS); | ||
121 | |||
122 | /* Hardware surface functions */ | ||
123 | |||
124 | static int EPOC_AllocHWSurface(_THIS, SDL_Surface *surface); | ||
125 | static int EPOC_LockHWSurface(_THIS, SDL_Surface *surface); | ||
126 | static int EPOC_FlipHWSurface(_THIS, SDL_Surface *surface); | ||
127 | static void EPOC_UnlockHWSurface(_THIS, SDL_Surface *surface); | ||
128 | static void EPOC_FreeHWSurface(_THIS, SDL_Surface *surface); | ||
129 | static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); | ||
130 | |||
131 | static int EPOC_Available(void); | ||
132 | static SDL_VideoDevice *EPOC_CreateDevice(int devindex); | ||
133 | |||
134 | void DrawBackground(_THIS); | ||
135 | void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer); | ||
136 | void DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer); | ||
137 | |||
138 | /* Mouse functions */ | ||
139 | |||
140 | static WMcursor *EPOC_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); | ||
141 | static void EPOC_FreeWMCursor(_THIS, WMcursor *cursor); | ||
142 | static int EPOC_ShowWMCursor(_THIS, WMcursor *cursor); | ||
143 | } | ||
144 | |||
145 | |||
146 | extern "C" | ||
147 | { | ||
148 | struct WMcursor | ||
149 | { | ||
150 | }; | ||
151 | } | ||
152 | |||
153 | /* Epoc video driver bootstrap functions */ | ||
154 | |||
155 | |||
156 | static int EPOC_Available(void) | ||
157 | { | ||
158 | return 1; /* Always available */ | ||
159 | } | ||
160 | |||
161 | static void EPOC_DeleteDevice(SDL_VideoDevice *device) | ||
162 | { | ||
163 | User::Free(device->hidden); | ||
164 | User::Free(device); | ||
165 | } | ||
166 | |||
167 | static 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 | |||
222 | VideoBootStrap EPOC_bootstrap = { | ||
223 | "epoc\0\0\0", "EPOC system", | ||
224 | EPOC_Available, EPOC_CreateDevice | ||
225 | }; | ||
226 | |||
227 | |||
228 | |||
229 | void DisableKeyBlocking(_THIS) | ||
230 | { | ||
231 | EpocSdlEnv::Request(EpocSdlEnv::EDisableKeyBlocking); | ||
232 | } | ||
233 | |||
234 | void ConstructWindowL(_THIS) | ||
235 | { | ||
236 | SDL_TRACE("SDL:ConstructWindowL"); | ||
237 | DisableKeyBlocking(_this); //disable key blocking | ||
238 | } | ||
239 | |||
240 | |||
241 | int 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 | |||
275 | SDL_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 | |||
290 | int 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 | /* | ||
344 | void 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 | |||
355 | int 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 | |||
385 | TDisplayMode 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 | |||
406 | SDL_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 | |||
508 | static int EPOC_AllocHWSurface(_THIS, SDL_Surface* surface) | ||
509 | { | ||
510 | return KErrNone == EpocSdlEnv::AllocHwSurface(TSize(surface->w, surface->h), GetDisplayMode(surface->format->BitsPerPixel)); | ||
511 | } | ||
512 | |||
513 | static void EPOC_FreeHWSurface(_THIS, SDL_Surface* /*surface*/) | ||
514 | { | ||
515 | } | ||
516 | |||
517 | static 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 | } | ||
530 | static void EPOC_UnlockHWSurface(_THIS, SDL_Surface* /*surface*/) | ||
531 | { | ||
532 | EpocSdlEnv::UnlockHwSurface(); | ||
533 | } | ||
534 | |||
535 | static int EPOC_FlipHWSurface(_THIS, SDL_Surface* /*surface*/) | ||
536 | { | ||
537 | return(0); | ||
538 | } | ||
539 | |||
540 | static 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 | */ | ||
569 | void 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 | |||
581 | WMcursor *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 | |||
586 | void EPOC_FreeWMCursor(_THIS, WMcursor* /*cursor*/) | ||
587 | { | ||
588 | } | ||
589 | |||
590 | int 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 | |||
32 | class CFbsBitmap; | ||
33 | |||
34 | struct SDL_VideoDevice; | ||
35 | void DisableKeyBlocking(SDL_VideoDevice*); | ||
36 | |||
37 | struct 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 | |||
6 | LOCAL_C TInt BytesPerPixel(TDisplayMode aMode) | ||
7 | { | ||
8 | return ((TDisplayModeUtils::NumDisplayModeBitsPerPixel(aMode) - 1) >> 3) + 1; | ||
9 | } | ||
10 | |||
11 | |||
12 | |||
13 | |||
14 | template<class T> | ||
15 | NONSHARABLE_CLASS(CBitmapSurface) : public T | ||
16 | { | ||
17 | public: | ||
18 | CBitmapSurface(RWsSession& aSession); | ||
19 | private: | ||
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(); | ||
29 | private: | ||
30 | CFbsBitmap* iBmp; | ||
31 | CFbsBitmap* iCopyBmp; | ||
32 | }; | ||
33 | |||
34 | |||
35 | template<class T> | ||
36 | void 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 | |||
44 | template<class T> | ||
45 | CBitmapSurface<T>::CBitmapSurface(RWsSession& aSession) : T(aSession) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | template<class T> | ||
50 | void CBitmapSurface<T>::Free() | ||
51 | { | ||
52 | delete iBmp; | ||
53 | iBmp = NULL; | ||
54 | T::Free(); | ||
55 | } | ||
56 | |||
57 | template<class T> | ||
58 | CBitmapSurface<T>::~CBitmapSurface() | ||
59 | { | ||
60 | __ASSERT_DEBUG(iBmp == NULL, PANIC(KErrNotReady)); | ||
61 | delete iCopyBmp; | ||
62 | } | ||
63 | |||
64 | template<class T> | ||
65 | TUint8* CBitmapSurface<T>::LockSurface() | ||
66 | { | ||
67 | iBmp->LockHeap(); | ||
68 | return reinterpret_cast<TUint8*>(iBmp->DataAddress()); | ||
69 | } | ||
70 | |||
71 | |||
72 | template<class T> | ||
73 | void CBitmapSurface<T>::UnlockHwSurface() | ||
74 | { | ||
75 | iBmp->UnlockHeap(); | ||
76 | T::SetUpdating(EFalse); | ||
77 | Update(*iBmp); | ||
78 | } | ||
79 | |||
80 | |||
81 | template<class T> | ||
82 | void 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 | |||
95 | template<class T> | ||
96 | void 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 | |||
104 | template<class T> | ||
105 | void CBitmapSurface<T>::Wipe(TInt aLength) //dont call in drawing | ||
106 | { | ||
107 | iBmp->LockHeap(); | ||
108 | Mem::FillZ(iBmp->DataAddress(), aLength); | ||
109 | iBmp->UnlockHeap(); | ||
110 | } | ||
111 | |||
112 | template<class T> | ||
113 | TInt 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 | |||
130 | NONSHARABLE_CLASS(CDsaBitgdi) : public CDsa | ||
131 | { | ||
132 | public: | ||
133 | CDsaBitgdi(RWsSession& aSession); | ||
134 | protected: | ||
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(); | ||
142 | private: | ||
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 | |||
154 | CDsaBitgdi::CDsaBitgdi(RWsSession& aSession) : CDsa(aSession) | ||
155 | { | ||
156 | } | ||
157 | |||
158 | CDsaBitgdi::~CDsaBitgdi() | ||
159 | { | ||
160 | delete iWinGc; | ||
161 | delete iBitGdiBmp; | ||
162 | } | ||
163 | |||
164 | void CDsaBitgdi::CompleteUpdate() | ||
165 | { | ||
166 | EpocSdlEnv::Request(CDsa::ERequestUpdate); | ||
167 | } | ||
168 | |||
169 | |||
170 | void 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 | |||
192 | void CDsaBitgdi::Resume() | ||
193 | { | ||
194 | Start(); | ||
195 | } | ||
196 | |||
197 | CBitmapContext& 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 | |||
217 | void CDsaBitgdi::CreateSurfaceL(CFbsBitmap& aBmp) | ||
218 | { | ||
219 | iDevice = CFbsBitmapDevice::NewL(&aBmp); | ||
220 | User::LeaveIfError(iDevice->CreateContext(iGc)); | ||
221 | iHandle = aBmp.Handle(); | ||
222 | } | ||
223 | |||
224 | void CDsaBitgdi::Free() | ||
225 | { | ||
226 | delete iGc; | ||
227 | iGc = NULL; | ||
228 | delete iDevice; | ||
229 | iDevice = NULL; | ||
230 | } | ||
231 | |||
232 | //////////////////////////////////////////////////////////////////////// | ||
233 | /////////////////////////////////////////////////////////////////////// | ||
234 | |||
235 | NONSHARABLE_CLASS(CDsaBase) : public CDsa, public MDirectScreenAccess | ||
236 | { | ||
237 | protected: | ||
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(); | ||
245 | protected: | ||
246 | CDirectScreenAccess* iDsa; | ||
247 | private: | ||
248 | void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); | ||
249 | void Restart(RDirectScreenAccess::TTerminationReasons aReason); | ||
250 | private: | ||
251 | void RestartL(); | ||
252 | }; | ||
253 | |||
254 | |||
255 | inline CDirectScreenAccess& CDsaBase::Dsa() const | ||
256 | { | ||
257 | return *iDsa; | ||
258 | } | ||
259 | |||
260 | |||
261 | CDsaBase::CDsaBase(RWsSession& aSession) : CDsa(aSession) | ||
262 | { | ||
263 | } | ||
264 | |||
265 | CBitmapContext& CDsaBase::Gc() | ||
266 | { | ||
267 | return *Dsa().Gc(); | ||
268 | } | ||
269 | |||
270 | void 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 | |||
288 | void CDsaBase::Resume() | ||
289 | { | ||
290 | if(Stopped()) | ||
291 | Restart(RDirectScreenAccess::ETerminateRegion); | ||
292 | } | ||
293 | |||
294 | CDsaBase::~CDsaBase() | ||
295 | { | ||
296 | if(iDsa != NULL) | ||
297 | { | ||
298 | iDsa->Cancel(); | ||
299 | } | ||
300 | delete iDsa; | ||
301 | } | ||
302 | |||
303 | |||
304 | void 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 | |||
328 | void CDsaBase::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) | ||
329 | { | ||
330 | Stop(); | ||
331 | } | ||
332 | |||
333 | void 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 | |||
343 | void CDsaBase::Stop() | ||
344 | { | ||
345 | CDsa::Stop(); | ||
346 | iDsa->Cancel(); | ||
347 | } | ||
348 | |||
349 | |||
350 | /////////////////////////////////////////////////////////////////////// | ||
351 | /////////////////////////////////////////////////////////////////////// | ||
352 | NONSHARABLE_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 | |||
367 | inline TDsa::TDsa(const CDsa& aDsa) : iDsa(aDsa) | ||
368 | { | ||
369 | } | ||
370 | |||
371 | inline TBool TDsa::IsTurn() const | ||
372 | { | ||
373 | return iDsa.iStateFlags & CDsa::EOrientation90; | ||
374 | } | ||
375 | |||
376 | inline TBool TDsa::IsFlip() const | ||
377 | { | ||
378 | return iDsa.iStateFlags & CDsa::EOrientation180; | ||
379 | } | ||
380 | |||
381 | inline const TSize& TDsa::SwSize() const | ||
382 | { | ||
383 | return iDsa.SwSize(); | ||
384 | } | ||
385 | |||
386 | inline void TDsa::Copy(TUint32* aTarget, const TUint8* aSrc, TInt aBytes, TInt aHeight) const | ||
387 | { | ||
388 | iDsa.iCopyFunction(iDsa, aTarget, aSrc, aBytes, aHeight); | ||
389 | } | ||
390 | |||
391 | template<class T, class S> | ||
392 | void 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 | |||
448 | NONSHARABLE_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 | |||
461 | CDsaA::CDsaA(RWsSession& aSession) : CDsaBase(aSession) | ||
462 | { | ||
463 | } | ||
464 | |||
465 | |||
466 | void CDsaA::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice) | ||
467 | { | ||
468 | CDsaBase::ConstructL(aWindow, aDevice); | ||
469 | } | ||
470 | |||
471 | void CDsaA::CompleteUpdate() | ||
472 | { | ||
473 | iDsa->ScreenDevice()->Update(); | ||
474 | } | ||
475 | |||
476 | void CDsaA::CreateSurfaceL(CFbsBitmap& /*aBmp*/) | ||
477 | { | ||
478 | } | ||
479 | |||
480 | void CDsaA::Free() | ||
481 | { | ||
482 | |||
483 | } | ||
484 | |||
485 | void CDsaA::UnlockHWSurfaceRequestComplete() | ||
486 | { | ||
487 | PANIC(KErrNotSupported); | ||
488 | } | ||
489 | |||
490 | |||
491 | |||
492 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
493 | |||
494 | NONSHARABLE_CLASS(MDsbObs) | ||
495 | { | ||
496 | public: | ||
497 | virtual void SurfaceReady() = 0; | ||
498 | virtual CDirectScreenBitmap& Dsb() = 0; | ||
499 | }; | ||
500 | |||
501 | NONSHARABLE_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 | |||
516 | CDsbSurface::CDsbSurface(MDsbObs& aDsb) : CActive(CActive::EPriorityHigh) , iDsb(aDsb) | ||
517 | { | ||
518 | CActiveScheduler::Add(this); | ||
519 | } | ||
520 | |||
521 | CDsbSurface::~CDsbSurface() | ||
522 | { | ||
523 | Cancel(); | ||
524 | } | ||
525 | |||
526 | void CDsbSurface::Complete() | ||
527 | { | ||
528 | if(iAddress != NULL && !IsActive()) | ||
529 | { | ||
530 | iAddress = NULL; | ||
531 | SetActive(); | ||
532 | iDsb.Dsb().EndUpdate(iStatus); | ||
533 | } | ||
534 | } | ||
535 | |||
536 | TUint8* 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 | |||
547 | void CDsbSurface::RunL() | ||
548 | { | ||
549 | iDsb.SurfaceReady(); | ||
550 | } | ||
551 | |||
552 | void CDsbSurface::DoCancel() | ||
553 | { | ||
554 | //empty | ||
555 | } | ||
556 | |||
557 | NONSHARABLE_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 | |||
581 | CDsaB::CDsaB(RWsSession& aSession, TInt aFlags) : CDsaBase(aSession), iType(aFlags) | ||
582 | { | ||
583 | } | ||
584 | |||
585 | |||
586 | |||
587 | void CDsaB::UnlockHWSurfaceRequestComplete() | ||
588 | { | ||
589 | iSurface1->Complete(); | ||
590 | if(iSurface2 != NULL) | ||
591 | iSurface2->Complete(); | ||
592 | } | ||
593 | |||
594 | void CDsaB::CreateSurfaceL() | ||
595 | { | ||
596 | __ASSERT_ALWAYS(SwSize() == HwRect().Size(), PANIC(KErrNotSupported)); | ||
597 | } | ||
598 | |||
599 | void 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 | |||
610 | void CDsaB::UnlockHwSurface() | ||
611 | { | ||
612 | EpocSdlEnv::Request(CDsa::ERequestUpdate); | ||
613 | } | ||
614 | |||
615 | TUint8* 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 | |||
624 | void CDsaB::SurfaceReady() | ||
625 | { | ||
626 | SetUpdating(EFalse); | ||
627 | } | ||
628 | |||
629 | CDirectScreenBitmap& CDsaB::Dsb() | ||
630 | { | ||
631 | return *iDsb; | ||
632 | } | ||
633 | |||
634 | void 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 | |||
645 | CDsaB::~CDsaB() | ||
646 | { | ||
647 | delete iSurface1; | ||
648 | delete iSurface2; | ||
649 | delete iDsb; | ||
650 | } | ||
651 | |||
652 | void CDsaB::RecreateL() | ||
653 | { | ||
654 | iDsb->Close(); | ||
655 | iDsb->Create(HwRect(), CDirectScreenBitmap::TSettingsFlags(iType)); | ||
656 | } | ||
657 | |||
658 | TInt CDsaB::ExternalUpdate() | ||
659 | { | ||
660 | if(LockSurface()) | ||
661 | { | ||
662 | UnlockHWSurfaceRequestComplete(); | ||
663 | return KErrNone; | ||
664 | } | ||
665 | return KErrNotReady; | ||
666 | } | ||
667 | |||
668 | |||
669 | ///////////////////////////////////////////////////////////////////////////////////////////////////// | ||
670 | |||
671 | |||
672 | |||
673 | CDsa* 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 | |||
695 | void CDsa::RecreateL() | ||
696 | { | ||
697 | } | ||
698 | |||
699 | void CDsa::Free() | ||
700 | { | ||
701 | } | ||
702 | |||
703 | TSize 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 | |||
715 | void CDsa::SetSuspend() | ||
716 | { | ||
717 | iStateFlags |= ESdlThreadSuspend; | ||
718 | } | ||
719 | |||
720 | |||
721 | void CDsa::SetUpdating(TBool aUpdate) | ||
722 | { | ||
723 | if(aUpdate) | ||
724 | iStateFlags |= EUpdating; | ||
725 | else | ||
726 | iStateFlags &= ~EUpdating; | ||
727 | } | ||
728 | |||
729 | |||
730 | TBool CDsa::Stopped() const | ||
731 | { | ||
732 | return (iStateFlags & ESdlThreadExplicitStop); | ||
733 | } | ||
734 | |||
735 | void 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 | |||
760 | CDsa::~CDsa() | ||
761 | { | ||
762 | iOverlays.Close(); | ||
763 | User::Free(iLut256); | ||
764 | } | ||
765 | |||
766 | void 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 | |||
776 | void 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 | |||
783 | TInt 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 | |||
792 | TInt 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 | |||
805 | void CDsa::LockPalette(TBool aLock) | ||
806 | { | ||
807 | if(aLock) | ||
808 | iStateFlags |= EPaletteLocked; | ||
809 | else | ||
810 | iStateFlags &= ~EPaletteLocked; | ||
811 | } | ||
812 | TInt 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 | |||
832 | CDsa::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 | |||
855 | RWsSession& CDsa::Session() | ||
856 | { | ||
857 | return iSession; | ||
858 | } | ||
859 | |||
860 | TInt CDsa::RedrawRequest() | ||
861 | { | ||
862 | if(!(iStateFlags & (EUpdating) && (iStateFlags & ERunning))) | ||
863 | { | ||
864 | return ExternalUpdate(); | ||
865 | } | ||
866 | return KErrNotReady; | ||
867 | } | ||
868 | |||
869 | TUint8* CDsa::LockHwSurface() | ||
870 | { | ||
871 | if((iStateFlags & EUpdating) == 0) //else frame is skipped | ||
872 | { | ||
873 | return LockSurface(); | ||
874 | } | ||
875 | return NULL; | ||
876 | } | ||
877 | |||
878 | /* | ||
879 | void CDsa::RunL() | ||
880 | { | ||
881 | iStateFlags &= ~EUpdating; | ||
882 | } | ||
883 | |||
884 | |||
885 | void CDsa::DoCancel() | ||
886 | { | ||
887 | iStateFlags &= ~EUpdating; | ||
888 | //nothing can do, just wait? | ||
889 | } | ||
890 | */ | ||
891 | |||
892 | |||
893 | TInt 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 | |||
918 | void CDsa::CreateZoomerL(const TSize& aSize) | ||
919 | { | ||
920 | iSwSize = aSize; | ||
921 | iStateFlags |= EResizeRequest; | ||
922 | CreateSurfaceL(); | ||
923 | SetTargetRect(); | ||
924 | } | ||
925 | |||
926 | |||
927 | /* | ||
928 | void 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 | |||
941 | void 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 | |||
963 | TBuf<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 | |||
973 | void 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 | |||
994 | void CDsa::Wipe() //dont call in drawing | ||
995 | { | ||
996 | if(IsDsaAvailable()) | ||
997 | Wipe(iTargetBpp * SwSize().iWidth * SwSize().iHeight); | ||
998 | } | ||
999 | |||
1000 | void 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 | |||
1028 | inline 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 | /* | ||
1042 | int bar = 0; | ||
1043 | */ | ||
1044 | |||
1045 | TBool 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 | |||
1098 | void 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 | |||
1107 | void CDsa::DoStop() | ||
1108 | { | ||
1109 | if(IsDsaAvailable()) | ||
1110 | iStateFlags |= ESdlThreadExplicitStop; | ||
1111 | Stop(); | ||
1112 | } | ||
1113 | |||
1114 | |||
1115 | void CDsa::Stop() | ||
1116 | { | ||
1117 | iStateFlags &= ~ERunning; | ||
1118 | } | ||
1119 | |||
1120 | void 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 | |||
1135 | TBool CDsa::Blitter(CFbsBitmap& aBmp) | ||
1136 | { | ||
1137 | return iBlitter && iBlitter->BitBlt(Gc(), aBmp, HwRect(), SwSize()); | ||
1138 | } | ||
1139 | |||
1140 | void CDsa::SetBlitter(MBlitter* aBlitter) | ||
1141 | { | ||
1142 | iBlitter = aBlitter; | ||
1143 | } | ||
1144 | |||
1145 | |||
1146 | TPoint 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 | |||
1171 | void 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 | |||
1206 | void 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 | |||
1217 | void 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 | |||
1228 | void 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 | |||
1241 | void 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 | |||
1254 | void 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 | |||
1260 | void 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 | |||
1273 | void 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 | |||
1285 | void 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 | |||
1300 | LOCAL_C TRgb rgb16MA(TInt aValue) | ||
1301 | { | ||
1302 | return TRgb::Color16MA(aValue); | ||
1303 | } | ||
1304 | */ | ||
1305 | NONSHARABLE_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 | |||
1312 | template <class T> | ||
1313 | NONSHARABLE_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 | |||
1333 | template <class T> | ||
1334 | void* TRgbCopy<T>::operator new(TUint /*aBytes*/, TAny* aMem) | ||
1335 | { | ||
1336 | return aMem; | ||
1337 | } | ||
1338 | |||
1339 | template <class T> | ||
1340 | TRgbCopy<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 | |||
1356 | template <class T> | ||
1357 | void 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 | |||
1381 | template <class T> | ||
1382 | void 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 | |||
1406 | template <class T> TUint32 TRgbCopy<T>::Gray256(const TUint8& aPixel) | ||
1407 | { | ||
1408 | const TUint32 px = aPixel << 16 | aPixel << 8 | aPixel; | ||
1409 | return px; | ||
1410 | } | ||
1411 | |||
1412 | template <class T> TUint32 TRgbCopy<T>::Color256(const TUint8& aPixel) | ||
1413 | { | ||
1414 | return TRgb::Color256(aPixel).Value(); | ||
1415 | } | ||
1416 | |||
1417 | template <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 | |||
1431 | template <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 | |||
1445 | template <class T> TUint32 TRgbCopy<T>::Color16M(const TUint32& aPixel) | ||
1446 | { | ||
1447 | return TRgb::Color16M(aPixel).Value(); | ||
1448 | } | ||
1449 | |||
1450 | template <class T> TUint32 TRgbCopy<T>::Color16MU(const TUint32& aPixel) | ||
1451 | { | ||
1452 | return TRgb::Color16MU(aPixel).Value(); | ||
1453 | } | ||
1454 | |||
1455 | template <class T> TUint32 TRgbCopy<T>::Color16MA(const TUint32& aPixel) | ||
1456 | { | ||
1457 | return TRgb::Color16MA(aPixel).Value(); | ||
1458 | } | ||
1459 | |||
1460 | typedef TUint64 TStackMem; | ||
1461 | |||
1462 | LOCAL_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 | |||
1481 | void 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 | |||
1487 | void 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 | |||
1493 | void 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 | |||
1499 | void 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 | |||
6 | LOCAL_C TInt BytesPerPixel(TDisplayMode aMode) | ||
7 | { | ||
8 | return ((TDisplayModeUtils::NumDisplayModeBitsPerPixel(aMode) - 1) >> 3) + 1; | ||
9 | } | ||
10 | |||
11 | |||
12 | NONSHARABLE_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 | |||
25 | inline TDsa::TDsa(const CDsa& aDsa) : iDsa(aDsa) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | inline TBool TDsa::IsTurn() const | ||
30 | { | ||
31 | return iDsa.iStateFlags & CDsa::EOrientation90; | ||
32 | } | ||
33 | |||
34 | inline TBool TDsa::IsFlip() const | ||
35 | { | ||
36 | return iDsa.iStateFlags & CDsa::EOrientation180; | ||
37 | } | ||
38 | |||
39 | inline const TSize& TDsa::SwSize() const | ||
40 | { | ||
41 | return iDsa.SwSize(); | ||
42 | } | ||
43 | |||
44 | inline void TDsa::Copy(TUint32* aTarget, const TUint8* aSrc, TInt aBytes, TInt aHeight) const | ||
45 | { | ||
46 | iDsa.iCopyFunction(iDsa, aTarget, aSrc, aBytes, aHeight); | ||
47 | } | ||
48 | |||
49 | template<class T, class S> | ||
50 | void 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 | |||
106 | NONSHARABLE_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 | |||
128 | CDsaA::CDsaA(RWsSession& aSession) : CDsa(aSession) | ||
129 | { | ||
130 | } | ||
131 | |||
132 | |||
133 | void CDsaA::Free() | ||
134 | { | ||
135 | delete iBmp; | ||
136 | iBmp = NULL; | ||
137 | } | ||
138 | |||
139 | CDsaA::~CDsaA() | ||
140 | { | ||
141 | __ASSERT_DEBUG(iBmp == NULL, PANIC(KErrNotReady)); | ||
142 | delete iCopyBmp; | ||
143 | } | ||
144 | |||
145 | TUint8* CDsaA::LockSurface() | ||
146 | { | ||
147 | iBmp->LockHeap(); | ||
148 | return reinterpret_cast<TUint8*>(iBmp->DataAddress()); | ||
149 | } | ||
150 | |||
151 | void CDsaA::UnlockHWSurfaceRequestComplete() | ||
152 | { | ||
153 | PANIC(KErrNotSupported); | ||
154 | } | ||
155 | |||
156 | void CDsaA::UnlockHwSurface() | ||
157 | { | ||
158 | iBmp->UnlockHeap(); | ||
159 | SetUpdating(EFalse); | ||
160 | Update(*iBmp); | ||
161 | } | ||
162 | |||
163 | void 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 | } | ||
175 | void CDsaA::CreateSurfaceL() | ||
176 | { | ||
177 | delete iBmp; | ||
178 | iBmp = NULL; | ||
179 | iBmp = new (ELeave) CFbsBitmap(); | ||
180 | User::LeaveIfError(iBmp->Create(SwSize(), DisplayMode())); | ||
181 | } | ||
182 | |||
183 | void 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 | |||
192 | TInt 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 | |||
204 | void CDsaA::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice) | ||
205 | { | ||
206 | iCopyBmp = new (ELeave) CFbsBitmap(); | ||
207 | CDsa::ConstructL(aWindow, aDevice); | ||
208 | } | ||
209 | |||
210 | |||
211 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
212 | |||
213 | NONSHARABLE_CLASS(MDsbObs) | ||
214 | { | ||
215 | public: | ||
216 | virtual void SurfaceReady() = 0; | ||
217 | virtual CDirectScreenBitmap& Dsb() = 0; | ||
218 | }; | ||
219 | |||
220 | NONSHARABLE_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 | |||
235 | CDsbSurface::CDsbSurface(MDsbObs& aDsb) : CActive(CActive::EPriorityHigh) , iDsb(aDsb) | ||
236 | { | ||
237 | CActiveScheduler::Add(this); | ||
238 | } | ||
239 | |||
240 | CDsbSurface::~CDsbSurface() | ||
241 | { | ||
242 | Cancel(); | ||
243 | } | ||
244 | |||
245 | void CDsbSurface::Complete() | ||
246 | { | ||
247 | if(iAddress != NULL && !IsActive()) | ||
248 | { | ||
249 | iAddress = NULL; | ||
250 | SetActive(); | ||
251 | iDsb.Dsb().EndUpdate(iStatus); | ||
252 | } | ||
253 | } | ||
254 | |||
255 | TUint8* 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 | |||
266 | void CDsbSurface::RunL() | ||
267 | { | ||
268 | iDsb.SurfaceReady(); | ||
269 | } | ||
270 | |||
271 | void CDsbSurface::DoCancel() | ||
272 | { | ||
273 | //empty | ||
274 | } | ||
275 | |||
276 | NONSHARABLE_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 | |||
299 | CDsaB::CDsaB(RWsSession& aSession, TInt aFlags) : CDsa(aSession), iType(aFlags) | ||
300 | { | ||
301 | } | ||
302 | |||
303 | |||
304 | |||
305 | void CDsaB::UnlockHWSurfaceRequestComplete() | ||
306 | { | ||
307 | iSurface1->Complete(); | ||
308 | if(iSurface2 != NULL) | ||
309 | iSurface2->Complete(); | ||
310 | } | ||
311 | |||
312 | void CDsaB::CreateSurfaceL() | ||
313 | { | ||
314 | __ASSERT_ALWAYS(SwSize() == HwRect().Size(), PANIC(KErrNotSupported)); | ||
315 | } | ||
316 | |||
317 | void 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 | |||
328 | void CDsaB::UnlockHwSurface() | ||
329 | { | ||
330 | EpocSdlEnv::Request(CDsa::ERequestUpdate); | ||
331 | } | ||
332 | |||
333 | TUint8* 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 | |||
342 | void CDsaB::SurfaceReady() | ||
343 | { | ||
344 | SetUpdating(EFalse); | ||
345 | } | ||
346 | |||
347 | CDirectScreenBitmap& CDsaB::Dsb() | ||
348 | { | ||
349 | return *iDsb; | ||
350 | } | ||
351 | |||
352 | void 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 | |||
363 | CDsaB::~CDsaB() | ||
364 | { | ||
365 | delete iSurface1; | ||
366 | delete iSurface2; | ||
367 | delete iDsb; | ||
368 | } | ||
369 | |||
370 | void CDsaB::RecreateL() | ||
371 | { | ||
372 | iDsb->Close(); | ||
373 | iDsb->Create(HwRect(), CDirectScreenBitmap::TSettingsFlags(iType)); | ||
374 | } | ||
375 | |||
376 | TInt CDsaB::ExternalUpdate() | ||
377 | { | ||
378 | if(LockSurface()) | ||
379 | { | ||
380 | UnlockHWSurfaceRequestComplete(); | ||
381 | return KErrNone; | ||
382 | } | ||
383 | return KErrNotReady; | ||
384 | } | ||
385 | |||
386 | |||
387 | ///////////////////////////////////////////////////////////////////////////////////////////////////// | ||
388 | |||
389 | |||
390 | CDsa* 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 | |||
406 | void CDsa::RecreateL() | ||
407 | { | ||
408 | } | ||
409 | |||
410 | void CDsa::Free() | ||
411 | { | ||
412 | } | ||
413 | |||
414 | TSize 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 | |||
426 | void CDsa::SetSuspend() | ||
427 | { | ||
428 | iStateFlags |= ESdlThreadSuspend; | ||
429 | } | ||
430 | |||
431 | void CDsa::ReleaseStop() | ||
432 | { | ||
433 | iStateFlags &= ~ESdlThreadExplicitStop; | ||
434 | } | ||
435 | |||
436 | |||
437 | TBool CDsa::Stopped() const | ||
438 | { | ||
439 | return (iStateFlags & ESdlThreadExplicitStop); | ||
440 | } | ||
441 | |||
442 | void 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 | |||
467 | CDsa::~CDsa() | ||
468 | { | ||
469 | if(iDsa != NULL) | ||
470 | { | ||
471 | iDsa->Cancel(); | ||
472 | } | ||
473 | iOverlays.Close(); | ||
474 | delete iDsa; | ||
475 | User::Free(iLut256); | ||
476 | } | ||
477 | |||
478 | void 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 | |||
502 | void 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 | |||
509 | TInt 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 | |||
518 | TInt 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 | |||
531 | void CDsa::LockPalette(TBool aLock) | ||
532 | { | ||
533 | if(aLock) | ||
534 | iStateFlags |= EPaletteLocked; | ||
535 | else | ||
536 | iStateFlags &= ~EPaletteLocked; | ||
537 | } | ||
538 | TInt 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 | |||
556 | void 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 | |||
592 | CDsa::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 | |||
614 | RWsSession& CDsa::Session() | ||
615 | { | ||
616 | return iSession; | ||
617 | } | ||
618 | |||
619 | TInt CDsa::RedrawRequest() | ||
620 | { | ||
621 | if(!(iStateFlags & (EUpdating) && (iStateFlags & ERunning))) | ||
622 | { | ||
623 | return ExternalUpdate(); | ||
624 | } | ||
625 | return KErrNotReady; | ||
626 | } | ||
627 | |||
628 | TUint8* CDsa::LockHwSurface() | ||
629 | { | ||
630 | if((iStateFlags & EUpdating) == 0) //else frame is skipped | ||
631 | { | ||
632 | return LockSurface(); | ||
633 | } | ||
634 | return NULL; | ||
635 | } | ||
636 | |||
637 | /* | ||
638 | void CDsa::RunL() | ||
639 | { | ||
640 | iStateFlags &= ~EUpdating; | ||
641 | } | ||
642 | |||
643 | |||
644 | void CDsa::DoCancel() | ||
645 | { | ||
646 | iStateFlags &= ~EUpdating; | ||
647 | //nothing can do, just wait? | ||
648 | } | ||
649 | */ | ||
650 | |||
651 | |||
652 | TInt 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 | |||
677 | void CDsa::CreateZoomerL(const TSize& aSize) | ||
678 | { | ||
679 | iSwSize = aSize; | ||
680 | iStateFlags |= EResizeRequest; | ||
681 | CreateSurfaceL(); | ||
682 | SetTargetRect(); | ||
683 | } | ||
684 | |||
685 | |||
686 | /* | ||
687 | void 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 | |||
700 | void 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 | |||
722 | TBuf<16> FooName(TInt aFoo) | ||
723 | { | ||
724 | TBuf<16> b; | ||
725 | b.Format(_L("C:\\pic%d.mbm"), aFoo); | ||
726 | return b; | ||
727 | } | ||
728 | |||
729 | void 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 | /* | ||
750 | void 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 | |||
808 | void 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 | /* | ||
854 | void 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 | |||
879 | void CDsa::Wipe() //dont call in drawing | ||
880 | { | ||
881 | if(IsDsaAvailable()) | ||
882 | Wipe(iTargetBpp * SwSize().iWidth * SwSize().iHeight); | ||
883 | } | ||
884 | |||
885 | void 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 | |||
913 | inline 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 | /* | ||
927 | int bar = 0; | ||
928 | */ | ||
929 | /* | ||
930 | TBool 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 | |||
983 | TBool 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 | } | ||
1029 | void 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 | |||
1036 | void CDsa::Resume() | ||
1037 | { | ||
1038 | if(Stopped()) | ||
1039 | Restart(RDirectScreenAccess::ETerminateRegion); | ||
1040 | } | ||
1041 | |||
1042 | void CDsa::DoStop() | ||
1043 | { | ||
1044 | if(IsDsaAvailable()) | ||
1045 | iStateFlags |= ESdlThreadExplicitStop; | ||
1046 | Stop(); | ||
1047 | } | ||
1048 | |||
1049 | void CDsa::Stop() | ||
1050 | { | ||
1051 | iStateFlags &= ~ERunning; | ||
1052 | // Cancel(); //can be called only from main! | ||
1053 | iDsa->Cancel(); | ||
1054 | } | ||
1055 | |||
1056 | void CDsa::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) | ||
1057 | { | ||
1058 | // iStateFlags |= EChangeNotify; | ||
1059 | Stop(); | ||
1060 | } | ||
1061 | |||
1062 | void 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 | |||
1071 | void CDsa::SetBlitter(MBlitter* aBlitter) | ||
1072 | { | ||
1073 | iBlitter = aBlitter; | ||
1074 | } | ||
1075 | |||
1076 | |||
1077 | TPoint 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 | |||
1102 | void 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 | /*) | ||
1135 | TBool CDsa::ChangeTrigger() | ||
1136 | { | ||
1137 | const TBool change = iStateFlags & EChangeNotify; | ||
1138 | iStateFlags &= ~EChangeNotify; | ||
1139 | return change; | ||
1140 | } | ||
1141 | */ | ||
1142 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
1143 | |||
1144 | void 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 | |||
1155 | void 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 | |||
1166 | void 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 | |||
1179 | void 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 | |||
1192 | void 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 | |||
1198 | void 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 | |||
1211 | void 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 | |||
1223 | void 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 | |||
1238 | LOCAL_C TRgb rgb16MA(TInt aValue) | ||
1239 | { | ||
1240 | return TRgb::Color16MA(aValue); | ||
1241 | } | ||
1242 | */ | ||
1243 | NONSHARABLE_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 | |||
1250 | template <class T> | ||
1251 | NONSHARABLE_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 | |||
1271 | template <class T> | ||
1272 | void* TRgbCopy<T>::operator new(TUint /*aBytes*/, TAny* aMem) | ||
1273 | { | ||
1274 | return aMem; | ||
1275 | } | ||
1276 | |||
1277 | template <class T> | ||
1278 | TRgbCopy<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 | |||
1294 | template <class T> | ||
1295 | void 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 | |||
1319 | template <class T> | ||
1320 | void 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 | |||
1344 | template <class T> TUint32 TRgbCopy<T>::Gray256(const TUint8& aPixel) | ||
1345 | { | ||
1346 | const TUint32 px = aPixel << 16 | aPixel << 8 | aPixel; | ||
1347 | return px; | ||
1348 | } | ||
1349 | |||
1350 | template <class T> TUint32 TRgbCopy<T>::Color256(const TUint8& aPixel) | ||
1351 | { | ||
1352 | return TRgb::Color256(aPixel).Value(); | ||
1353 | } | ||
1354 | |||
1355 | template <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 | |||
1369 | template <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 | |||
1383 | template <class T> TUint32 TRgbCopy<T>::Color16M(const TUint32& aPixel) | ||
1384 | { | ||
1385 | return TRgb::Color16M(aPixel).Value(); | ||
1386 | } | ||
1387 | |||
1388 | template <class T> TUint32 TRgbCopy<T>::Color16MU(const TUint32& aPixel) | ||
1389 | { | ||
1390 | return TRgb::Color16MU(aPixel).Value(); | ||
1391 | } | ||
1392 | |||
1393 | template <class T> TUint32 TRgbCopy<T>::Color16MA(const TUint32& aPixel) | ||
1394 | { | ||
1395 | return TRgb::Color16MA(aPixel).Value(); | ||
1396 | } | ||
1397 | |||
1398 | typedef TUint64 TStackMem; | ||
1399 | |||
1400 | LOCAL_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 | |||
1419 | void 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 | |||
1425 | void 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 | |||
1431 | void 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 | |||
1437 | void 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 | |||
5 | LOCAL_C TInt BytesPerPixel(TDisplayMode aMode) | ||
6 | { | ||
7 | return ((TDisplayModeUtils::NumDisplayModeBitsPerPixel(aMode) - 1) >> 3) + 1; | ||
8 | } | ||
9 | |||
10 | |||
11 | //////////////////////////////////////////////////////////////////////////////////////////////// | ||
12 | |||
13 | NONSHARABLE_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 | |||
32 | CDsaA::CDsaA(RWsSession& aSession) : CDsa(aSession) | ||
33 | { | ||
34 | } | ||
35 | |||
36 | void CDsaA::Free() | ||
37 | { | ||
38 | delete iBmp; | ||
39 | iBmp = NULL; | ||
40 | } | ||
41 | |||
42 | CDsaA::~CDsaA() | ||
43 | { | ||
44 | __ASSERT_DEBUG(iBmp == NULL, PANIC(KErrNotReady)); | ||
45 | } | ||
46 | |||
47 | TUint8* CDsaA::LockSurface() | ||
48 | { | ||
49 | iBmp->LockHeap(); | ||
50 | return reinterpret_cast<TUint8*>(iBmp->DataAddress()); | ||
51 | } | ||
52 | |||
53 | void CDsaA::UnlockHWSurfaceRequestComplete() | ||
54 | { | ||
55 | PANIC(KErrNotSupported); | ||
56 | } | ||
57 | |||
58 | void CDsaA::UnlockHwSurface() | ||
59 | { | ||
60 | iBmp->UnlockHeap(); | ||
61 | SetUpdating(EFalse); | ||
62 | Dsa().Gc()->BitBlt(HwRect().iTl, iBmp); | ||
63 | Dsa().ScreenDevice()->Update(); | ||
64 | } | ||
65 | |||
66 | void CDsaA::CreateSurfaceL() | ||
67 | { | ||
68 | delete iBmp; | ||
69 | iBmp = NULL; | ||
70 | iBmp = new (ELeave) CFbsBitmap(); | ||
71 | User::LeaveIfError(iBmp->Create(HwRect().Size(), DisplayMode())); | ||
72 | } | ||
73 | |||
74 | void CDsaA::Wipe(TInt aLength) //dont call in drawing | ||
75 | { | ||
76 | iBmp->LockHeap(); | ||
77 | Mem::FillZ(iBmp->DataAddress(), aLength); | ||
78 | iBmp->UnlockHeap(); | ||
79 | } | ||
80 | |||
81 | void CDsaA::RecreateL() | ||
82 | { | ||
83 | } | ||
84 | |||
85 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
86 | |||
87 | NONSHARABLE_CLASS(MDsbObs) | ||
88 | { | ||
89 | public: | ||
90 | virtual void SurfaceReady() = 0; | ||
91 | virtual CDirectScreenBitmap& Dsb() = 0; | ||
92 | }; | ||
93 | |||
94 | NONSHARABLE_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 | |||
109 | CDsbSurface::CDsbSurface(MDsbObs& aDsb) : CActive(CActive::EPriorityHigh) , iDsb(aDsb) | ||
110 | { | ||
111 | CActiveScheduler::Add(this); | ||
112 | } | ||
113 | |||
114 | CDsbSurface::~CDsbSurface() | ||
115 | { | ||
116 | Cancel(); | ||
117 | } | ||
118 | |||
119 | void CDsbSurface::Complete() | ||
120 | { | ||
121 | if(iAddress != NULL && !IsActive()) | ||
122 | { | ||
123 | iAddress = NULL; | ||
124 | SetActive(); | ||
125 | iDsb.Dsb().EndUpdate(iStatus); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | TUint8* 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 | |||
140 | void CDsbSurface::RunL() | ||
141 | { | ||
142 | iDsb.SurfaceReady(); | ||
143 | } | ||
144 | |||
145 | void CDsbSurface::DoCancel() | ||
146 | { | ||
147 | //empty | ||
148 | } | ||
149 | |||
150 | NONSHARABLE_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 | |||
173 | CDsaB::CDsaB(RWsSession& aSession) : CDsa(aSession) | ||
174 | { | ||
175 | } | ||
176 | |||
177 | void CDsaB::Free() | ||
178 | { | ||
179 | } | ||
180 | |||
181 | void CDsaB::UnlockHWSurfaceRequestComplete() | ||
182 | { | ||
183 | iSurface1->Complete(); | ||
184 | iSurface2->Complete(); | ||
185 | } | ||
186 | |||
187 | void CDsaB::CreateSurfaceL() | ||
188 | { | ||
189 | } | ||
190 | |||
191 | void 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 | |||
201 | void CDsaB::UnlockHwSurface() | ||
202 | { | ||
203 | EpocSdlEnv::Request(CDsa::ERequestUpdate); | ||
204 | } | ||
205 | |||
206 | TUint8* 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 | |||
215 | void CDsaB::SurfaceReady() | ||
216 | { | ||
217 | SetUpdating(EFalse); | ||
218 | } | ||
219 | |||
220 | CDirectScreenBitmap& CDsaB::Dsb() | ||
221 | { | ||
222 | return *iDsb; | ||
223 | } | ||
224 | |||
225 | void 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 | |||
234 | CDsaB::~CDsaB() | ||
235 | { | ||
236 | delete iSurface1; | ||
237 | delete iSurface2; | ||
238 | delete iDsb; | ||
239 | } | ||
240 | |||
241 | void CDsaB::RecreateL() | ||
242 | { | ||
243 | iDsb->Close(); | ||
244 | iDsb->Create(HwRect(), CDirectScreenBitmap::EDoubleBuffer); | ||
245 | } | ||
246 | |||
247 | ///////////////////////////////////////////////////////////////////////////////////////////////////// | ||
248 | |||
249 | |||
250 | TSize 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 | |||
262 | void CDsa::SetSuspend() | ||
263 | { | ||
264 | iStateFlags |= ESdlThreadSuspend; | ||
265 | } | ||
266 | |||
267 | void CDsa::ReleaseStop() | ||
268 | { | ||
269 | iStateFlags &= ~ESdlThreadExplicitStop; | ||
270 | } | ||
271 | |||
272 | |||
273 | TBool CDsa::Stopped() const | ||
274 | { | ||
275 | return (iStateFlags & ESdlThreadExplicitStop); | ||
276 | } | ||
277 | |||
278 | void 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 | |||
303 | CDsa::~CDsa() | ||
304 | { | ||
305 | if(iDsa != NULL) | ||
306 | { | ||
307 | iDsa->Cancel(); | ||
308 | } | ||
309 | delete iDsa; | ||
310 | User::Free(iLut256); | ||
311 | } | ||
312 | |||
313 | void 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 | |||
337 | void CDsa::LockPalette(TBool aLock) | ||
338 | { | ||
339 | if(aLock) | ||
340 | iStateFlags |= EPaletteLocked; | ||
341 | else | ||
342 | iStateFlags &= ~EPaletteLocked; | ||
343 | } | ||
344 | TInt 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 | |||
363 | void 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 | |||
393 | CDsa::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 | |||
415 | RWsSession& CDsa::Session() | ||
416 | { | ||
417 | return iSession; | ||
418 | } | ||
419 | |||
420 | |||
421 | |||
422 | TUint8* CDsa::LockHwSurface() | ||
423 | { | ||
424 | if((iStateFlags & EUpdating) == 0) //else frame is skipped | ||
425 | { | ||
426 | return LockSurface(); | ||
427 | } | ||
428 | return NULL; | ||
429 | } | ||
430 | |||
431 | /* | ||
432 | void CDsa::RunL() | ||
433 | { | ||
434 | iStateFlags &= ~EUpdating; | ||
435 | } | ||
436 | |||
437 | |||
438 | void CDsa::DoCancel() | ||
439 | { | ||
440 | iStateFlags &= ~EUpdating; | ||
441 | //nothing can do, just wait? | ||
442 | } | ||
443 | */ | ||
444 | |||
445 | TInt 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 | /* | ||
474 | void 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 | |||
487 | void 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 | |||
509 | TBuf<16> FooName(TInt aFoo) | ||
510 | { | ||
511 | TBuf<16> b; | ||
512 | b.Format(_L("C:\\pic%d.mbm"), aFoo); | ||
513 | return b; | ||
514 | } | ||
515 | */ | ||
516 | void 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 | |||
562 | void CDsa::Wipe() //dont call in drawing | ||
563 | { | ||
564 | if(IsDsaAvailable()) | ||
565 | Wipe(iTargetBpp * iScreenRect.Width() * iScreenRect.Height()); | ||
566 | } | ||
567 | |||
568 | void 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 | |||
596 | inline 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 | /* | ||
610 | int bar = 0; | ||
611 | */ | ||
612 | TBool 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 | |||
659 | CDsa* 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 | |||
674 | void CDsa::CreateZoomerL(const TSize& aSize) | ||
675 | { | ||
676 | iSwSize = aSize; | ||
677 | iStateFlags |= EResizeRequest; | ||
678 | CreateSurfaceL(); | ||
679 | SetTargetRect(); | ||
680 | } | ||
681 | |||
682 | TPoint 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 | |||
707 | void 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 | |||
739 | void CDsa::RecreateL() | ||
740 | { | ||
741 | } | ||
742 | |||
743 | void CDsa::Free() | ||
744 | { | ||
745 | } | ||
746 | |||
747 | void 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 | |||
753 | void CDsa::SetBlitter(MBlitter* aBlitter) | ||
754 | { | ||
755 | iBlitter = aBlitter; | ||
756 | } | ||
757 | |||
758 | void 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 | |||
765 | TInt 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 | |||
774 | TInt 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 | |||
787 | TInt CDsa::RedrawRequest() | ||
788 | { | ||
789 | if(!(iStateFlags & (EUpdating) && (iStateFlags & ERunning))) | ||
790 | { | ||
791 | return ExternalUpdate(); | ||
792 | } | ||
793 | return KErrNotReady; | ||
794 | } | ||
795 | |||
796 | |||
797 | void CDsa::Resume() | ||
798 | { | ||
799 | if(Stopped()) | ||
800 | Restart(RDirectScreenAccess::ETerminateRegion); | ||
801 | } | ||
802 | |||
803 | void CDsa::DoStop() | ||
804 | { | ||
805 | if(IsDsaAvailable()) | ||
806 | iStateFlags |= ESdlThreadExplicitStop; | ||
807 | Stop(); | ||
808 | } | ||
809 | |||
810 | void CDsa::Stop() | ||
811 | { | ||
812 | iStateFlags &= ~ERunning; | ||
813 | // Cancel(); //can be called only from main! | ||
814 | iDsa->Cancel(); | ||
815 | } | ||
816 | |||
817 | void CDsa::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) | ||
818 | { | ||
819 | // iStateFlags |= EChangeNotify; | ||
820 | Stop(); | ||
821 | } | ||
822 | |||
823 | void 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 | /*) | ||
832 | TBool CDsa::ChangeTrigger() | ||
833 | { | ||
834 | const TBool change = iStateFlags & EChangeNotify; | ||
835 | iStateFlags &= ~EChangeNotify; | ||
836 | return change; | ||
837 | } | ||
838 | */ | ||
839 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
840 | |||
841 | void 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 | |||
852 | void 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 | |||
863 | void 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 | |||
876 | void 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 | |||
889 | void CDsa::CopyMem(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) | ||
890 | { | ||
891 | Mem::Copy(aTarget, aSource, aBytes); | ||
892 | } | ||
893 | |||
894 | void 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 | |||
907 | void 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 | |||
919 | void 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 | |||
933 | typedef TRgb (*TRgbFunc) (TInt aValue); | ||
934 | |||
935 | LOCAL_C TRgb rgb16MA(TInt aValue) | ||
936 | { | ||
937 | return TRgb::Color16MA(aValue); | ||
938 | } | ||
939 | |||
940 | NONSHARABLE_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 | }; | ||
946 | template <class T> | ||
947 | NONSHARABLE_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 | |||
958 | template <class T> | ||
959 | void* TRgbCopy<T>::operator new(TUint /*aBytes*/, TAny* aMem) | ||
960 | { | ||
961 | return aMem; | ||
962 | } | ||
963 | |||
964 | template <class T> | ||
965 | TRgbCopy<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 | |||
981 | template <class T> | ||
982 | void 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 | |||
1006 | template <class T> | ||
1007 | void 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 | |||
1032 | typedef TUint64 TStackMem; | ||
1033 | |||
1034 | LOCAL_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 | |||
1053 | void 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 | |||
1059 | void 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 | |||
1065 | void 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 | |||
1071 | void 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 | ||