[Haiku-commits] r21282 - haiku/trunk/src/servers/app/drawing
axeld at BerliOS
axeld at mail.berlios.de
Fri Jun 1 00:39:18 CEST 2007
Author: axeld
Date: 2007-06-01 00:39:16 +0200 (Fri, 01 Jun 2007)
New Revision: 21282
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=21282&view=rev
Modified:
haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp
haiku/trunk/src/servers/app/drawing/HWInterface.cpp
haiku/trunk/src/servers/app/drawing/HWInterface.h
Log:
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.
Modified: haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp
===================================================================
--- haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp 2007-05-31 22:12:07 UTC (rev 21281)
+++ haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp 2007-05-31 22:39:16 UTC (rev 21282)
@@ -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 at gmx.de>
*/
-/** Accelerant based HWInterface implementation */
+/*! Accelerant based HWInterface implementation */
#include "AccelerantHWInterface.h"
@@ -438,8 +438,7 @@
// 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 @@
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 @@
// 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()
Modified: haiku/trunk/src/servers/app/drawing/HWInterface.cpp
===================================================================
--- haiku/trunk/src/servers/app/drawing/HWInterface.cpp 2007-05-31 22:12:07 UTC (rev 21281)
+++ haiku/trunk/src/servers/app/drawing/HWInterface.cpp 2007-05-31 22:39:16 UTC (rev 21282)
@@ -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 @@
}
}
+
+/*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;
+}
+
Modified: haiku/trunk/src/servers/app/drawing/HWInterface.h
===================================================================
--- haiku/trunk/src/servers/app/drawing/HWInterface.h 2007-05-31 22:12:07 UTC (rev 21281)
+++ haiku/trunk/src/servers/app/drawing/HWInterface.h 2007-05-31 22:39:16 UTC (rev 21282)
@@ -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 @@
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
More information about the Haiku-commits
mailing list