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:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2006, Haiku.
|
* Copyright 2001-2007, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
* Stephan Aßmus <[email protected]>
|
* Stephan Aßmus <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Accelerant based HWInterface implementation */
|
/*! Accelerant based HWInterface implementation */
|
||||||
|
|
||||||
|
|
||||||
#include "AccelerantHWInterface.h"
|
#include "AccelerantHWInterface.h"
|
||||||
@@ -438,8 +438,7 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
|
|||||||
|
|
||||||
// some safety checks
|
// some safety checks
|
||||||
// TODO: more of those!
|
// TODO: more of those!
|
||||||
if (mode.virtual_width < 320
|
if (!_IsValidMode(mode))
|
||||||
|| mode.virtual_height < 200)
|
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// just try to set the mode - we let the graphics driver
|
// 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)
|
if (fAccGetDisplayMode(&newMode) != B_OK)
|
||||||
return B_ERROR;
|
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
|
// TODO: if the mode switch before fails as well, we must forbid
|
||||||
// any uses of this class!
|
// any uses of this class!
|
||||||
status = B_OK;
|
status = B_OK;
|
||||||
@@ -497,7 +500,8 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
|
|||||||
// update backbuffer if neccessary
|
// update backbuffer if neccessary
|
||||||
if (!fBackBuffer || fBackBuffer->Width() != fDisplayMode.virtual_width
|
if (!fBackBuffer || fBackBuffer->Width() != fDisplayMode.virtual_width
|
||||||
|| fBackBuffer->Height() != fDisplayMode.virtual_height
|
|| 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
|
// NOTE: backbuffer is always B_RGBA32, this simplifies the
|
||||||
// drawing backend implementation tremendously for the time
|
// drawing backend implementation tremendously for the time
|
||||||
// being. The color space conversion is handled in CopyBackToFront()
|
// 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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -23,13 +23,19 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
HWInterfaceListener::HWInterfaceListener() {}
|
HWInterfaceListener::HWInterfaceListener()
|
||||||
HWInterfaceListener::~HWInterfaceListener() {}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HWInterfaceListener::~HWInterfaceListener()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - HWInterface
|
// #pragma mark - HWInterface
|
||||||
|
|
||||||
// constructor
|
|
||||||
HWInterface::HWInterface(bool doubleBuffered)
|
HWInterface::HWInterface(bool doubleBuffered)
|
||||||
: MultiLocker("hw interface lock"),
|
: MultiLocker("hw interface lock"),
|
||||||
fCursorAreaBackup(NULL),
|
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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -180,6 +180,8 @@ class HWInterface : protected MultiLocker {
|
|||||||
|
|
||||||
void _NotifyFrameBufferChanged();
|
void _NotifyFrameBufferChanged();
|
||||||
|
|
||||||
|
static bool _IsValidMode(const display_mode& mode);
|
||||||
|
|
||||||
// If we draw the cursor somewhere in the drawing buffer,
|
// If we draw the cursor somewhere in the drawing buffer,
|
||||||
// we need to backup its contents before drawing, so that
|
// we need to backup its contents before drawing, so that
|
||||||
// we can restore that area when the cursor needs to be
|
// we can restore that area when the cursor needs to be
|
||||||
|
|||||||
Reference in New Issue
Block a user