📄 sdl_epocvideo.cpp
字号:
rect2.y = currentRect.y; rect2.w = currentRect.w; rect2.h = currentRect.h; if (rect2.w <= 0 || rect2.h <= 0) /* sanity check *//* continue; /* All variables are measured in pixels */ /* Check rects validity, i.e. upper and lower bounds *//* TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1); TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1); if (maxX < 0 || maxY < 0) /* sanity check *//* continue; /* Clip from bottom *//* maxY = Min(maxY, Private->EPOC_ScreenSize.iHeight-1); /* TODO: Clip from the right side *//* TInt sourceRectWidth = maxX - rect2.x + 1; const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel; const TInt sourceRectHeight = maxY - rect2.y + 1; const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength; const TUint skipValue = Private->EPOC_ScreenXScaleValue; //1; // no skip const TInt targetStartOffset = // = (fixedOffset.iX + (rect2.x / skipValue) + (fixedOffset.iY + rect2.y) * targetScanlineLength ) ; (skipValue > 1 ? (fixedOffset.iX + (rect2.x / skipValue) + (fixedOffset.iY + rect2.y) * targetScanlineLength ) : (fixedOffset.iX + rect2.x + (fixedOffset.iY + rect2.y) * targetScanlineLength )); __ASSERT_DEBUG(skipValue >= 1, User::Panic(KLibName, KErrArgument)); // Nokia7650 native mode: 12 bpp --> 12 bpp // switch (_this->screen->format->BitsPerPixel) { case 12: { TUint16* bitmapLine = (TUint16*)_this->screen->pixels + sourceStartOffset; TUint16* screenMemory = screenBuffer + targetStartOffset; if (skipValue == 1) { for(TInt y = 0 ; y < sourceRectHeight ; y++) { Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes); } bitmapLine += sourceScanlineLength; screenMemory += targetScanlineLength; } else { for(TInt y = 0 ; y < sourceRectHeight ; y++) { //TODO: optimize: separate loops for 1, 2 and n skip. Mem::Copy() can be used in unscaled case. TUint16* bitmapPos = bitmapLine; /* 2 bytes per pixel *//* TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel *//* for(TInt x = 0 ; x < sourceRectWidth ; x++) { __ASSERT_DEBUG(screenMemory < (screenBuffer + Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight), User::Panic(KLibName, KErrCorrupt)); __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(KLibName, KErrCorrupt)); __ASSERT_DEBUG(bitmapLine < ((TUint16*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt)); __ASSERT_DEBUG(bitmapLine >= (TUint16*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt)); *screenMemoryLinePos++ = *bitmapPos; bitmapPos+=skipValue; } bitmapLine += sourceScanlineLength; screenMemory += targetScanlineLength; } } } break; // 256 color paletted mode: 8 bpp --> 12 bpp // default: { TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset; TUint16* screenMemory = screenBuffer + targetStartOffset; if (skipValue > 1) sourceRectWidth /= skipValue;#if defined __MARM_ARMI__ __asm volatile(" mov %4, %4, lsl #1 @ targetScanLineLength is in pixels, we need it in bytes 1: mov r6, %0 @ bitmapLine mov r7, %2 @ screenMemory mov r8, %6 @ sourceRectWidth 2: ldrb r4, [%0], %7 @ r4 = *bitmapPos; bitmapPos += skipValue ldr r5, [%1, r4, lsl #2] @ only 16 lower bits actually used subs r8, r8, #1 @ x-- strh r5, [%2], #2 @ *screenMemoryLinePos++ = r4 bne 2b add %0, r6, %3 @ bitmapLine += sourceScanlineLength add %2, r7, %4 @ screenMemory += targetScanlineLength subs %5, %5, #1 @ sourceRectHeight-- bne 1b " : // no output // %0 %1 %2 %3 %4 %5 %6 %7 : "r" (bitmapLine), "r" (&EPOC_HWPalette_256_to_Screen[0]), "r" (screenMemory), "r" (sourceScanlineLength), "r" (targetScanlineLength), "r" (sourceRectHeight), "r" (sourceRectWidth), "r" (skipValue) : "r4", "r5", "r6", "r7", "r8" );#else for(TInt y = 0 ; y < sourceRectHeight ; y++) { TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel *//* TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ /* Convert each pixel from 256 palette to 4k color values *//* for (TInt x = 0 ; x < sourceRectWidth ; x++) { //__ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(KLibName, KErrCorrupt)); //__ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(KLibName, KErrCorrupt)); //__ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt)); //__ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt)); *screenMemoryLinePos++ = EPOC_HWPalette_256_to_Screen[*bitmapPos]; bitmapPos += skipValue; } bitmapLine += sourceScanlineLength; screenMemory += targetScanlineLength; }//#endif } } // switch } // for}*/void DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer){ TInt i;// TInt sourceNumBytesPerPixel = ((_this->screen->format->BitsPerPixel-1)>>3) + 1; TPoint fixedScreenOffset = Private->EPOC_ScreenOffset; TInt bufferW = _this->screen->w; TInt bufferH = _this->screen->h; TInt ScreenW = Private->EPOC_ScreenSize.iWidth;// TInt ScreenH = Private->EPOC_ScreenSize.iWidth; TInt sourceW = bufferW; TInt sourceH = bufferH; TInt targetW = ScreenW - fixedScreenOffset.iX * 2;// TInt targetH = ScreenH - fixedScreenOffset.iY * 2; TInt sourceScanlineLength = bufferW; TInt targetScanlineLength = Private->EPOC_ScreenSize.iWidth; /* Render the rectangles in the list */ for ( i=0; i < numrects; ++i ) { SDL_Rect rect2; const SDL_Rect& currentRect = rects[i]; rect2.x = currentRect.x; rect2.y = currentRect.y; rect2.w = currentRect.w; rect2.h = currentRect.h; if (rect2.w <= 0 || rect2.h <= 0) /* sanity check */ continue; /* All variables are measured in pixels */ /* Check rects validity, i.e. upper and lower bounds */ TInt maxX = Min(sourceW - 1, rect2.x + rect2.w - 1); TInt maxY = Min(sourceH - 1, rect2.y + rect2.h - 1); if (maxX < 0 || maxY < 0) /* sanity check */ continue; /* Clip from bottom */ //maxX = Min(maxX, Private->EPOC_ScreenSize.iHeight-1); /* TODO: Clip from the right side */ TInt sourceRectWidth = maxX - rect2.x + 1;// TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel; TInt sourceRectHeight = maxY - rect2.y + 1; TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength; TInt targetStartOffset = fixedScreenOffset.iX + (targetW-1 - rect2.y) + (fixedScreenOffset.iY +rect2.x) * targetScanlineLength; // Nokia7650 native mode: 12 bpp --> 12 bpp if (_this->screen->format->BitsPerPixel == 12) { /* !!TODO: not yet implemented TUint16* bitmapLine = (TUint16*)_this->screen->pixels + sourceStartOffset; TUint16* screenMemory = screenBuffer + targetStartOffset; for(TInt y = 0 ; y < sourceRectHeight ; y++) { //TODO: optimize: separate loops for 1, 2 and n skip //Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes); TUint16* bitmapPos = bitmapLine; // 2 bytes per pixel TUint16* screenMemoryLinePos = screenMemory; // 2 bytes per pixel for(TInt x = 0 ; x < sourceRectWidth ; x++) { __ASSERT_DEBUG(screenMemory < (screenBuffer + Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight), User::Panic(KLibName, KErrCorrupt)); __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(KLibName, KErrCorrupt)); __ASSERT_DEBUG(bitmapLine < ((TUint16*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt)); __ASSERT_DEBUG(bitmapLine >= (TUint16*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt)); *screenMemoryLinePos = *bitmapPos; bitmapPos++; screenMemoryLinePos += targetScanlineLength; } bitmapLine += sourceScanlineLength; screenMemory--; } */ } // 256 color paletted mode: 8 bpp --> 12 bpp else { TUint8* bitmapLine = (TUint8*)_this->screen->pixels + sourceStartOffset; TUint16* screenMemory = screenBuffer + targetStartOffset; TInt screenXScaleValue = Private->EPOC_ScreenXScaleValue; TInt debug_ycount=0; for(TInt y = 0 ; y < sourceRectHeight ; y++) { if(--screenXScaleValue) { TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */ TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */ TInt screenYScaleValue = Private->EPOC_ScreenYScaleValue; TInt debug_xcount=0; /* Convert each pixel from 256 palette to 4k color values */ for(TInt x = 0 ; x < sourceRectWidth ; x++) { if(--screenYScaleValue) { __ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (Private->EPOC_ScreenSize.iWidth * Private->EPOC_ScreenSize.iHeight)), User::Panic(KLibName, KErrCorrupt)); __ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(KLibName, KErrCorrupt)); __ASSERT_DEBUG(bitmapPos < ((TUint8*)_this->screen->pixels + (_this->screen->w * _this->screen->h)), User::Panic(KLibName, KErrCorrupt)); __ASSERT_DEBUG(bitmapPos >= (TUint8*)_this->screen->pixels, User::Panic(KLibName, KErrCorrupt)); *screenMemoryLinePos = TUint16(EPOC_HWPalette_256_to_Screen[*bitmapPos]); screenMemoryLinePos += targetScanlineLength; debug_xcount++; } else screenYScaleValue = Private->EPOC_ScreenYScaleValue; bitmapPos++; } screenMemory--; debug_ycount++; } // endif else screenXScaleValue = Private->EPOC_ScreenXScaleValue; bitmapLine += sourceScanlineLength; } } } }/* Note: If we are terminated, this could be called in the middle of another SDL video routine -- notably UpdateRects.*/void EPOC_VideoQuit(_THIS){ int i; /* Free video mode lists */ for ( i=0; i<SDL_NUMMODES; ++i ) { if ( Private->SDL_modelist[i] != NULL ) { free(Private->SDL_modelist[i]); Private->SDL_modelist[i] = NULL; } } if ( _this->screen && (_this->screen->flags & SDL_HWSURFACE) ) { /* Direct screen access, no memory buffer */ _this->screen->pixels = NULL; } if (_this->screen && _this->screen->pixels) { free(_this->screen->pixels); _this->screen->pixels = NULL; } /* Free Epoc resources */ /* Disable events for me */ if (Private->EPOC_WsEventStatus != KRequestPending) Private->EPOC_WsSession.EventReadyCancel(); if (Private->EPOC_RedrawEventStatus != KRequestPending) Private->EPOC_WsSession.RedrawReadyCancel(); #if defined(__WINS__) || defined(TEST_BM_DRAW) delete Private->EPOC_Bitmap; Private->EPOC_Bitmap = NULL; #else #endif#ifndef SYMBIAN_CRYSTAL free(Private->EPOC_DrawDevice);#endif if (Private->EPOC_WsWindow.WsHandle()) Private->EPOC_WsWindow.Close(); if (Private->EPOC_WsWindowGroup.WsHandle()) Private->EPOC_WsWindowGroup.Close(); delete Private->EPOC_WindowGc; Private->EPOC_WindowGc = NULL; delete Private->EPOC_WsScreen; Private->EPOC_WsScreen = NULL; if (Private->EPOC_WsSession.WsHandle()) Private->EPOC_WsSession.Close();}WMcursor *EPOC_CreateWMCursor(_THIS, Uint8* /*data*/, Uint8* /*mask*/, int /*w*/, int /*h*/, int /*hot_x*/, int /*hot_y*/){ return (WMcursor *) 9210; // it's ok to return something unuseful but true}void EPOC_FreeWMCursor(_THIS, WMcursor* /*cursor*/){ /* Disable virtual cursor */ HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible); Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone);}int EPOC_ShowWMCursor(_THIS, WMcursor *cursor){ if (cursor == (WMcursor *)9210) { /* Enable virtual cursor */ Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNormal); if (isCursorVisible) HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible); else Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone); } else { /* Disable virtual cursor */ HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible); Private->EPOC_WsSession.SetPointerCursorMode(EPointerCursorNone); } return(1);}}; // extern "C"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -