| 1 | #include "DST_WinList.h" |
|---|
| 2 | #include "DST_Window.h" |
|---|
| 3 | #include "DST_WinManager.h" |
|---|
| 4 | #include "DST_OSDImage.h" |
|---|
| 5 | #include "DST_CommonAPI.h" |
|---|
| 6 | #include "DST_SignalMonitor.h" |
|---|
| 7 | |
|---|
| 8 | static int gWinEventMsgQ = 0; |
|---|
| 9 | static int gWinEventMsgQ_Count = 0; |
|---|
| 10 | |
|---|
| 11 | void DST_CreateBaseSystemWindow(SWinEventMsg event); |
|---|
| 12 | |
|---|
| 13 | void DST_CreateTestOSDWin(SWinEventMsg event); |
|---|
| 14 | void DST_CreateEAWindow(SWinEventMsg event); |
|---|
| 15 | |
|---|
| 16 | void DST_CreateCaptionWin(SWinEventMsg event); |
|---|
| 17 | void DST_CreateSuperImposeWin(SWinEventMsg event); |
|---|
| 18 | // Muon2 Àü¿ë OSD |
|---|
| 19 | void DST_CreateSignalMeterWin(SWinEventMsg event); |
|---|
| 20 | |
|---|
| 21 | #if SUPPORT_CHANNEL_EDIT |
|---|
| 22 | void DST_CreateChannelEditWin(SWinEventMsg event); |
|---|
| 23 | #endif |
|---|
| 24 | |
|---|
| 25 | void DST_CreateLowBatteryWindow(SWinEventMsg event); |
|---|
| 26 | void DST_CreateSplashScreenWindow(SWinEventMsg event); |
|---|
| 27 | |
|---|
| 28 | // Maya Àü¿ë |
|---|
| 29 | void DST_CreateFMWin(SWinEventMsg event); |
|---|
| 30 | void DST_CreateMayaMain(SWinEventMsg event); |
|---|
| 31 | void DST_CreateMayaSub(SWinEventMsg event); |
|---|
| 32 | void DST_CreateSetUpWizard(SWinEventMsg event); |
|---|
| 33 | |
|---|
| 34 | // miru |
|---|
| 35 | void DST_CreateErrorWin(SWinEventMsg event); |
|---|
| 36 | void DST_CreateAudioWindow(SWinEventMsg event); |
|---|
| 37 | void DST_CreateEWSWin(SWinEventMsg event); |
|---|
| 38 | void DST_CreateFactoryResetWin(SWinEventMsg event); |
|---|
| 39 | void DST_CreateFactoryResetAskWin(SWinEventMsg event); |
|---|
| 40 | |
|---|
| 41 | void DST_CreateStationSearchWin(SWinEventMsg event); |
|---|
| 42 | void DST_CreateLowBattery(SWinEventMsg event); |
|---|
| 43 | void DST_CreateSplashWindow(SWinEventMsg event); |
|---|
| 44 | |
|---|
| 45 | void DST_CreateWinPasswordCheck(SWinEventMsg event); |
|---|
| 46 | void DST_CreateWinPasswordChange(SWinEventMsg event); |
|---|
| 47 | void DST_CreateWinPasswordConfirm(SWinEventMsg event); |
|---|
| 48 | void DST_CreateAgeRating(SWinEventMsg event); |
|---|
| 49 | void DST_CreateMainMenu(SWinEventMsg event); |
|---|
| 50 | void DST_CreateMenu2Depth(SWinEventMsg event); |
|---|
| 51 | void DST_CreateMenu3Depth(SWinEventMsg event); |
|---|
| 52 | void DST_CreateMenu4Depth(SWinEventMsg event); |
|---|
| 53 | void DST_CreateVolumeMuteWindow(SWinEventMsg event); |
|---|
| 54 | void DST_CreateDirectTuneWindow(SWinEventMsg event); |
|---|
| 55 | void DST_CreateSignalMeterWindow(SWinEventMsg event); |
|---|
| 56 | void DST_CreateClosedCaptionHotWindow(SWinEventMsg event); |
|---|
| 57 | void DST_CreatePowerDownCautionWin(SWinEventMsg event); |
|---|
| 58 | void DST_CreateRFUpdateWindow(SWinEventMsg event); |
|---|
| 59 | //void DST_CreateDebugSQLWin(SWinEventMsg event); |
|---|
| 60 | //void DST_CreateDebugSQLSubWin(SWinEventMsg event); |
|---|
| 61 | void DST_CreateFactoryWin(SWinEventMsg event); |
|---|
| 62 | void DST_CreateDisplayModeWindow(SWinEventMsg event);; |
|---|
| 63 | void DST_CreateEngineerMenuWin(SWinEventMsg event); |
|---|
| 64 | void DST_CreateFrequencySettingWin(SWinEventMsg event); |
|---|
| 65 | void DST_CreateManualSearchWin(SWinEventMsg event); |
|---|
| 66 | void DST_CreateCC708Win(SWinEventMsg event); |
|---|
| 67 | void DST_CreateOTCDownloadFailResetWin(SWinEventMsg event); |
|---|
| 68 | void DST_CreateOTCDownLoadingWin(SWinEventMsg event); |
|---|
| 69 | void DST_CreateUpdateResetWin(SWinEventMsg event); |
|---|
| 70 | void DST_CreateUpdateWin(SWinEventMsg event); |
|---|
| 71 | void DST_CreateSTBInfo(SWinEventMsg event); |
|---|
| 72 | |
|---|
| 73 | DS_U8 DST_GetKeyCode(); |
|---|
| 74 | void DST_ResetKeyCode(); |
|---|
| 75 | |
|---|
| 76 | // CC¿Í µ¿ÀÏ PlaneÀ» »ç¿ëÇϱâ À§ÇØ Àӽ÷ΠstaticÀ» Ç®¾î³õÀ½ |
|---|
| 77 | // ŽºÅ© ÅëÇÕÈÄ ´Ù½Ã staticÀ¸·Î µ¿ÀÛÇØ¾ß ÇÔ |
|---|
| 78 | |
|---|
| 79 | static void DST_BlockCopy(OSD_PIXEL_T *src, int x, int y, int w, int h) |
|---|
| 80 | { |
|---|
| 81 | static bool bInit = false; |
|---|
| 82 | if (bInit == false) |
|---|
| 83 | { |
|---|
| 84 | DHL_GFX_Open(); |
|---|
| 85 | bInit = true; |
|---|
| 86 | } |
|---|
| 87 | if (src) DHL_GFX_Draw(src,x,y,w,h); |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | // µÎ ¹Ú½ºÀÇ °øÅë ¿µ¿ªÀ» ±¸ÇÑ´Ù. |
|---|
| 91 | static bool MakeCommonRect(DST_RECT A, DST_RECT B, DST_RECT *C) |
|---|
| 92 | { |
|---|
| 93 | C->x= (A.x > B.x) ? A.x : B.x; |
|---|
| 94 | C->y= (A.y > B.y) ? A.y : B.y; |
|---|
| 95 | C->w= (A.x + A.w < B.x + B.w) ? (A.x + A.w - C->x) : (B.x + B.w - C->x); |
|---|
| 96 | C->h= (A.y + A.h < B.y + B.h) ? (A.y + A.h - C->y) : (B.y + B.h - C->y); |
|---|
| 97 | if (C->w <= 0 || C->h <= 0) return false; |
|---|
| 98 | return true; |
|---|
| 99 | } |
|---|
| 100 | static void WinMgrWinCreate(SWinEventMsg event) |
|---|
| 101 | { |
|---|
| 102 | switch (event.data[0]) |
|---|
| 103 | { |
|---|
| 104 | case WIN_ENGINEER_MODE: |
|---|
| 105 | DST_CreateEngineerMenuWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 106 | break; |
|---|
| 107 | |
|---|
| 108 | case WIN_FREQUENCY_SETTING: |
|---|
| 109 | DST_CreateFrequencySettingWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 110 | break; |
|---|
| 111 | |
|---|
| 112 | case WIN_FACTORY_MODE: |
|---|
| 113 | DST_CreateFactoryWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 114 | break; |
|---|
| 115 | |
|---|
| 116 | case WIN_DEBUG_SQL_SUB: |
|---|
| 117 | DST_CreateDebugSQLSubWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 118 | break; |
|---|
| 119 | |
|---|
| 120 | case WIN_DEBUG_SQL: |
|---|
| 121 | DST_CreateDebugSQLWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 122 | break; |
|---|
| 123 | |
|---|
| 124 | case WIN_RF_UPDATE: |
|---|
| 125 | DST_CreateRFUpdateWindow(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 126 | break; |
|---|
| 127 | |
|---|
| 128 | case WIN_CLOSED_CAPTION_HOT: |
|---|
| 129 | DST_CreateClosedCaptionHotWindow(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 130 | break; |
|---|
| 131 | |
|---|
| 132 | case WIN_SIGNAL_METER: |
|---|
| 133 | DST_CreateSignalMeterWindow(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 134 | break; |
|---|
| 135 | |
|---|
| 136 | case WIN_MAIN_MENU: |
|---|
| 137 | DST_CreateMainMenu(event); |
|---|
| 138 | break; |
|---|
| 139 | |
|---|
| 140 | case WIN_POWER_DOWN_CAUTION: |
|---|
| 141 | DST_CreatePowerDownCautionWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 142 | break; |
|---|
| 143 | |
|---|
| 144 | case WIN_OTC_DOWNLOAD: |
|---|
| 145 | DST_CreateOTCDownLoadingWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 146 | break; |
|---|
| 147 | |
|---|
| 148 | case WIN_OTC_DOWNLOAD_FAIL: |
|---|
| 149 | DST_CreateOTCDownloadFailResetWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 150 | break; |
|---|
| 151 | |
|---|
| 152 | case WIN_UPDATE: |
|---|
| 153 | DST_CreateUpdateWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 154 | break; |
|---|
| 155 | case WIN_UPDATE_RESET: |
|---|
| 156 | DST_CreateUpdateResetWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 157 | break; |
|---|
| 158 | |
|---|
| 159 | case WIN_BASIC: |
|---|
| 160 | DST_CreateBaseSystemWindow(event); |
|---|
| 161 | break; |
|---|
| 162 | |
|---|
| 163 | case WIN_AUTO_SEARCH: |
|---|
| 164 | DST_CreateAutoSearchWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 165 | break; |
|---|
| 166 | |
|---|
| 167 | case WIN_MANUAL_SEARCH: |
|---|
| 168 | DST_CreateManualSearchWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 169 | break; |
|---|
| 170 | |
|---|
| 171 | #if EPG_SUPPORT |
|---|
| 172 | case WIN_PROGRAM_GUIDE: |
|---|
| 173 | DST_CreateProgramGuideWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 174 | break; |
|---|
| 175 | #endif |
|---|
| 176 | |
|---|
| 177 | #if SUPPORT_CHANNEL_EDIT |
|---|
| 178 | case WIN_CHANNEL_LIST: |
|---|
| 179 | DST_CreateChannelEditWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 180 | break; |
|---|
| 181 | #endif |
|---|
| 182 | |
|---|
| 183 | case WIN_CHANNEL_BANNER: |
|---|
| 184 | DST_CreateChannelBannerWindow(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 185 | break; |
|---|
| 186 | |
|---|
| 187 | case WIN_DIRECT_TUNE: |
|---|
| 188 | DST_CreateDirectTuneWindow(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 189 | break; |
|---|
| 190 | |
|---|
| 191 | case WIN_INFOR_BANNER: |
|---|
| 192 | DST_CreateInforbannerWindow(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 193 | break; |
|---|
| 194 | |
|---|
| 195 | case WIN_FACTORY_RESET: |
|---|
| 196 | DST_CreateFactoryResetWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 197 | break; |
|---|
| 198 | |
|---|
| 199 | case WIN_FACTORY_RESET_ASK: |
|---|
| 200 | DST_CreateFactoryResetAskWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 201 | break; |
|---|
| 202 | |
|---|
| 203 | case WIN_VOLUME: |
|---|
| 204 | DST_CreateVolumeWindow(event); |
|---|
| 205 | break; |
|---|
| 206 | |
|---|
| 207 | case WIN_VOLUME_MUTE: |
|---|
| 208 | DST_CreateVolumeMuteWindow(event); |
|---|
| 209 | break; |
|---|
| 210 | |
|---|
| 211 | case WIN_AUDIO_HOT: |
|---|
| 212 | DST_CreateAudioWindow(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 213 | break; |
|---|
| 214 | |
|---|
| 215 | case WIN_DISPLAY_MODE_HOT: |
|---|
| 216 | DST_CreateDisplayModeWindow(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 217 | break; |
|---|
| 218 | |
|---|
| 219 | case WIN_CAPTION: |
|---|
| 220 | DST_CreateCC708Win(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 221 | break; |
|---|
| 222 | |
|---|
| 223 | case WIN_ERROR: |
|---|
| 224 | DST_CreateErrorWin(event); // C ¾ð¾î Æ÷ÆÃ ÇÊ¿ä |
|---|
| 225 | break; |
|---|
| 226 | |
|---|
| 227 | case WIN_STB_INFO: |
|---|
| 228 | DST_CreateSTBInfo(event); |
|---|
| 229 | break; |
|---|
| 230 | |
|---|
| 231 | } |
|---|
| 232 | } |
|---|
| 233 | |
|---|
| 234 | static void WinMgrKeyProcess() |
|---|
| 235 | { |
|---|
| 236 | static CWindow *pPrevWin = 0; |
|---|
| 237 | static DS_U8 ucPrevKey = 0; |
|---|
| 238 | static DS_U32 nPrevKeyTime = 0; |
|---|
| 239 | static bool bRepeat = false; |
|---|
| 240 | DS_U8 nKeyCode = DST_GetKeyCode(); |
|---|
| 241 | |
|---|
| 242 | if (nKeyCode == 0) //۰¡ ¸±¸®Áî µÇ¸é 0ÀÌ µÈ´Ù. |
|---|
| 243 | { |
|---|
| 244 | pPrevWin = 0; |
|---|
| 245 | ucPrevKey = 0; |
|---|
| 246 | nPrevKeyTime = 0; |
|---|
| 247 | bRepeat = false; |
|---|
| 248 | return; |
|---|
| 249 | } |
|---|
| 250 | int i; |
|---|
| 251 | for ( i = 1; i < WIN_ID_MAX; i++) |
|---|
| 252 | { |
|---|
| 253 | CWindow *pWin = DST_GetWin((WinID)i); |
|---|
| 254 | if (pWin == 0) continue; |
|---|
| 255 | if (pWin->IsRegisterKey(pWin, nKeyCode) == false) continue; |
|---|
| 256 | pWin->ResetTimer(pWin, 0); |
|---|
| 257 | // Repeat ۰¡ ¾Æ´Ñ ۵é |
|---|
| 258 | if (pWin->GetKeyDelay(pWin, nKeyCode)==0 || pWin->GetKeyRepeat(pWin, nKeyCode)==0) |
|---|
| 259 | { |
|---|
| 260 | DST_ResetKeyCode(); |
|---|
| 261 | pWin->KeyInput(pWin, nKeyCode, false); |
|---|
| 262 | nKeyCode = 0; |
|---|
| 263 | break; |
|---|
| 264 | } |
|---|
| 265 | // Repeat ŰÀÇ Ã³À½ µ¿ÀÛ ½ÇÇà |
|---|
| 266 | if (pPrevWin != pWin || ucPrevKey != nKeyCode) |
|---|
| 267 | { |
|---|
| 268 | pWin->KeyInput(pWin, nKeyCode, false); |
|---|
| 269 | pPrevWin = pWin; |
|---|
| 270 | ucPrevKey = nKeyCode; |
|---|
| 271 | nPrevKeyTime = DST_OS_GetTickCount(); |
|---|
| 272 | bRepeat = false; |
|---|
| 273 | break; |
|---|
| 274 | } |
|---|
| 275 | if (bRepeat == false) |
|---|
| 276 | { |
|---|
| 277 | // Repeat ŰÀÇ µÎ¹øÂ° µ¿ÀÛ ½ÇÇà |
|---|
| 278 | if (nPrevKeyTime > DST_OS_GetTickCount()) nPrevKeyTime = DST_OS_GetTickCount(); |
|---|
| 279 | if (DST_OS_GetTickCount() - nPrevKeyTime < pWin->GetKeyDelay(pWin, nKeyCode)) break; |
|---|
| 280 | pWin->KeyInput(pWin, nKeyCode, true); |
|---|
| 281 | nPrevKeyTime = DST_OS_GetTickCount(); |
|---|
| 282 | bRepeat = true; |
|---|
| 283 | } |
|---|
| 284 | else |
|---|
| 285 | { |
|---|
| 286 | // Repeat ŰÀÇ ¼¼¹øÂ° ºÎÅÍ µ¿ÀÛ ½ÇÇà |
|---|
| 287 | if (nPrevKeyTime > DST_OS_GetTickCount()) nPrevKeyTime = DST_OS_GetTickCount(); |
|---|
| 288 | if (DST_OS_GetTickCount() - nPrevKeyTime < pWin->GetKeyRepeat(pWin, nKeyCode)) break; |
|---|
| 289 | nPrevKeyTime = DST_OS_GetTickCount(); |
|---|
| 290 | pWin->KeyInput(pWin, nKeyCode, true); |
|---|
| 291 | } |
|---|
| 292 | break; |
|---|
| 293 | } |
|---|
| 294 | } |
|---|
| 295 | |
|---|
| 296 | static void WinMgrMessageProcess(SWinEventMsg event) |
|---|
| 297 | { |
|---|
| 298 | switch (event.cmd) |
|---|
| 299 | { |
|---|
| 300 | case WM_WIN_CREATE: |
|---|
| 301 | WinMgrWinCreate(event); |
|---|
| 302 | break; |
|---|
| 303 | |
|---|
| 304 | case WM_WIN_DELETE: |
|---|
| 305 | { |
|---|
| 306 | CWindow *pWin = DST_GetWin((WinID)event.data[0]); |
|---|
| 307 | if (pWin) pWin->Close(pWin); |
|---|
| 308 | } |
|---|
| 309 | break; |
|---|
| 310 | |
|---|
| 311 | default: |
|---|
| 312 | { |
|---|
| 313 | int i; |
|---|
| 314 | for ( i= 1; i < WIN_ID_MAX; i++) |
|---|
| 315 | { |
|---|
| 316 | CWindow *pWin = DST_GetWin((WinID)i); |
|---|
| 317 | if (pWin) pWin->DoOnMessage(pWin, event); |
|---|
| 318 | } |
|---|
| 319 | } |
|---|
| 320 | break; |
|---|
| 321 | } |
|---|
| 322 | } |
|---|
| 323 | static bool WinMgrSub() |
|---|
| 324 | { |
|---|
| 325 | SWinEventMsg event; |
|---|
| 326 | DS_U32 retLen; |
|---|
| 327 | DST_OS_Delay(10); |
|---|
| 328 | if (DST_OS_ReceiveMessage_NoWait(gWinEventMsgQ, (DS_U32*)&event, sizeof(SWinEventMsg), &retLen) == noError) // ¸Þ½ÃÁö¸¦ ¹ÞÀº °æ¿ì ¸Þ½ÃÁö ó¸® |
|---|
| 329 | { |
|---|
| 330 | gWinEventMsgQ_Count--; |
|---|
| 331 | if (event.cmd == WM_MANAGER_CLOSE) return false; |
|---|
| 332 | WinMgrMessageProcess(event); |
|---|
| 333 | } |
|---|
| 334 | WinMgrKeyProcess(); |
|---|
| 335 | |
|---|
| 336 | int i; |
|---|
| 337 | for ( i= 1; i < WIN_ID_MAX; i++) |
|---|
| 338 | { |
|---|
| 339 | CWindow *pWin = DST_GetWin((WinID)i); |
|---|
| 340 | if (pWin == 0) continue; |
|---|
| 341 | switch (pWin->GetState(pWin)) |
|---|
| 342 | { |
|---|
| 343 | case 0: // Before Create |
|---|
| 344 | { |
|---|
| 345 | pWin->DoShow(pWin); |
|---|
| 346 | pWin->SetState(pWin, 1); |
|---|
| 347 | int j; |
|---|
| 348 | for ( j= 1; j < WIN_ID_MAX; j++) |
|---|
| 349 | { |
|---|
| 350 | CWindow *pWin1 = DST_GetWin((WinID)j); |
|---|
| 351 | if (pWin1) pWin1->ShowWindow(pWin1, (WinID)i); |
|---|
| 352 | } |
|---|
| 353 | } |
|---|
| 354 | break; |
|---|
| 355 | |
|---|
| 356 | case 2: // Before Close |
|---|
| 357 | { |
|---|
| 358 | pWin->UpdateScreen(pWin); |
|---|
| 359 | int j; |
|---|
| 360 | for ( j= 1; j < WIN_ID_MAX; j++) |
|---|
| 361 | { |
|---|
| 362 | CWindow *pWin1 = DST_GetWin((WinID)j); |
|---|
| 363 | if (pWin1) pWin1->Hide(pWin1, (WinID)i); |
|---|
| 364 | } |
|---|
| 365 | DST_RemoveWin((WinID)i); |
|---|
| 366 | } |
|---|
| 367 | break; |
|---|
| 368 | } |
|---|
| 369 | } |
|---|
| 370 | // ŸÀÌ¸Ó Ã³¸® |
|---|
| 371 | for ( i= 1; i < WIN_ID_MAX; i++) |
|---|
| 372 | { |
|---|
| 373 | CWindow *pWin = DST_GetWin((WinID)i); |
|---|
| 374 | if (pWin == 0) continue; |
|---|
| 375 | // ŸÀÌ¸Ó Ã³¸®¿Í ±×¸®±âÀÇ µ¿±âÈ? |
|---|
| 376 | if (pWin->ProcessTimer(pWin) == true) continue; |
|---|
| 377 | } |
|---|
| 378 | |
|---|
| 379 | DST_RECT rectTemp = DST_GetUpdateRegion(); |
|---|
| 380 | if (rectTemp.w != 0 && rectTemp.h != 0) |
|---|
| 381 | { |
|---|
| 382 | #if 1 |
|---|
| 383 | static int imgBuffSize = 0; |
|---|
| 384 | static OSD_PIXEL_T *imgBuff = 0; |
|---|
| 385 | if (rectTemp.w * rectTemp.h > imgBuffSize) |
|---|
| 386 | { |
|---|
| 387 | DST_OS_Free(&imgBuff); |
|---|
| 388 | imgBuffSize = rectTemp.w * rectTemp.h; |
|---|
| 389 | imgBuff = (OSD_PIXEL_T*)DST_OS_Malloc(imgBuffSize*sizeof(OSD_PIXEL_T)); |
|---|
| 390 | } |
|---|
| 391 | memset(imgBuff,0, rectTemp.w * rectTemp.h*sizeof(OSD_PIXEL_T)); |
|---|
| 392 | #else |
|---|
| 393 | static OSD_PIXEL_T imgBuff[720 * 480]; |
|---|
| 394 | memset(imgBuff,0, 720 * 480*sizeof(OSD_PIXEL_T)); |
|---|
| 395 | #endif |
|---|
| 396 | int i; |
|---|
| 397 | for ( i= WIN_ID_MAX - 2; i >=0 ; i--) |
|---|
| 398 | { |
|---|
| 399 | CWindow *pWin = DST_GetWin((WinID)i); |
|---|
| 400 | if (pWin== 0) continue; |
|---|
| 401 | if (pWin->GetVisible(pWin) == false) continue; |
|---|
| 402 | OSD_PIXEL_T *srcBuff = pWin->GetImgBuff(pWin); |
|---|
| 403 | if (srcBuff == 0) continue; |
|---|
| 404 | DST_RECT rectCommon; |
|---|
| 405 | DST_RECT rectSrc = pWin->GetSize(pWin); |
|---|
| 406 | if (MakeCommonRect(rectTemp, rectSrc, &rectCommon ) == false) continue; |
|---|
| 407 | int srcStartX = rectCommon.x - rectSrc.x; |
|---|
| 408 | if (srcStartX < 0) srcStartX = 0; |
|---|
| 409 | int srcStartY = rectCommon.y - rectSrc.y; |
|---|
| 410 | if (srcStartY < 0) srcStartY = 0; |
|---|
| 411 | int desStartX = rectCommon.x - rectTemp.x; |
|---|
| 412 | if (desStartX < 0) desStartX = 0; |
|---|
| 413 | int desStartY = rectCommon.y - rectTemp.y; |
|---|
| 414 | if (desStartY < 0) desStartY = 0; |
|---|
| 415 | |
|---|
| 416 | OSD_PIXEL_T *des = imgBuff + desStartY * rectTemp.w + desStartX; |
|---|
| 417 | OSD_PIXEL_T *src = srcBuff + srcStartY * rectSrc.w + srcStartX; |
|---|
| 418 | if (pWin->GetTransparent(pWin)) |
|---|
| 419 | { |
|---|
| 420 | int y; |
|---|
| 421 | for ( y = 0; y < rectCommon.h; y++) |
|---|
| 422 | { |
|---|
| 423 | OSD_PIXEL_T* des1 = des; |
|---|
| 424 | OSD_PIXEL_T* src1 = src; |
|---|
| 425 | int x; |
|---|
| 426 | for ( x = 0; x < rectCommon.w; x++) |
|---|
| 427 | { |
|---|
| 428 | OSD_PIXEL_T max = (sizeof(OSD_PIXEL_T) == 2) ? 0x0F : 0xFF; |
|---|
| 429 | OSD_PIXEL_T sa,sr,sg,sb; |
|---|
| 430 | DST_GetColor(*src1, &sa, &sr, &sg, &sb); |
|---|
| 431 | OSD_PIXEL_T da,dr,dg,db; |
|---|
| 432 | DST_GetColor(*des1, &da, &dr, &dg, &db); |
|---|
| 433 | if (sa != 0) // Åõ¸íÀÌ ¾Æ´Ñ °æ¿ì¸¸ ±×¸°´Ù. |
|---|
| 434 | { |
|---|
| 435 | if (sa == max || da == 0) // ¼Ò½º°¡ ¿ÏÀüºÒÅõ¸íÀ̰ųª ¹è°æÀÌ Åõ¸íÀΰæ¿ì |
|---|
| 436 | { |
|---|
| 437 | *des1 = *src1; |
|---|
| 438 | } |
|---|
| 439 | else // ¹ÝÅõ¸í |
|---|
| 440 | { |
|---|
| 441 | // http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending |
|---|
| 442 | OSD_PIXEL_T t = (da * (max-sa) + (max/2)) / max; |
|---|
| 443 | OSD_PIXEL_T a = sa + t; |
|---|
| 444 | if (a > max) a = max; |
|---|
| 445 | OSD_PIXEL_T r = ((sr * sa + dr * t) + (a/2)) / a; |
|---|
| 446 | OSD_PIXEL_T g = ((sg * sa + dg * t) + (a/2)) / a; |
|---|
| 447 | OSD_PIXEL_T b = ((sb * sa + db * t) + (a/2)) / a; |
|---|
| 448 | *des1 = DST_SetColor(a, r, g, b); |
|---|
| 449 | } |
|---|
| 450 | } |
|---|
| 451 | des1++; |
|---|
| 452 | src1++; |
|---|
| 453 | } |
|---|
| 454 | des += rectTemp.w; |
|---|
| 455 | src += rectSrc.w; |
|---|
| 456 | } |
|---|
| 457 | } |
|---|
| 458 | else |
|---|
| 459 | { |
|---|
| 460 | int yy = rectCommon.h; |
|---|
| 461 | int nDataLength = rectCommon.w*sizeof(OSD_PIXEL_T); |
|---|
| 462 | if (rectTemp.w == rectSrc.w) |
|---|
| 463 | { |
|---|
| 464 | memcpy(des, src, nDataLength * yy); |
|---|
| 465 | } |
|---|
| 466 | else |
|---|
| 467 | { |
|---|
| 468 | while (yy--) |
|---|
| 469 | { |
|---|
| 470 | memcpy(des, src, nDataLength); |
|---|
| 471 | des += rectTemp.w; |
|---|
| 472 | src += rectSrc.w; |
|---|
| 473 | } |
|---|
| 474 | } |
|---|
| 475 | } |
|---|
| 476 | } |
|---|
| 477 | DST_BlockCopy(imgBuff, rectTemp.x, rectTemp.y, rectTemp.w, rectTemp.h); |
|---|
| 478 | DST_ResetUpdateRegion(); |
|---|
| 479 | } |
|---|
| 480 | return true; |
|---|
| 481 | } |
|---|
| 482 | |
|---|
| 483 | |
|---|
| 484 | bool bWinManagerReady = false; |
|---|
| 485 | int DST_IsWinManagerReady(void) |
|---|
| 486 | { |
|---|
| 487 | return (bWinManagerReady == true) ? 1 : 0; |
|---|
| 488 | } |
|---|
| 489 | |
|---|
| 490 | static void tWinMgr() |
|---|
| 491 | { |
|---|
| 492 | T(); |
|---|
| 493 | OSD_PIXEL_T tmp=0; |
|---|
| 494 | DST_BlockCopy(&tmp, 0,0,1,1); |
|---|
| 495 | DST_CreateWin(WIN_BASIC, WIN_NULL, 0,0,0,0); |
|---|
| 496 | bWinManagerReady = true; |
|---|
| 497 | while (1) WinMgrSub(); |
|---|
| 498 | } |
|---|
| 499 | |
|---|
| 500 | // À©µµ¿ì ¸Å´ÏÀú µð¹ö±× ÇÔ¼ö |
|---|
| 501 | static void PrintWindowMsg(SWinEventMsg event) |
|---|
| 502 | { |
|---|
| 503 | #if 0 |
|---|
| 504 | switch (event.cmd) |
|---|
| 505 | { |
|---|
| 506 | case WM_WIN_CREATE: DST_Printf("WM_WIN_CREATE\n"); break; |
|---|
| 507 | case WM_WIN_DELETE: DST_Printf("WM_WIN_DELETE\n"); break; |
|---|
| 508 | case WM_POWER_DOWN_ENTER: DST_Printf("WM_POWER_DOWN_ENTER\n"); break; |
|---|
| 509 | case WM_SOURCE_FORMAT_DONE: DST_Printf("WM_SOURCE_FORMAT_DONE\n"); break; |
|---|
| 510 | case WM_MANAGER_CLOSE: DST_Printf("WM_MANAGER_CLOSE\n"); break; |
|---|
| 511 | case WM_SIGNAL_STATE: DST_Printf("WM_SIGNAL_STATE\n"); break; |
|---|
| 512 | case WM_MTS_UPDATE: DST_Printf("WM_MTS_UPDATE\n"); break; |
|---|
| 513 | case WM_MENU_LANGUAGE_CHANGE: DST_Printf("WM_MENU_LANGUAGE_CHANGE\n"); break; |
|---|
| 514 | case WM_CT_MSG: DST_Printf("WM_CT_MSG\n"); break; |
|---|
| 515 | case WM_FACTORY_KEYPAD: DST_Printf("WM_FACTORY_KEYPAD\n"); break; |
|---|
| 516 | } |
|---|
| 517 | #endif |
|---|
| 518 | } |
|---|
| 519 | |
|---|
| 520 | void DST_SendWindowEventWithOnlyCmd(int command) |
|---|
| 521 | { |
|---|
| 522 | SWinEventMsg event; |
|---|
| 523 | memset(&event, 0, sizeof(SWinEventMsg)); |
|---|
| 524 | event.cmd=command; |
|---|
| 525 | DST_SendWindowEvent(event); |
|---|
| 526 | } |
|---|
| 527 | |
|---|
| 528 | void DST_SendWindowEvent(SWinEventMsg event) |
|---|
| 529 | { |
|---|
| 530 | if (!gWinEventMsgQ) return; |
|---|
| 531 | PrintWindowMsg(event); |
|---|
| 532 | //DST_Printf("event.cmd = %d %d\n", event.cmd, event.data32[0]); |
|---|
| 533 | if (gWinEventMsgQ_Count > 100) |
|---|
| 534 | { |
|---|
| 535 | DST_Printf("gWinEventMsgQ_Count = %d\n", gWinEventMsgQ_Count); |
|---|
| 536 | return; |
|---|
| 537 | } |
|---|
| 538 | gWinEventMsgQ_Count++; |
|---|
| 539 | |
|---|
| 540 | #if 0 |
|---|
| 541 | if (gWinEventMsgQ_Count > 100) |
|---|
| 542 | { |
|---|
| 543 | DST_Printf("DST_SendWindowEvent - event.cmd = %ld gWinEventMsg Q_Count = %d\n", event.cmd, gWinEventMsgQ_Count); |
|---|
| 544 | DST_Reset((char*)__func__); |
|---|
| 545 | } |
|---|
| 546 | #endif |
|---|
| 547 | |
|---|
| 548 | DST_OS_SendMessage(gWinEventMsgQ, (DS_U32 *)&event, sizeof(SWinEventMsg)); |
|---|
| 549 | } |
|---|
| 550 | |
|---|
| 551 | void DST_CreateWin(WinID nID, WinID nParentID, unsigned char nParameter1 , unsigned char nParameter2, unsigned char nParameter3, unsigned char nParameter4) |
|---|
| 552 | { |
|---|
| 553 | if (nID == WIN_NULL) return; |
|---|
| 554 | SWinEventMsg event; |
|---|
| 555 | memset(&event, 0, sizeof(SWinEventMsg)); |
|---|
| 556 | event.cmd = WM_WIN_CREATE; |
|---|
| 557 | event.data[0] = nID; |
|---|
| 558 | event.data[1] = nParentID; |
|---|
| 559 | event.data[2] = nParameter1; |
|---|
| 560 | event.data[3] = nParameter2; |
|---|
| 561 | event.data[4] = nParameter3; |
|---|
| 562 | event.data[5] = nParameter4; |
|---|
| 563 | DST_SendWindowEvent(event); |
|---|
| 564 | } |
|---|
| 565 | |
|---|
| 566 | void DST_CreateWin2(WinID nID, WinID nParentID, unsigned long nParameter1) |
|---|
| 567 | { |
|---|
| 568 | SWinEventMsg event; |
|---|
| 569 | memset(&event, 0, sizeof(SWinEventMsg)); |
|---|
| 570 | event.cmd = WM_WIN_CREATE; |
|---|
| 571 | event.data[0] = nID; |
|---|
| 572 | event.data[1] = nParentID; |
|---|
| 573 | event.data32[1] = nParameter1; |
|---|
| 574 | DST_SendWindowEvent(event); |
|---|
| 575 | } |
|---|
| 576 | |
|---|
| 577 | void DST_CloseWin(WinID nID) |
|---|
| 578 | { |
|---|
| 579 | SWinEventMsg event; |
|---|
| 580 | memset(&event, 0, sizeof(SWinEventMsg)); |
|---|
| 581 | event.cmd = WM_WIN_DELETE; |
|---|
| 582 | event.data[0] = nID; |
|---|
| 583 | DST_SendWindowEvent(event); |
|---|
| 584 | } |
|---|
| 585 | |
|---|
| 586 | void DST_WinManagerInit(void) |
|---|
| 587 | { |
|---|
| 588 | static int WinMngTaskID = 0; |
|---|
| 589 | if (WinMngTaskID != 0) return; |
|---|
| 590 | DST_RemoveAllWindows(); |
|---|
| 591 | DST_ResetUpdateRegion(); |
|---|
| 592 | gWinEventMsgQ = DST_OS_CreateMessageQueue("gWinEventMsgQ", 0/*OS_MSGQ_FIFO*/, 300/*100*/, sizeof(SWinEventMsg)); |
|---|
| 593 | WinMngTaskID = DST_OS_SpawnTask((void(*)(void *))tWinMgr, (char*)"tWinMgr", APP_TASK_PRIO_WIN_MGR, WIN_MGR_TASK_STACKSIZE, 0); |
|---|
| 594 | T(); |
|---|
| 595 | } |
|---|