moved more of the old stuff from DisplayDriver into DisplayDriverImpl

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12141 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2005-03-29 22:22:28 +00:00
parent 13066bfea1
commit 3f537e5fa7
4 changed files with 104 additions and 82 deletions

View File

@ -38,15 +38,9 @@
\brief Sets up internal variables needed by all DisplayDriver subclasses
*/
DisplayDriver::DisplayDriver()
: fDPMSState(B_DPMS_ON),
fDPMSCaps(B_DPMS_ON)
{
fDisplayMode.virtual_width = 640;
fDisplayMode.virtual_height = 480;
fDisplayMode.space = B_RGBA32;
}
/*!
\brief Does nothing
*/
@ -82,72 +76,4 @@ DisplayDriver::Shutdown()
{
}
// Protected Internal Functions
/*
\brief Sets the screen mode to specified resolution and color depth.
\param mode Data structure as defined in Screen.h
Subclasses must include calls to _SetDepth, _SetHeight, _SetWidth, and _SetMode
to update the state variables kept internally by the DisplayDriver class.
*/
void
DisplayDriver::SetMode(const display_mode &mode)
{
fDisplayMode = mode;
}
// GetMode
void
DisplayDriver::GetMode(display_mode *mode)
{
if (!mode)
return;
Lock();
*mode = fDisplayMode;
Unlock();
}
/*!
\brief Sets the driver's Display Power Management System state
\param state The state which the driver should enter
\return B_OK if successful, B_ERROR for failure
This function will fail if the driver's rendering context does not support a
particular DPMS state. Use DPMSCapabilities to find out the supported states.
The default implementation supports only B_DPMS_ON.
*/
status_t
DisplayDriver::SetDPMSMode(const uint32 &state)
{
if (state != B_DPMS_ON)
return B_ERROR;
fDPMSState = state;
return B_OK;
}
/*!
\brief Returns the driver's current DPMS state
\return The driver's current DPMS state
*/
uint32
DisplayDriver::DPMSMode()
{
return fDPMSState;
}
/*!
\brief Returns the driver's DPMS capabilities
\return The driver's DPMS capabilities
The capabilities are the modes supported by the driver. The default implementation
allows only B_DPMS_ON. Other possible states are B_DPMS_STANDBY, SUSPEND, and OFF.
*/
uint32
DisplayDriver::DPMSCapabilities()
{
return fDPMSCaps;
}

View File

@ -52,8 +52,13 @@ static Blitter blitter;
DisplayDriverImpl::DisplayDriverImpl()
: DisplayDriver(),
fLocker("DisplayDriver lock"),
fCursorHandler(this)
fCursorHandler(this),
fDPMSState(B_DPMS_ON),
fDPMSCaps(B_DPMS_ON)
{
fDisplayMode.virtual_width = 640;
fDisplayMode.virtual_height = 480;
fDisplayMode.space = B_RGBA32;
}
@ -2421,6 +2426,86 @@ DisplayDriverImpl::Unlock()
fLocker.Unlock();
}
// Protected Internal Functions
/*
\brief Sets the screen mode to specified resolution and color depth.
\param mode Data structure as defined in Screen.h
Subclasses must include calls to _SetDepth, _SetHeight, _SetWidth, and _SetMode
to update the state variables kept internally by the DisplayDriver class.
*/
void
DisplayDriverImpl::SetMode(const display_mode &mode)
{
fDisplayMode = mode;
}
// GetMode
void
DisplayDriverImpl::GetMode(display_mode *mode)
{
if (!mode)
return;
Lock();
*mode = fDisplayMode;
Unlock();
}
// DisplayMode
const display_mode*
DisplayDriverImpl::DisplayMode()
{
const display_mode* mode = NULL;
Lock();
mode = &fDisplayMode;
Unlock();
return mode;
}
/*!
\brief Sets the driver's Display Power Management System state
\param state The state which the driver should enter
\return B_OK if successful, B_ERROR for failure
This function will fail if the driver's rendering context does not support a
particular DPMS state. Use DPMSCapabilities to find out the supported states.
The default implementation supports only B_DPMS_ON.
*/
status_t
DisplayDriverImpl::SetDPMSMode(const uint32 &state)
{
if (state != B_DPMS_ON)
return B_ERROR;
fDPMSState = state;
return B_OK;
}
/*!
\brief Returns the driver's current DPMS state
\return The driver's current DPMS state
*/
uint32
DisplayDriverImpl::DPMSMode()
{
return fDPMSState;
}
/*!
\brief Returns the driver's DPMS capabilities
\return The driver's DPMS capabilities
The capabilities are the modes supported by the driver. The default implementation
allows only B_DPMS_ON. Other possible states are B_DPMS_STANDBY, SUSPEND, and OFF.
*/
uint32
DisplayDriverImpl::DPMSCapabilities()
{
return fDPMSCaps;
}
/*!
\brief Dumps the contents of the frame buffer to a file.
\param path Path and leaf of the file to be created without an extension

View File

@ -297,6 +297,11 @@ class DisplayDriverImpl : public DisplayDriver {
virtual bool Lock(bigtime_t timeout = B_INFINITE_TIMEOUT);
virtual void Unlock();
// display mode access
virtual void SetMode(const display_mode &mode);
virtual void GetMode(display_mode *mode);
virtual const display_mode* DisplayMode();
virtual bool DumpToFile(const char *path);
virtual ServerBitmap* DumpToBitmap();
@ -304,6 +309,10 @@ class DisplayDriverImpl : public DisplayDriver {
const LineArrayData *data,
const DrawData *d);
virtual status_t SetDPMSMode(const uint32 &state);
virtual uint32 DPMSMode();
virtual uint32 DPMSCapabilities();
virtual status_t GetDeviceInfo(accelerant_device_info *info);
virtual status_t GetModeList(display_mode **mode_list,
@ -421,6 +430,10 @@ friend class WinBorder;
protected:
BLocker fLocker;
CursorHandler fCursorHandler;
display_mode fDisplayMode;
uint32 fDPMSState;
uint32 fDPMSCaps;
};
#endif

View File

@ -64,12 +64,11 @@ DisplayDriverPainter::~DisplayDriverPainter()
bool
DisplayDriverPainter::Initialize()
{
if (DisplayDriver::Initialize()) {
status_t err = fGraphicsCard->Initialize();
if (err < B_OK)
fprintf(stderr, "HWInterface::Initialize() failed: %s\n", strerror(err));
return err >= B_OK;
}
status_t err = fGraphicsCard->Initialize();
if (err < B_OK)
fprintf(stderr, "HWInterface::Initialize() failed: %s\n", strerror(err));
if (err >= B_OK)
return DisplayDriver::Initialize();
return false;
}
@ -872,7 +871,6 @@ DisplayDriverPainter::SetMode(const display_mode &mode)
{
if (Lock() && fGraphicsCard->SetMode(mode) >= B_OK) {
fPainter->AttachToBuffer(fGraphicsCard->BackBuffer());
DisplayDriver::SetMode(mode);
Unlock();
} else {
fprintf(stderr, "DisplayDriverPainter::SetMode() - unsupported mode!\n");