⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdl_epocvideo.cpp

📁 SDL库 在进行视频显示程序spcaview安装时必须的库文件
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/*    SDL - Simple DirectMedia Layer    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga    This library is free software; you can redistribute it and/or    modify it under the terms of the GNU Library General Public    License as published by the Free Software Foundation; either    version 2 of the License, or (at your option) any later version.    This library is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    Library General Public License for more details.    You should have received a copy of the GNU Library General Public    License along with this library; if not, write to the Free    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA    Sam Lantinga    slouken@devolution.com*//*    SDL_epocvideo.cpp    Epoc based SDL video driver implementation    Thanks to Peter van Sebille, the author of EMame. It is a great example of     low level graphics coding in Epoc.    Epoc version by Hannu Viitala (hannu.j.viitala@mbnet.fi)	Assembler routines by Kimmo Kinnunen*/#include <stdlib.h>#include <stdio.h>#include <string.h>extern "C" {#include "SDL_error.h"#include "SDL_timer.h"#include "SDL_video.h"#undef NULL#include "SDL_pixels_c.h"#include "SDL.h"};#include "SDL_epocvideo.h"#include "SDL_epocevents_c.h"#include "sdl_epocruntime.h"#include <hal.h>#include <coedef.h>#include <flogger.h>#ifdef SYMBIAN_QUARTZSDL_VideoDevice* _thisDevice;#endif_LIT(KLibName, "SDL");/* For debugging *///if old SOS, from 7.x this is public!class CLockable : public CFbsBitmap    {    public:        static  CLockable* Lockable(CFbsBitmap* aBmp) {return static_cast<CLockable*>(aBmp);}        void Lock() {LockHeap();}        void Unlock() {UnlockHeap();}    };#define LockHeap(x) CLockable::Lockable(x)->Lock()#define UnlockHeap(x) CLockable::Lockable(x)->Unlock()void RDebug_Print_b(char* error_str, void* param)    {    TBuf8<128> error8((TUint8*)error_str);    TBuf<128> error;    error.Copy(error8);#ifndef TRACE_TO_FILE    if (param) //!! Do not work if the parameter is really 0!!        RDebug::Print(error, param);    else         RDebug::Print(error);#else    if (param) //!! Do not work if the parameter is really 0!!        RFileLogger::WriteFormat(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error, param);    else         RFileLogger::Write(KLibName, _L("SDL.txt"), EFileLoggingModeAppend, error);#endif    }extern "C" void RDebug_Print(char* error_str, void* param)    {    RDebug_Print_b(error_str, param);    }int Debug_AvailMem2()    {    //User::CompressAllHeaps();    TMemoryInfoV1Buf membuf;     User::LeaveIfError(UserHal::MemoryInfo(membuf));    TMemoryInfoV1 minfo = membuf();	return(minfo.iFreeRamInBytes);    }extern "C" int Debug_AvailMem()    {    return(Debug_AvailMem2());    }extern "C" {/* Initialization/Query functions */static int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat);static SDL_Rect **EPOC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);static SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);static int EPOC_SetColors(_THIS, int firstcolor, int ncolors,			  SDL_Color *colors);static void EPOC_VideoQuit(_THIS);/* Hardware surface functions */static int EPOC_AllocHWSurface(_THIS, SDL_Surface *surface);static int EPOC_LockHWSurface(_THIS, SDL_Surface *surface);static int EPOC_FlipHWSurface(_THIS, SDL_Surface *surface);static void EPOC_UnlockHWSurface(_THIS, SDL_Surface *surface);static void EPOC_FreeHWSurface(_THIS, SDL_Surface *surface);static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);static int EPOC_Available(void);static SDL_VideoDevice *EPOC_CreateDevice(int devindex);void DrawBackground(_THIS);void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer);void DirectDrawRotated(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer);/* Mouse functions */static WMcursor *EPOC_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);static void EPOC_FreeWMCursor(_THIS, WMcursor *cursor);static int EPOC_ShowWMCursor(_THIS, WMcursor *cursor);/* !!For 12 bit screen HW. Table for fast conversion from 8 bit to 12 bit */// TUint16 is enough, but using TUint32 so we can use better instruction selection on ARMIstatic TUint32 EPOC_HWPalette_256_to_Screen[256];VideoBootStrap EPOC_bootstrap = {	"epoc", "EPOC system",    EPOC_Available, EPOC_CreateDevice};const TUint32 WindowClientHandle = 9210; //!! const/* Epoc video driver bootstrap functions */static int EPOC_Available(void){    return 1; /* Always available */}static void EPOC_DeleteDevice(SDL_VideoDevice *device){	free(device->hidden);	free(device);}static SDL_VideoDevice *EPOC_CreateDevice(int /*devindex*/){	SDL_VideoDevice *device;	SDL_TRACE("SDL:EPOC_CreateDevice");	/* Allocate all variables that we free on delete */	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));	if ( device ) {		memset(device, 0, (sizeof *device));		device->hidden = (struct SDL_PrivateVideoData *)				malloc((sizeof *device->hidden));	}	if ( (device == NULL) || (device->hidden == NULL) ) {		SDL_OutOfMemory();		if ( device ) {			free(device);		}		return(0);	}	memset(device->hidden, 0, (sizeof *device->hidden));	/* Set the function pointers */	device->VideoInit = EPOC_VideoInit;	device->ListModes = EPOC_ListModes;	device->SetVideoMode = EPOC_SetVideoMode;	device->SetColors = EPOC_SetColors;	device->UpdateRects = NULL;	device->VideoQuit = EPOC_VideoQuit;	device->AllocHWSurface = EPOC_AllocHWSurface;	device->CheckHWBlit = NULL;	device->FillHWRect = NULL;	device->SetHWColorKey = NULL;	device->SetHWAlpha = NULL;	device->LockHWSurface = EPOC_LockHWSurface;	device->UnlockHWSurface = EPOC_UnlockHWSurface;	device->FlipHWSurface = EPOC_FlipHWSurface;	device->FreeHWSurface = EPOC_FreeHWSurface;	device->SetIcon = NULL;	device->SetCaption = NULL;	device->GetWMInfo = NULL;	device->FreeWMCursor = EPOC_FreeWMCursor;	device->CreateWMCursor = EPOC_CreateWMCursor;	device->ShowWMCursor = EPOC_ShowWMCursor;	device->WarpWMCursor = NULL;	device->InitOSKeymap = EPOC_InitOSKeymap;	device->PumpEvents = EPOC_PumpEvents;	device->free = EPOC_DeleteDevice;	return device;}int GetBpp(TDisplayMode displaymode){    /*TInt numColors = TDisplayModeUtils::NumDisplayModeColors(displaymode);    TInt bitsPerPixel = 1;    for (TInt32 i = 2; i < numColors; i <<= 1, bitsPerPixel++);    return bitsPerPixel;*/    return  TDisplayModeUtils::NumDisplayModeBitsPerPixel(displaymode);   }void DisableKeyBlocking(_THIS)    {    // Disable key blocking    TRawEvent event;    event.Set((TRawEvent::TType)/*EDisableKeyBlock*/51); // !!EDisableKeyBlock not found in epoc32\include!    Private->EPOC_WsSession.SimulateRawEvent(event);    }void ConstructWindowL(_THIS){	TInt	error;	SDL_TRACE("SDL:ConstructWindowL");	error = Private->EPOC_WsSession.Connect();	User::LeaveIfError(error);	Private->EPOC_WsScreen=new(ELeave) CWsScreenDevice(Private->EPOC_WsSession);	User::LeaveIfError(Private->EPOC_WsScreen->Construct());	User::LeaveIfError(Private->EPOC_WsScreen->CreateContext(Private->EPOC_WindowGc));	Private->EPOC_WsWindowGroup=RWindowGroup(Private->EPOC_WsSession);	User::LeaveIfError(Private->EPOC_WsWindowGroup.Construct(WindowClientHandle));	Private->EPOC_WsWindowGroup.SetOrdinalPosition(0);	// Set window group name (the same as process name)) !!Gives always "EPOC" in WINS	RProcess thisProcess;	TParse exeName;	exeName.Set(thisProcess.FileName(), NULL, NULL);    TBuf<32> winGroupName;    winGroupName.Append(0);    winGroupName.Append(0);    winGroupName.Append(0);// uid    winGroupName.Append(0);    winGroupName.Append(exeName.Name()); // caption    winGroupName.Append(0);    winGroupName.Append(0); //doc name	Private->EPOC_WsWindowGroup.SetName(winGroupName); 	Private->EPOC_WsWindow=RWindow(Private->EPOC_WsSession);  // Markus, it was:  // User::LeaveIfError(Private->EPOC_WsWindow.Construct(Private->EPOC_WsWindowGroup,WindowClientHandle ));  // but SOS 7.0s debug does not accept same window handle twice	User::LeaveIfError(Private->EPOC_WsWindow.Construct(Private->EPOC_WsWindowGroup,WindowClientHandle - 1));	Private->EPOC_WsWindow.SetBackgroundColor(KRgbWhite);    Private->EPOC_WsWindow.Activate();	Private->EPOC_WsWindow.SetSize(Private->EPOC_WsScreen->SizeInPixels()); 	Private->EPOC_WsWindow.SetVisible(ETrue);    Private->EPOC_WsWindowGroupID = Private->EPOC_WsWindowGroup.Identifier();    Private->EPOC_IsWindowFocused = EFalse;    DisableKeyBlocking(_this); //disable key blocking}int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat){    // !!TODO:handle leave functions!    int i;	SDL_TRACE("SDL:EPOC_VideoInit");	/* Initialize all variables that we clean on shutdown */   	for ( i=0; i<SDL_NUMMODES; ++i ) {		Private->SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect));		Private->SDL_modelist[i]->x = Private->SDL_modelist[i]->y = 0;	}	/* Modes sorted largest to smallest */	Private->SDL_modelist[0]->w = 800; Private->SDL_modelist[0]->h = 250;	Private->SDL_modelist[1]->w = 640; Private->SDL_modelist[1]->h = 480;	Private->SDL_modelist[2]->w = 480; Private->SDL_modelist[2]->h = 600;	Private->SDL_modelist[3]->w = 640; Private->SDL_modelist[3]->h = 400;	Private->SDL_modelist[4]->w = 352; Private->SDL_modelist[4]->h = 416;	Private->SDL_modelist[5]->w = 416; Private->SDL_modelist[5]->h = 352;	Private->SDL_modelist[6]->w = 416; Private->SDL_modelist[6]->h = 312;	Private->SDL_modelist[7]->w = 352; Private->SDL_modelist[7]->h = 264;	Private->SDL_modelist[8]->w = 800; Private->SDL_modelist[8]->h = 240; //for doom all these..	Private->SDL_modelist[9]->w = 640; Private->SDL_modelist[9]->h = 240; 	Private->SDL_modelist[10]->w = 480; Private->SDL_modelist[10]->h = 240; 	Private->SDL_modelist[11]->w = 640; Private->SDL_modelist[11]->h = 240; 	Private->SDL_modelist[12]->w = 352; Private->SDL_modelist[12]->h = 240; 	Private->SDL_modelist[13]->w = 416; Private->SDL_modelist[13]->h = 240; 	Private->SDL_modelist[14]->w = 416; Private->SDL_modelist[14]->h = 240; 	Private->SDL_modelist[15]->w = 352; Private->SDL_modelist[15]->h = 240;     Private->SDL_modelist[16]->w = 640; Private->SDL_modelist[16]->h = 200; 	Private->SDL_modelist[17]->w = 320; Private->SDL_modelist[17]->h = 240; //...for doom, currently engine renders no-higher windows :-(, propably should get fixed 	Private->SDL_modelist[18]->w = 320; Private->SDL_modelist[18]->h = 200;	Private->SDL_modelist[19]->w = 256; Private->SDL_modelist[19]->h = 192;	Private->SDL_modelist[20]->w = 176; Private->SDL_modelist[20]->h = 208;	Private->SDL_modelist[21]->w = 208; Private->SDL_modelist[21]->h = 176; // Rotated	Private->SDL_modelist[22]->w = 160; Private->SDL_modelist[22]->h = 144;     Private->SDL_modelist[23]->w = 640; Private->SDL_modelist[2]->h = 200;  //s80 some new modes     Private->SDL_modelist[24]->w = 640; Private->SDL_modelist[2]->h = 320;  //s90 modes are added    Private->SDL_modelist[25]->w = 640; Private->SDL_modelist[2]->h = 240;  //here	Private->SDL_modelist[26]->w = 640; Private->SDL_modelist[4]->h = 200;  //now	Private->SDL_modelist[27] = NULL;    /* Construct Epoc window */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -