2004-01-17 21:37:57 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2004-09-21 02:50:02 +04:00
|
|
|
// Copyright (c) 2001-2002, Haiku, Inc.
|
2004-01-17 21:37:57 +03:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
// File Name: ServerScreen.cpp
|
|
|
|
// Author: Adi Oanca <adioanca@myrealbox.com>
|
|
|
|
// Description: Handles individual screens
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
2004-01-12 01:12:55 +03:00
|
|
|
#include <Accelerant.h>
|
|
|
|
#include <Point.h>
|
|
|
|
#include <GraphicsDefs.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "ServerScreen.h"
|
|
|
|
#include "DisplayDriver.h"
|
|
|
|
|
2004-02-12 04:25:41 +03:00
|
|
|
Screen::Screen(DisplayDriver *dDriver, BPoint res, uint32 colorspace, const int32 &ID)
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
|
|
|
fID = ID;
|
2004-01-13 14:00:22 +03:00
|
|
|
fDDriver = dDriver;
|
2004-01-12 01:12:55 +03:00
|
|
|
SetResolution(res, colorspace);
|
|
|
|
}
|
|
|
|
|
2004-02-12 04:25:41 +03:00
|
|
|
Screen::~Screen(void)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
//printf("~Screen( %ld )\n", fID);
|
|
|
|
}
|
|
|
|
|
2004-02-12 04:25:41 +03:00
|
|
|
bool Screen::SupportsResolution(BPoint res, uint32 colorspace)
|
|
|
|
{
|
2004-08-08 00:30:58 +04:00
|
|
|
// TODO: remove/improve
|
2004-01-13 14:00:22 +03:00
|
|
|
return true;
|
|
|
|
display_mode *dm = NULL;
|
2004-01-12 01:12:55 +03:00
|
|
|
uint32 count;
|
|
|
|
|
2004-08-08 00:30:58 +04:00
|
|
|
status_t err=fDDriver->GetModeList(&dm, &count);
|
|
|
|
|
|
|
|
if(err==B_UNSUPPORTED)
|
|
|
|
{
|
|
|
|
// We've run into quite a problem here! This is a function which is a requirement
|
|
|
|
// for a graphics module. The best thing that we can hope for is 640x480x8 without
|
|
|
|
// knowing anything else. While even this seems like insanity to assume that we
|
|
|
|
// can support this, the only lower mode supported is 640x400, but we shouldn't even
|
|
|
|
// bother with such a pathetic possibility.
|
|
|
|
if( (uint16)res.x == 640 && (uint16)res.y ==480 && colorspace==B_CMAP8)
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-02-12 04:25:41 +03:00
|
|
|
for (uint32 i=0; i < count; i++)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
if (dm[i].virtual_width == (uint16)res.x &&
|
|
|
|
dm[i].virtual_height == (uint16)res.y &&
|
|
|
|
dm[i].space == colorspace)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-08-08 00:30:58 +04:00
|
|
|
delete [] dm;
|
2004-01-12 01:12:55 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-02-12 04:25:41 +03:00
|
|
|
bool Screen::SetResolution(BPoint res, uint32 colorspace)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
if (!SupportsResolution(res, colorspace))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
display_mode mode;
|
|
|
|
|
|
|
|
mode.virtual_width = (uint16)res.x;
|
|
|
|
mode.virtual_height = (uint16)res.y;
|
|
|
|
mode.space = colorspace;
|
|
|
|
|
2004-02-12 04:25:41 +03:00
|
|
|
fDDriver->SetMode(mode);
|
2004-01-12 01:12:55 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-02-12 04:25:41 +03:00
|
|
|
BPoint Screen::Resolution() const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
display_mode mode;
|
|
|
|
|
2004-01-27 03:38:14 +03:00
|
|
|
fDDriver->GetMode(&mode);
|
2004-01-12 01:12:55 +03:00
|
|
|
|
|
|
|
return BPoint(mode.virtual_width, mode.virtual_height);
|
|
|
|
}
|
|
|
|
|
2004-02-12 04:25:41 +03:00
|
|
|
int32 Screen::ScreenNumber(void) const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fID;
|
|
|
|
}
|
|
|
|
|