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

📄 instance_displayadapter.cpp

📁 270的linux说明
💻 CPP
字号:
/*

Copyright (c) 2008, Intel Corporation. 

All rights reserved.

 

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:


    * Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation and/or 
other materials provided with the distribution.

    * Neither the name of Intel Corporation nor the names of its contributors 
may be used to endorse or promote products derived from this software without 
specific prior written permission.

 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.

*/#include "inc/framework/basetypes.h"#include "inc/framework/win2linux.h"#include "Instance_DisplayAdapter.h"#include "inc/framework/base_Enum.h"#include "x11_util.h"#include "fb_util.h"//==============================================================================////	DefaultDisplayAdapterInstanceObject implementation////==============================================================================bool DefaultDisplayAdapterInstanceObject::Initialize( const IntelMobileString& szKey ){	_Log(IntelMobileText("DefaultDisplayAdapterInstanceObject::Initialize(%s)"), szKey.c_str());	m_sKey = szKey;#ifdef X11_SUPPORT	X11DisplayInit();#endif	return true;}DefaultDisplayAdapterInstanceObject::~DefaultDisplayAdapterInstanceObject(){	_Log( LOG_DEBUG_DEVICE, IntelMobileText("Trace: DefaultDisplayAdapterInstanceObject::~DefaultDisplayAdapterInstanceObject()") );#ifdef X11_SUPPORT	X11DisplayFinish();#endif}//==============================================================================//==============================================================================//// DisplayAdapter properties////==============================================================================//==============================================================================//// These all return the true value.  If there is an error, throw // an appropriate HRESULT.  These need to return the true value// because the override the virtual GetValue() function in the // Property base class.void DisplayAdapterIdClass::GetValueImpl(){	//XXX	this->SetValueImpl( IntelMobileText("DisplayAdapter") );}void DisplayAdapterProductNameClass::GetValueImpl(){	//TODO: Linux	this->SetNull(true);}void DisplayAdapterManufacturerClass::GetValueImpl(){	//TODO: Linux	this->SetNull(true);}void    DisplayAdapterMemorySizeClass::GetValueImpl(){	//TODO: Linux	this->SetNull(true);}void DisplayAdapterColorDepthClass::GetValueImpl(){	//TODO	//int colorDepth = GetDeviceCaps( hdc, BITSPIXEL );  // bits per pixel	/*int colorDepth = GetDeviceCaps( hdc, NUMCOLORS );  // bits per pixel	if ( colorDepth == -1 )	{		if ( GetDeviceCaps( hdc, RASTERCAPS ) == RC_PALETTE )		{			colorDepth = GetDeviceCaps( hdc, COLORRES );		}		else		{			this->SetNull( true );			DeleteDC( hdc );			return;		}	}*/	int colorDepth = X11GetScreenProperty(0, 0, COLORDEP);	this->SetValueImpl( colorDepth );	//DeleteDC( hdc );}void DisplayAdapterIsPrimaryClass::GetValueImpl(){        //Static, so initiate in the constrcture	this->SetValueImpl(true);}void DisplayAdapterHorizontalResolutionClass::GetValueImpl(){	//HDC hdc = CreateDC( IntelMobileText("DISPLAY"), NULL, NULL, NULL );	//int horizontalResolution = GetDeviceCaps( hdc, HORZRES );	int horizontalResolution = X11GetScreenProperty(0, 0, XRES);	this->SetValueImpl( horizontalResolution );	//DeleteDC( hdc );}void DisplayAdapterVerticalResolutionClass::GetValueImpl(){	//HDC hdc = CreateDC( IntelMobileText("DISPLAY"), NULL, NULL, NULL );	//int verticalResolution = GetDeviceCaps( hdc, VERTRES );	int verticalResolution = X11GetScreenProperty(0, 0, YRES);	this->SetValueImpl( verticalResolution );	//DeleteDC( hdc );}void DisplayAdapterRefreshRateClass::GetValueImpl(){	//TODO	int refreshrate = X11GetScreenProperty(0, 0, RATE);	if(refreshrate == 0)	{		//try to use fb to get rate		refreshrate = GetRate();	}	this->SetValueImpl(refreshrate);}void DisplayAdapterPixelDensityClass::GetValueImpl(){	//TODO: Linux	this->SetNull(true);}/*void DisplayAdapterRotationSupportedClass::GetValueImpl(){	if(X11GetRotateSupported(0))	{		this->SetValueImpl( true );	}	else	{		this->SetValueImpl( false );	}}*/void DisplayAdapterOrientationClass::GetValueImpl(){	unsigned int rotation = X11GetCurrentRotate(0);	switch(rotation)	{		case 0:			this->SetValueImpl( OrientationEnum::Portrait );                        break;		case 1:			this->SetValueImpl( OrientationEnum::Landscape );                        break;		case 2:			this->SetValueImpl( OrientationEnum::InvertedPortrait );                                break;		case 3:			this->SetValueImpl( OrientationEnum::InvertedLandscape );                                break;		default:			this->SetNull( true );	}}bool DisplayAdapterOrientationClass::IsSettable( ){		/*	    try	    {				if(X11GetRotateSupported(0))				{					return true;				}				else				{					return false;				}		}	    catch (...)	    {	        THROWIMEXCEPTION("80043315");	    }		*/		return false;}bool DisplayAdapterOrientationClass::SetValueImplOnDevice(IntelMobileOrientationEnum sInput){	unsigned int rotation, rot;	int ret;    try    {	switch (sInput)	{		case OrientationEnum::Portrait:			rotation = 0;			break;		case OrientationEnum::Landscape:			rotation = 1;			break;		case OrientationEnum::InvertedPortrait:			rotation = 2;			break;		case OrientationEnum::InvertedLandscape:			rotation = 3;			break;		default:			return false;	}		rot = 0;	rot = 1 << rotation;	ret = X11SetRotation(0, rot);	    }    catch (...)    {        THROWIMEXCEPTION("80043315");    }	if( ret < 0)		return false;	return true;}void DisplayAdapterScreenStateClass::GetValueImpl(){	//TODO: Linux    this->SetNull(true);}bool DisplayAdapterScreenStateClass::IsSettable( ){	    //80043316	    return false;}bool DisplayAdapterScreenStateClass::SetValueImplOnDevice(IntelMobileScreenStateEnum sInput){	//TODO: Linux	return false;}void DisplayAdapterBrightnessClass::GetValueImpl(){	//TODO: Linux    this->SetNull(true);}bool DisplayAdapterBrightnessClass::IsSettable( ){	    //80043317	    return false;}bool DisplayAdapterBrightnessClass::SetValueImplOnDevice(IntelMobileFloat sInput){	//TODO: Linux    return false;}/*void DisplayAdapterCurrentRotationAngleClass::GetValueImpl(){	unsigned int rotation = X11GetCurrentRotate(0);	switch(rotation)	{		case 0:			this->SetValueImpl( Angle_0 );                        break;		case 1:			this->SetValueImpl( Angle_90 );                        break;		case 2:			this->SetValueImpl( Angle_180 );                                break;		case 3:			this->SetValueImpl( Angle_270 );                                break;		default:			this->SetValueImpl( Angle_0 );	}}*///==============================================================================//==============================================================================//// DisplayAdapter methods////==============================================================================//==============================================================================/*bool DefaultDisplayAdapterInstanceObject::Rotate( IntelMobileRotationAngleType angle ){*/	/*	DEVMODE devMode;	devMode.dmFields = DM_DISPLAYORIENTATION;	switch (angle)	{		case Angle_0:			devMode.dmDisplayOrientation = DMDO_0;			break;		case Angle_90:			devMode.dmDisplayOrientation = DMDO_90;			break;		case Angle_180:			devMode.dmDisplayOrientation = DMDO_180;			break;		case Angle_270:			devMode.dmDisplayOrientation = DMDO_270;			break;		default:			return false;	}	long bCanRotate = ChangeDisplaySettingsEx(NULL, &devMode, NULL, CDS_RESET, NULL);	if ( bCanRotate == DISP_CHANGE_SUCCESSFUL )		return true;	else		return false;	*//*	unsigned int rotation, rot;	int ret;	switch (angle)	{		case Angle_0:			rotation = 0;			break;		case Angle_90:			rotation = 1;			break;		case Angle_180:			rotation = 2;			break;		case Angle_270:			rotation = 3;			break;		default:			return false;	}		rot = 0;	rot = 1 << rotation;	ret = X11SetRotation(0, rot);		if( ret < 0)		return false;	return true;}*/DisplayModesList DefaultDisplayAdapterInstanceObject::GetValidModes(){	DisplayModesList modeVector;        SERVERDISPLAYMODE dm;	unsigned int count, i;	count = X11GetScreenSizeCount(0);	for( i = 0; i < count; i++)	{		dm.HorizontalResolution = X11GetScreenProperty(0, i, XRES);        	dm.VerticalResolution = X11GetScreenProperty(0, i, YRES);        	dm.ColorDepth = X11GetScreenProperty(0, i, COLORDEP);				dm.RefreshRate = X11GetScreenProperty(0, i, RATE);		if(dm.RefreshRate == 0)		{			dm.RefreshRate = GetRate();		}				modeVector.push_back(dm);	}	return modeVector;}bool DefaultDisplayAdapterInstanceObject::SetDisplayMode(DisplayMode mode){	//TODO: Linux	return false;}bool DefaultDisplayAdapterInstanceObject::SetScreenState(IntelMobileScreenStateEnum ScreenState){	//TODO: Linux	return false;}/*bool DefaultDisplayAdapterInstanceObject::SetResolution(int horizontal, int vertical){	return false;}bool DefaultDisplayAdapterInstanceObject::SetColorDepth(int color){	return false;}bool DefaultDisplayAdapterInstanceObject::SetRefreshRate(int rate){	return false;}bool DefaultDisplayAdapterInstanceObject::ChangeDisplayMode(int horizontal, int vertical, int color, int rate){	return false;}*/

⌨️ 快捷键说明

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