diff --git a/src/servers/app/drawing/DisplayDriver.cpp b/src/servers/app/drawing/DisplayDriver.cpp index ea24bfddfb..9dd83572ac 100644 --- a/src/servers/app/drawing/DisplayDriver.cpp +++ b/src/servers/app/drawing/DisplayDriver.cpp @@ -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; -} diff --git a/src/servers/app/drawing/DisplayDriverImpl.cpp b/src/servers/app/drawing/DisplayDriverImpl.cpp index c747c981fe..f1c8b1cb32 100644 --- a/src/servers/app/drawing/DisplayDriverImpl.cpp +++ b/src/servers/app/drawing/DisplayDriverImpl.cpp @@ -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 diff --git a/src/servers/app/drawing/DisplayDriverImpl.h b/src/servers/app/drawing/DisplayDriverImpl.h index d992346da6..07bb0c9ef4 100644 --- a/src/servers/app/drawing/DisplayDriverImpl.h +++ b/src/servers/app/drawing/DisplayDriverImpl.h @@ -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 diff --git a/src/servers/app/drawing/DisplayDriverPainter.cpp b/src/servers/app/drawing/DisplayDriverPainter.cpp index 368a0aa287..f2108af3eb 100644 --- a/src/servers/app/drawing/DisplayDriverPainter.cpp +++ b/src/servers/app/drawing/DisplayDriverPainter.cpp @@ -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");