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

📄 sdl_epocvideo.cpp

📁 SDL库 在进行视频显示程序spcaview安装时必须的库文件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        for(int i = firstcolor; i < ncolors; i++)            {	        // 4k value: 0000 rrrr gggg bbbb	        TUint32 color4K	 = (colors[i].r & 0x0000f0) << 4;	        color4K			|= (colors[i].g & 0x0000f0);      	        color4K			|= (colors[i].b & 0x0000f0) >> 4;            palette[i] = color4K;            }        }    else if(TDisplayModeUtils::NumDisplayModeColors(mode) == 65536)        {        for(int i = firstcolor; i < ncolors; i++)            {			// 64k-colour displays effectively support RGB values			// with 5 bits allocated to red, 6 to green and 5 to blue			// 64k value: rrrr rggg gggb bbbb	        TUint32 color64K = (colors[i].r & 0x0000f8) << 8;	        color64K		|= (colors[i].g & 0x0000fc) << 3;	        color64K		|= (colors[i].b & 0x0000f8) >> 3;            palette[i] = color64K;            }        }    else if(TDisplayModeUtils::NumDisplayModeColors(mode) == 16777216)        {        for(int i = firstcolor; i < ncolors; i++)            {			// 16M-colour            //0000 0000 rrrr rrrr gggg gggg bbbb bbbb	        TUint32 color16M = colors[i].r << 16;	        color16M		|= colors[i].g << 8;	        color16M		|= colors[i].b;            palette[i] = color16M;            }        }    else        {        return -2;        }    if(EpocSdlEnv::SetPalette(firstcolor, ncolors, palette) == KErrNone)    	return 0;	return -1;	}/*	void AllocHWSurfaceL(CFbsBitmap*& aBitmap, const TDisplayMode& aMode, const TSize& aSize)	{	aBitmap = new (ELeave) CFbsBitmap();		if(KErrNone != aBitmap->CreateHardwareBitmap(aSize, aMode,		EpocSdlEnv::EikonEnv().EikAppUi()->Application()->AppDllUid())) 	//...if it fails - should we use wsbitmaps???		{//the good reason to use hw bitmaps is that they wont need lock heap		PANIC_IF_ERROR(aBitmap->Create(aSize, aMode));		}	}	int CreateSurfaceL(_THIS, SDL_Surface* surface)    {    __ASSERT_ALWAYS(Private->iFrame == NULL, PANIC(KErrAlreadyExists));;	TInt dmode = EColorLast;		TDisplayMode displayMode;	EpocSdlEnv::GetDiplayMode(displayMode);		if(	TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode)	== surface->format->BitsPerPixel)		{		dmode = displayMode;		}	else		{		--dmode;		while(TDisplayModeUtils::IsDisplayModeColor(TDisplayMode(dmode)) &&			TDisplayModeUtils::NumDisplayModeBitsPerPixel(TDisplayMode(dmode)) !=			surface->format->BitsPerPixel)			--dmode;		}	__ASSERT_ALWAYS(TDisplayModeUtils::IsDisplayModeColor(TDisplayMode(dmode)), PANIC(KErrNotSupported));	TRAPD(err, AllocHWSurfaceL(Private->iFrame, TDisplayMode(dmode), TSize(surface->w, surface->h)));	return err == KErrNone ? 0 : -1;    }*/TDisplayMode GetDisplayMode(TInt aBitsPerPixel)	{	const TDisplayMode displayMode = EpocSdlEnv::DisplayMode();	TInt dmode = EColorLast;	if(	TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode)	== aBitsPerPixel)		{		dmode = displayMode;		}	else		{		--dmode;		while(TDisplayModeUtils::IsDisplayModeColor(TDisplayMode(dmode)) &&			TDisplayModeUtils::NumDisplayModeBitsPerPixel(TDisplayMode(dmode)) !=			aBitsPerPixel)			--dmode;		}	return TDisplayMode(dmode);	}SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current,				int width, int height, int bpp, Uint32 flags)	{	const TSize screenSize = EpocSdlEnv::WindowSize(TSize(width, height));	if(width > screenSize.iWidth || height > screenSize.iHeight)	    {	    if(flags & SDL_FULLSCREEN)	        {	        width = screenSize.iWidth;	        height = screenSize.iHeight;	        }	    else    		    return NULL;	    }    if(current && current->pixels)    	{      //  free(current->pixels);        current->pixels = NULL;    	}    		if(!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0))	 	{		return(NULL);	 	}	current->flags = 0;	if(width == screenSize.iWidth && height == screenSize.iHeight)		current->flags |= SDL_FULLSCREEN;		const int numBytesPerPixel = ((bpp-1)>>3) + 1;   	current->pitch = numBytesPerPixel * width; // Number of bytes in scanline     /* Set up the new mode framebuffer */   	current->flags |= SDL_PREALLOC;   	   	if(bpp <= 8)   		current->flags |= SDL_HWPALETTE;   	   	User::Free(Private->iSwSurface);   	current->pixels = NULL;   	Private->iSwSurface = NULL;   	   	if(flags & SDL_HWSURFACE)   	    {   	    current->flags |= SDL_HWSURFACE;   	   //	current->pixels = NULL;   	   // 	Private->iSwSurface = NULL;   	    }   	else   	    {   	    current->flags |= SDL_SWSURFACE;   	    const TInt surfacesize = width * height * numBytesPerPixel;     	   	Private->iSwSurfaceSize = TSize(width, height);   	   	delete Private->iSwSurface;   	   	Private->iSwSurface = NULL;   	  	current->pixels = (TUint8*) User::AllocL(surfacesize);   	  	Private->iSwSurface = (TUint8*) current->pixels;   	  	const TInt err = EpocSdlEnv::AllocSwSurface   	  		(TSize(width, height), GetDisplayMode(current->format->BitsPerPixel));	    if(err != KErrNone)	    	return NULL;	    }		current->w = width;	current->h = height;	  		/* Set the blit function */	_this->UpdateRects = EPOC_DirectUpdate;    /*     *  Logic for getting suitable screen dimensions, offset, scaling and orientation     */    /* Centralize game window on device screen  */           Private->iScreenPos.iX = Max(0, (screenSize.iWidth  - width)  / 2);    Private->iScreenPos.iY = Max(0, (screenSize.iHeight - height) / 2);     //   delete (Private->iFrame);//	Private->iFrame = NULL;	  //  TRAPD(err, CreateSurfaceL(_this, current));  //  PANIC_IF_ERROR(err);        SDL_TRACE1("View width %d", width);    SDL_TRACE1("View height %d", height);    SDL_TRACE1("View bmode %d", bpp);    SDL_TRACE1("View x %d", Private->iScreenPos.iX);    SDL_TRACE1("View y %d", Private->iScreenPos.iY);	EpocSdlEnv::LockPalette(EFalse);	/* We're done */	return(current);}static int EPOC_AllocHWSurface(_THIS, SDL_Surface* surface)	{	return KErrNone == EpocSdlEnv::AllocHwSurface(TSize(surface->w, surface->h), GetDisplayMode(surface->format->BitsPerPixel));	}	static void EPOC_FreeHWSurface(_THIS, SDL_Surface* /*surface*/)	{	}static int EPOC_LockHWSurface(_THIS, SDL_Surface* surface)	{	if(EpocSdlEnv::IsDsaAvailable())		{		TUint8* address = EpocSdlEnv::LockHwSurface();		if(address != NULL)			{			surface->pixels = address;			return 1;			}		}	return 0;	}static void EPOC_UnlockHWSurface(_THIS, SDL_Surface* /*surface*/)	{	EpocSdlEnv::UnlockHwSurface();	}static int EPOC_FlipHWSurface(_THIS, SDL_Surface* /*surface*/)	{	return(0);	}static void EPOC_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)	{	if(EpocSdlEnv::IsDsaAvailable())		{		if(Private->iSwSurface)		    {		    const TRect target(Private->iScreenPos, Private->iSwSurfaceSize);		    for(TInt i = 0; i < numrects ;i++)		    	{		    	const TRect rect(TPoint(rects[i].x, rects[i].y),		    		TSize(rects[i].w, rects[i].h));		    	if(!EpocSdlEnv::AddUpdateRect(Private->iSwSurface, rect, target))		    		return; //not succesful		    	}		    EpocSdlEnv::UpdateSwSurface();		    }		SDL_PauseAudio(0);		}    else    	{                                                           	SDL_PauseAudio(1);    	EpocSdlEnv::WaitDsaAvailable();              		}	}/* Note:  If we are terminated, this could be called in the middle of   another SDL video routine -- notably UpdateRects.*/void EPOC_VideoQuit(_THIS)	{//	delete Private->iFrame;//	Private->iFrame = NULL;	User::Free(Private->iSwSurface);	Private->iSwSurface = NULL;	EpocSdlEnv::FreeSurface();	}		WMcursor *EPOC_CreateWMCursor(_THIS, Uint8* /*data*/, Uint8* /*mask*/, int /*w*/, int /*h*/, int /*hot_x*/, int /*hot_y*/)    {    return (WMcursor*) 1; //hii! prevents SDL to view a std cursor    }void EPOC_FreeWMCursor(_THIS, WMcursor* /*cursor*/)    {    }int EPOC_ShowWMCursor(_THIS, WMcursor *cursor)    {    return true;      }

⌨️ 快捷键说明

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