Moved the (currently very simplistic) code to check if a display_mode is valid into
it's own (static) method. In case setting the display mode fails, the returned mode is now checked for validity as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21282 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c15a5012ef
commit
d6f8cacab9
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2006, Haiku.
|
||||
* Copyright 2001-2007, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -8,7 +8,7 @@
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
*/
|
||||
|
||||
/** Accelerant based HWInterface implementation */
|
||||
/*! Accelerant based HWInterface implementation */
|
||||
|
||||
|
||||
#include "AccelerantHWInterface.h"
|
||||
@ -438,8 +438,7 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
|
||||
|
||||
// some safety checks
|
||||
// TODO: more of those!
|
||||
if (mode.virtual_width < 320
|
||||
|| mode.virtual_height < 200)
|
||||
if (!_IsValidMode(mode))
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// just try to set the mode - we let the graphics driver
|
||||
@ -466,6 +465,10 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
|
||||
if (fAccGetDisplayMode(&newMode) != B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
// TODO: check if the mode returned is valid!
|
||||
if (!_IsValidMode(newMode))
|
||||
return B_BAD_DATA;
|
||||
|
||||
// TODO: if the mode switch before fails as well, we must forbid
|
||||
// any uses of this class!
|
||||
status = B_OK;
|
||||
@ -497,7 +500,8 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
|
||||
// update backbuffer if neccessary
|
||||
if (!fBackBuffer || fBackBuffer->Width() != fDisplayMode.virtual_width
|
||||
|| fBackBuffer->Height() != fDisplayMode.virtual_height
|
||||
|| (fDisplayMode.space == B_RGB32 && fBackBuffer != NULL && !HWInterface::IsDoubleBuffered())) {
|
||||
|| (fDisplayMode.space == B_RGB32 && fBackBuffer != NULL
|
||||
&& !HWInterface::IsDoubleBuffered())) {
|
||||
// NOTE: backbuffer is always B_RGBA32, this simplifies the
|
||||
// drawing backend implementation tremendously for the time
|
||||
// being. The color space conversion is handled in CopyBackToFront()
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2006, Haiku.
|
||||
* Copyright 2005-2007, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -23,13 +23,19 @@
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
HWInterfaceListener::HWInterfaceListener() {}
|
||||
HWInterfaceListener::~HWInterfaceListener() {}
|
||||
HWInterfaceListener::HWInterfaceListener()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
HWInterfaceListener::~HWInterfaceListener()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - HWInterface
|
||||
|
||||
// constructor
|
||||
|
||||
HWInterface::HWInterface(bool doubleBuffered)
|
||||
: MultiLocker("hw interface lock"),
|
||||
fCursorAreaBackup(NULL),
|
||||
@ -956,3 +962,15 @@ HWInterface::_NotifyFrameBufferChanged()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*static*/ bool
|
||||
HWInterface::_IsValidMode(const display_mode& mode)
|
||||
{
|
||||
// TODO: more of those!
|
||||
if (mode.virtual_width < 320
|
||||
|| mode.virtual_height < 200)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2006, Haiku.
|
||||
* Copyright 2005-2007, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -180,6 +180,8 @@ class HWInterface : protected MultiLocker {
|
||||
|
||||
void _NotifyFrameBufferChanged();
|
||||
|
||||
static bool _IsValidMode(const display_mode& mode);
|
||||
|
||||
// If we draw the cursor somewhere in the drawing buffer,
|
||||
// we need to backup its contents before drawing, so that
|
||||
// we can restore that area when the cursor needs to be
|
||||
|
Loading…
Reference in New Issue
Block a user