19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Library General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Library General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Library General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@devolution.com 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_epocvideo.cpp 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Epoc based SDL video driver implementation 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Thanks to Peter van Sebille, the author of EMame. It is a great example of 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall low level graphics coding in Epoc. 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Epoc version by Hannu Viitala (hannu.j.viitala@mbnet.fi) 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Assembler routines by Kimmo Kinnunen 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdlib.h> 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdio.h> 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <string.h> 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" { 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_error.h" 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_timer.h" 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_video.h" 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#undef NULL 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_pixels_c.h" 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL.h" 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}; 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_epocvideo.h" 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_epocevents_c.h" 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "sdl_epocruntime.h" 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <hal.h> 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <coedef.h> 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <flogger.h> 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef SYMBIAN_QUARTZ 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_VideoDevice* _thisDevice; 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall_LIT(KLibName, "SDL"); 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* For debugging */ 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//if old SOS, from 7.x this is public! 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallclass CLockable : public CFbsBitmap 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall public: 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static CLockable* Lockable(CFbsBitmap* aBmp) {return static_cast<CLockable*>(aBmp);} 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void Lock() {LockHeap();} 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void Unlock() {UnlockHeap();} 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }; 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define LockHeap(x) CLockable::Lockable(x)->Lock() 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define UnlockHeap(x) CLockable::Lockable(x)->Unlock() 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid RDebug_Print_b(char* error_str, void* param) 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TBuf8<128> error8((TUint8*)error_str); 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TBuf<128> error; 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error.Copy(error8); 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef TRACE_TO_FILE 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (param) //!! Do not work if the parameter is really 0!! 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RDebug::Print(error, param); 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RDebug::Print(error); 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (param) //!! Do not work if the parameter is really 0!! 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RFileLogger::WriteFormat(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error, param); 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RFileLogger::Write(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error); 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" void RDebug_Print(char* error_str, void* param) 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RDebug_Print_b(error_str, param); 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint Debug_AvailMem2() 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //User::CompressAllHeaps(); 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TMemoryInfoV1Buf membuf; 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::LeaveIfError(UserHal::MemoryInfo(membuf)); 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TMemoryInfoV1 minfo = membuf(); 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(minfo.iFreeRamInBytes); 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" int Debug_AvailMem() 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(Debug_AvailMem2()); 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" { 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Initialization/Query functions */ 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat); 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_SetColors(_THIS, int firstcolor, int ncolors, 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Color *colors); 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_VideoQuit(_THIS); 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Hardware surface functions */ 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_AllocHWSurface(_THIS, SDL_Surface *surface); 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_LockHWSurface(_THIS, SDL_Surface *surface); 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_FlipHWSurface(_THIS, SDL_Surface *surface); 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_UnlockHWSurface(_THIS, SDL_Surface *surface); 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_FreeHWSurface(_THIS, SDL_Surface *surface); 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_Available(void); 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_VideoDevice *EPOC_CreateDevice(int devindex); 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DrawBackground(_THIS); 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer); 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer); 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Mouse functions */ 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic WMcursor *EPOC_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_FreeWMCursor(_THIS, WMcursor *cursor); 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_ShowWMCursor(_THIS, WMcursor *cursor); 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* !!For 12 bit screen HW. Table for fast conversion from 8 bit to 12 bit */ 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// TUint16 is enough, but using TUint32 so we can use better instruction selection on ARMI 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic TUint32 EPOC_HWPalette_256_to_Screen[256]; 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallVideoBootStrap EPOC_bootstrap = { 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall "epoc", "EPOC system", 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EPOC_Available, EPOC_CreateDevice 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}; 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallconst TUint32 WindowClientHandle = 9210; //!! const 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Epoc video driver bootstrap functions */ 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_Available(void) 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 1; /* Always available */ 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_DeleteDevice(SDL_VideoDevice *device) 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall free(device->hidden); 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall free(device); 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_VideoDevice *EPOC_CreateDevice(int /*devindex*/) 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VideoDevice *device; 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE("SDL:EPOC_CreateDevice"); 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Allocate all variables that we free on delete */ 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( device ) { 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall memset(device, 0, (sizeof *device)); 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->hidden = (struct SDL_PrivateVideoData *) 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall malloc((sizeof *device->hidden)); 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (device == NULL) || (device->hidden == NULL) ) { 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory(); 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( device ) { 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall free(device); 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall memset(device->hidden, 0, (sizeof *device->hidden)); 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set the function pointers */ 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->VideoInit = EPOC_VideoInit; 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->ListModes = EPOC_ListModes; 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetVideoMode = EPOC_SetVideoMode; 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetColors = EPOC_SetColors; 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->UpdateRects = NULL; 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->VideoQuit = EPOC_VideoQuit; 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->AllocHWSurface = EPOC_AllocHWSurface; 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->CheckHWBlit = NULL; 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->FillHWRect = NULL; 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetHWColorKey = NULL; 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetHWAlpha = NULL; 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->LockHWSurface = EPOC_LockHWSurface; 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->UnlockHWSurface = EPOC_UnlockHWSurface; 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->FlipHWSurface = EPOC_FlipHWSurface; 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->FreeHWSurface = EPOC_FreeHWSurface; 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetIcon = NULL; 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetCaption = NULL; 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->GetWMInfo = NULL; 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->FreeWMCursor = EPOC_FreeWMCursor; 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->CreateWMCursor = EPOC_CreateWMCursor; 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->ShowWMCursor = EPOC_ShowWMCursor; 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->WarpWMCursor = NULL; 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->InitOSKeymap = EPOC_InitOSKeymap; 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->PumpEvents = EPOC_PumpEvents; 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->free = EPOC_DeleteDevice; 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return device; 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint GetBpp(TDisplayMode displaymode) 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*TInt numColors = TDisplayModeUtils::NumDisplayModeColors(displaymode); 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt bitsPerPixel = 1; 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (TInt32 i = 2; i < numColors; i <<= 1, bitsPerPixel++); 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return bitsPerPixel;*/ 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return TDisplayModeUtils::NumDisplayModeBitsPerPixel(displaymode); 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DisableKeyBlocking(_THIS) 2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Disable key blocking 2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TRawEvent event; 2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall event.Set((TRawEvent::TType)/*EDisableKeyBlock*/51); // !!EDisableKeyBlock not found in epoc32\include! 2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.SimulateRawEvent(event); 2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid ConstructWindowL(_THIS) 2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt error; 2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE("SDL:ConstructWindowL"); 2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error = Private->EPOC_WsSession.Connect(); 2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::LeaveIfError(error); 2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsScreen=new(ELeave) CWsScreenDevice(Private->EPOC_WsSession); 2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::LeaveIfError(Private->EPOC_WsScreen->Construct()); 2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::LeaveIfError(Private->EPOC_WsScreen->CreateContext(Private->EPOC_WindowGc)); 2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindowGroup=RWindowGroup(Private->EPOC_WsSession); 2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::LeaveIfError(Private->EPOC_WsWindowGroup.Construct(WindowClientHandle)); 2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindowGroup.SetOrdinalPosition(0); 2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Set window group name (the same as process name)) !!Gives always "EPOC" in WINS 2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RProcess thisProcess; 2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TParse exeName; 2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall exeName.Set(thisProcess.FileName(), NULL, NULL); 2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TBuf<32> winGroupName; 2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall winGroupName.Append(0); 2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall winGroupName.Append(0); 2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall winGroupName.Append(0);// uid 2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall winGroupName.Append(0); 2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall winGroupName.Append(exeName.Name()); // caption 2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall winGroupName.Append(0); 2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall winGroupName.Append(0); //doc name 2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindowGroup.SetName(winGroupName); 2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow=RWindow(Private->EPOC_WsSession); 2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Markus, it was: 2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // User::LeaveIfError(Private->EPOC_WsWindow.Construct(Private->EPOC_WsWindowGroup,WindowClientHandle )); 2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // but SOS 7.0s debug does not accept same window handle twice 2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::LeaveIfError(Private->EPOC_WsWindow.Construct(Private->EPOC_WsWindowGroup,WindowClientHandle - 1)); 2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.SetBackgroundColor(KRgbWhite); 2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.Activate(); 2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.SetSize(Private->EPOC_WsScreen->SizeInPixels()); 2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.SetVisible(ETrue); 2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindowGroupID = Private->EPOC_WsWindowGroup.Identifier(); 2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_IsWindowFocused = EFalse; 2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisableKeyBlocking(_this); //disable key blocking 2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat) 2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // !!TODO:handle leave functions! 2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE("SDL:EPOC_VideoInit"); 3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Initialize all variables that we clean on shutdown */ 3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; i<SDL_NUMMODES; ++i ) { 3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); 3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[i]->x = Private->SDL_modelist[i]->y = 0; 3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Modes sorted largest to smallest */ 3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[0]->w = 800; Private->SDL_modelist[0]->h = 250; 3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[1]->w = 640; Private->SDL_modelist[1]->h = 480; 3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[2]->w = 480; Private->SDL_modelist[2]->h = 600; 3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[3]->w = 640; Private->SDL_modelist[3]->h = 400; 3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[4]->w = 352; Private->SDL_modelist[4]->h = 416; 3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[5]->w = 416; Private->SDL_modelist[5]->h = 352; 3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[6]->w = 416; Private->SDL_modelist[6]->h = 312; 3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[7]->w = 352; Private->SDL_modelist[7]->h = 264; 3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[8]->w = 800; Private->SDL_modelist[8]->h = 240; //for doom all these.. 3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[9]->w = 640; Private->SDL_modelist[9]->h = 240; 3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[10]->w = 480; Private->SDL_modelist[10]->h = 240; 3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[11]->w = 640; Private->SDL_modelist[11]->h = 240; 3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[12]->w = 352; Private->SDL_modelist[12]->h = 240; 3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[13]->w = 416; Private->SDL_modelist[13]->h = 240; 3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[14]->w = 416; Private->SDL_modelist[14]->h = 240; 3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[15]->w = 352; Private->SDL_modelist[15]->h = 240; 3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[16]->w = 640; Private->SDL_modelist[16]->h = 200; 3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[17]->w = 320; Private->SDL_modelist[17]->h = 240; //...for doom, currently engine renders no-higher windows :-(, propably should get fixed 3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[18]->w = 320; Private->SDL_modelist[18]->h = 200; 3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[19]->w = 256; Private->SDL_modelist[19]->h = 192; 3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[20]->w = 176; Private->SDL_modelist[20]->h = 208; 3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[21]->w = 208; Private->SDL_modelist[21]->h = 176; // Rotated 3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[22]->w = 160; Private->SDL_modelist[22]->h = 144; 3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[23]->w = 640; Private->SDL_modelist[2]->h = 200; //s80 some new modes 3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[24]->w = 640; Private->SDL_modelist[2]->h = 320; //s90 modes are added 3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[25]->w = 640; Private->SDL_modelist[2]->h = 240; //here 3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[26]->w = 640; Private->SDL_modelist[4]->h = 200; //now 3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[27] = NULL; 3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Construct Epoc window */ 3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ConstructWindowL(_this); 3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Initialise Epoc frame buffer */ 3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TDisplayMode displayMode = Private->EPOC_WsScreen->DisplayMode(); 3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if !defined(__WINS__) && !defined(TEST_BM_DRAW) 3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TScreenInfoV01 screenInfo; 3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TPckg<TScreenInfoV01> sInfo(screenInfo); 3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall UserSvr::ScreenInfo(sInfo); 3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_ScreenSize = screenInfo.iScreenSize; 3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_DisplayMode = displayMode; 3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_HasFrameBuffer = screenInfo.iScreenAddressValid; 3579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_FrameBuffer = Private->EPOC_HasFrameBuffer ? (TUint8*) screenInfo.iScreenAddress : NULL; 3589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_BytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1; 3599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_BytesPerScanLine = screenInfo.iScreenSize.iWidth * Private->EPOC_BytesPerPixel; 3619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_BytesPerScreen = Private->EPOC_BytesPerScanLine * Private->EPOC_ScreenSize.iHeight; 3629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("Screen width %d", screenInfo.iScreenSize.iWidth); 3649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("Screen height %d", screenInfo.iScreenSize.iHeight); 3659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("Screen dmode %d", displayMode); 3669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("Screen valid %d", screenInfo.iScreenAddressValid); 3679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("bpp %d", Private->EPOC_BytesPerPixel); 3699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("bpsl %d", Private->EPOC_BytesPerScanLine); 3709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("bps %d", Private->EPOC_BytesPerScreen); 3719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* It seems that in SA1100 machines for 8bpp displays there is a 512 palette table at the 3749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * beginning of the frame buffer. E.g. Series 7 and Netbook. 3759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * In 12 bpp machines the table has 16 entries. 3769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 3779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (Private->EPOC_HasFrameBuffer && GetBpp(displayMode) == 8) 3789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_FrameBuffer += 512; 3809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 3829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_FrameBuffer += 32; 3849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*if (Private->EPOC_HasFrameBuffer && GetBpp(displayMode) == 12) 3869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_FrameBuffer += 16 * 2; 3879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (Private->EPOC_HasFrameBuffer && GetBpp(displayMode) == 16) 3889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_FrameBuffer += 16 * 2; 3899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 3909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else /* defined __WINS__ */ 3919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Create bitmap, device and context for screen drawing */ 3939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_ScreenSize = Private->EPOC_WsScreen->SizeInPixels(); 3949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_Bitmap = new (ELeave) CWsBitmap(Private->EPOC_WsSession); 3969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_Bitmap->Create(Private->EPOC_ScreenSize, displayMode); 3979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_DisplayMode = displayMode; 3999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_HasFrameBuffer = ETrue; 4009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_FrameBuffer = NULL; /* Private->EPOC_Bitmap->DataAddress() can change any time */ 4019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_BytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1; 4029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_BytesPerScanLine = Private->EPOC_WsScreen->SizeInPixels().iWidth * Private->EPOC_BytesPerPixel; 4039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* __WINS__ */ 4059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef SYMBIAN_CRYSTAL 4079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Get draw device for updating the screen 4089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TScreenInfoV01 screenInfo2; 4099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Epoc_Runtime::GetScreenInfo(screenInfo2); 4119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TRAPD(status, Private->EPOC_DrawDevice = CFbsDrawDevice::NewScreenDeviceL(screenInfo2, displayMode)); 4139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::LeaveIfError(status); 4149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 4159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* The "best" video format should be returned to caller. */ 4179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall vformat->BitsPerPixel = /*!!GetBpp(displayMode) */ 8; 4199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall vformat->BytesPerPixel = /*!!Private->EPOC_BytesPerPixel*/ 1; 4209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Activate events for me */ 4229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsEventStatus = KRequestPending; 4249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus); 4259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE("SDL:WsEventStatus"); 4279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::WaitForRequest(Private->EPOC_WsEventStatus); //Markus: I added this and ... 4289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_RedrawEventStatus = KRequestPending; 4309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.RedrawReady(&Private->EPOC_RedrawEventStatus); 4319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE("SDL:RedrawEventStatus"); 4339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::WaitForRequest(Private->EPOC_RedrawEventStatus); //...this, if not catches a stray event is risen 4349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //if there are active objects used, or confucing 4359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //actions with User::WaitForAnyRequest 4369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.PointerFilter(EPointerFilterDrag, 0); 4379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_ScreenOffset = TPoint(0, 0); 4399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(__WINS__) || defined(TEST_BM_DRAW) 4419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall LockHeap(Private->EPOC_Bitmap); // Lock bitmap heap 4429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 4439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE("SDL:DrawBackground"); 4459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawBackground(_this); // Clear screen 4469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(__WINS__) || defined(TEST_BM_DRAW) 4489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall UnlockHeap(Private->EPOC_Bitmap); // Unlock bitmap heap 4499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 4509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //!! TODO: error handling 4519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //if (ret != KErrNone) 4529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // return(-1); 4539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //else 4549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 4559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 4569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 /*flags*/) 4599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 4609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (format->BitsPerPixel == 12 || format->BitsPerPixel == 8) 4619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return Private->SDL_modelist; 4629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 4639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 4649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint EPOC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) 4669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 4679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((firstcolor+ncolors) > 256) 4689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 4699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// SDL_TRACE1("colors %d", (TDisplayModeUtils::NumDisplayModeColors(Private->EPOC_DisplayMode))); 4709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(TDisplayModeUtils::NumDisplayModeColors(Private->EPOC_DisplayMode) == 4096) 4719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Set 12 bit palette 4739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(int i = firstcolor; i < ncolors; i++) 4749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 4k value: 0000 rrrr gggg bbbb 4769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint32 color4K = (colors[i].r & 0x0000f0) << 4; 4779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall color4K |= (colors[i].g & 0x0000f0); 4789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall color4K |= (colors[i].b & 0x0000f0) >> 4; 4799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EPOC_HWPalette_256_to_Screen[i] = color4K; 4809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else if(TDisplayModeUtils::NumDisplayModeColors(Private->EPOC_DisplayMode) == 65536) 4839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(int i = firstcolor; i < ncolors; i++) 4859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 64k-colour displays effectively support RGB values 4879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // with 5 bits allocated to red, 6 to green and 5 to blue 4889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 64k value: rrrr rggg gggb bbbb 4899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint32 color64K = (colors[i].r & 0x0000f8) << 8; 4909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall color64K |= (colors[i].g & 0x0000fc) << 3; 4919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall color64K |= (colors[i].b & 0x0000f8) >> 3; 4929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EPOC_HWPalette_256_to_Screen[i] = color64K; 4939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else if(TDisplayModeUtils::NumDisplayModeColors(Private->EPOC_DisplayMode) == 16777216) 4969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(int i = firstcolor; i < ncolors; i++) 4989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 16M-colour 5009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //0000 0000 rrrr rrrr gggg gggg bbbb bbbb 5019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint32 color16M = colors[i].r << 16; 5029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall color16M |= colors[i].g << 8; 5039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall color16M |= colors[i].b; 5049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EPOC_HWPalette_256_to_Screen[i] = color16M; 5059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 5089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -2; 5109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 5129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 5139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, 5169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int width, int height, int bpp, Uint32 /*flags*/) 5179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 5189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE("SDL:EPOC_SetVideoMode"); 5199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Check parameters */ 5209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef SYMBIAN_CRYSTAL 5219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (! (bpp == 8 || bpp == 12 || bpp == 16) && 5229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ( 5239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (width == 640 && height == 200) || 5249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (width == 640 && height == 400) || 5259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (width == 640 && height == 480) || 5269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (width == 320 && height == 200) || 5279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (width == 320 && height == 240) 5289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall )) { 5299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("Requested video mode is not supported"); 5309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 5319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else // SYMBIAN_SERIES60 5339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (! (bpp == 8 || bpp == 12 || bpp == 16) && 5349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ( 5359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (width == 320 && height == 200) || 5369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (width == 320 && height == 240) || 5379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (width == 256 && height == 192) || 5389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (width == 176 && height == 208) || 5399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (width == 208 && height == 176) || // Rotated 5409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (width == 160 && height == 144) 5419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall )) { 5429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("Requested video mode is not supported"); 5439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 5449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 5469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (current && current->pixels) { 5489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall free(current->pixels); 5499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->pixels = NULL; 5509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) { 5529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(NULL); 5539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set up the new mode framebuffer */ 5569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (bpp == 8) 5579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags = (SDL_FULLSCREEN|SDL_SWSURFACE|SDL_PREALLOC|SDL_HWPALETTE); 5589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else // 12 bpp, 16 bpp 5599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags = (SDL_FULLSCREEN|SDL_SWSURFACE|SDL_PREALLOC); 5609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->w = width; 5619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->h = height; 5629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int numBytesPerPixel = ((bpp-1)>>3) + 1; 5639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->pitch = numBytesPerPixel * width; // Number of bytes in scanline 5649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->pixels = malloc(width * height * numBytesPerPixel); 5659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall memset(current->pixels, 0, width * height * numBytesPerPixel); 5669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set the blit function */ 5689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _this->UpdateRects = EPOC_DirectUpdate; 5699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* 5719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * Logic for getting suitable screen dimensions, offset, scaling and orientation 5729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 5739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int w = current->w; 5759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int h = current->h; 5769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Rotate, if the screen does not fit horizontally and it is landscape screen 5789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 5799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((width>Private->EPOC_ScreenSize.iWidth) && (width>height)) { 5809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_ScreenOrientation = CFbsBitGc::EGraphicsOrientationRotated270; 5819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall w = current->h; 5829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall h = current->w; 5839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 5859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Get nearest stepwise scale values for width and height. The smallest supported scaled screen is 1/2. 5869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt scaleValue = 0; 5879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_ScreenXScaleValue = 1; 5889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_ScreenYScaleValue = 1; 5899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (w > Private->EPOC_ScreenSize.iWidth) { 5909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Find the biggest scale value that result the width that fits in the screen HW 5919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (scaleValue = 2; scaleValue++;) { 5929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt scaledWidth = (w * (scaleValue-1))/scaleValue; 5939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (scaledWidth > Private->EPOC_ScreenSize.iWidth) 5949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 5959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_ScreenXScaleValue = Max(2, scaleValue - 1); 5979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall w = (w * (Private->EPOC_ScreenXScaleValue-1))/Private->EPOC_ScreenXScaleValue; 5989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (h > Private->EPOC_ScreenSize.iHeight) { 6009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Find the biggest scale value that result the height that fits in the screen HW 6019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (scaleValue = 2; scaleValue++;) { 6029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt scaledHeight = (h * (scaleValue-1))/scaleValue; 6039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (scaledHeight > Private->EPOC_ScreenSize.iHeight) 6049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 6059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_ScreenYScaleValue = Max(2, scaleValue - 1); 6079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall h = (h * (Private->EPOC_ScreenYScaleValue-1))/Private->EPOC_ScreenYScaleValue; 6089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Centralize game window on device screen */ 6119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_ScreenOffset.iX = (Private->EPOC_ScreenSize.iWidth - w) / 2; 6129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (Private->EPOC_ScreenOffset.iX < 0) 6139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_ScreenOffset.iX = 0; 6149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_ScreenOffset.iY = (Private->EPOC_ScreenSize.iHeight - h) / 2; 6159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (Private->EPOC_ScreenOffset.iY < 0) 6169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_ScreenOffset.iY = 0; 6179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("View width %d", w); 6209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("View height %d", h); 6219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("View bmode %d", bpp); 6229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("View s %d", scaleValue); 6239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("View x %d", Private->EPOC_ScreenOffset.iX); 6249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("View y %d", Private->EPOC_ScreenOffset.iY); 6259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* We're done */ 6279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(current); 6289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid RedrawWindowL(_THIS) 6329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 6339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(__WINS__) || defined(TEST_BM_DRAW) 6359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall LockHeap(Private->EPOC_Bitmap); // Lock bitmap heap 6369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow); 6379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 6389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int w = _this->screen->w; 6409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int h = _this->screen->h; 6419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (Private->EPOC_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) { 6429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall w = _this->screen->h; 6439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall h = _this->screen->w; 6449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((w < Private->EPOC_ScreenSize.iWidth) 6469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall || (h < Private->EPOC_ScreenSize.iHeight)) { 6479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawBackground(_this); 6489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Tell the system that something has been drawn */ 6519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TRect rect = TRect(Private->EPOC_WsWindow.Size()); 6529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.Invalidate(rect); 6539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(__WINS__) || defined(TEST_BM_DRAW) 6559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.BeginRedraw(rect); 6569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WindowGc->BitBlt(TPoint(), Private->EPOC_Bitmap); 6579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.EndRedraw(); 6589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WindowGc->Deactivate(); 6599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall UnlockHeap(Private->EPOC_Bitmap);; // Unlock bitmap heap 6609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.Flush(); 6619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 6629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Draw current buffer */ 6649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Rect fullScreen; 6659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fullScreen.x = 0; 6669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fullScreen.y = 0; 6679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fullScreen.w = _this->screen->w; 6689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fullScreen.h = _this->screen->h; 6699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall EPOC_DirectUpdate(_this, 1, &fullScreen); 6709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DrawBackground(_THIS) 6749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 6759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Draw background */ 6769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(__WINS__) || defined(TEST_BM_DRAW) 6779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //warning heap is not locked! - a function calling must ensure that it's ok 6789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenBuffer = (TUint16*)Private->EPOC_Bitmap->DataAddress(); 6799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 6809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenBuffer = (TUint16*)Private->EPOC_FrameBuffer; 6819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 6829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Draw black background 6839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Mem::FillZ(screenBuffer, Private->EPOC_BytesPerScreen); 6849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if 0 6869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (int y = 0; y < Private->EPOC_ScreenSize.iHeight; y++) { 6879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (int x = 0; x < Private->EPOC_ScreenSize.iWidth; x++) { 6889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef SYMBIAN_CRYSTAL 6899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TUint16 color = 0; // ((x+y)>>1) & 0xf; /* Draw blue stripes pattern, because in e.g. 320x200 mode there is a big background area*/ 6909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else // SYMBIAN_SERIES60 6919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TUint16 color = 0; /* Draw black background */ 6929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 6939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *screenBuffer++ = color; 6949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 6979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* We don't actually allow hardware surfaces other than the main one */ 7019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_AllocHWSurface(_THIS, SDL_Surface* /*surface*/) 7029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(-1); 7049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_FreeHWSurface(_THIS, SDL_Surface* /*surface*/) 7069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 7089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_LockHWSurface(_THIS, SDL_Surface* /*surface*/) 7119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 7139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_UnlockHWSurface(_THIS, SDL_Surface* /*surface*/) 7159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 7179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int EPOC_FlipHWSurface(_THIS, SDL_Surface* /*surface*/) 7209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 7229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) 7259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //TInt focusWindowGroupId = Private->EPOC_WsSession.GetFocusWindowGroup();//these are async services 7279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // if (focusWindowGroupId != Private->EPOC_WsWindowGroupID) { //for that cannot be called from 7289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //SDL threads ??? 7299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (!Private->EPOC_IsWindowFocused) 7309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 7319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Force focus window to redraw again for cleaning away SDL screen graphics */ 7329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 7339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt pos = Private->EPOC_WsWindowGroup.OrdinalPosition(); 7349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindowGroup.SetOrdinalPosition(0, KMaxTInt); 7359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TRect rect = TRect(Private->EPOC_WsWindow.Size()); 7369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.Invalidate(rect); 7379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindowGroup.SetOrdinalPosition(pos, ECoeWinPriorityNormal); 7389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ /* If this is not the topmost window, wait here! Sleep for 1 second to give cpu time to 7399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall multitasking and poll for being the topmost window. 7409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 7419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // if (Private->EPOC_WsSession.GetFocusWindowGroup() != Private->EPOC_WsWindowGroupID) { 7429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* !!TODO: Could call GetRedraw() etc. for WsSession and redraw the screen if needed. That might be 7449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall needed if a small dialog comes in front of Game screen. 7459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 7469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // while (Private->EPOC_WsSession.GetFocusWindowGroup() != Private->EPOC_WsWindowGroupID) 7479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_PauseAudio(1); 7499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Delay(1000); 7509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 7519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // } 7529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // RedrawWindowL(_this); 7549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_PauseAudio(0); 7579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // if we are not focused, do not draw 7599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// if (!Private->EPOC_IsWindowFocused) 7609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// return; 7619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(__WINS__) || defined(TEST_BM_DRAW) 7629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TBitmapUtil lock(Private->EPOC_Bitmap); 7639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall lock.Begin(TPoint(0,0)); // Lock bitmap heap 7649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow); 7659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenBuffer = (TUint16*)Private->EPOC_Bitmap->DataAddress(); 7669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 7679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenBuffer = (TUint16*)Private->EPOC_FrameBuffer; 7689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 7699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (Private->EPOC_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) 7719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DirectDrawRotated(_this, numrects, rects, screenBuffer); 7729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 7739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DirectDraw(_this, numrects, rects, screenBuffer); 7749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(__WINS__) || defined(TEST_BM_DRAW) 7779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TRect rect = TRect(Private->EPOC_WsWindow.Size()); 7799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.Invalidate(rect); 7809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.BeginRedraw(rect); 7819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WindowGc->BitBlt(TPoint(), Private->EPOC_Bitmap); 7829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.EndRedraw(); 7839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WindowGc->Deactivate(); 7849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall lock.End(); // Unlock bitmap heap 7859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.Flush(); 7869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 7879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef SYMBIAN_CRYSTAL 7889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // This is not needed in Crystal. What is the performance penalty in SERIES60? 7899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TRect rect2 = TRect(Private->EPOC_WsWindow.Size()); 7909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_DrawDevice->UpdateRegion(rect2); // Should we update rects parameter area only?? 7929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_DrawDevice->Update(); 7939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 7949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 7959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Update virtual cursor. !!Do not yet work properly 7979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.SetPointerCursorPosition(Private->EPOC_WsSession.PointerCursorPosition()); 7989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 7999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*static int foo = 1; 8019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( int i=0; i < numrects; ++i ) { 8039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const SDL_Rect& currentRect = rects[i]; 8049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Rect rect2; 8059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.x = currentRect.x; 8069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.y = currentRect.y; 8079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.w = currentRect.w; 8089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.h = currentRect.h; 8099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (rect2.w <= 0 || rect2.h <= 0) 8119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall continue; 8129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall foo++; 8159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if((foo % 200) == 0) 8169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("foo %d", foo); 8189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFbsBitmap* b = new (ELeave) CFbsBitmap; 8199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("bee %d", (int)b); 8209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int e = b->Create(TSize(currentRect.w, currentRect.h), Private->EPOC_DisplayMode); 8219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("err %d", e); 8239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(e != KErrNone) 8249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::Panic(_L("damn"), e); 8259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TBitmapUtil u(b); 8279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall u.Begin(TPoint(0, 0)); 8289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint32* d = b->DataAddress(); 8299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("addr %d", (int)d); 8319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt o = 0; o < currentRect.h; o++) 8339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt p = 0; p < currentRect.w; p++) 8349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall u.SetPos(TPoint(p, o)); 8369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall u.SetPixel(0xFFFF); 8379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("w %d", (int)currentRect.w); 8409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("h %d", (int)currentRect.h); 8419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("addr %d", (int)Private->EPOC_DisplayMode); 8439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TUint f = (TUint)Private->EPOC_FrameBuffer; 8469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TUint y = (TUint)Private->EPOC_BytesPerScreen; 8479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("frame %u", f); 8509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE1("bytes %u", y); 8519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Mem::Copy(d, Private->EPOC_FrameBuffer, Private->EPOC_BytesPerScreen); 8539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_TRACE("kopied"); 8559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall u.End(); 8579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TBuf<32> name; 8589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall name.Format(_L("C:\\nokia\\images\\doom%d.mbm"), (foo / 200)); 8599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall e= b->Save(name); 8609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(e != KErrNone) 8619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall User::Panic(_L("damned"), e); 8629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delete b; 8639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }}*/ 8649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 8659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer) 8689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 8699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt i; 8709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt sourceNumBytesPerPixel = ((_this->screen->format->BitsPerPixel-1)>>3) + 1; 8729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TPoint fixedOffset = Private->EPOC_ScreenOffset; 8739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt screenW = _this->screen->w; 8749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt screenH = _this->screen->h; 8759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt sourceScanlineLength = screenW; 8769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt targetScanlineLength = Private->EPOC_ScreenSize.iWidth; 8779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Render the rectangles in the list */ 8799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; i < numrects; ++i ) { 8819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const SDL_Rect& currentRect = rects[i]; 8829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Rect rect2; 8839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.x = currentRect.x; 8849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.y = currentRect.y; 8859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.w = currentRect.w; 8869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.h = currentRect.h; 8879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (rect2.w <= 0 || rect2.h <= 0) /* sanity check */ 8899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall continue; 8909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* All variables are measured in pixels */ 8929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Check rects validity, i.e. upper and lower bounds */ 8949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1); 8959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1); 8969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (maxX < 0 || maxY < 0) /* sanity check */ 8979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall continue; 8989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Clip from bottom */ 8999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall maxY = Min(maxY, Private->EPOC_ScreenSize.iHeight-1); 9009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* TODO: Clip from the right side */ 9019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt sourceRectWidth = maxX - rect2.x + 1; 9039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel; 9049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt sourceRectHeight = maxY - rect2.y + 1; 9059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength; 9069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TUint skipValue = 1; // no skip 9079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt targetStartOffset = fixedOffset.iX + rect2.x + (fixedOffset.iY +rect2.y) * targetScanlineLength; 9099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Nokia7650 native mode: 12 bpp --> 12 bpp 9119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 9129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch (_this->screen->format->BitsPerPixel) 9149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 12: 9169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* bitmapLine = (TUint16*)_this->screen->pixels + sourceStartOffset; 9189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenMemory = screenBuffer + targetStartOffset; 9199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (skipValue == 1) 9209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt y = 0 ; y < sourceRectHeight ; y++) 9229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes); 9249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapLine += sourceScanlineLength; 9269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenMemory += targetScanlineLength; 9279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 9299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt y = 0 ; y < sourceRectHeight ; y++) 9319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //TODO: optimize: separate loops for 1, 2 and n skip. Mem::Copy() can be used in unscaled case. 9339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* bitmapPos = bitmapLine; /* 2 bytes per pixel */ 9349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ 9359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt x = 0 ; x < sourceRectWidth ; x++) 9369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(screenMemory < (screenBuffer + Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight), User::Panic(_L("SDL"), KErrCorrupt)); 9389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt)); 9399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(bitmapLine < ((TUint16*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(_L("SDL"), KErrCorrupt)); 9409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(bitmapLine >= (TUint16*)_this->screen->pixels, User::Panic(_L("SDL"), KErrCorrupt)); 9419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *screenMemoryLinePos++ = *bitmapPos; 9439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapPos+=skipValue; 9449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapLine += sourceScanlineLength; 9469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenMemory += targetScanlineLength; 9479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 9519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 256 color paletted mode: 8 bpp --> 12 bpp 9529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 9539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default: 9549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(Private->EPOC_BytesPerPixel <= 2) 9569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset; 9589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenMemory = screenBuffer + targetStartOffset; 9599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt y = 0 ; y < sourceRectHeight ; y++) 9609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */ 9629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ 9639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Convert each pixel from 256 palette to 4k color values */ 9649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt x = 0 ; x < sourceRectWidth ; x++) 9659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt)); 9679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt)); 9689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(_L("SDL"), KErrCorrupt)); 9699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(_L("SDL"), KErrCorrupt)); 9709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *screenMemoryLinePos++ = EPOC_HWPalette_256_to_Screen[*bitmapPos++]; 9719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // bitmapPos+=skipValue; //TODO: optimize: separate loops for 1, 2 and n skip 9729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapLine += sourceScanlineLength; 9749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenMemory += targetScanlineLength; 9759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 9789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset; 9809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint32* screenMemory = reinterpret_cast<TUint32*>(screenBuffer + targetStartOffset); 9819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt y = 0 ; y < sourceRectHeight ; y++) 9829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */ 9849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint32* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ 9859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Convert each pixel from 256 palette to 4k color values */ 9869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt x = 0 ; x < sourceRectWidth ; x++) 9879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(screenMemoryLinePos < (reinterpret_cast<TUint32*>(screenBuffer) + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt)); 9899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(screenMemoryLinePos >= reinterpret_cast<TUint32*>(screenBuffer), User::Panic(_L("SDL"), KErrCorrupt)); 9909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(_L("SDL"), KErrCorrupt)); 9919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(_L("SDL"), KErrCorrupt)); 9929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *screenMemoryLinePos++ = EPOC_HWPalette_256_to_Screen[*bitmapPos++]; 9939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // bitmapPos+=skipValue; //TODO: optimize: separate loops for 1, 2 and n skip 9949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapLine += sourceScanlineLength; 9969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenMemory += targetScanlineLength; 9979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } // switch 10019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } // for 10029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 10039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 10059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer) 10069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 10079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt i; 10089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt sourceNumBytesPerPixel = ((_this->screen->format->BitsPerPixel-1)>>3) + 1; 10099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TPoint fixedOffset = Private->EPOC_ScreenOffset; 10109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt screenW = _this->screen->w; 10119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt screenH = _this->screen->h; 10129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt sourceScanlineLength = screenW; 10139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt targetScanlineLength = Private->EPOC_ScreenSize.iWidth; 10149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Render the rectangles in the list */ 10169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* for ( i=0; i < numrects; ++i ) { 10189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const SDL_Rect& currentRect = rects[i]; 10199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Rect rect2; 10209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.x = currentRect.x; 10219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.y = currentRect.y; 10229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.w = currentRect.w; 10239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.h = currentRect.h; 10249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (rect2.w <= 0 || rect2.h <= 0) /* sanity check */ 10269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* continue; 10279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* All variables are measured in pixels */ 10299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Check rects validity, i.e. upper and lower bounds */ 10319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1); 10329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1); 10339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (maxX < 0 || maxY < 0) /* sanity check */ 10349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* continue; 10359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Clip from bottom */ 10369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* maxY = Min(maxY, Private->EPOC_ScreenSize.iHeight-1); 10379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* TODO: Clip from the right side */ 10389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* TInt sourceRectWidth = maxX - rect2.x + 1; 10409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel; 10419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt sourceRectHeight = maxY - rect2.y + 1; 10429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength; 10439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TUint skipValue = Private->EPOC_ScreenXScaleValue; //1; // no skip 10449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const TInt targetStartOffset = // = (fixedOffset.iX + (rect2.x / skipValue) + (fixedOffset.iY + rect2.y) * targetScanlineLength ) ; 10469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (skipValue > 1 ? 10479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (fixedOffset.iX + (rect2.x / skipValue) + (fixedOffset.iY + rect2.y) * targetScanlineLength ) : 10489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (fixedOffset.iX + rect2.x + (fixedOffset.iY + rect2.y) * targetScanlineLength )); 10499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(skipValue >= 1, User::Panic(KLibName, KErrArgument)); 10519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Nokia7650 native mode: 12 bpp --> 12 bpp 10539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 10549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch (_this->screen->format->BitsPerPixel) 10559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 12: 10579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* bitmapLine = (TUint16*)_this->screen->pixels + sourceStartOffset; 10599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenMemory = screenBuffer + targetStartOffset; 10609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (skipValue == 1) 10619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt y = 0 ; y < sourceRectHeight ; y++) 10639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes); 10659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapLine += sourceScanlineLength; 10679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenMemory += targetScanlineLength; 10689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 10709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt y = 0 ; y < sourceRectHeight ; y++) 10729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //TODO: optimize: separate loops for 1, 2 and n skip. Mem::Copy() can be used in unscaled case. 10749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* bitmapPos = bitmapLine; /* 2 bytes per pixel */ 10759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ 10769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* for(TInt x = 0 ; x < sourceRectWidth ; x++) 10779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(screenMemory < (screenBuffer + Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight), User::Panic(KLibName, KErrCorrupt)); 10799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(KLibName, KErrCorrupt)); 10809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(bitmapLine < ((TUint16*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt)); 10819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(bitmapLine >= (TUint16*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt)); 10829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *screenMemoryLinePos++ = *bitmapPos; 10849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapPos+=skipValue; 10859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapLine += sourceScanlineLength; 10879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenMemory += targetScanlineLength; 10889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 10929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 256 color paletted mode: 8 bpp --> 12 bpp 10939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 10949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default: 10959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset; 10979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenMemory = screenBuffer + targetStartOffset; 10989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (skipValue > 1) 10999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sourceRectWidth /= skipValue; 11009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined __MARM_ARMI__ 11019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __asm volatile(" 11029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mov %4, %4, lsl #1 @ targetScanLineLength is in pixels, we need it in bytes 11039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1: 11049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mov r6, %0 @ bitmapLine 11059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mov r7, %2 @ screenMemory 11069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mov r8, %6 @ sourceRectWidth 11079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2: 11089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ldrb r4, [%0], %7 @ r4 = *bitmapPos; bitmapPos += skipValue 11099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ldr r5, [%1, r4, lsl #2] @ only 16 lower bits actually used 11109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall subs r8, r8, #1 @ x-- 11119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall strh r5, [%2], #2 @ *screenMemoryLinePos++ = r4 11129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bne 2b 11139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall add %0, r6, %3 @ bitmapLine += sourceScanlineLength 11159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall add %2, r7, %4 @ screenMemory += targetScanlineLength 11169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall subs %5, %5, #1 @ sourceRectHeight-- 11179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bne 1b 11189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall " 11199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall : // no output 11209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // %0 %1 %2 %3 %4 %5 %6 %7 11219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall : "r" (bitmapLine), "r" (&EPOC_HWPalette_256_to_Screen[0]), "r" (screenMemory), "r" (sourceScanlineLength), "r" (targetScanlineLength), "r" (sourceRectHeight), "r" (sourceRectWidth), "r" (skipValue) 11229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall : "r4", "r5", "r6", "r7", "r8" 11239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ); 11249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 11259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt y = 0 ; y < sourceRectHeight ; y++) 11269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 11279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */ 11289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ 11299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Convert each pixel from 256 palette to 4k color values */ 11309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* for (TInt x = 0 ; x < sourceRectWidth ; x++) 11319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 11329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //__ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(KLibName, KErrCorrupt)); 11339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //__ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(KLibName, KErrCorrupt)); 11349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //__ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt)); 11359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //__ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt)); 11369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *screenMemoryLinePos++ = EPOC_HWPalette_256_to_Screen[*bitmapPos]; 11389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapPos += skipValue; 11399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 11409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapLine += sourceScanlineLength; 11419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenMemory += targetScanlineLength; 11429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 11439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//#endif 11449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 11459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } // switch 11469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } // for 11479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 11489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 11499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer) 11519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 11529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt i; 11539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// TInt sourceNumBytesPerPixel = ((_this->screen->format->BitsPerPixel-1)>>3) + 1; 11549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TPoint fixedScreenOffset = Private->EPOC_ScreenOffset; 11559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt bufferW = _this->screen->w; 11569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt bufferH = _this->screen->h; 11579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt ScreenW = Private->EPOC_ScreenSize.iWidth; 11589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// TInt ScreenH = Private->EPOC_ScreenSize.iWidth; 11599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt sourceW = bufferW; 11609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt sourceH = bufferH; 11619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt targetW = ScreenW - fixedScreenOffset.iX * 2; 11629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// TInt targetH = ScreenH - fixedScreenOffset.iY * 2; 11639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt sourceScanlineLength = bufferW; 11649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt targetScanlineLength = Private->EPOC_ScreenSize.iWidth; 11659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Render the rectangles in the list */ 11679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; i < numrects; ++i ) { 11699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Rect rect2; 11709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const SDL_Rect& currentRect = rects[i]; 11719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.x = currentRect.x; 11729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.y = currentRect.y; 11739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.w = currentRect.w; 11749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect2.h = currentRect.h; 11759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (rect2.w <= 0 || rect2.h <= 0) /* sanity check */ 11779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall continue; 11789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* All variables are measured in pixels */ 11809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Check rects validity, i.e. upper and lower bounds */ 11829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt maxX = Min(sourceW - 1, rect2.x + rect2.w - 1); 11839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt maxY = Min(sourceH - 1, rect2.y + rect2.h - 1); 11849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (maxX < 0 || maxY < 0) /* sanity check */ 11859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall continue; 11869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Clip from bottom */ 11879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //maxX = Min(maxX, Private->EPOC_ScreenSize.iHeight-1); 11889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* TODO: Clip from the right side */ 11899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt sourceRectWidth = maxX - rect2.x + 1; 11919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel; 11929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt sourceRectHeight = maxY - rect2.y + 1; 11939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength; 11949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt targetStartOffset = fixedScreenOffset.iX + (targetW-1 - rect2.y) + (fixedScreenOffset.iY +rect2.x) * targetScanlineLength; 11959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // Nokia7650 native mode: 12 bpp --> 12 bpp 11979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (_this->screen->format->BitsPerPixel == 12) { 11989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* !!TODO: not yet implemented 12009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* bitmapLine = (TUint16*)_this->screen->pixels + sourceStartOffset; 12029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenMemory = screenBuffer + targetStartOffset; 12039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt y = 0 ; y < sourceRectHeight ; y++) { 12049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //TODO: optimize: separate loops for 1, 2 and n skip 12059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes); 12069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* bitmapPos = bitmapLine; // 2 bytes per pixel 12079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenMemoryLinePos = screenMemory; // 2 bytes per pixel 12089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt x = 0 ; x < sourceRectWidth ; x++) { 12099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(screenMemory < (screenBuffer + Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight), User::Panic(KLibName, KErrCorrupt)); 12119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(KLibName, KErrCorrupt)); 12129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(bitmapLine < ((TUint16*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt)); 12139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(bitmapLine >= (TUint16*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt)); 12149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *screenMemoryLinePos = *bitmapPos; 12169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapPos++; 12179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenMemoryLinePos += targetScanlineLength; 12189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapLine += sourceScanlineLength; 12209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenMemory--; 12219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 12249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // 256 color paletted mode: 8 bpp --> 12 bpp 12269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else { 12279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset; 12289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenMemory = screenBuffer + targetStartOffset; 12299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt screenXScaleValue = Private->EPOC_ScreenXScaleValue; 12309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt debug_ycount=0; 12319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt y = 0 ; y < sourceRectHeight ; y++) { 12329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(--screenXScaleValue) { 12339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */ 12349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ 12359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt screenYScaleValue = Private->EPOC_ScreenYScaleValue; 12369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TInt debug_xcount=0; 12379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Convert each pixel from 256 palette to 4k color values */ 12389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(TInt x = 0 ; x < sourceRectWidth ; x++) { 12399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(--screenYScaleValue) { 12409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(KLibName, KErrCorrupt)); 12429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(KLibName, KErrCorrupt)); 12439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt)); 12449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall __ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt)); 12459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *screenMemoryLinePos = TUint16(EPOC_HWPalette_256_to_Screen[*bitmapPos]); 12479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenMemoryLinePos += targetScanlineLength; debug_xcount++; 12489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 12509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenYScaleValue = Private->EPOC_ScreenYScaleValue; 12519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapPos++; 12529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenMemory--; debug_ycount++; 12549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } // endif 12559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 12569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screenXScaleValue = Private->EPOC_ScreenXScaleValue; 12579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bitmapLine += sourceScanlineLength; 12589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 12629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Note: If we are terminated, this could be called in the middle of 12659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall another SDL video routine -- notably UpdateRects. 12669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 12679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid EPOC_VideoQuit(_THIS) 12689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 12699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 12709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Free video mode lists */ 12729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; i<SDL_NUMMODES; ++i ) { 12739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( Private->SDL_modelist[i] != NULL ) { 12749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall free(Private->SDL_modelist[i]); 12759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->SDL_modelist[i] = NULL; 12769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( _this->screen && (_this->screen->flags & SDL_HWSURFACE) ) { 12809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Direct screen access, no memory buffer */ 12819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _this->screen->pixels = NULL; 12829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (_this->screen && _this->screen->pixels) { 12859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall free(_this->screen->pixels); 12869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _this->screen->pixels = NULL; 12879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Free Epoc resources */ 12909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Disable events for me */ 12929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (Private->EPOC_WsEventStatus != KRequestPending) 12939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.EventReadyCancel(); 12949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (Private->EPOC_RedrawEventStatus != KRequestPending) 12959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.RedrawReadyCancel(); 12969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if defined(__WINS__) || defined(TEST_BM_DRAW) 12989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delete Private->EPOC_Bitmap; 12999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_Bitmap = NULL; 13009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #else 13019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 13029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef SYMBIAN_CRYSTAL 13049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall free(Private->EPOC_DrawDevice); 13059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 13069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (Private->EPOC_WsWindow.WsHandle()) 13089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindow.Close(); 13099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (Private->EPOC_WsWindowGroup.WsHandle()) 13119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsWindowGroup.Close(); 13129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delete Private->EPOC_WindowGc; 13149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WindowGc = NULL; 13159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delete Private->EPOC_WsScreen; 13179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsScreen = NULL; 13189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (Private->EPOC_WsSession.WsHandle()) 13209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.Close(); 13219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 13229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallWMcursor *EPOC_CreateWMCursor(_THIS, Uint8* /*data*/, Uint8* /*mask*/, int /*w*/, int /*h*/, int /*hot_x*/, int /*hot_y*/) 13259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 13269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (WMcursor *) 9210; // it's ok to return something unuseful but true 13279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 13289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid EPOC_FreeWMCursor(_THIS, WMcursor* /*cursor*/) 13309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 13319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Disable virtual cursor */ 13329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible); 13339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone); 13349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 13359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint EPOC_ShowWMCursor(_THIS, WMcursor *cursor) 13379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 13389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (cursor == (WMcursor *)9210) { 13409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Enable virtual cursor */ 13419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNormal); 13429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (isCursorVisible) 13439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible); 13449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 13459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone); 13469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 13479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else { 13489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Disable virtual cursor */ 13499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible); 13509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone); 13519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 13529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(1); 13549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 13559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}; // extern "C" 1357