From 6039eb05ba6d82ef56f2868c96654c552d117bf9 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Wed, 7 Feb 2018 20:04:46 -0500 Subject: sdl: remove non-rockbox drivers We never use any of these other drivers, so having them around just takes up space. Change-Id: Iced812162df1fef3fd55522b7e700acb6c3bcd41 --- .../sdl/src/video/symbian/EKA2/SDL_epocevents.cpp | 521 ------- .../sdl/src/video/symbian/EKA2/SDL_epocvideo.cpp | 594 -------- .../sdl/src/video/symbian/EKA2/SDL_epocvideo.h | 51 - apps/plugins/sdl/src/video/symbian/EKA2/dsa.cpp | 1505 -------------------- .../plugins/sdl/src/video/symbian/EKA2/dsa_new.cpp | 1443 ------------------- .../plugins/sdl/src/video/symbian/EKA2/dsa_old.cpp | 1075 -------------- 6 files changed, 5189 deletions(-) delete mode 100644 apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocevents.cpp delete mode 100644 apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocvideo.cpp delete mode 100644 apps/plugins/sdl/src/video/symbian/EKA2/SDL_epocvideo.h delete mode 100644 apps/plugins/sdl/src/video/symbian/EKA2/dsa.cpp delete mode 100644 apps/plugins/sdl/src/video/symbian/EKA2/dsa_new.cpp delete mode 100644 apps/plugins/sdl/src/video/symbian/EKA2/dsa_old.cpp (limited to 'apps/plugins/sdl/src/video/symbian/EKA2') 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 @@ -#include "epoc_sdl.h" - -#include -#undef NULL -extern "C" { -//#define DEBUG_TRACE_ENABLED -#include "SDL_error.h" -#include "SDL_video.h" -#include "SDL_keysym.h" -#include "SDL_keyboard.h" -#include "SDL_events_c.h" -#include "SDL_timer.h" -} /* extern "C" */ - -#include "SDL_epocvideo.h" -#include "SDL_epocevents_c.h" - -#include "sdlepocapi.h" - -#include - -#include - - -extern "C" - { - static SDL_keysym *TranslateKey(_THIS, int scancode, SDL_keysym *keysym); - } - -//extern "C" { -/* The translation tables from a console scancode to a SDL keysym */ -static SDLKey keymap[MAX_SCANCODE]; -static SDL_keysym *TranslateKey(_THIS, int scancode, SDL_keysym *keysym); -void DisableKeyBlocking(_THIS); -//} /* extern "C" */ - -SDLKey* KeyMap() - { - return keymap; - } - -TBool isCursorVisible = EFalse; - -void ResetKeyMap() - { - int i; - - /* Initialize the key translation table */ - for ( i=0; i array; - TRAPD(err, ReadL(fs, array)); - if(err == KErrNone && array.Count() > 0) - { - - SDLKey temp[MAX_SCANCODE]; - Mem::Copy(temp, keymap, MAX_SCANCODE * sizeof(SDLKey)); - - for(TInt k = 0; k < array.Count(); k+= 2) - { - const TInt oldval = array[k]; - const TInt newval = array[k + 1]; - if(oldval >= 0 && oldval < MAX_SCANCODE && newval >= 0 && newval < MAX_SCANCODE) - { - keymap[oldval] = temp[newval]; - } - } - } - array.Close(); - } - - fs.Close();*/ - /////////////////////////////////////////////////////////// - - - keymap[EStdKeyNumLock] = SDLK_NUMLOCK; - keymap[EStdKeyScrollLock] = SDLK_SCROLLOCK; - - keymap[EStdKeyNkpForwardSlash] = SDLK_KP_DIVIDE; - keymap[EStdKeyNkpAsterisk] = SDLK_KP_MULTIPLY; - keymap[EStdKeyNkpMinus] = SDLK_KP_MINUS; - keymap[EStdKeyNkpPlus] = SDLK_KP_PLUS; - keymap[EStdKeyNkpEnter] = SDLK_KP_ENTER; - keymap[EStdKeyNkp1] = SDLK_KP1; - keymap[EStdKeyNkp2] = SDLK_KP2; - keymap[EStdKeyNkp3] = SDLK_KP3; - keymap[EStdKeyNkp4] = SDLK_KP4; - keymap[EStdKeyNkp5] = SDLK_KP5; - keymap[EStdKeyNkp6] = SDLK_KP6; - keymap[EStdKeyNkp7] = SDLK_KP7; - keymap[EStdKeyNkp8] = SDLK_KP8; - keymap[EStdKeyNkp9] = SDLK_KP9; - keymap[EStdKeyNkp0] = SDLK_KP0; - keymap[EStdKeyNkpFullStop] = SDLK_KP_PERIOD; - /* - keymap[EStdKeyMenu] = SDLK_MENU; should be, but not yet - keymap[EStdKeyBacklightOn] = - keymap[EStdKeyBacklightOff] = - keymap[EStdKeyBacklightToggle] = - keymap[EStdKeyIncContrast] = - keymap[EStdKeyDecContrast] = - keymap[EStdKeySliderDown] = - keymap[EStdKeySliderUp] = - keymap[EStdKeyDictaphonePlay] = - keymap[EStdKeyDictaphoneStop] = - keymap[EStdKeyDictaphoneRecord] = - keymap[EStdKeyHelp] = - keymap[EStdKeyOff] = - keymap[EStdKeyDial] = - keymap[EStdKeyIncVolume] = - keymap[EStdKeyDecVolume] = - keymap[EStdKeyDevice0] = - keymap[EStdKeyDevice1] = - keymap[EStdKeyDevice2] = - keymap[EStdKeyDevice3] = - keymap[EStdKeyDevice4] = - keymap[EStdKeyDevice5] = - keymap[EStdKeyDevice6] = - keymap[EStdKeyDevice7] = - keymap[EStdKeyDevice8] = - keymap[EStdKeyDevice9] = - keymap[EStdKeyDeviceA] = - keymap[EStdKeyDeviceB] = - keymap[EStdKeyDeviceC] = - keymap[EStdKeyDeviceD] = - keymap[EStdKeyDeviceE] = - keymap[EStdKeyDeviceF] = - keymap[EStdKeyApplication0] = - keymap[EStdKeyApplication1] = - keymap[EStdKeyApplication2] = - keymap[EStdKeyApplication3] = - keymap[EStdKeyApplication4] = - keymap[EStdKeyApplication5] = - keymap[EStdKeyApplication6] = - keymap[EStdKeyApplication7] = - keymap[EStdKeyApplication8] = - keymap[EStdKeyApplication9] = - keymap[EStdKeyApplicationA] = - keymap[EStdKeyApplicationB] = - keymap[EStdKeyApplicationC] = - keymap[EStdKeyApplicationD] = - keymap[EStdKeyApplicationE] = - keymap[EStdKeyApplicationF] = - keymap[EStdKeyYes] = - keymap[EStdKeyNo] = - keymap[EStdKeyIncBrightness] = - keymap[EStdKeyDecBrightness] = - keymap[EStdKeyCaseOpen] = - keymap[EStdKeyCaseClose] = */ - - - -} - - -int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent) -{ - int posted = 0; - SDL_keysym keysym; - -// SDL_TRACE1("hws %d", aWsEvent.Type()); - - switch (aWsEvent.Type()) - { - case EEventPointer: /* Mouse pointer events */ - { -/* const TPointerCursorMode mode = EpocSdlEnv::PointerMode(); - - - if(mode == EPointerCursorNone) - { - return 0; //TODO: Find out why events are get despite of cursor should be off - } -*/ - const TPointerEvent* pointerEvent = aWsEvent.Pointer(); - const TPoint mousePos = EpocSdlEnv::WindowCoordinates(pointerEvent->iPosition); - - /*!! TODO Pointer do not yet work properly - //SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!! - - if (Private->EPOC_ShrinkedHeight) { - mousePos.iY <<= 1; // Scale y coordinate to shrinked screen height - } - if (Private->EPOC_ShrinkedWidth) { - mousePos.iX <<= 1; // Scale x coordinate to shrinked screen width - } - */ - - posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */ - - switch (pointerEvent->iType) - { - case TPointerEvent::EButton1Down: - posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); - break; - case TPointerEvent::EButton1Up: - posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); - break; - case TPointerEvent::EButton2Down: - posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0); - break; - case TPointerEvent::EButton2Up: - posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); - break; - case TPointerEvent::EButton3Down: - posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0); - break; - case TPointerEvent::EButton3Up: - posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); - break; - } // switch - break; - } - - case EEventKeyDown: /* Key events */ - { -#ifdef SYMBIAN_CRYSTAL - // special case: 9300/9500 rocker down, simulate left mouse button - if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA) - { - const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode(); - if(mode != EPointerCursorNone) - posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); - } -#endif - (void*)TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym); - -#ifndef DISABLE_JOYSTICK - /* Special handling */ - switch((int)keysym.sym) { - case SDLK_CAPSLOCK: - if (!isCursorVisible) { - /* Enable virtual cursor */ - HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible); - } - else { - /* Disable virtual cursor */ - HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible); - } - isCursorVisible = !isCursorVisible; - break; - } -#endif - posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym); - break; - } - - case EEventKeyUp: /* Key events */ - { -#ifdef SYMBIAN_CRYSTAL - // special case: 9300/9500 rocker up, simulate left mouse button - if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA) - { - posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); - } -#endif - posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym)); - break; - } - - case EEventFocusGained: /* SDL window got focus */ - { - Private->iIsWindowFocused = ETrue; - posted += SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); - /* Draw window background and screen buffer */ - DisableKeyBlocking(_this); //Markus: guess why:-) - - //RedrawWindowL(_this); - break; - } - - case EEventFocusLost: /* SDL window lost focus */ - { - - Private->iIsWindowFocused = EFalse; - - posted += SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); - - - break; - } - - case EEventModifiersChanged: - { - TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged(); - TUint modstate = KMOD_NONE; - if (modEvent->iModifiers == EModifierLeftShift) - modstate |= KMOD_LSHIFT; - if (modEvent->iModifiers == EModifierRightShift) - modstate |= KMOD_RSHIFT; - if (modEvent->iModifiers == EModifierLeftCtrl) - modstate |= KMOD_LCTRL; - if (modEvent->iModifiers == EModifierRightCtrl) - modstate |= KMOD_RCTRL; - if (modEvent->iModifiers == EModifierLeftAlt) - modstate |= KMOD_LALT; - if (modEvent->iModifiers == EModifierRightAlt) - modstate |= KMOD_RALT; - if (modEvent->iModifiers == EModifierLeftFunc) - modstate |= KMOD_LMETA; - if (modEvent->iModifiers == EModifierRightFunc) - modstate |= KMOD_RMETA; - if (modEvent->iModifiers == EModifierCapsLock) - modstate |= KMOD_CAPS; - SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT))); - break; - } - case EEventScreenDeviceChanged: - { - EpocSdlEnv::WaitDeviceChange(); - } - break; - default: - break; - } - - return posted; -} - -extern "C" { - -void EPOC_PumpEvents(_THIS) - { - MEventQueue& events = EpocSdlEnv::EventQueue(); - while(events.HasData()) - { - events.Lock(); - - //there have to be a copy, so we can release - //lock immediately. HandleWsEvent may cause - //deadlock otherwise. - - const TWsEvent event = events.Shift(); - events.Unlock(); -// const TWsEvent& event = events.Top(); - EPOC_HandleWsEvent(_this, event); -// events.Shift(); - } - } - - - -void EPOC_InitOSKeymap(_THIS) - { - ResetKeyMap(); - EpocSdlEnv::ObserverEvent(MSDLObserver::EEventKeyMapInit ,0); - } - -static SDL_keysym *TranslateKey(_THIS, int scancode, SDL_keysym *keysym) -{ -// char debug[256]; - //SDL_TRACE1("SDL: TranslateKey, scancode=%d", scancode); //!! - - /* Set the keysym information */ - - keysym->scancode = scancode; - - if ((scancode >= MAX_SCANCODE) && - ((scancode - ENonCharacterKeyBase + 0x0081) >= MAX_SCANCODE)) { - SDL_SetError("Too big scancode"); - keysym->scancode = SDLK_UNKNOWN; - keysym->mod = KMOD_NONE; - return keysym; - } - - keysym->mod = SDL_GetModState(); - - /* Handle function keys: F1, F2, F3 ... */ - if (keysym->mod & KMOD_META) { - if (scancode >= 'A' && scancode < ('A' + 24)) { /* first 32 alphabet keys */ - switch(scancode) { - case 'Q': scancode = EStdKeyF1; break; - case 'W': scancode = EStdKeyF2; break; - case 'E': scancode = EStdKeyF3; break; - case 'R': scancode = EStdKeyF4; break; - case 'T': scancode = EStdKeyF5; break; - case 'Y': scancode = EStdKeyF6; break; - case 'U': scancode = EStdKeyF7; break; - case 'I': scancode = EStdKeyF8; break; - case 'A': scancode = EStdKeyF9; break; - case 'S': scancode = EStdKeyF10; break; - case 'D': scancode = EStdKeyF11; break; - case 'F': scancode = EStdKeyF12; break; - } - keysym->sym = keymap[scancode]; - } - } - - if (scancode >= ENonCharacterKeyBase) { - // Non character keys - keysym->sym = keymap[scancode - - ENonCharacterKeyBase + 0x0081]; // !!hard coded - } else { - keysym->sym = keymap[scancode]; - } - - /* Remap the arrow keys if the device is rotated */ -/* - if (Private->EPOC_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) { - switch(keysym->sym) { - case SDLK_UP: keysym->sym = SDLK_LEFT; break; - case SDLK_DOWN: keysym->sym = SDLK_RIGHT; break; - case SDLK_LEFT: keysym->sym = SDLK_DOWN; break; - case SDLK_RIGHT:keysym->sym = SDLK_UP; break; - } - } -*/ - /* If UNICODE is on, get the UNICODE value for the key */ - keysym->unicode = 0; - -#if 0 // !!TODO:unicode - - if ( SDL_TranslateUNICODE ) - { - /* Populate the unicode field with the ASCII value */ - keysym->unicode = scancode; - } -#endif - - //!! - //sprintf(debug, "SDL: TranslateKey: keysym->scancode=%d, keysym->sym=%d, keysym->mod=%d", - // keysym->scancode, keysym->sym, keysym->mod); - //SDL_TRACE(debug); //!! - - return(keysym); -} - -} /* extern "C" */ - - 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 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@devolution.com -*/ - -/* - SDL_epocvideo.cpp - Epoc based SDL video driver implementation - - Markus Mertama -*/ - - - -#include "epoc_sdl.h" - -#include -#include -#include - -extern "C" { -#include "SDL_error.h" -#include "SDL_timer.h" -#include "SDL_video.h" -#undef NULL -#include "SDL_pixels_c.h" -#include "SDL.h" -#include "SDL_mouse.h" -} - -#include "SDL_epocvideo.h" -#include "SDL_epocevents_c.h" - - - -#include -#include - -#include -#include -#include -#include "sdlepocapi.h" - - -//////////////////////////////////////////////////////////////// - - - - -_LIT(KLibName, "SDL"); - -void RDebug_Print_b(char* error_str, void* param) - { - TBuf8<128> error8((TUint8*)error_str); - TBuf<128> error; - error.Copy(error8); - -#ifndef TRACE_TO_FILE - if (param) //!! Do not work if the parameter is really 0!! - RDebug::Print(error, param); - else - RDebug::Print(error); -#else - if (param) //!! Do not work if the parameter is really 0!! - RFileLogger::WriteFormat(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error, param); - else - RFileLogger::Write(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error); -#endif - - } - -extern "C" void RDebug_Print(char* error_str, void* param) - { - RDebug_Print_b(error_str, param); - } - -/* -int Debug_AvailMem2() - { - //User::CompressAllHeaps(); - TMemoryInfoV1Buf membuf; - User::LeaveIfError(UserHal::MemoryInfo(membuf)); - TMemoryInfoV1 minfo = membuf(); - return(minfo.iFreeRamInBytes); - } - -extern "C" int Debug_AvailMem() - { - return(Debug_AvailMem2()); - } - -*/ - -extern "C" { - -/* Initialization/Query functions */ - -static int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat); -static SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); -static SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); -static int EPOC_SetColors(_THIS, int firstcolor, int ncolors, - SDL_Color *colors); -static void EPOC_VideoQuit(_THIS); - -/* Hardware surface functions */ - -static int EPOC_AllocHWSurface(_THIS, SDL_Surface *surface); -static int EPOC_LockHWSurface(_THIS, SDL_Surface *surface); -static int EPOC_FlipHWSurface(_THIS, SDL_Surface *surface); -static void EPOC_UnlockHWSurface(_THIS, SDL_Surface *surface); -static void EPOC_FreeHWSurface(_THIS, SDL_Surface *surface); -static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); - -static int EPOC_Available(void); -static SDL_VideoDevice *EPOC_CreateDevice(int devindex); - -void DrawBackground(_THIS); -void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer); -void DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer); - -/* Mouse functions */ - -static WMcursor *EPOC_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); -static void EPOC_FreeWMCursor(_THIS, WMcursor *cursor); -static int EPOC_ShowWMCursor(_THIS, WMcursor *cursor); -} - - -extern "C" - { - struct WMcursor - { - }; - } - -/* Epoc video driver bootstrap functions */ - - -static int EPOC_Available(void) - { - return 1; /* Always available */ - } - -static void EPOC_DeleteDevice(SDL_VideoDevice *device) - { - User::Free(device->hidden); - User::Free(device); - } - -static SDL_VideoDevice *EPOC_CreateDevice(int /*devindex*/) - { - SDL_VideoDevice *device; - - SDL_TRACE("SDL:EPOC_CreateDevice"); - - /* Allocate all variables that we free on delete */ - device = static_cast(User::Alloc(sizeof(SDL_VideoDevice))); - if ( device ) - { - Mem::FillZ(device, (sizeof *device)); - device->hidden = static_cast - (User::Alloc((sizeof *device->hidden))); - } - if ( (device == NULL) || (device->hidden == NULL) ) - { - SDL_OutOfMemory(); - if ( device ) { - User::Free(device); - } - return(0); - } - Mem::FillZ(device->hidden, (sizeof *device->hidden)); - - /* Set the function pointers */ - device->VideoInit = EPOC_VideoInit; - device->ListModes = EPOC_ListModes; - device->SetVideoMode = EPOC_SetVideoMode; - device->SetColors = EPOC_SetColors; - device->UpdateRects = NULL; - device->VideoQuit = EPOC_VideoQuit; - device->AllocHWSurface = EPOC_AllocHWSurface; - device->CheckHWBlit = NULL; - device->FillHWRect = NULL; - device->SetHWColorKey = NULL; - device->SetHWAlpha = NULL; - device->LockHWSurface = EPOC_LockHWSurface; - device->UnlockHWSurface = EPOC_UnlockHWSurface; - device->FlipHWSurface = EPOC_FlipHWSurface; - device->FreeHWSurface = EPOC_FreeHWSurface; - device->SetIcon = NULL; - device->SetCaption = NULL; - device->GetWMInfo = NULL; - device->FreeWMCursor = EPOC_FreeWMCursor; - device->CreateWMCursor = EPOC_CreateWMCursor; - device->ShowWMCursor = EPOC_ShowWMCursor; - device->WarpWMCursor = NULL; - device->InitOSKeymap = EPOC_InitOSKeymap; - device->PumpEvents = EPOC_PumpEvents; - device->free = EPOC_DeleteDevice; - - return device; -} - - -VideoBootStrap EPOC_bootstrap = { - "epoc\0\0\0", "EPOC system", - EPOC_Available, EPOC_CreateDevice -}; - - - -void DisableKeyBlocking(_THIS) - { - EpocSdlEnv::Request(EpocSdlEnv::EDisableKeyBlocking); - } - -void ConstructWindowL(_THIS) - { - SDL_TRACE("SDL:ConstructWindowL"); - DisableKeyBlocking(_this); //disable key blocking - } - - -int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat) - { - /* Construct Epoc window */ - - ConstructWindowL(_this); - - /* Initialise Epoc frame buffer */ - - - const TDisplayMode displayMode = EpocSdlEnv::DisplayMode(); - - /* The "best" video format should be returned to caller. */ - - vformat->BitsPerPixel = TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode); - vformat->BytesPerPixel = TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode) / 8; - - - //?? Private->iWindow->PointerFilter(EPointerFilterDrag, 0); - - Private->iScreenPos = TPoint(0, 0); - - Private->iRect.x = Private->iScreenPos.iX; - Private->iRect.y = Private->iScreenPos.iY; - - const TSize sz = EpocSdlEnv::WindowSize(); - - Private->iRect.w = sz.iWidth; - Private->iRect.h = sz.iHeight; - Private->iRectPtr = &Private->iRect; - - return(0); - } - - -SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) - { - if(flags & SDL_HWSURFACE) - { - if(format->BytesPerPixel != 4) //in HW only full color is supported - return NULL; - } - if(flags & SDL_FULLSCREEN) - { - return &Private->iRectPtr; - } - return (SDL_Rect **)(-1); //everythingisok, unless too small shoes - } - - -int EPOC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) - { - if ((firstcolor+ncolors) > 256) - return -1; - TUint32 palette[256]; - const TDisplayMode mode = EpocSdlEnv::DisplayMode(); - if(TDisplayModeUtils::NumDisplayModeColors(mode) == 4096) - { - // Set 12 bit palette - for(int i = firstcolor; i < ncolors; i++) - { - // 4k value: 0000 rrrr gggg bbbb - TUint32 color4K = (colors[i].r & 0x0000f0) << 4; - color4K |= (colors[i].g & 0x0000f0); - color4K |= (colors[i].b & 0x0000f0) >> 4; - palette[i] = color4K; - } - } - else if(TDisplayModeUtils::NumDisplayModeColors(mode) == 65536) - { - for(int i = firstcolor; i < ncolors; i++) - { - // 64k-colour displays effectively support RGB values - // with 5 bits allocated to red, 6 to green and 5 to blue - // 64k value: rrrr rggg gggb bbbb - TUint32 color64K = (colors[i].r & 0x0000f8) << 8; - color64K |= (colors[i].g & 0x0000fc) << 3; - color64K |= (colors[i].b & 0x0000f8) >> 3; - palette[i] = color64K; - } - } - else if(TDisplayModeUtils::NumDisplayModeColors(mode) == 16777216) - { - for(int i = firstcolor; i < ncolors; i++) - { - // 16M-colour - //0000 0000 rrrr rrrr gggg gggg bbbb bbbb - TUint32 color16M = colors[i].r << 16; - color16M |= colors[i].g << 8; - color16M |= colors[i].b; - palette[i] = color16M; - } - } - else - { - return -2; - } - if(EpocSdlEnv::SetPalette(firstcolor, ncolors, palette) == KErrNone) - return 0; - return -1; - } - - -/* -void AllocHWSurfaceL(CFbsBitmap*& aBitmap, const TDisplayMode& aMode, const TSize& aSize) - { - aBitmap = new (ELeave) CFbsBitmap(); - if(KErrNone != aBitmap->CreateHardwareBitmap(aSize, aMode, - EpocSdlEnv::EikonEnv().EikAppUi()->Application()->AppDllUid())) - //...if it fails - should we use wsbitmaps??? - {//the good reason to use hw bitmaps is that they wont need lock heap - PANIC_IF_ERROR(aBitmap->Create(aSize, aMode)); - } - } - -int CreateSurfaceL(_THIS, SDL_Surface* surface) - { - __ASSERT_ALWAYS(Private->iFrame == NULL, PANIC(KErrAlreadyExists)); -; - TInt dmode = EColorLast; - - TDisplayMode displayMode; - EpocSdlEnv::GetDiplayMode(displayMode); - - if( - TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode) - == surface->format->BitsPerPixel) - { - dmode = displayMode; - } - else - { - --dmode; - while(TDisplayModeUtils::IsDisplayModeColor(TDisplayMode(dmode)) && - TDisplayModeUtils::NumDisplayModeBitsPerPixel(TDisplayMode(dmode)) != - surface->format->BitsPerPixel) - --dmode; - } - - __ASSERT_ALWAYS(TDisplayModeUtils::IsDisplayModeColor(TDisplayMode(dmode)), PANIC(KErrNotSupported)); - TRAPD(err, AllocHWSurfaceL(Private->iFrame, TDisplayMode(dmode), TSize(surface->w, surface->h))); - return err == KErrNone ? 0 : -1; - } -*/ - -TDisplayMode GetDisplayMode(TInt aBitsPerPixel) - { - const TDisplayMode displayMode = EpocSdlEnv::DisplayMode(); - TInt dmode = EColorLast; - if( - TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode) - == aBitsPerPixel) - { - dmode = displayMode; - } - else - { - --dmode; - while(TDisplayModeUtils::IsDisplayModeColor(TDisplayMode(dmode)) && - TDisplayModeUtils::NumDisplayModeBitsPerPixel(TDisplayMode(dmode)) != - aBitsPerPixel) - --dmode; - } - return TDisplayMode(dmode); - } - -SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, - int width, int height, int bpp, Uint32 flags) - { - const TSize screenSize = EpocSdlEnv::WindowSize(TSize(width, height)); - if(width > screenSize.iWidth || height > screenSize.iHeight) - { - if(flags & SDL_FULLSCREEN) - { - width = screenSize.iWidth; - height = screenSize.iHeight; - } - else - return NULL; - } - - if(current && current->pixels) - { - // free(current->pixels); - current->pixels = NULL; - } - - if(!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) - { - return(NULL); - } - - current->flags = 0; - if(width == screenSize.iWidth && height == screenSize.iHeight) - current->flags |= SDL_FULLSCREEN; - - const int numBytesPerPixel = ((bpp-1)>>3) + 1; - current->pitch = numBytesPerPixel * width; // Number of bytes in scanline - - /* Set up the new mode framebuffer */ - current->flags |= SDL_PREALLOC; - - if(bpp <= 8) - current->flags |= SDL_HWPALETTE; - - User::Free(Private->iSwSurface); - current->pixels = NULL; - Private->iSwSurface = NULL; - - if(flags & SDL_HWSURFACE) - { - current->flags |= SDL_HWSURFACE; - // current->pixels = NULL; - // Private->iSwSurface = NULL; - } - else - { - current->flags |= SDL_SWSURFACE; - const TInt surfacesize = width * height * numBytesPerPixel; - Private->iSwSurfaceSize = TSize(width, height); - delete Private->iSwSurface; - Private->iSwSurface = NULL; - current->pixels = (TUint8*) User::AllocL(surfacesize); - Private->iSwSurface = (TUint8*) current->pixels; - const TInt err = EpocSdlEnv::AllocSwSurface - (TSize(width, height), GetDisplayMode(current->format->BitsPerPixel)); - if(err != KErrNone) - return NULL; - } - - current->w = width; - current->h = height; - - - - /* Set the blit function */ - _this->UpdateRects = EPOC_DirectUpdate; - - /* - * Logic for getting suitable screen dimensions, offset, scaling and orientation - */ - - - /* Centralize game window on device screen */ - - - Private->iScreenPos.iX = Max(0, (screenSize.iWidth - width) / 2); - Private->iScreenPos.iY = Max(0, (screenSize.iHeight - height) / 2); - - // delete (Private->iFrame); -// Private->iFrame = NULL; - - // TRAPD(err, CreateSurfaceL(_this, current)); - // PANIC_IF_ERROR(err); - - SDL_TRACE1("View width %d", width); - SDL_TRACE1("View height %d", height); - SDL_TRACE1("View bmode %d", bpp); - SDL_TRACE1("View x %d", Private->iScreenPos.iX); - SDL_TRACE1("View y %d", Private->iScreenPos.iY); - - EpocSdlEnv::LockPalette(EFalse); - /* We're done */ - return(current); -} - - - -static int EPOC_AllocHWSurface(_THIS, SDL_Surface* surface) - { - return KErrNone == EpocSdlEnv::AllocHwSurface(TSize(surface->w, surface->h), GetDisplayMode(surface->format->BitsPerPixel)); - } - -static void EPOC_FreeHWSurface(_THIS, SDL_Surface* /*surface*/) - { - } - -static int EPOC_LockHWSurface(_THIS, SDL_Surface* surface) - { - if(EpocSdlEnv::IsDsaAvailable()) - { - TUint8* address = EpocSdlEnv::LockHwSurface(); - if(address != NULL) - { - surface->pixels = address; - return 1; - } - } - return 0; - } -static void EPOC_UnlockHWSurface(_THIS, SDL_Surface* /*surface*/) - { - EpocSdlEnv::UnlockHwSurface(); - } - -static int EPOC_FlipHWSurface(_THIS, SDL_Surface* /*surface*/) - { - return(0); - } - -static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) - { - if(EpocSdlEnv::IsDsaAvailable()) - { - if(Private->iSwSurface) - { - const TRect target(Private->iScreenPos, Private->iSwSurfaceSize); - for(TInt i = 0; i < numrects ;i++) - { - const TRect rect(TPoint(rects[i].x, rects[i].y), - TSize(rects[i].w, rects[i].h)); - if(!EpocSdlEnv::AddUpdateRect(Private->iSwSurface, rect, target)) - return; //not succesful - } - EpocSdlEnv::UpdateSwSurface(); - } - SDL_PauseAudio(0); - } - else - { - SDL_PauseAudio(1); - EpocSdlEnv::WaitDsaAvailable(); - } - } - - -/* Note: If we are terminated, this could be called in the middle of - another SDL video routine -- notably UpdateRects. -*/ -void EPOC_VideoQuit(_THIS) - { -// delete Private->iFrame; -// Private->iFrame = NULL; - User::Free(Private->iSwSurface); - Private->iSwSurface = NULL; - EpocSdlEnv::FreeSurface(); - } - - - - -WMcursor *EPOC_CreateWMCursor(_THIS, Uint8* /*data*/, Uint8* /*mask*/, int /*w*/, int /*h*/, int /*hot_x*/, int /*hot_y*/) - { - return (WMcursor*) 1; //hii! prevents SDL to view a std cursor - } - -void EPOC_FreeWMCursor(_THIS, WMcursor* /*cursor*/) - { - } - -int EPOC_ShowWMCursor(_THIS, WMcursor *cursor) - { - return true; - } - 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 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@devolution.com -*/ - -#ifndef EPOCVIDEO_H -#define EPOCVIDEO_H - -#include - -/* Hidden "this" pointer for the video functions */ -#define _THIS SDL_VideoDevice *_this -#define Private _this->hidden - -class CFbsBitmap; - -struct SDL_VideoDevice; -void DisableKeyBlocking(SDL_VideoDevice*); - -struct SDL_PrivateVideoData - { - TPoint iScreenPos; - TBool iIsWindowFocused; - TSize iSwSurfaceSize; - TUint8* iSwSurface; - SDL_Rect iRect; //same info in SDL format - SDL_Rect* iRectPtr; - }; - -#endif - - - - 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 @@ -#include "dsa.h" -#include "sdlepocapi.h" -#include - - -LOCAL_C TInt BytesPerPixel(TDisplayMode aMode) - { - return ((TDisplayModeUtils::NumDisplayModeBitsPerPixel(aMode) - 1) >> 3) + 1; - } - - - - -template -NONSHARABLE_CLASS(CBitmapSurface) : public T - { -public: - CBitmapSurface(RWsSession& aSession); -private: - void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice); - ~CBitmapSurface(); - TUint8* LockSurface(); - void UnlockHwSurface(); - void CreateSurfaceL(); - void Wipe(TInt aLength); - void Free(); - void Update(CFbsBitmap& aBmp); - TInt ExternalUpdate(); -private: - CFbsBitmap* iBmp; - CFbsBitmap* iCopyBmp; - }; - - -template -void CBitmapSurface::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice) - { - delete iCopyBmp; - iCopyBmp = NULL; - iCopyBmp = new (ELeave) CFbsBitmap(); - T::ConstructL(aWindow, aDevice); - } - -template -CBitmapSurface::CBitmapSurface(RWsSession& aSession) : T(aSession) - { - } - -template -void CBitmapSurface::Free() - { - delete iBmp; - iBmp = NULL; - T::Free(); - } - -template -CBitmapSurface::~CBitmapSurface() - { - __ASSERT_DEBUG(iBmp == NULL, PANIC(KErrNotReady)); - delete iCopyBmp; - } - -template -TUint8* CBitmapSurface::LockSurface() - { - iBmp->LockHeap(); - return reinterpret_cast(iBmp->DataAddress()); - } - - -template -void CBitmapSurface::UnlockHwSurface() - { - iBmp->UnlockHeap(); - T::SetUpdating(EFalse); - Update(*iBmp); - } - - -template -void CBitmapSurface::Update(CFbsBitmap& aBmp) - { - if(!T::Blitter(aBmp)) - { - if(T::SwSize() == T::HwRect().Size()) - T::Gc().BitBlt(T::HwRect().iTl, &aBmp); - else - T::Gc().DrawBitmap(T::HwRect(), &aBmp); - } - T::DrawOverlays(); - T::CompleteUpdate(); - } - -template -void CBitmapSurface::CreateSurfaceL() - { - Free(); - iBmp = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iBmp->Create(T::SwSize(), T::DisplayMode())); - T::CreateSurfaceL(*iBmp); - } - -template -void CBitmapSurface::Wipe(TInt aLength) //dont call in drawing - { - iBmp->LockHeap(); - Mem::FillZ(iBmp->DataAddress(), aLength); - iBmp->UnlockHeap(); - } - -template -TInt CBitmapSurface::ExternalUpdate() - { - if(iCopyBmp->Handle() == 0) - { - const TInt err = iCopyBmp->Duplicate(iBmp->Handle()); - if(err != KErrNone) - return err; - } - Update(*iCopyBmp); - return KErrNone; - } - - -////////////////////////////////////////////////////////////////////// - - - -NONSHARABLE_CLASS(CDsaBitgdi) : public CDsa - { -public: - CDsaBitgdi(RWsSession& aSession); -protected: - void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice); - CBitmapContext& Gc(); - void CompleteUpdate(); - ~CDsaBitgdi(); - void CreateSurfaceL(CFbsBitmap& aBmp); - void Free(); - void UnlockHWSurfaceRequestComplete(); -private: - void Resume(); - - CFbsBitGc* iGc; - CFbsDevice* iDevice; - CFbsBitmap* iBitGdiBmp; - CWindowGc* iWinGc; - RWindow* iWindow; - TInt iHandle; - }; - - -CDsaBitgdi::CDsaBitgdi(RWsSession& aSession) : CDsa(aSession) - { - } - -CDsaBitgdi::~CDsaBitgdi() - { - delete iWinGc; - delete iBitGdiBmp; - } - -void CDsaBitgdi::CompleteUpdate() - { - EpocSdlEnv::Request(CDsa::ERequestUpdate); - } - - -void CDsaBitgdi::UnlockHWSurfaceRequestComplete() - { - if(iHandle == 0) - return; - - if(iBitGdiBmp == NULL) - { - iBitGdiBmp = new CFbsBitmap(); - if(iBitGdiBmp == NULL) - return; - iBitGdiBmp->Duplicate(iHandle); - } - - iWindow->Invalidate(); - - iWindow->BeginRedraw(); - iWinGc->Activate(*iWindow); - iWinGc->BitBlt(TPoint(0, 0), iBitGdiBmp); - iWinGc->Deactivate(); - iWindow->EndRedraw(); - } - -void CDsaBitgdi::Resume() - { - Start(); - } - -CBitmapContext& CDsaBitgdi::Gc() - { - return *iGc; - } - - void CDsaBitgdi::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice) - { - - delete iBitGdiBmp; - iBitGdiBmp = NULL; - delete iWinGc; - iWinGc = NULL; - iHandle = 0; - - iWindow = &aWindow; - User::LeaveIfError(aDevice.CreateContext(iWinGc)); - CDsa::ConstructL(aWindow, aDevice); - Start(); - } - -void CDsaBitgdi::CreateSurfaceL(CFbsBitmap& aBmp) - { - iDevice = CFbsBitmapDevice::NewL(&aBmp); - User::LeaveIfError(iDevice->CreateContext(iGc)); - iHandle = aBmp.Handle(); - } - -void CDsaBitgdi::Free() - { - delete iGc; - iGc = NULL; - delete iDevice; - iDevice = NULL; - } - -//////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////// - -NONSHARABLE_CLASS(CDsaBase) : public CDsa, public MDirectScreenAccess - { -protected: - inline CDirectScreenAccess& Dsa() const; - CDsaBase(RWsSession& aSession); - ~CDsaBase(); - void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice); - void Stop(); - void Resume(); - CBitmapContext& Gc(); -protected: - CDirectScreenAccess* iDsa; -private: - void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); - void Restart(RDirectScreenAccess::TTerminationReasons aReason); -private: - void RestartL(); - }; - - -inline CDirectScreenAccess& CDsaBase::Dsa() const - { - return *iDsa; - } - - -CDsaBase::CDsaBase(RWsSession& aSession) : CDsa(aSession) - { - } - -CBitmapContext& CDsaBase::Gc() - { - return *Dsa().Gc(); - } - -void CDsaBase::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice) - { - CDsa::ConstructL(aWindow, aDevice); - if(iDsa != NULL) - { - iDsa->Cancel(); - delete iDsa; - iDsa = NULL; - } - - iDsa = CDirectScreenAccess::NewL( - Session(), - aDevice, - aWindow, - *this); - RestartL(); - } - -void CDsaBase::Resume() - { - if(Stopped()) - Restart(RDirectScreenAccess::ETerminateRegion); - } - -CDsaBase::~CDsaBase() - { - if(iDsa != NULL) - { - iDsa->Cancel(); - } - delete iDsa; - } - - -void CDsaBase::RestartL() - { - - - iDsa->StartL(); - - const RRegion* r = iDsa->DrawingRegion(); - const TRect rect = r->BoundingRect(); - iDsa->Gc()->SetClippingRegion(r); - - if(rect != ScreenRect()) - { - return ; - } - - - SetTargetRect(); - RecreateL(); - - Start(); - - - } - -void CDsaBase::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { - Stop(); - } - -void CDsaBase::Restart(RDirectScreenAccess::TTerminationReasons aReason) - { - if(aReason == RDirectScreenAccess::ETerminateRegion) //auto restart - { - TRAPD(err, RestartL()); - PANIC_IF_ERROR(err); - } - } - - -void CDsaBase::Stop() - { - CDsa::Stop(); - iDsa->Cancel(); - } - - - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -NONSHARABLE_CLASS(TDsa) - { - public: - inline TDsa(const CDsa& aDsa); - inline TBool IsFlip() const; - inline TBool IsTurn() const; - inline const TSize& SwSize() const; - inline void Copy(TUint32* aTarget, const TUint8* aSrc, TInt aBytes, TInt aHeight) const; - private: - const CDsa& iDsa; - }; - - - - -inline TDsa::TDsa(const CDsa& aDsa) : iDsa(aDsa) - { - } - -inline TBool TDsa::IsTurn() const - { - return iDsa.iStateFlags & CDsa::EOrientation90; - } - -inline TBool TDsa::IsFlip() const - { - return iDsa.iStateFlags & CDsa::EOrientation180; - } - -inline const TSize& TDsa::SwSize() const - { - return iDsa.SwSize(); - } - -inline void TDsa::Copy(TUint32* aTarget, const TUint8* aSrc, TInt aBytes, TInt aHeight) const - { - iDsa.iCopyFunction(iDsa, aTarget, aSrc, aBytes, aHeight); - } - -template -void ClipCopy(const TDsa& iDsa, TUint8* aTarget, - const TUint8* aSource, - const TRect& aUpdateRect, - const TRect& aSourceRect) - { - const S* source = reinterpret_cast(aSource); - const TInt lineWidth = aSourceRect.Width(); - - source += (aUpdateRect.iTl.iY * lineWidth); - const TInt sourceStartOffset = aUpdateRect.iTl.iX; - source += sourceStartOffset; - - T* targetPtr = reinterpret_cast(aTarget); - - const TInt scanLineWidth = iDsa.SwSize().iWidth; - - targetPtr += (aSourceRect.iTl.iY + aUpdateRect.iTl.iY ) * scanLineWidth; - const TInt targetStartOffset = (aUpdateRect.iTl.iX + aSourceRect.iTl.iX); - - targetPtr += targetStartOffset; - - - const TInt height = aUpdateRect.Height(); - - const TInt lineMove = iDsa.IsTurn() ? 1 : lineWidth; - const TInt copyLen = aUpdateRect.Width(); - - - if(iDsa.IsFlip()) - { - - targetPtr += scanLineWidth * (height - 1); - - for(TInt i = 0; i < height; i++) //source is always smaller - { - iDsa.Copy(reinterpret_cast(targetPtr), reinterpret_cast(source), copyLen, height); - source += lineMove; - targetPtr -= scanLineWidth; - } - } - else - { - - - for(TInt i = 0; i < height; i++) //source is always smaller - { - iDsa.Copy(reinterpret_cast(targetPtr), reinterpret_cast(source), copyLen, height); - source += lineMove; - targetPtr += scanLineWidth; // >> 2; - } - } - - } - - - -NONSHARABLE_CLASS(CDsaA) : public CDsaBase - { - public: - CDsaA(RWsSession& aSession); - protected: - void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice); - void CompleteUpdate(); - void CreateSurfaceL(CFbsBitmap& aBmp); - void Free(); - void UnlockHWSurfaceRequestComplete(); - }; - - -CDsaA::CDsaA(RWsSession& aSession) : CDsaBase(aSession) - { - } - - -void CDsaA::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice) - { - CDsaBase::ConstructL(aWindow, aDevice); - } - -void CDsaA::CompleteUpdate() - { - iDsa->ScreenDevice()->Update(); - } - -void CDsaA::CreateSurfaceL(CFbsBitmap& /*aBmp*/) - { - } - -void CDsaA::Free() - { - - } - -void CDsaA::UnlockHWSurfaceRequestComplete() - { - PANIC(KErrNotSupported); - } - - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -NONSHARABLE_CLASS(MDsbObs) - { - public: - virtual void SurfaceReady() = 0; - virtual CDirectScreenBitmap& Dsb() = 0; - }; - -NONSHARABLE_CLASS(CDsbSurface) : public CActive - { - public: - CDsbSurface(MDsbObs& aDsb); - TUint8* Address(); - void Complete(); - ~CDsbSurface(); - private: - void RunL(); - void DoCancel(); - private: - MDsbObs& iDsb; - TUint8* iAddress; - }; - -CDsbSurface::CDsbSurface(MDsbObs& aDsb) : CActive(CActive::EPriorityHigh) , iDsb(aDsb) - { - CActiveScheduler::Add(this); - } - -CDsbSurface::~CDsbSurface() - { - Cancel(); - } - -void CDsbSurface::Complete() - { - if(iAddress != NULL && !IsActive()) - { - iAddress = NULL; - SetActive(); - iDsb.Dsb().EndUpdate(iStatus); - } - } - -TUint8* CDsbSurface::Address() - { - if(iAddress == NULL && !IsActive()) - { - TAcceleratedBitmapInfo info; - if(KErrNone == iDsb.Dsb().BeginUpdate(info)) - iAddress = info.iAddress; - } - return iAddress; - } - -void CDsbSurface::RunL() - { - iDsb.SurfaceReady(); - } - -void CDsbSurface::DoCancel() - { - //empty - } - -NONSHARABLE_CLASS(CDsaB) : public CDsaBase, - public MDsbObs - { - public: - CDsaB(RWsSession& aSession, TInt aFlags); - private: - ~CDsaB(); - TUint8* LockSurface(); - void UnlockHWSurfaceRequestComplete(); - void UnlockHwSurface(); - void CreateSurfaceL(); - void Wipe(TInt aLength); - void RecreateL(); - void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice); - CDirectScreenBitmap& Dsb(); - void SurfaceReady(); - TInt ExternalUpdate(); - private: - CDsbSurface* iSurface1; - CDsbSurface* iSurface2; - CDirectScreenBitmap* iDsb; - TInt iType; - }; - -CDsaB::CDsaB(RWsSession& aSession, TInt aFlags) : CDsaBase(aSession), iType(aFlags) - { - } - - - -void CDsaB::UnlockHWSurfaceRequestComplete() - { - iSurface1->Complete(); - if(iSurface2 != NULL) - iSurface2->Complete(); - } - -void CDsaB::CreateSurfaceL() - { - __ASSERT_ALWAYS(SwSize() == HwRect().Size(), PANIC(KErrNotSupported)); - } - -void CDsaB::Wipe(TInt aLength) //dont call in drawing - { - TUint8* addr = LockSurface(); - if(addr != NULL) - { - Mem::FillZ(addr, aLength); - UnlockHwSurface(); - } - } - - -void CDsaB::UnlockHwSurface() - { - EpocSdlEnv::Request(CDsa::ERequestUpdate); - } - -TUint8* CDsaB::LockSurface() - { - TUint8* addr = iSurface1->Address(); - if(addr == NULL && iSurface2 != NULL) - addr = iSurface2->Address(); - SetUpdating(addr == NULL); - return addr; - } - -void CDsaB::SurfaceReady() - { - SetUpdating(EFalse); - } - -CDirectScreenBitmap& CDsaB::Dsb() - { - return *iDsb; - } - -void CDsaB::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice) - { - if(iDsb == NULL) - iDsb = CDirectScreenBitmap::NewL(); - CDsaBase::ConstructL(aWindow, aDevice); - if(iSurface1 == NULL) - iSurface1 = new (ELeave) CDsbSurface(*this); - if(iSurface2 == NULL && iType & CDirectScreenBitmap::EDoubleBuffer) - iSurface2 = new (ELeave) CDsbSurface(*this); - } - -CDsaB::~CDsaB() - { - delete iSurface1; - delete iSurface2; - delete iDsb; - } - -void CDsaB::RecreateL() - { - iDsb->Close(); - iDsb->Create(HwRect(), CDirectScreenBitmap::TSettingsFlags(iType)); - } - -TInt CDsaB::ExternalUpdate() - { - if(LockSurface()) - { - UnlockHWSurfaceRequestComplete(); - return KErrNone; - } - return KErrNotReady; - } - - -///////////////////////////////////////////////////////////////////////////////////////////////////// - - - -CDsa* CDsa::CreateL(RWsSession& aSession) - { - if(EpocSdlEnv::Flags(CSDL::EDrawModeDSB)) - { - TInt flags = CDirectScreenBitmap::ENone; - if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBDoubleBuffer)) - flags |= CDirectScreenBitmap::EDoubleBuffer; - if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBIncrementalUpdate)) - flags |= CDirectScreenBitmap::EIncrementalUpdate; - return new (ELeave) CDsaB(aSession, flags); - } - else if(EpocSdlEnv::Flags(CSDL::EDrawModeGdi)) - { - return new (ELeave) CBitmapSurface(aSession); - } - else - { - return new (ELeave) CBitmapSurface(aSession); - } - } - - -void CDsa::RecreateL() - { - } - -void CDsa::Free() - { - } - -TSize CDsa::WindowSize() const - { - TSize size = iSwSize; - if(iStateFlags & EOrientation90) - { - const TInt tmp = size.iWidth; - size.iWidth = size.iHeight; - size.iHeight = tmp; - } - return size; - } - -void CDsa::SetSuspend() - { - iStateFlags |= ESdlThreadSuspend; - } - - -void CDsa::SetUpdating(TBool aUpdate) - { - if(aUpdate) - iStateFlags |= EUpdating; - else - iStateFlags &= ~EUpdating; - } - - -TBool CDsa::Stopped() const - { - return (iStateFlags & ESdlThreadExplicitStop); - } - -void CDsa::SetOrientation(CSDL::TOrientationMode aOrientation) - { - TInt flags = 0; - switch(aOrientation) - { - case CSDL::EOrientation90: - flags = EOrientation90; - break; - case CSDL::EOrientation180: - flags = EOrientation180; - break; - case CSDL::EOrientation270: - flags = EOrientation90 | EOrientation180; - break; - case CSDL::EOrientation0: - flags = 0; - break; - } - if(flags != (iStateFlags & EOrientationFlags)) - { - iStateFlags |= EOrientationChanged; - iNewFlags = flags; //cannot be set during drawing... - } - } - -CDsa::~CDsa() - { - iOverlays.Close(); - User::Free(iLut256); - } - -void CDsa::ConstructL(RWindow& aWindow, CWsScreenDevice& /*aDevice*/) - { - if(iLut256 == NULL) - iLut256 = (TUint32*) User::AllocL(256 * sizeof(TUint32)); - iTargetMode = aWindow.DisplayMode(); - iTargetBpp = BytesPerPixel(DisplayMode()); - iScreenRect = TRect(aWindow.Position(), aWindow.Size()); - SetTargetRect(); - } - -void CDsa::DrawOverlays() - { - const TInt last = iOverlays.Count() - 1; - for(TInt i = last; i >= 0 ; i--) - iOverlays[i].iOverlay->Draw(Gc(), HwRect(), SwSize()); - } - -TInt CDsa::AppendOverlay(MOverlay& aOverlay, TInt aPriority) - { - TInt i; - for(i = 0; i < iOverlays.Count() && iOverlays[i].iPriority < aPriority; i++) - {} - const TOverlay overlay = {&aOverlay, aPriority}; - return iOverlays.Insert(overlay, i); - } - -TInt CDsa::RemoveOverlay(MOverlay& aOverlay) - { - for(TInt i = 0; i < iOverlays.Count(); i++) - { - if(iOverlays[i].iOverlay == &aOverlay) - { - iOverlays.Remove(i); - return KErrNone; - } - } - return KErrNotFound; - } - -void CDsa::LockPalette(TBool aLock) - { - if(aLock) - iStateFlags |= EPaletteLocked; - else - iStateFlags &= ~EPaletteLocked; - } -TInt CDsa::SetPalette(TInt aFirst, TInt aCount, TUint32* aPalette) - { - if(iLut256 == NULL) - return KErrNotFound; - const TInt count = aCount - aFirst; - if(count > 256) - return KErrArgument; - if(iStateFlags & EPaletteLocked) - return KErrNone; - for(TInt i = aFirst; i < count; i++) //not so busy here:-) - { - iLut256[i] = aPalette[i]; - } - return KErrNone; - } - - - - - -CDsa::CDsa(RWsSession& aSession) : - iStateFlags(0), - iSession(aSession) - - { -// CActiveScheduler::Add(this); - iCFTable[0] = CopyMem; - iCFTable[1] = CopyMemFlipReversed; - iCFTable[2] = CopyMemReversed; - iCFTable[3] = CopyMemFlip; - - iCFTable[4] = Copy256; - iCFTable[5] = Copy256FlipReversed; - iCFTable[6] = Copy256Reversed; - iCFTable[7] = Copy256Flip; - - - iCFTable[8] = CopySlow; - iCFTable[9] = CopySlowFlipReversed; - iCFTable[10] = CopySlowReversed; - iCFTable[11] = CopySlowFlip; - } - -RWsSession& CDsa::Session() - { - return iSession; - } - -TInt CDsa::RedrawRequest() - { - if(!(iStateFlags & (EUpdating) && (iStateFlags & ERunning))) - { - return ExternalUpdate(); - } - return KErrNotReady; - } - -TUint8* CDsa::LockHwSurface() - { - if((iStateFlags & EUpdating) == 0) //else frame is skipped - { - return LockSurface(); - } - return NULL; - } - -/* -void CDsa::RunL() - { - iStateFlags &= ~EUpdating; - } - - -void CDsa::DoCancel() - { - iStateFlags &= ~EUpdating; - //nothing can do, just wait? - } -*/ - - -TInt CDsa::AllocSurface(TBool aHwSurface, const TSize& aSize, TDisplayMode aMode) - { - if(aHwSurface && aMode != DisplayMode()) - return KErrArgument; - - iSourceMode = aMode; - - iSourceBpp = BytesPerPixel(aMode); - - const TSize size = WindowSize(); - if(aSize.iWidth > size.iWidth) - return KErrTooBig; - if(aSize.iHeight > size.iHeight) - return KErrTooBig; - - TRAPD(err, CreateSurfaceL()); - if(err != KErrNone) - return err; - - SetCopyFunction(); - - return KErrNone; - } - - -void CDsa::CreateZoomerL(const TSize& aSize) - { - iSwSize = aSize; - iStateFlags |= EResizeRequest; - CreateSurfaceL(); - SetTargetRect(); - } - - -/* -void SaveBmp(const TDesC& aName, const TAny* aData, TInt aLength, const TSize& aSz, TDisplayMode aMode) - { - CFbsBitmap* s = new CFbsBitmap(); - s->Create(aSz, aMode); - s->LockHeap(); - TUint32* addr = s->DataAddress(); - Mem::Copy(addr, aData, aLength); - s->UnlockHeap(); - s->Save(aName); - s->Reset(); - delete s; - } - -void SaveBmp(const TDesC& aName, const TUint32* aData, const TSize& aSz) - { - CFbsBitmap* s = new CFbsBitmap(); - s->Create(aSz, EColor64K); - TBitmapUtil bmp(s); - bmp.Begin(TPoint(0, 0)); - for(TInt j = 0; j < aSz.iHeight; j++) - { - bmp.SetPos(TPoint(0, j)); - for(TInt i = 0; i < aSz.iWidth; i++) - { - bmp.SetPixel(*aData); - aData++; - bmp.IncXPos(); - } - } - bmp.End(); - s->Save(aName); - s->Reset(); - delete s; - } - -TBuf<16> FooName(TInt aFoo) - { - TBuf<16> b; - b.Format(_L("C:\\pic%d.mbm"), aFoo); - return b; - } - -*/ - - -void CDsa::ClipCopy(TUint8* aTarget, - const TUint8* aSource, - const TRect& aUpdateRect, - const TRect& aSourceRect) const - { - const TDsa dsa(*this); - switch(iSourceBpp) - { - case 1: - ::ClipCopy(dsa, aTarget, aSource, aUpdateRect, aSourceRect); - break; - case 2: - ::ClipCopy(dsa, aTarget, aSource, aUpdateRect, aSourceRect); - break; - case 4: - ::ClipCopy(dsa, aTarget, aSource, aUpdateRect, aSourceRect); - break; - } - } - - -void CDsa::Wipe() //dont call in drawing - { - if(IsDsaAvailable()) - Wipe(iTargetBpp * SwSize().iWidth * SwSize().iHeight); - } - -void CDsa::SetCopyFunction() - { - //calculate offset to correct function in iCFTable according to given parameters - TInt function = 0; - const TInt KCopyFunctions = 4; - const TInt KOffsetToNative = 0; - const TInt KOffsetTo256 = KOffsetToNative + KCopyFunctions; - const TInt KOffsetToOtherModes = KOffsetTo256 + KCopyFunctions; - const TInt KOffsetTo90Functions = 1; - const TInt KOffsetTo180Functions = 2; - - if(iSourceMode == DisplayMode()) - function = KOffsetToNative; //0 - else if(iSourceMode == EColor256) - function = KOffsetTo256; //4 - else - function = KOffsetToOtherModes; //8 - - if(iStateFlags & EOrientation90) - function += KOffsetTo90Functions; // + 1 - if(iStateFlags & EOrientation180) - function += KOffsetTo180Functions; //+ 2 - - iCopyFunction = iCFTable[function]; - - Wipe(); - } - -inline void Rotate(TRect& aRect) - { - const TInt dx = aRect.iBr.iX - aRect.iTl.iX; - const TInt dy = aRect.iBr.iY - aRect.iTl.iY; - - aRect.iBr.iX = aRect.iTl.iX + dy; - aRect.iBr.iY = aRect.iTl.iY + dx; - - const TInt tmp = aRect.iTl.iX; - aRect.iTl.iX = aRect.iTl.iY; - aRect.iTl.iY = tmp; - } - -/* -int bar = 0; -*/ - -TBool CDsa::AddUpdateRect(const TUint8* aBits, const TRect& aUpdateRect, const TRect& aRect) - { - - if(iStateFlags & EOrientationChanged) - { - iStateFlags &= ~EOrientationFlags; - iStateFlags |= iNewFlags; - SetCopyFunction(); - iStateFlags &= ~EOrientationChanged; - EpocSdlEnv::WaitDeviceChange(); - return EFalse; //skip this frame as data is may be changed - } - - if(iTargetAddr == NULL) - { - iTargetAddr = LockHwSurface(); - } - - TUint8* target = iTargetAddr; - if(target == NULL) - return EFalse; - - - TRect targetRect = TRect(TPoint(0, 0), SwSize()); - - TRect sourceRect = aRect; - TRect updateRect = aUpdateRect; - -// TPoint move(0, 0); - - - if(iStateFlags & EOrientation90) - { - Rotate(sourceRect); - Rotate(updateRect); - } - - if(iSourceMode != DisplayMode() || targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0)) - { - sourceRect.Intersection(targetRect); //so source always smaller or equal than target - //updateRect.Intersection(targetRect); - ClipCopy(target, aBits, updateRect, sourceRect); - } - else - { - const TInt byteCount = aRect.Width() * aRect.Height() * iSourceBpp; //this could be stored - Mem::Copy(target, aBits, byteCount); - } - - return ETrue; - } - - -void CDsa::UpdateSwSurface() - { - iTargetAddr = NULL; - UnlockHwSurface(); //could be faster if does not use AO, but only check status before redraw, then no context switch needed - } - - - - -void CDsa::DoStop() - { - if(IsDsaAvailable()) - iStateFlags |= ESdlThreadExplicitStop; - Stop(); - } - - -void CDsa::Stop() - { - iStateFlags &= ~ERunning; - } - -void CDsa::Start() - { - iStateFlags |= ERunning; - - iStateFlags &= ~ESdlThreadExplicitStop; - - if(iStateFlags & ESdlThreadSuspend) - { - EpocSdlEnv::Resume(); - iStateFlags &= ~ ESdlThreadSuspend; - } - EpocSdlEnv::ObserverEvent(MSDLObserver::EEventWindowReserved); - } - - -TBool CDsa::Blitter(CFbsBitmap& aBmp) - { - return iBlitter && iBlitter->BitBlt(Gc(), aBmp, HwRect(), SwSize()); - } - -void CDsa::SetBlitter(MBlitter* aBlitter) - { - iBlitter = aBlitter; - } - - -TPoint CDsa::WindowCoordinates(const TPoint& aPoint) const - { - TPoint pos = aPoint - iScreenRect.iTl; - const TSize asz = iScreenRect.Size(); - if(iStateFlags & EOrientation180) - { - pos.iX = asz.iWidth - pos.iX; - pos.iY = asz.iHeight - pos.iY; - } - if(iStateFlags & EOrientation90) - { - pos.iX = aPoint.iY; - pos.iY = aPoint.iX; - } - pos.iX <<= 16; - pos.iY <<= 16; - pos.iX /= asz.iWidth; - pos.iY /= asz.iHeight; - pos.iX *= iSwSize.iWidth; - pos.iY *= iSwSize.iHeight; - pos.iX >>= 16; - pos.iY >>= 16; - return pos; - } - -void CDsa::SetTargetRect() - { - iTargetRect = iScreenRect; - if(iStateFlags & EResizeRequest && EpocSdlEnv::Flags(CSDL::EAllowImageResizeKeepRatio)) - { - const TSize asz = iScreenRect.Size(); - const TSize sz = iSwSize; - - TRect rect; - - const TInt dh = (sz.iHeight << 16) / sz.iWidth; - - if((asz.iWidth * dh ) >> 16 <= asz.iHeight) - { - rect.SetRect(TPoint(0, 0), TSize(asz.iWidth, (asz.iWidth * dh) >> 16)); - } - else - { - const TInt dw = (sz.iWidth << 16) / sz.iHeight; - rect.SetRect(TPoint(0, 0), TSize((asz.iHeight * dw) >> 16, asz.iHeight)); - } - rect.Move((asz.iWidth - rect.Size().iWidth) >> 1, (asz.iHeight - rect.Size().iHeight) >> 1); - - iTargetRect = rect; - iTargetRect.Move(iScreenRect.iTl); - - } - if(!(iStateFlags & EResizeRequest)) - iSwSize = iScreenRect.Size(); - - } - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CDsa::Copy256(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - TUint32* target = aTarget; - const TUint32* endt = target + aBytes; - const TUint8* source = aSource; - while(target < endt) - { - *target++ = aDsa.iLut256[*source++]; - } - } - -void CDsa::Copy256Reversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - const TUint32* target = aTarget; - TUint32* endt = aTarget + aBytes; - const TUint8* source = aSource; - while(target < endt) - { - *(--endt) = aDsa.iLut256[*source++]; - } - } - -void CDsa::Copy256Flip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - TUint32* target = aTarget; - const TUint32* endt = target + aBytes; - const TUint8* column = aSource; - - while(target < endt) - { - *target++ = aDsa.iLut256[*column]; - column += aLineLen; - } - } - -void CDsa::Copy256FlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - const TUint32* target = aTarget; - TUint32* endt = aTarget + aBytes; - const TUint8* column = aSource; - - while(target < endt) - { - *(--endt) = aDsa.iLut256[*column]; - column += aLineLen; - } - } - -void CDsa::CopyMem(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - const TUint32* src = reinterpret_cast(aSource); - Mem::Copy(aTarget, src, aBytes << 2); - } - -void CDsa::CopyMemFlip(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - TUint32* target = aTarget; - const TUint32* endt = target + aBytes; - const TUint32* column = reinterpret_cast(aSource); - - while(target < endt) - { - *target++ = *column; - column += aLineLen; - } - } - -void CDsa::CopyMemReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - const TUint32* target = aTarget; - TUint32* endt = aTarget + aBytes; - const TUint32* source = reinterpret_cast(aSource); - while(target < endt) - { - *(--endt) = *source++; - } - } - - -void CDsa::CopyMemFlipReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - const TUint32* target = aTarget; - TUint32* endt = aTarget + aBytes; - const TUint32* column = reinterpret_cast(aSource); - - while(target < endt) - { - *(--endt) = *column; - column += aLineLen; - } - } - -/* - -LOCAL_C TRgb rgb16MA(TInt aValue) - { - return TRgb::Color16MA(aValue); - } -*/ -NONSHARABLE_CLASS(MRgbCopy) - { - public: - virtual void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed) = 0; - virtual void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed) = 0; - }; - -template -NONSHARABLE_CLASS(TRgbCopy) : public MRgbCopy - { - public: - TRgbCopy(TDisplayMode aMode); - void* operator new(TUint aBytes, TAny* aMem); - void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed); - void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed); - static TUint32 Gray256(const TUint8& aPixel); - static TUint32 Color256(const TUint8& aPixel); - static TUint32 Color4K(const TUint16& aPixel); - static TUint32 Color64K(const TUint16& aPixel); - static TUint32 Color16M(const TUint32& aPixel); - static TUint32 Color16MU(const TUint32& aPixel); - static TUint32 Color16MA(const TUint32& aPixel); - private: - typedef TUint32 (*TRgbFunc) (const T& aValue); - TRgbFunc iFunc; - }; - - -template -void* TRgbCopy::operator new(TUint /*aBytes*/, TAny* aMem) - { - return aMem; - } - -template -TRgbCopy::TRgbCopy(TDisplayMode aMode) - { - switch(aMode) - { - case EGray256 : iFunc = (TRgbFunc) Gray256; break; - case EColor256 : iFunc = (TRgbFunc) Color256; break; - case EColor4K : iFunc = (TRgbFunc) Color4K; break; - case EColor64K : iFunc = (TRgbFunc) Color64K; break; - case EColor16M : iFunc = (TRgbFunc) Color16M; break; - case EColor16MU : iFunc = (TRgbFunc) Color16MU; break; - case EColor16MA : iFunc = (TRgbFunc) Color16MA; break; - default: - PANIC(KErrNotSupported); - } - } - -template -void TRgbCopy::Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed) - { - const T* source = reinterpret_cast(aSource); - TUint32* target = aTarget; - TUint32* endt = target + aBytes; - - if(aReversed) - { - while(target < endt) - { - const T value = *source++; - *(--endt) = iFunc(value);//iFunc(value).Value(); - } - } - else - { - while(target < endt) - { - const T value = *source++; - *target++ = iFunc(value);//iFunc(value).Value(); - } - } - } - -template -void TRgbCopy::FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed) - { - const T* column = reinterpret_cast(aSource); - TUint32* target = aTarget; - TUint32* endt = target + aBytes; - - if(aReversed) - { - while(target < endt) - { - *(--endt) = iFunc(*column); - column += aLineLen; - } - } - else - { - while(target < endt) - { - *target++ = iFunc(*column); - column += aLineLen; - } - } - } - -template TUint32 TRgbCopy::Gray256(const TUint8& aPixel) - { - const TUint32 px = aPixel << 16 | aPixel << 8 | aPixel; - return px; - } - -template TUint32 TRgbCopy::Color256(const TUint8& aPixel) - { - return TRgb::Color256(aPixel).Value(); - } - -template TUint32 TRgbCopy::Color4K(const TUint16& aPixel) - { - TUint32 col = (aPixel & 0xF00) << 12; - col |= (aPixel & 0xF00) << 8; - - col |= (aPixel & 0x0F0) << 8; - col |= (aPixel & 0x0F0); - - col |= (aPixel & 0x00F) << 4; - col |= (aPixel & 0x00F); - - return col; - } - -template TUint32 TRgbCopy::Color64K(const TUint16& aPixel) - { - TUint32 col = (aPixel & 0xF800)<< 8; - col |= (aPixel & 0xE000) << 3; - - col |= (aPixel & 0x07E0) << 5; - col |= (aPixel & 0xC0) >> 1; - - col |= (aPixel & 0x07E0) << 3; - col |= (aPixel & 0x1C) >> 2; - - return col; - } - -template TUint32 TRgbCopy::Color16M(const TUint32& aPixel) - { - return TRgb::Color16M(aPixel).Value(); - } - -template TUint32 TRgbCopy::Color16MU(const TUint32& aPixel) - { - return TRgb::Color16MU(aPixel).Value(); - } - -template TUint32 TRgbCopy::Color16MA(const TUint32& aPixel) - { - return TRgb::Color16MA(aPixel).Value(); - } - -typedef TUint64 TStackMem; - -LOCAL_C MRgbCopy* GetCopy(TAny* mem, TDisplayMode aMode) - { - if(aMode == EColor256 || aMode == EGray256) - { - return new (mem) TRgbCopy(aMode); - } - if(aMode == EColor4K || aMode == EColor64K) - { - return new (mem) TRgbCopy(aMode); - } - if(aMode == EColor16M || aMode == EColor16MU || aMode == EColor16MA) - { - return new (mem) TRgbCopy(aMode); - } - PANIC(KErrNotSupported); - return NULL; - } - - -void CDsa::CopySlowFlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - TStackMem mem = 0; - GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, ETrue); - } - -void CDsa::CopySlowFlip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - TStackMem mem = 0; - GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, EFalse); - } - -void CDsa::CopySlow(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - TStackMem mem = 0; - GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, EFalse); - } - -void CDsa::CopySlowReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - TStackMem mem = 0; - GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, ETrue); - } - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////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 @@ -#include "dsa.h" -#include "sdlepocapi.h" -#include - - -LOCAL_C TInt BytesPerPixel(TDisplayMode aMode) - { - return ((TDisplayModeUtils::NumDisplayModeBitsPerPixel(aMode) - 1) >> 3) + 1; - } - - -NONSHARABLE_CLASS(TDsa) - { - public: - inline TDsa(const CDsa& aDsa); - inline TBool IsFlip() const; - inline TBool IsTurn() const; - inline const TSize& SwSize() const; - inline void Copy(TUint32* aTarget, const TUint8* aSrc, TInt aBytes, TInt aHeight) const; - private: - const CDsa& iDsa; - }; - - -inline TDsa::TDsa(const CDsa& aDsa) : iDsa(aDsa) - { - } - -inline TBool TDsa::IsTurn() const - { - return iDsa.iStateFlags & CDsa::EOrientation90; - } - -inline TBool TDsa::IsFlip() const - { - return iDsa.iStateFlags & CDsa::EOrientation180; - } - -inline const TSize& TDsa::SwSize() const - { - return iDsa.SwSize(); - } - -inline void TDsa::Copy(TUint32* aTarget, const TUint8* aSrc, TInt aBytes, TInt aHeight) const - { - iDsa.iCopyFunction(iDsa, aTarget, aSrc, aBytes, aHeight); - } - -template -void ClipCopy(const TDsa& iDsa, TUint8* aTarget, - const TUint8* aSource, - const TRect& aUpdateRect, - const TRect& aSourceRect) - { - const S* source = reinterpret_cast(aSource); - const TInt lineWidth = aSourceRect.Width(); - - source += (aUpdateRect.iTl.iY * lineWidth); - const TInt sourceStartOffset = aUpdateRect.iTl.iX; - source += sourceStartOffset; - - T* targetPtr = reinterpret_cast(aTarget); - - const TInt scanLineWidth = iDsa.SwSize().iWidth; - - targetPtr += (aSourceRect.iTl.iY + aUpdateRect.iTl.iY ) * scanLineWidth; - const TInt targetStartOffset = (aUpdateRect.iTl.iX + aSourceRect.iTl.iX); - - targetPtr += targetStartOffset; - - - const TInt height = aUpdateRect.Height(); - - const TInt lineMove = iDsa.IsTurn() ? 1 : lineWidth; - const TInt copyLen = aUpdateRect.Width(); - - - if(iDsa.IsFlip()) - { - - targetPtr += scanLineWidth * (height - 1); - - for(TInt i = 0; i < height; i++) //source is always smaller - { - iDsa.Copy(reinterpret_cast(targetPtr), reinterpret_cast(source), copyLen, height); - source += lineMove; - targetPtr -= scanLineWidth; - } - } - else - { - - - for(TInt i = 0; i < height; i++) //source is always smaller - { - iDsa.Copy(reinterpret_cast(targetPtr), reinterpret_cast(source), copyLen, height); - source += lineMove; - targetPtr += scanLineWidth; // >> 2; - } - } - - } - - - -NONSHARABLE_CLASS(CDsaA) : public CDsa - { - public: - CDsaA(RWsSession& aSession); - private: - ~CDsaA(); - TUint8* LockSurface(); - void UnlockHWSurfaceRequestComplete(); - void UnlockHwSurface(); - void CreateSurfaceL(); - void Wipe(TInt aLength); - void Free(); - void Update(CFbsBitmap& aBmp); - void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice); - TInt ExternalUpdate(); - // void ExternalUpdate(); - protected: - CFbsBitmap* iBmp; - CFbsBitmap* iCopyBmp; - }; - - -CDsaA::CDsaA(RWsSession& aSession) : CDsa(aSession) - { - } - - -void CDsaA::Free() - { - delete iBmp; - iBmp = NULL; - } - -CDsaA::~CDsaA() - { - __ASSERT_DEBUG(iBmp == NULL, PANIC(KErrNotReady)); - delete iCopyBmp; - } - -TUint8* CDsaA::LockSurface() - { - iBmp->LockHeap(); - return reinterpret_cast(iBmp->DataAddress()); - } - -void CDsaA::UnlockHWSurfaceRequestComplete() - { - PANIC(KErrNotSupported); - } - -void CDsaA::UnlockHwSurface() - { - iBmp->UnlockHeap(); - SetUpdating(EFalse); - Update(*iBmp); - } - -void CDsaA::Update(CFbsBitmap& aBmp) - { - if(!Blitter(aBmp)) - { - if(SwSize() == HwRect().Size()) - Dsa().Gc()->BitBlt(HwRect().iTl, &aBmp); - else - Dsa().Gc()->DrawBitmap(HwRect(), &aBmp); - } - DrawOverlays(); - Dsa().ScreenDevice()->Update(); - } -void CDsaA::CreateSurfaceL() - { - delete iBmp; - iBmp = NULL; - iBmp = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iBmp->Create(SwSize(), DisplayMode())); - } - -void CDsaA::Wipe(TInt aLength) //dont call in drawing - { - iBmp->LockHeap(); - Mem::FillZ(iBmp->DataAddress(), aLength); - iBmp->UnlockHeap(); - } - - - -TInt CDsaA::ExternalUpdate() - { - if(iCopyBmp->Handle() == 0) - { - const TInt err = iCopyBmp->Duplicate(iBmp->Handle()); - if(err != KErrNone) - return err; - } - Update(*iCopyBmp); - return KErrNone; - } - -void CDsaA::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice) - { - iCopyBmp = new (ELeave) CFbsBitmap(); - CDsa::ConstructL(aWindow, aDevice); - } - - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -NONSHARABLE_CLASS(MDsbObs) - { - public: - virtual void SurfaceReady() = 0; - virtual CDirectScreenBitmap& Dsb() = 0; - }; - -NONSHARABLE_CLASS(CDsbSurface) : public CActive - { - public: - CDsbSurface(MDsbObs& aDsb); - TUint8* Address(); - void Complete(); - ~CDsbSurface(); - private: - void RunL(); - void DoCancel(); - private: - MDsbObs& iDsb; - TUint8* iAddress; - }; - -CDsbSurface::CDsbSurface(MDsbObs& aDsb) : CActive(CActive::EPriorityHigh) , iDsb(aDsb) - { - CActiveScheduler::Add(this); - } - -CDsbSurface::~CDsbSurface() - { - Cancel(); - } - -void CDsbSurface::Complete() - { - if(iAddress != NULL && !IsActive()) - { - iAddress = NULL; - SetActive(); - iDsb.Dsb().EndUpdate(iStatus); - } - } - -TUint8* CDsbSurface::Address() - { - if(iAddress == NULL && !IsActive()) - { - TAcceleratedBitmapInfo info; - if(KErrNone == iDsb.Dsb().BeginUpdate(info)) - iAddress = info.iAddress; - } - return iAddress; - } - -void CDsbSurface::RunL() - { - iDsb.SurfaceReady(); - } - -void CDsbSurface::DoCancel() - { - //empty - } - -NONSHARABLE_CLASS(CDsaB) : public CDsa, public MDsbObs - { - public: - CDsaB(RWsSession& aSession, TInt aFlags); - private: - ~CDsaB(); - TUint8* LockSurface(); - void UnlockHWSurfaceRequestComplete(); - void UnlockHwSurface(); - void CreateSurfaceL(); - void Wipe(TInt aLength); - void RecreateL(); - void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice); - CDirectScreenBitmap& Dsb(); - void SurfaceReady(); - TInt ExternalUpdate(); - private: - CDsbSurface* iSurface1; - CDsbSurface* iSurface2; - CDirectScreenBitmap* iDsb; - TInt iType; - }; - -CDsaB::CDsaB(RWsSession& aSession, TInt aFlags) : CDsa(aSession), iType(aFlags) - { - } - - - -void CDsaB::UnlockHWSurfaceRequestComplete() - { - iSurface1->Complete(); - if(iSurface2 != NULL) - iSurface2->Complete(); - } - -void CDsaB::CreateSurfaceL() - { - __ASSERT_ALWAYS(SwSize() == HwRect().Size(), PANIC(KErrNotSupported)); - } - -void CDsaB::Wipe(TInt aLength) //dont call in drawing - { - TUint8* addr = LockSurface(); - if(addr != NULL) - { - Mem::FillZ(addr, aLength); - UnlockHwSurface(); - } - } - - -void CDsaB::UnlockHwSurface() - { - EpocSdlEnv::Request(CDsa::ERequestUpdate); - } - -TUint8* CDsaB::LockSurface() - { - TUint8* addr = iSurface1->Address(); - if(addr == NULL && iSurface2 != NULL) - addr = iSurface2->Address(); - SetUpdating(addr == NULL); - return addr; - } - -void CDsaB::SurfaceReady() - { - SetUpdating(EFalse); - } - -CDirectScreenBitmap& CDsaB::Dsb() - { - return *iDsb; - } - -void CDsaB::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice) - { - if(iDsb == NULL) - iDsb = CDirectScreenBitmap::NewL(); - CDsa::ConstructL(aWindow, aDevice); - if(iSurface1 == NULL) - iSurface1 = new (ELeave) CDsbSurface(*this); - if(iSurface2 == NULL && iType & CDirectScreenBitmap::EDoubleBuffer) - iSurface2 = new (ELeave) CDsbSurface(*this); - } - -CDsaB::~CDsaB() - { - delete iSurface1; - delete iSurface2; - delete iDsb; - } - -void CDsaB::RecreateL() - { - iDsb->Close(); - iDsb->Create(HwRect(), CDirectScreenBitmap::TSettingsFlags(iType)); - } - -TInt CDsaB::ExternalUpdate() - { - if(LockSurface()) - { - UnlockHWSurfaceRequestComplete(); - return KErrNone; - } - return KErrNotReady; - } - - -///////////////////////////////////////////////////////////////////////////////////////////////////// - - -CDsa* CDsa::CreateL(RWsSession& aSession) - { - if(EpocSdlEnv::Flags(CSDL::EDrawModeDSB)) - { - TInt flags = CDirectScreenBitmap::ENone; - if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBDoubleBuffer)) - flags |= CDirectScreenBitmap::EDoubleBuffer; - if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBIncrentalUpdate)) - flags |= CDirectScreenBitmap::EIncrementalUpdate; - return new (ELeave) CDsaB(aSession, flags); - } - else - return new (ELeave) CDsaA(aSession); - } - - -void CDsa::RecreateL() - { - } - -void CDsa::Free() - { - } - -TSize CDsa::WindowSize() const - { - TSize size = iSwSize; - if(iStateFlags & EOrientation90) - { - const TInt tmp = size.iWidth; - size.iWidth = size.iHeight; - size.iHeight = tmp; - } - return size; - } - -void CDsa::SetSuspend() - { - iStateFlags |= ESdlThreadSuspend; - } - -void CDsa::ReleaseStop() - { - iStateFlags &= ~ESdlThreadExplicitStop; - } - - -TBool CDsa::Stopped() const - { - return (iStateFlags & ESdlThreadExplicitStop); - } - -void CDsa::SetOrientation(CSDL::TOrientationMode aOrientation) - { - TInt flags = 0; - switch(aOrientation) - { - case CSDL::EOrientation90: - flags = EOrientation90; - break; - case CSDL::EOrientation180: - flags = EOrientation180; - break; - case CSDL::EOrientation270: - flags = EOrientation90 | EOrientation180; - break; - case CSDL::EOrientation0: - flags = 0; - break; - } - if(flags != (iStateFlags & EOrientationFlags)) - { - iStateFlags |= EOrientationChanged; - iNewFlags = flags; //cannot be set during drawing... - } - } - -CDsa::~CDsa() - { - if(iDsa != NULL) - { - iDsa->Cancel(); - } - iOverlays.Close(); - delete iDsa; - User::Free(iLut256); - } - -void CDsa::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice) - { - if(iDsa != NULL) - { - iDsa->Cancel(); - delete iDsa; - iDsa = NULL; - } - - iDsa = CDirectScreenAccess::NewL( - iSession, - aDevice, - aWindow, - *this); - - if(iLut256 == NULL) - iLut256 = (TUint32*) User::AllocL(256 * sizeof(TUint32)); - iTargetMode = aWindow.DisplayMode(); - iTargetBpp = BytesPerPixel(DisplayMode()); - iScreenRect = TRect(aWindow.Position(), aWindow.Size()); - SetTargetRect(); - RestartL(); - } - -void CDsa::DrawOverlays() - { - const TInt last = iOverlays.Count() - 1; - for(TInt i = last; i >= 0 ; i--) - iOverlays[i].iOverlay->Draw(*iDsa->Gc(), HwRect(), SwSize()); - } - -TInt CDsa::AppendOverlay(MOverlay& aOverlay, TInt aPriority) - { - TInt i; - for(i = 0; i < iOverlays.Count() && iOverlays[i].iPriority < aPriority; i++) - {} - const TOverlay overlay = {&aOverlay, aPriority}; - return iOverlays.Insert(overlay, i); - } - -TInt CDsa::RemoveOverlay(MOverlay& aOverlay) - { - for(TInt i = 0; i < iOverlays.Count(); i++) - { - if(iOverlays[i].iOverlay == &aOverlay) - { - iOverlays.Remove(i); - return KErrNone; - } - } - return KErrNotFound; - } - -void CDsa::LockPalette(TBool aLock) - { - if(aLock) - iStateFlags |= EPaletteLocked; - else - iStateFlags &= ~EPaletteLocked; - } -TInt CDsa::SetPalette(TInt aFirst, TInt aCount, TUint32* aPalette) - { - if(iLut256 == NULL) - return KErrNotFound; - const TInt count = aCount - aFirst; - if(count > 256) - return KErrArgument; - if(iStateFlags & EPaletteLocked) - return KErrNone; - for(TInt i = aFirst; i < count; i++) //not so busy here:-) - { - iLut256[i] = aPalette[i]; - } - return KErrNone; - } - - - -void CDsa::RestartL() - { - //const TBool active = iDsa->IsActive(); - - //if(!active) - - iDsa->StartL(); - - const RRegion* r = iDsa->DrawingRegion(); - const TRect rect = r->BoundingRect(); - iDsa->Gc()->SetClippingRegion(r); - - if(rect != iScreenRect) - { - // iDsa->Cancel(); - return ; - } - - - - //iScreenRect = rect; //to ensure properly set, albeit may not(?) match to value SDL has - therefore may has to clip - //targetrect shall no change - SetTargetRect(); - RecreateL(); - - iStateFlags |= ERunning; - - ReleaseStop(); - if(iStateFlags & ESdlThreadSuspend) - { - EpocSdlEnv::Resume(); - iStateFlags &= ~ ESdlThreadSuspend; - } - EpocSdlEnv::ObserverEvent(MSDLObserver::EEventWindowReserved); - } - -CDsa::CDsa(RWsSession& aSession) : - iSession(aSession), - iStateFlags(0) - { -// CActiveScheduler::Add(this); - iCFTable[0] = CopyMem; - iCFTable[1] = CopyMemFlipReversed; - iCFTable[2] = CopyMemReversed; - iCFTable[3] = CopyMemFlip; - - iCFTable[4] = Copy256; - iCFTable[5] = Copy256FlipReversed; - iCFTable[6] = Copy256Reversed; - iCFTable[7] = Copy256Flip; - - - iCFTable[8] = CopySlow; - iCFTable[9] = CopySlowFlipReversed; - iCFTable[10] = CopySlowReversed; - iCFTable[11] = CopySlowFlip; - } - -RWsSession& CDsa::Session() - { - return iSession; - } - -TInt CDsa::RedrawRequest() - { - if(!(iStateFlags & (EUpdating) && (iStateFlags & ERunning))) - { - return ExternalUpdate(); - } - return KErrNotReady; - } - -TUint8* CDsa::LockHwSurface() - { - if((iStateFlags & EUpdating) == 0) //else frame is skipped - { - return LockSurface(); - } - return NULL; - } - -/* -void CDsa::RunL() - { - iStateFlags &= ~EUpdating; - } - - -void CDsa::DoCancel() - { - iStateFlags &= ~EUpdating; - //nothing can do, just wait? - } -*/ - - -TInt CDsa::AllocSurface(TBool aHwSurface, const TSize& aSize, TDisplayMode aMode) - { - if(aHwSurface && aMode != DisplayMode()) - return KErrArgument; - - iSourceMode = aMode; - - iSourceBpp = BytesPerPixel(aMode); - - const TSize size = WindowSize(); - if(aSize.iWidth > size.iWidth) - return KErrTooBig; - if(aSize.iHeight > size.iHeight) - return KErrTooBig; - - TRAPD(err, CreateSurfaceL()); - if(err != KErrNone) - return err; - - SetCopyFunction(); - - return KErrNone; - } - - -void CDsa::CreateZoomerL(const TSize& aSize) - { - iSwSize = aSize; - iStateFlags |= EResizeRequest; - CreateSurfaceL(); - SetTargetRect(); - } - - -/* -void SaveBmp(const TDesC& aName, const TAny* aData, TInt aLength, const TSize& aSz, TDisplayMode aMode) - { - CFbsBitmap* s = new CFbsBitmap(); - s->Create(aSz, aMode); - s->LockHeap(); - TUint32* addr = s->DataAddress(); - Mem::Copy(addr, aData, aLength); - s->UnlockHeap(); - s->Save(aName); - s->Reset(); - delete s; - } - -void SaveBmp(const TDesC& aName, const TUint32* aData, const TSize& aSz) - { - CFbsBitmap* s = new CFbsBitmap(); - s->Create(aSz, EColor64K); - TBitmapUtil bmp(s); - bmp.Begin(TPoint(0, 0)); - for(TInt j = 0; j < aSz.iHeight; j++) - { - bmp.SetPos(TPoint(0, j)); - for(TInt i = 0; i < aSz.iWidth; i++) - { - bmp.SetPixel(*aData); - aData++; - bmp.IncXPos(); - } - } - bmp.End(); - s->Save(aName); - s->Reset(); - delete s; - } - -TBuf<16> FooName(TInt aFoo) - { - TBuf<16> b; - b.Format(_L("C:\\pic%d.mbm"), aFoo); - return b; - } - -void ClipCopy(TUint8* aTarget, const TUint8* aSource, const TRect& aRect, const TPoint& aTargetPos) - { - const TInt iSourceBpp = 1; - const TInt iTargetBpp = 4; - const TInt iScanLineWidth = 800; - - TUint8* target = aTarget; - const TUint8* source = aSource; - const TInt lineWidth = aRect.Width(); - source += iSourceBpp * (aRect.iTl.iY * lineWidth); - const TInt sourceStartOffset = iSourceBpp * aRect.iTl.iX; - source += sourceStartOffset; - target += iTargetBpp * ((aTargetPos.iY + aRect.iTl.iY ) * lineWidth); - const TInt targetStartOffset = iTargetBpp * (aRect.iTl.iX + aTargetPos.iX); - target += targetStartOffset; - TUint32* targetPtr = reinterpret_cast(target); - const TInt targetWidth = iScanLineWidth >> 2; - const TInt height = aRect.Height(); - } -*/ -/* -void CDsa::ClipCopy(TUint8* aTarget, - const TUint8* aSource, - const TRect& aUpdateRect, - const TRect& aSourceRect) const - { - //TUint8* target = aTarget; - const TUint32* source = (const TUint32*) aSource; - const TInt lineWidth = aSourceRect.Width(); - - source += (aUpdateRect.iTl.iY * lineWidth); - const TInt sourceStartOffset = aUpdateRect.iTl.iX; - source += sourceStartOffset; - - TUint32* targetPtr = reinterpret_cast(aTarget); - - targetPtr += (aSourceRect.iTl.iY + aUpdateRect.iTl.iY ) * SwSize().iWidth; - const TInt targetStartOffset = (aUpdateRect.iTl.iX + aSourceRect.iTl.iX); - - targetPtr += targetStartOffset; - -// TUint32* targetPtr = reinterpret_cast(target); - - const TInt targetWidth32 = SwSize().iWidth; - - const TInt height = aUpdateRect.Height(); - - const TInt lineMove = iStateFlags & EOrientation90 ? 1 : lineWidth; - const TInt copyLen = aUpdateRect.Width(); - - - if(iStateFlags & EOrientation180) - { - - targetPtr += targetWidth32 * (height - 1); - - for(TInt i = 0; i < height; i++) //source is always smaller - { - iCopyFunction(*this, targetPtr, (TUint8*)source, copyLen, height); - source += lineMove; - targetPtr -= targetWidth32; - } - } - else - { - - - for(TInt i = 0; i < height; i++) //source is always smaller - { - iCopyFunction(*this, targetPtr, (TUint8*)source, copyLen, height); - source += lineMove; - targetPtr += targetWidth32; // >> 2; - } - } - - } - -*/ - -void CDsa::ClipCopy(TUint8* aTarget, const TUint8* aSource, const TRect& aRect, const TPoint& aTargetPos) const - { - TUint8* target = aTarget; - const TUint8* source = aSource; - const TInt lineWidth = aRect.Width(); - source += iSourceBpp * (aRect.iTl.iY * lineWidth); - TInt sourceStartOffset = iSourceBpp * aRect.iTl.iX; - source += sourceStartOffset; - target += iTargetBpp * ((aTargetPos.iY + aRect.iTl.iY ) * lineWidth); - TInt targetStartOffset = iTargetBpp * (aRect.iTl.iX + aTargetPos.iX); - target += targetStartOffset; - TUint32* targetPtr = reinterpret_cast(target); - const TInt targetWidth = iScanLineWidth >> 2; - const TInt height = aRect.Height(); - - TInt lineMove = iStateFlags & EOrientation90 ? 1 : lineWidth; - - if(iStateFlags & EOrientation180) - { - - targetPtr += targetWidth * (height - 1); - - for(TInt i = 0; i < height; i++) //source is always smaller - { - iCopyFunction(*this, targetPtr, source, lineWidth, height); - source += lineMove; - targetPtr -= targetWidth; - } - } - else - { - - - for(TInt i = 0; i < height; i++) //source is always smaller - { - iCopyFunction(*this, targetPtr, source, lineWidth, height); - source += lineMove; - targetPtr += targetWidth; - } - } - - } - - - - /* -void CDsa::ClipCopy(TUint8* aTarget, - const TUint8* aSource, - const TRect& aUpdateRect, - const TRect& aSourceRect) const - { - const TDsa dsa(*this); - switch(iSourceBpp) - { - case 1: - ::ClipCopy(dsa, aTarget, aSource, aUpdateRect, aSourceRect); - break; - case 2: - ::ClipCopy(dsa, aTarget, aSource, aUpdateRect, aSourceRect); - break; - case 4: - ::ClipCopy(dsa, aTarget, aSource, aUpdateRect, aSourceRect); - break; - } - } - - -*/ - - - -void CDsa::Wipe() //dont call in drawing - { - if(IsDsaAvailable()) - Wipe(iTargetBpp * SwSize().iWidth * SwSize().iHeight); - } - -void CDsa::SetCopyFunction() - { - //calculate offset to correct function in iCFTable according to given parameters - TInt function = 0; - const TInt KCopyFunctions = 4; - const TInt KOffsetToNative = 0; - const TInt KOffsetTo256 = KOffsetToNative + KCopyFunctions; - const TInt KOffsetToOtherModes = KOffsetTo256 + KCopyFunctions; - const TInt KOffsetTo90Functions = 1; - const TInt KOffsetTo180Functions = 2; - - if(iSourceMode == DisplayMode()) - function = KOffsetToNative; //0 - else if(iSourceMode == EColor256) - function = KOffsetTo256; //4 - else - function = KOffsetToOtherModes; //8 - - if(iStateFlags & EOrientation90) - function += KOffsetTo90Functions; // + 1 - if(iStateFlags & EOrientation180) - function += KOffsetTo180Functions; //+ 2 - - iCopyFunction = iCFTable[function]; - - Wipe(); - } - -inline void Rotate(TRect& aRect) - { - const TInt dx = aRect.iBr.iX - aRect.iTl.iX; - const TInt dy = aRect.iBr.iY - aRect.iTl.iY; - - aRect.iBr.iX = aRect.iTl.iX + dy; - aRect.iBr.iY = aRect.iTl.iY + dx; - - const TInt tmp = aRect.iTl.iX; - aRect.iTl.iX = aRect.iTl.iY; - aRect.iTl.iY = tmp; - } - -/* -int bar = 0; -*/ -/* -TBool CDsa::AddUpdateRect(const TUint8* aBits, const TRect& aUpdateRect, const TRect& aRect) - { - - if(iStateFlags & EOrientationChanged) - { - iStateFlags &= ~EOrientationFlags; - iStateFlags |= iNewFlags; - SetCopyFunction(); - iStateFlags &= ~EOrientationChanged; - EpocSdlEnv::WaitDeviceChange(); - return EFalse; //skip this frame as data is may be changed - } - - if(iTargetAddr == NULL) - { - iTargetAddr = LockHwSurface(); - } - - TUint8* target = iTargetAddr; - if(target == NULL) - return EFalse; - - - TRect targetRect = TRect(TPoint(0, 0), SwSize()); - - TRect sourceRect = aRect; - TRect updateRect = aUpdateRect; - -// TPoint move(0, 0); - - - if(iStateFlags & EOrientation90) - { - Rotate(sourceRect); - Rotate(updateRect); - } - - if(iSourceMode != DisplayMode() || targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0)) - { - sourceRect.Intersection(targetRect); //so source always smaller or equal than target - //updateRect.Intersection(targetRect); - ClipCopy(target, aBits, updateRect, sourceRect); - } - else - { - const TInt byteCount = aRect.Width() * aRect.Height() * iSourceBpp; //this could be stored - Mem::Copy(target, aBits, byteCount); - } - - return ETrue; - } - */ - -TBool CDsa::AddUpdateRect(const TUint8* aBits, const TRect& aUpdateRect, const TRect& aRect) - { - - if(iStateFlags & EOrientationChanged) - { - iStateFlags &= ~EOrientationFlags; - iStateFlags |= iNewFlags; - SetCopyFunction(); - iStateFlags &= ~EOrientationChanged; - EpocSdlEnv::WaitDeviceChange(); - return EFalse; //skip this frame as data is may be changed - } - - if(iTargetAddr == NULL) - { - iTargetAddr = LockHwSurface(); - } - TUint8* target = iTargetAddr; - if(target == NULL) - return EFalse; - - - TRect targetRect = Rect(); - TRect sourceRect = aRect; - TRect updateRect = aUpdateRect; - - if(iStateFlags & EOrientation90) - { - Rotate(sourceRect); - Rotate(updateRect); - } - - if(iSourceMode != DisplayMode() || targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0)) - { - sourceRect.Intersection(targetRect); //so source always smaller or equal than target - updateRect.Intersection(targetRect); - ClipCopy(target, aBits, updateRect, sourceRect.iTl); - } - else - { - const TInt byteCount = aRect.Width() * aRect.Height() * iSourceBpp; //this could be stored - Mem::Copy(target, aBits, byteCount); - } - - return ETrue; - } -void CDsa::UpdateSwSurface() - { - iTargetAddr = NULL; - UnlockHwSurface(); //could be faster if does not use AO, but only check status before redraw, then no context switch needed - } - - -void CDsa::Resume() - { - if(Stopped()) - Restart(RDirectScreenAccess::ETerminateRegion); - } - -void CDsa::DoStop() - { - if(IsDsaAvailable()) - iStateFlags |= ESdlThreadExplicitStop; - Stop(); - } - -void CDsa::Stop() - { - iStateFlags &= ~ERunning; -// Cancel(); //can be called only from main! - iDsa->Cancel(); - } - -void CDsa::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { -// iStateFlags |= EChangeNotify; - Stop(); - } - -void CDsa::Restart(RDirectScreenAccess::TTerminationReasons aReason) - { - if(aReason == RDirectScreenAccess::ETerminateRegion) //auto restart - { - TRAPD(err, RestartL()); - PANIC_IF_ERROR(err); - } - } - -void CDsa::SetBlitter(MBlitter* aBlitter) - { - iBlitter = aBlitter; - } - - -TPoint CDsa::WindowCoordinates(const TPoint& aPoint) const - { - TPoint pos = aPoint - iScreenRect.iTl; - const TSize asz = iScreenRect.Size(); - if(iStateFlags & EOrientation180) - { - pos.iX = asz.iWidth - pos.iX; - pos.iY = asz.iHeight - pos.iY; - } - if(iStateFlags & EOrientation90) - { - pos.iX = aPoint.iY; - pos.iY = aPoint.iX; - } - pos.iX <<= 16; - pos.iY <<= 16; - pos.iX /= asz.iWidth; - pos.iY /= asz.iHeight; - pos.iX *= iSwSize.iWidth; - pos.iY *= iSwSize.iHeight; - pos.iX >>= 16; - pos.iY >>= 16; - return pos; - } - -void CDsa::SetTargetRect() - { - iTargetRect = iScreenRect; - if(iStateFlags & EResizeRequest && EpocSdlEnv::Flags(CSDL::EAllowImageResizeKeepRatio)) - { - const TSize asz = iScreenRect.Size(); - const TSize sz = iSwSize; - - TRect rect; - - const TInt dh = (sz.iHeight << 16) / sz.iWidth; - - if((asz.iWidth * dh ) >> 16 <= asz.iHeight) - { - rect.SetRect(TPoint(0, 0), TSize(asz.iWidth, (asz.iWidth * dh) >> 16)); - } - else - { - const TInt dw = (sz.iWidth << 16) / sz.iHeight; - rect.SetRect(TPoint(0, 0), TSize((asz.iHeight * dw) >> 16, asz.iHeight)); - } - rect.Move((asz.iWidth - rect.Size().iWidth) >> 1, (asz.iHeight - rect.Size().iHeight) >> 1); - - iTargetRect = rect; - iTargetRect.Move(iScreenRect.iTl); - - } - if(!(iStateFlags & EResizeRequest)) - iSwSize = iScreenRect.Size(); -// iScanLineWidth = /*iTargetBpp **/ SwSize().iWidth; - } - -/*) -TBool CDsa::ChangeTrigger() - { - const TBool change = iStateFlags & EChangeNotify; - iStateFlags &= ~EChangeNotify; - return change; - } -*/ -///////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CDsa::Copy256(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - TUint32* target = aTarget; - const TUint32* endt = target + aBytes; - const TUint8* source = aSource; - while(target < endt) - { - *target++ = aDsa.iLut256[*source++]; - } - } - -void CDsa::Copy256Reversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - const TUint32* target = aTarget; - TUint32* endt = aTarget + aBytes; - const TUint8* source = aSource; - while(target < endt) - { - *(--endt) = aDsa.iLut256[*source++]; - } - } - -void CDsa::Copy256Flip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - TUint32* target = aTarget; - const TUint32* endt = target + aBytes; - const TUint8* column = aSource; - - while(target < endt) - { - *target++ = aDsa.iLut256[*column]; - column += aLineLen; - } - } - -void CDsa::Copy256FlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - const TUint32* target = aTarget; - TUint32* endt = aTarget + aBytes; - const TUint8* column = aSource; - - while(target < endt) - { - *(--endt) = aDsa.iLut256[*column]; - column += aLineLen; - } - } - -void CDsa::CopyMem(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - const TUint32* src = reinterpret_cast(aSource); - Mem::Copy(aTarget, src, aBytes << 2); - } - -void CDsa::CopyMemFlip(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - TUint32* target = aTarget; - const TUint32* endt = target + aBytes; - const TUint32* column = reinterpret_cast(aSource); - - while(target < endt) - { - *target++ = *column; - column += aLineLen; - } - } - -void CDsa::CopyMemReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - const TUint32* target = aTarget; - TUint32* endt = aTarget + aBytes; - const TUint32* source = reinterpret_cast(aSource); - while(target < endt) - { - *(--endt) = *source++; - } - } - - -void CDsa::CopyMemFlipReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - const TUint32* target = aTarget; - TUint32* endt = aTarget + aBytes; - const TUint32* column = reinterpret_cast(aSource); - - while(target < endt) - { - *(--endt) = *column; - column += aLineLen; - } - } - -/* - -LOCAL_C TRgb rgb16MA(TInt aValue) - { - return TRgb::Color16MA(aValue); - } -*/ -NONSHARABLE_CLASS(MRgbCopy) - { - public: - virtual void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed) = 0; - virtual void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed) = 0; - }; - -template -NONSHARABLE_CLASS(TRgbCopy) : public MRgbCopy - { - public: - TRgbCopy(TDisplayMode aMode); - void* operator new(TUint aBytes, TAny* aMem); - void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed); - void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed); - static TUint32 Gray256(const TUint8& aPixel); - static TUint32 Color256(const TUint8& aPixel); - static TUint32 Color4K(const TUint16& aPixel); - static TUint32 Color64K(const TUint16& aPixel); - static TUint32 Color16M(const TUint32& aPixel); - static TUint32 Color16MU(const TUint32& aPixel); - static TUint32 Color16MA(const TUint32& aPixel); - private: - typedef TUint32 (*TRgbFunc) (const T& aValue); - TRgbFunc iFunc; - }; - - -template -void* TRgbCopy::operator new(TUint /*aBytes*/, TAny* aMem) - { - return aMem; - } - -template -TRgbCopy::TRgbCopy(TDisplayMode aMode) - { - switch(aMode) - { - case EGray256 : iFunc = (TRgbFunc) Gray256; break; - case EColor256 : iFunc = (TRgbFunc) Color256; break; - case EColor4K : iFunc = (TRgbFunc) Color4K; break; - case EColor64K : iFunc = (TRgbFunc) Color64K; break; - case EColor16M : iFunc = (TRgbFunc) Color16M; break; - case EColor16MU : iFunc = (TRgbFunc) Color16MU; break; - case EColor16MA : iFunc = (TRgbFunc) Color16MA; break; - default: - PANIC(KErrNotSupported); - } - } - -template -void TRgbCopy::Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed) - { - const T* source = reinterpret_cast(aSource); - TUint32* target = aTarget; - TUint32* endt = target + aBytes; - - if(aReversed) - { - while(target < endt) - { - const T value = *source++; - *(--endt) = iFunc(value);//iFunc(value).Value(); - } - } - else - { - while(target < endt) - { - const T value = *source++; - *target++ = iFunc(value);//iFunc(value).Value(); - } - } - } - -template -void TRgbCopy::FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed) - { - const T* column = reinterpret_cast(aSource); - TUint32* target = aTarget; - TUint32* endt = target + aBytes; - - if(aReversed) - { - while(target < endt) - { - *(--endt) = iFunc(*column); - column += aLineLen; - } - } - else - { - while(target < endt) - { - *target++ = iFunc(*column); - column += aLineLen; - } - } - } - -template TUint32 TRgbCopy::Gray256(const TUint8& aPixel) - { - const TUint32 px = aPixel << 16 | aPixel << 8 | aPixel; - return px; - } - -template TUint32 TRgbCopy::Color256(const TUint8& aPixel) - { - return TRgb::Color256(aPixel).Value(); - } - -template TUint32 TRgbCopy::Color4K(const TUint16& aPixel) - { - TUint32 col = (aPixel & 0xF00) << 12; - col |= (aPixel & 0xF00) << 8; - - col |= (aPixel & 0x0F0) << 8; - col |= (aPixel & 0x0F0); - - col |= (aPixel & 0x00F) << 4; - col |= (aPixel & 0x00F); - - return col; - } - -template TUint32 TRgbCopy::Color64K(const TUint16& aPixel) - { - TUint32 col = (aPixel & 0xF800)<< 8; - col |= (aPixel & 0xE000) << 3; - - col |= (aPixel & 0x07E0) << 5; - col |= (aPixel & 0xC0) >> 1; - - col |= (aPixel & 0x07E0) << 3; - col |= (aPixel & 0x1C) >> 2; - - return col; - } - -template TUint32 TRgbCopy::Color16M(const TUint32& aPixel) - { - return TRgb::Color16M(aPixel).Value(); - } - -template TUint32 TRgbCopy::Color16MU(const TUint32& aPixel) - { - return TRgb::Color16MU(aPixel).Value(); - } - -template TUint32 TRgbCopy::Color16MA(const TUint32& aPixel) - { - return TRgb::Color16MA(aPixel).Value(); - } - -typedef TUint64 TStackMem; - -LOCAL_C MRgbCopy* GetCopy(TAny* mem, TDisplayMode aMode) - { - if(aMode == EColor256 || aMode == EGray256) - { - return new (mem) TRgbCopy(aMode); - } - if(aMode == EColor4K || aMode == EColor64K) - { - return new (mem) TRgbCopy(aMode); - } - if(aMode == EColor16M || aMode == EColor16MU || aMode == EColor16MA) - { - return new (mem) TRgbCopy(aMode); - } - PANIC(KErrNotSupported); - return NULL; - } - - -void CDsa::CopySlowFlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - TStackMem mem = 0; - GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, ETrue); - } - -void CDsa::CopySlowFlip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - TStackMem mem = 0; - GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, EFalse); - } - -void CDsa::CopySlow(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - TStackMem mem = 0; - GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, EFalse); - } - -void CDsa::CopySlowReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - TStackMem mem = 0; - GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, ETrue); - } - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////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 @@ -#include "dsa.h" -#include "sdlepocapi.h" -#include - -LOCAL_C TInt BytesPerPixel(TDisplayMode aMode) - { - return ((TDisplayModeUtils::NumDisplayModeBitsPerPixel(aMode) - 1) >> 3) + 1; - } - - -//////////////////////////////////////////////////////////////////////////////////////////////// - -NONSHARABLE_CLASS(CDsaA) : public CDsa - { - public: - CDsaA(RWsSession& aSession); - private: - ~CDsaA(); - TUint8* LockSurface(); - void UnlockHWSurfaceRequestComplete(); - void UnlockHwSurface(); - void CreateSurfaceL(); - void Wipe(TInt aLength); - void RecreateL(); - void Free(); - TInt ExternalUpdate() {return 0;} - private: - CFbsBitmap* iBmp; - }; - - -CDsaA::CDsaA(RWsSession& aSession) : CDsa(aSession) - { - } - -void CDsaA::Free() - { - delete iBmp; - iBmp = NULL; - } - -CDsaA::~CDsaA() - { - __ASSERT_DEBUG(iBmp == NULL, PANIC(KErrNotReady)); - } - -TUint8* CDsaA::LockSurface() - { - iBmp->LockHeap(); - return reinterpret_cast(iBmp->DataAddress()); - } - -void CDsaA::UnlockHWSurfaceRequestComplete() - { - PANIC(KErrNotSupported); - } - -void CDsaA::UnlockHwSurface() - { - iBmp->UnlockHeap(); - SetUpdating(EFalse); - Dsa().Gc()->BitBlt(HwRect().iTl, iBmp); - Dsa().ScreenDevice()->Update(); - } - -void CDsaA::CreateSurfaceL() - { - delete iBmp; - iBmp = NULL; - iBmp = new (ELeave) CFbsBitmap(); - User::LeaveIfError(iBmp->Create(HwRect().Size(), DisplayMode())); - } - -void CDsaA::Wipe(TInt aLength) //dont call in drawing - { - iBmp->LockHeap(); - Mem::FillZ(iBmp->DataAddress(), aLength); - iBmp->UnlockHeap(); - } - -void CDsaA::RecreateL() - { - } - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -NONSHARABLE_CLASS(MDsbObs) - { - public: - virtual void SurfaceReady() = 0; - virtual CDirectScreenBitmap& Dsb() = 0; - }; - -NONSHARABLE_CLASS(CDsbSurface) : public CActive - { - public: - CDsbSurface(MDsbObs& aDsb); - TUint8* Address(); - void Complete(); - ~CDsbSurface(); - private: - void RunL(); - void DoCancel(); - private: - MDsbObs& iDsb; - TUint8* iAddress; - }; - -CDsbSurface::CDsbSurface(MDsbObs& aDsb) : CActive(CActive::EPriorityHigh) , iDsb(aDsb) - { - CActiveScheduler::Add(this); - } - -CDsbSurface::~CDsbSurface() - { - Cancel(); - } - -void CDsbSurface::Complete() - { - if(iAddress != NULL && !IsActive()) - { - iAddress = NULL; - SetActive(); - iDsb.Dsb().EndUpdate(iStatus); - } - } - -TUint8* CDsbSurface::Address() - { - if(iAddress == NULL && !IsActive()) - { - TAcceleratedBitmapInfo info; - if(KErrNone == iDsb.Dsb().BeginUpdate(info)) - iAddress = info.iAddress; - } - return iAddress; - } - -void CDsbSurface::RunL() - { - iDsb.SurfaceReady(); - } - -void CDsbSurface::DoCancel() - { - //empty - } - -NONSHARABLE_CLASS(CDsaB) : public CDsa, public MDsbObs - { - public: - CDsaB(RWsSession& aSession); - private: - ~CDsaB(); - TUint8* LockSurface(); - void UnlockHWSurfaceRequestComplete(); - void UnlockHwSurface(); - void CreateSurfaceL(); - void Wipe(TInt aLength); - void RecreateL(); - void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice); - void Free(); - CDirectScreenBitmap& Dsb(); - void SurfaceReady(); - TInt ExternalUpdate() {return 0;} - private: - CDsbSurface* iSurface1; - CDsbSurface* iSurface2; - CDirectScreenBitmap* iDsb; - }; - -CDsaB::CDsaB(RWsSession& aSession) : CDsa(aSession) - { - } - -void CDsaB::Free() - { - } - -void CDsaB::UnlockHWSurfaceRequestComplete() - { - iSurface1->Complete(); - iSurface2->Complete(); - } - -void CDsaB::CreateSurfaceL() - { - } - -void CDsaB::Wipe(TInt aLength) //dont call in drawing - { - TUint8* addr = LockSurface(); - if(addr != NULL) - { - Mem::FillZ(addr, aLength); - UnlockHwSurface(); - } - } - -void CDsaB::UnlockHwSurface() - { - EpocSdlEnv::Request(CDsa::ERequestUpdate); - } - -TUint8* CDsaB::LockSurface() - { - TUint8* addr = iSurface1->Address(); - if(addr == NULL) - addr = iSurface2->Address(); - SetUpdating(addr == NULL); - return addr; - } - -void CDsaB::SurfaceReady() - { - SetUpdating(EFalse); - } - -CDirectScreenBitmap& CDsaB::Dsb() - { - return *iDsb; - } - -void CDsaB::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice) - { - if(iDsb == NULL) - iDsb = CDirectScreenBitmap::NewL(); - CDsa::ConstructL(aWindow, aDevice); - iSurface1 = new (ELeave) CDsbSurface(*this); - iSurface2 = new (ELeave) CDsbSurface(*this); - } - -CDsaB::~CDsaB() - { - delete iSurface1; - delete iSurface2; - delete iDsb; - } - -void CDsaB::RecreateL() - { - iDsb->Close(); - iDsb->Create(HwRect(), CDirectScreenBitmap::EDoubleBuffer); - } - -///////////////////////////////////////////////////////////////////////////////////////////////////// - - -TSize CDsa::WindowSize() const - { - TSize size = HwRect().Size(); - if(iStateFlags & EOrientation90) - { - const TInt tmp = size.iWidth; - size.iWidth = size.iHeight; - size.iHeight = tmp; - } - return size; - } - -void CDsa::SetSuspend() - { - iStateFlags |= ESdlThreadSuspend; - } - -void CDsa::ReleaseStop() - { - iStateFlags &= ~ESdlThreadExplicitStop; - } - - -TBool CDsa::Stopped() const - { - return (iStateFlags & ESdlThreadExplicitStop); - } - -void CDsa::SetOrientation(CSDL::TOrientationMode aOrientation) - { - TInt flags = 0; - switch(aOrientation) - { - case CSDL::EOrientation90: - flags = EOrientation90; - break; - case CSDL::EOrientation180: - flags = EOrientation180; - break; - case CSDL::EOrientation270: - flags = EOrientation90 | EOrientation180; - break; - case CSDL::EOrientation0: - flags = 0; - break; - } - if(flags != (iStateFlags & EOrientationFlags)) - { - iStateFlags |= EOrientationChanged; - iNewFlags = flags; //cannot be set during drawing... - } - } - -CDsa::~CDsa() - { - if(iDsa != NULL) - { - iDsa->Cancel(); - } - delete iDsa; - User::Free(iLut256); - } - -void CDsa::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice) - { - if(iDsa != NULL) - { - iDsa->Cancel(); - delete iDsa; - iDsa = NULL; - } - - - iDsa = CDirectScreenAccess::NewL( - iSession, - aDevice, - aWindow, - *this); - - if(iLut256 == NULL) - iLut256 = (TUint32*) User::AllocL(256 * sizeof(TUint32)); - iTargetMode = aWindow.DisplayMode(); - iTargetBpp = BytesPerPixel(DisplayMode()); - iTargetRect = TRect(aWindow.Position(), aWindow.Size()); - RestartL(); - } - -void CDsa::LockPalette(TBool aLock) - { - if(aLock) - iStateFlags |= EPaletteLocked; - else - iStateFlags &= ~EPaletteLocked; - } -TInt CDsa::SetPalette(TInt aFirst, TInt aCount, TUint32* aPalette) - { - if(iLut256 == NULL) - return KErrNotFound; - const TInt count = aCount - aFirst; - if(count > 256) - return KErrArgument; - if(iStateFlags & EPaletteLocked) - return KErrNone; - for(TInt i = aFirst; i < count; i++) //not so busy here:-) - { - iLut256[i] = aPalette[i]; - } - return KErrNone; - } - - - - -void CDsa::RestartL() - { - //const TBool active = iDsa->IsActive(); - - //if(!active) - iDsa->StartL(); - - RRegion* r = iDsa->DrawingRegion(); - iDsa->Gc()->SetClippingRegion(r); - TRect rect = r->BoundingRect(); - - if(rect.IsEmpty()) - { - return; - } - - iScreenRect = rect; //to ensure properly set, albeit may not(?) match to value SDL has - therefore may has to clip - - RecreateL(); - - iStateFlags |= ERunning; -// iScanLineWidth = iTargetBpp * HwRect().Width(); - ReleaseStop(); - if(iStateFlags & ESdlThreadSuspend) - { - EpocSdlEnv::Resume(); - iStateFlags &= ~ ESdlThreadSuspend; - } - } - -CDsa::CDsa(RWsSession& aSession) : - iSession(aSession), - iStateFlags(0) - { -// CActiveScheduler::Add(this); - iCFTable[0] = CopyMem; - iCFTable[1] = CopyMemFlipReversed; - iCFTable[2] = CopyMemReversed; - iCFTable[3] = CopyMemFlip; - - iCFTable[4] = Copy256; - iCFTable[5] = Copy256FlipReversed; - iCFTable[6] = Copy256Reversed; - iCFTable[7] = Copy256Flip; - - - iCFTable[8] = CopySlow; - iCFTable[9] = CopySlowFlipReversed; - iCFTable[10] = CopySlowReversed; - iCFTable[11] = CopySlowFlip; - } - -RWsSession& CDsa::Session() - { - return iSession; - } - - - -TUint8* CDsa::LockHwSurface() - { - if((iStateFlags & EUpdating) == 0) //else frame is skipped - { - return LockSurface(); - } - return NULL; - } - -/* -void CDsa::RunL() - { - iStateFlags &= ~EUpdating; - } - - -void CDsa::DoCancel() - { - iStateFlags &= ~EUpdating; - //nothing can do, just wait? - } -*/ - -TInt CDsa::AllocSurface(TBool aHwSurface, const TSize& aSize, TDisplayMode aMode) - { - if(aHwSurface && aMode != DisplayMode()) - return KErrArgument; - - iSourceMode = aMode; - - iSourceBpp = BytesPerPixel(aMode); - - const TSize size = WindowSize(); - if(aSize.iWidth > size.iWidth) - return KErrTooBig; - if(aSize.iHeight > size.iHeight) - return KErrTooBig; - - TRAPD(err, CreateSurfaceL()); - if(err != KErrNone) - return err; - - - SetCopyFunction(); - - EpocSdlEnv::ObserverEvent(MSDLObserver::EEventWindowReserved); - - return KErrNone; - } - - -/* -void SaveBmp(const TDesC& aName, const TAny* aData, TInt aLength, const TSize& aSz, TDisplayMode aMode) - { - CFbsBitmap* s = new CFbsBitmap(); - s->Create(aSz, aMode); - s->LockHeap(); - TUint32* addr = s->DataAddress(); - Mem::Copy(addr, aData, aLength); - s->UnlockHeap(); - s->Save(aName); - s->Reset(); - delete s; - } - -void SaveBmp(const TDesC& aName, const TUint32* aData, const TSize& aSz) - { - CFbsBitmap* s = new CFbsBitmap(); - s->Create(aSz, EColor64K); - TBitmapUtil bmp(s); - bmp.Begin(TPoint(0, 0)); - for(TInt j = 0; j < aSz.iHeight; j++) - { - bmp.SetPos(TPoint(0, j)); - for(TInt i = 0; i < aSz.iWidth; i++) - { - bmp.SetPixel(*aData); - aData++; - bmp.IncXPos(); - } - } - bmp.End(); - s->Save(aName); - s->Reset(); - delete s; - } - -TBuf<16> FooName(TInt aFoo) - { - TBuf<16> b; - b.Format(_L("C:\\pic%d.mbm"), aFoo); - return b; - } -*/ -void CDsa::ClipCopy(TUint8* aTarget, const TUint8* aSource, const TRect& aRect, const TRect& aTargetPos) const - { - TUint8* target = aTarget; - const TUint8* source = aSource; - const TInt lineWidth = aRect.Width(); - source += iSourceBpp * (aRect.iTl.iY * lineWidth); - TInt sourceStartOffset = iSourceBpp * aRect.iTl.iX; - source += sourceStartOffset; - target += iTargetBpp * ((aTargetPos.iTl.iY + aRect.iTl.iY ) * lineWidth); - TInt targetStartOffset = iTargetBpp * (aRect.iTl.iX + aTargetPos.iTl.iX); - target += targetStartOffset; - TUint32* targetPtr = reinterpret_cast(target); - const TInt targetWidth = HwRect().Size().iWidth; - const TInt height = aRect.Height(); - - TInt lineMove = iStateFlags & EOrientation90 ? 1 : lineWidth; - - if(iStateFlags & EOrientation180) - { - - targetPtr += targetWidth * (height - 1); - - for(TInt i = 0; i < height; i++) //source is always smaller - { - iCopyFunction(*this, targetPtr, source, lineWidth, height); - source += lineMove; - targetPtr -= targetWidth; - } - } - else - { - - - for(TInt i = 0; i < height; i++) //source is always smaller - { - iCopyFunction(*this, targetPtr, source, lineWidth, height); - source += lineMove; - targetPtr += targetWidth; - } - } - - } - - - - -void CDsa::Wipe() //dont call in drawing - { - if(IsDsaAvailable()) - Wipe(iTargetBpp * iScreenRect.Width() * iScreenRect.Height()); - } - -void CDsa::SetCopyFunction() - { - //calculate offset to correct function in iCFTable according to given parameters - TInt function = 0; - const TInt KCopyFunctions = 4; - const TInt KOffsetToNative = 0; - const TInt KOffsetTo256 = KOffsetToNative + KCopyFunctions; - const TInt KOffsetToOtherModes = KOffsetTo256 + KCopyFunctions; - const TInt KOffsetTo90Functions = 1; - const TInt KOffsetTo180Functions = 2; - - if(iSourceMode == DisplayMode()) - function = KOffsetToNative; //0 - else if(iSourceMode == EColor256) - function = KOffsetTo256; //4 - else - function = KOffsetToOtherModes; //8 - - if(iStateFlags & EOrientation90) - function += KOffsetTo90Functions; // + 1 - if(iStateFlags & EOrientation180) - function += KOffsetTo180Functions; //+ 2 - - iCopyFunction = iCFTable[function]; - - Wipe(); - } - -inline void Rotate(TRect& aRect) - { - const TInt dx = aRect.iBr.iX - aRect.iTl.iX; - const TInt dy = aRect.iBr.iY - aRect.iTl.iY; - - aRect.iBr.iX = aRect.iTl.iX + dy; - aRect.iBr.iY = aRect.iTl.iY + dx; - - const TInt tmp = aRect.iTl.iX; - aRect.iTl.iX = aRect.iTl.iY; - aRect.iTl.iY = tmp; - } - -/* -int bar = 0; -*/ -TBool CDsa::AddUpdateRect(const TUint8* aBits, const TRect& aUpdateRect, const TRect& aRect) - { - - if(iStateFlags & EOrientationChanged) - { - iStateFlags &= ~EOrientationFlags; - iStateFlags |= iNewFlags; - SetCopyFunction(); - iStateFlags &= ~EOrientationChanged; - EpocSdlEnv::WaitDeviceChange(); - return EFalse; //skip this frame as data is may be changed - } - - if(iTargetAddr == NULL) - { - iTargetAddr = LockHwSurface(); - } - TUint8* target = iTargetAddr; - if(target == NULL) - return EFalse; - - - TRect targetRect = HwRect(); - TRect sourceRect = aRect; - TRect updateRect = aUpdateRect; - - if(iStateFlags & EOrientation90) - { - Rotate(sourceRect); - Rotate(updateRect); - } - - if(iSourceMode != DisplayMode() || targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0)) - { - sourceRect.Intersection(targetRect); //so source always smaller or equal than target - updateRect.Intersection(targetRect); - ClipCopy(target, aBits, updateRect, sourceRect); - } - else - { - const TInt byteCount = aRect.Width() * aRect.Height() * iSourceBpp; //this could be stored - Mem::Copy(target, aBits, byteCount); - } - - return ETrue; - } - -CDsa* CDsa::CreateL(RWsSession& aSession) - { - if(EpocSdlEnv::Flags(CSDL::EDrawModeDSB)) - { - TInt flags = CDirectScreenBitmap::ENone; - if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBDoubleBuffer)) - flags |= CDirectScreenBitmap::EDoubleBuffer; - if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBIncrentalUpdate)) - flags |= CDirectScreenBitmap::EIncrementalUpdate; - return new (ELeave) CDsaB(aSession); - } - else - return new (ELeave) CDsaA(aSession); - } - -void CDsa::CreateZoomerL(const TSize& aSize) - { - iSwSize = aSize; - iStateFlags |= EResizeRequest; - CreateSurfaceL(); - SetTargetRect(); - } - -TPoint CDsa::WindowCoordinates(const TPoint& aPoint) const - { - TPoint pos = aPoint - iScreenRect.iTl; - const TSize asz = iScreenRect.Size(); - if(iStateFlags & EOrientation180) - { - pos.iX = asz.iWidth - pos.iX; - pos.iY = asz.iHeight - pos.iY; - } - if(iStateFlags & EOrientation90) - { - pos.iX = aPoint.iY; - pos.iY = aPoint.iX; - } - pos.iX <<= 16; - pos.iY <<= 16; - pos.iX /= asz.iWidth; - pos.iY /= asz.iHeight; - pos.iX *= iSwSize.iWidth; - pos.iY *= iSwSize.iHeight; - pos.iX >>= 16; - pos.iY >>= 16; - return pos; - } - -void CDsa::SetTargetRect() - { - iTargetRect = iScreenRect; - if(iStateFlags & EResizeRequest && EpocSdlEnv::Flags(CSDL::EAllowImageResizeKeepRatio)) - { - const TSize asz = iScreenRect.Size(); - const TSize sz = iSwSize; - - TRect rect; - - const TInt dh = (sz.iHeight << 16) / sz.iWidth; - - if((asz.iWidth * dh ) >> 16 <= asz.iHeight) - { - rect.SetRect(TPoint(0, 0), TSize(asz.iWidth, (asz.iWidth * dh) >> 16)); - } - else - { - const TInt dw = (sz.iWidth << 16) / sz.iHeight; - rect.SetRect(TPoint(0, 0), TSize((asz.iHeight * dw) >> 16, asz.iHeight)); - } - rect.Move((asz.iWidth - rect.Size().iWidth) >> 1, (asz.iHeight - rect.Size().iHeight) >> 1); - - iTargetRect = rect; - iTargetRect.Move(iScreenRect.iTl); - - } - if(!(iStateFlags & EResizeRequest)) - iSwSize = iScreenRect.Size(); -// iScanLineWidth = /*iTargetBpp **/ SwSize().iWidth; - } - -void CDsa::RecreateL() - { - } - -void CDsa::Free() - { - } - -void CDsa::UpdateSwSurface() - { - iTargetAddr = NULL; - UnlockHwSurface(); //could be faster if does not use AO, but only check status before redraw, then no context switch needed - } - -void CDsa::SetBlitter(MBlitter* aBlitter) - { - iBlitter = aBlitter; - } - -void CDsa::DrawOverlays() - { - const TInt last = iOverlays.Count() - 1; - for(TInt i = last; i >= 0 ; i--) - iOverlays[i].iOverlay->Draw(*iDsa->Gc(), HwRect(), SwSize()); - } - -TInt CDsa::AppendOverlay(MOverlay& aOverlay, TInt aPriority) - { - TInt i; - for(i = 0; i < iOverlays.Count() && iOverlays[i].iPriority < aPriority; i++) - {} - const TOverlay overlay = {&aOverlay, aPriority}; - return iOverlays.Insert(overlay, i); - } - -TInt CDsa::RemoveOverlay(MOverlay& aOverlay) - { - for(TInt i = 0; i < iOverlays.Count(); i++) - { - if(iOverlays[i].iOverlay == &aOverlay) - { - iOverlays.Remove(i); - return KErrNone; - } - } - return KErrNotFound; - } - -TInt CDsa::RedrawRequest() - { - if(!(iStateFlags & (EUpdating) && (iStateFlags & ERunning))) - { - return ExternalUpdate(); - } - return KErrNotReady; - } - - -void CDsa::Resume() - { - if(Stopped()) - Restart(RDirectScreenAccess::ETerminateRegion); - } - -void CDsa::DoStop() - { - if(IsDsaAvailable()) - iStateFlags |= ESdlThreadExplicitStop; - Stop(); - } - -void CDsa::Stop() - { - iStateFlags &= ~ERunning; -// Cancel(); //can be called only from main! - iDsa->Cancel(); - } - -void CDsa::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) - { -// iStateFlags |= EChangeNotify; - Stop(); - } - -void CDsa::Restart(RDirectScreenAccess::TTerminationReasons aReason) - { - if(aReason == RDirectScreenAccess::ETerminateRegion) //auto restart - { - TRAPD(err, RestartL()); - PANIC_IF_ERROR(err); - } - } -/*) -TBool CDsa::ChangeTrigger() - { - const TBool change = iStateFlags & EChangeNotify; - iStateFlags &= ~EChangeNotify; - return change; - } -*/ -///////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CDsa::Copy256(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - TUint32* target = aTarget; - const TUint32* endt = target + aBytes; - const TUint8* source = aSource; - while(target < endt) - { - *target++ = aDsa.iLut256[*source++]; - } - } - -void CDsa::Copy256Reversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - const TUint32* target = aTarget; - TUint32* endt = aTarget + aBytes; - const TUint8* source = aSource; - while(target < endt) - { - *(--endt) = aDsa.iLut256[*source++]; - } - } - -void CDsa::Copy256Flip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - TUint32* target = aTarget; - const TUint32* endt = target + aBytes; - const TUint8* column = aSource; - - while(target < endt) - { - *target++ = aDsa.iLut256[*column]; - column += aLineLen; - } - } - -void CDsa::Copy256FlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - const TUint32* target = aTarget; - TUint32* endt = aTarget + aBytes; - const TUint8* column = aSource; - - while(target < endt) - { - *(--endt) = aDsa.iLut256[*column]; - column += aLineLen; - } - } - -void CDsa::CopyMem(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - Mem::Copy(aTarget, aSource, aBytes); - } - -void CDsa::CopyMemFlip(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - TUint32* target = aTarget; - const TUint32* endt = target + aBytes; - const TUint32* column = reinterpret_cast(aSource); - - while(target < endt) - { - *target++ = *column; - column += aLineLen; - } - } - -void CDsa::CopyMemReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - const TUint32* target = aTarget; - TUint32* endt = aTarget + aBytes; - const TUint32* source = reinterpret_cast(aSource); - while(target < endt) - { - *(--endt) = *source++; - } - } - - -void CDsa::CopyMemFlipReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - const TUint32* target = aTarget; - TUint32* endt = aTarget + aBytes; - const TUint32* column = reinterpret_cast(aSource); - - while(target < endt) - { - *(--endt) = *column; - column += aLineLen; - } - } - - -typedef TRgb (*TRgbFunc) (TInt aValue); - -LOCAL_C TRgb rgb16MA(TInt aValue) - { - return TRgb::Color16MA(aValue); - } - -NONSHARABLE_CLASS(MRgbCopy) - { - public: - virtual void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed) = 0; - virtual void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed) = 0; - }; -template -NONSHARABLE_CLASS(TRgbCopy) : public MRgbCopy - { - public: - TRgbCopy(TDisplayMode aMode); - void* operator new(TUint aBytes, TAny* aMem); - void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed); - void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed); - private: - TRgbFunc iFunc; - }; - -template -void* TRgbCopy::operator new(TUint /*aBytes*/, TAny* aMem) - { - return aMem; - } - -template -TRgbCopy::TRgbCopy(TDisplayMode aMode) - { - switch(aMode) - { - case EGray256 : iFunc = TRgb::Gray256; break; - case EColor256 : iFunc = TRgb::Color256; break; - case EColor4K : iFunc = TRgb::Color4K; break; - case EColor64K : iFunc = TRgb::Color64K; break; - case EColor16M : iFunc = TRgb::Color16M; break; - case EColor16MU : iFunc = TRgb::Color16MU; break; - case EColor16MA : iFunc = rgb16MA; break; - default: - PANIC(KErrNotSupported); - } - } - -template -void TRgbCopy::Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed) - { - const T* source = reinterpret_cast(aSource); - TUint32* target = aTarget; - TUint32* endt = target + aBytes; - - if(aReversed) - { - while(target < endt) - { - TUint32 value = *source++; - *(--endt) = iFunc(value).Value(); - } - } - else - { - while(target < endt) - { - TUint32 value = *source++; - *target++ = iFunc(value).Value(); - } - } - } - -template -void TRgbCopy::FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed) - { - const T* column = reinterpret_cast(aSource); - TUint32* target = aTarget; - TUint32* endt = target + aBytes; - - if(aReversed) - { - while(target < endt) - { - *(--endt) = iFunc(*column).Value(); - column += aLineLen; - } - } - else - { - while(target < endt) - { - *target++ = iFunc(*column).Value(); - column += aLineLen; - } - } - } - - -typedef TUint64 TStackMem; - -LOCAL_C MRgbCopy* GetCopy(TAny* mem, TDisplayMode aMode) - { - if(aMode == EColor256 || aMode == EGray256) - { - return new (mem) TRgbCopy(aMode); - } - if(aMode == EColor4K || aMode == EColor64K) - { - return new (mem) TRgbCopy(aMode); - } - if(aMode == EColor16M || aMode == EColor16MU || aMode == EColor16MA) - { - return new (mem) TRgbCopy(aMode); - } - PANIC(KErrNotSupported); - return NULL; - } - - -void CDsa::CopySlowFlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - TStackMem mem = 0; - GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, ETrue); - } - -void CDsa::CopySlowFlip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen) - { - TStackMem mem = 0; - GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, EFalse); - } - -void CDsa::CopySlow(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - TStackMem mem = 0; - GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, EFalse); - } - -void CDsa::CopySlowReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt) - { - TStackMem mem = 0; - GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, ETrue); - } \ No newline at end of file -- cgit v1.2.3