Removed unnecessary methods in ServerScreen and DisplayDriver

Bugfixes - cursor now works under new DisplayDriver cursor management
Currently still searching for a clipping bug in ViewDriver::CopyToBitmap


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6563 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2004-02-12 01:25:41 +00:00
parent 2bde7b6696
commit 9e7c0e5d01
7 changed files with 75 additions and 213 deletions

View File

@ -673,11 +673,7 @@ void AppServer::DispatchMessage(PortMessage *msg)
PortLink replylink(replyport);
replylink.SetOpCode(AS_GET_SCREEN_MODE);
replylink.Attach<int16>(dmode.virtual_width);
replylink.Attach<int16>(dmode.virtual_height);
// Eventually, GetDepth() will get replaced
replylink.Attach<int16>(fDriver->GetDepth());
replylink.Attach<display_mode>(dmode);
replylink.Flush();
break;
}

View File

@ -97,10 +97,9 @@ void BitmapDriver::SetTarget(ServerBitmap *target)
if(target)
{
_buffer_depth=target->Width();
_buffer_height=target->Height();
_buffer_depth=target->BitsPerPixel();
_bytes_per_row=target->BytesPerRow();
_displaymode.virtual_width=target->Width();
_displaymode.virtual_height=target->Height();
_displaymode.space=target->ColorSpace();
// Setting mode not necessary. Can get color space stuff via ServerBitmap->ColorSpace
}

View File

@ -242,14 +242,10 @@ DisplayDriver::DisplayDriver(void)
{
_locker=new BLocker();
_buffer_depth=0;
_buffer_width=0;
_buffer_height=0;
_buffer_mode=-1;
_is_cursor_hidden=false;
_is_cursor_obscured=false;
_cursor=NULL;
_cursorsave=NULL;
_dpms_caps=B_DPMS_ON;
_dpms_state=B_DPMS_ON;
}
@ -1354,7 +1350,7 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, DisplayDriver* dri
}
if (segmentArray[i].MinY() == segmentArray[i].MaxY())
{
if ( (segmentArray[i].MinX() < _buffer_width) &&
if ( (segmentArray[i].MinX() < _displaymode.virtual_width) &&
(segmentArray[i].MaxX() >= 0) )
(driver->*setLine)(ROUND(segmentArray[i].MinX()),
ROUND(segmentArray[i].MaxX()), y);
@ -1362,7 +1358,7 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, DisplayDriver* dri
}
else
{
if ( (segmentArray[i].GetX(y) < _buffer_width) &&
if ( (segmentArray[i].GetX(y) < _displaymode.virtual_width) &&
(segmentArray[i+1].GetX(y) >= 0) )
(driver->*setLine)(ROUND(segmentArray[i].GetX(y)),
ROUND(segmentArray[i+1].GetX(y)), y);
@ -1598,12 +1594,7 @@ void DisplayDriver::HideCursor(void)
_is_cursor_hidden=true;
if(_cursorsave)
{
CopyBitmap(_cursorsave,_cursorsave->Bounds(),cursorframe, &_drawdata);
delete _cursorsave;
_cursorsave=NULL;
}
Unlock();
}
@ -1654,15 +1645,18 @@ void DisplayDriver::MoveCursorTo(const float &x, const float &y)
return;
}
// if(!_cursorsave)
// _cursorsave=new ServerBitmap(_cursor);
if(!_cursorsave)
_cursorsave=new UtilityBitmap(_cursor->Bounds(),(color_space)_displaymode.space,0);
_drawdata.draw_mode=B_OP_COPY;
CopyBitmap(_cursorsave,_cursor->Bounds(),saveframe,&_drawdata);
CopyToBitmap(_cursorsave,cursorframe);
saveframe=cursorframe;
_drawdata.draw_mode=B_OP_ALPHA;
CopyBitmap(_cursor,_cursor->Bounds(),cursorframe,&_drawdata);
_drawdata.draw_mode=B_OP_COPY;
Unlock();
}
@ -1719,12 +1713,7 @@ void DisplayDriver::ObscureCursor(void)
_is_cursor_obscured=true;
if(_cursorsave)
{
CopyBitmap(_cursorsave,_cursorsave->Bounds(),cursorframe, &_drawdata);
delete _cursorsave;
_cursorsave=NULL;
}
Unlock();
@ -1753,8 +1742,6 @@ void DisplayDriver::SetCursor(ServerCursor *cursor)
if(visible)
CopyBitmap(_cursorsave,_cursorsave->Bounds(),cursorframe, &_drawdata);
delete _cursor;
delete _cursorsave;
_cursorsave=NULL;
}
_cursor=new ServerCursor(cursor);
@ -1768,7 +1755,9 @@ void DisplayDriver::SetCursor(ServerCursor *cursor)
if(visible)
{
CopyToBitmap(_cursorsave, cursorframe);
_drawdata.draw_mode=B_OP_ALPHA;
CopyBitmap(_cursor, _cursor->Bounds(), cursorframe, &_drawdata);
_drawdata.draw_mode=B_OP_COPY;
}
Unlock();
@ -2313,17 +2302,6 @@ void DisplayDriver::StrokeLineArray(BPoint *pts, const int32 &numlines, const Dr
{
}
/*!
\brief Sets the screen mode to specified resolution and color depth.
\param mode constant as defined in GraphicsDefs.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 int32 &mode)
{
}
/*
\brief Sets the screen mode to specified resolution and color depth.
\param mode Data structure as defined in Screen.h
@ -2476,33 +2454,6 @@ void DisplayDriver::GetTruncatedStrings(const char **instrings,const int32 &stri
{
}
/*!
\brief Returns the bit depth for the current screen mode
\return Current number of bits per pixel
*/
uint8 DisplayDriver::GetDepth(void)
{
return _buffer_depth;
}
/*!
\brief Returns the number of bytes used in each row of the frame buffer
\return The number of bytes used in each row of the frame buffer
*/
uint32 DisplayDriver::GetBytesPerRow(void)
{
return _bytes_per_row;
}
/*!
\brief Returns the screen mode constant in use by the driver
\return Current screen mode
*/
int32 DisplayDriver::GetMode(void)
{
return _buffer_mode;
}
/*!
\brief Returns whether or not the cursor is currently obscured
\return True if obscured, false if not.

View File

@ -32,27 +32,20 @@
#include "ServerScreen.h"
#include "DisplayDriver.h"
Screen::Screen(DisplayDriver *dDriver, BPoint res, uint32 colorspace,
const int32 &ID)
Screen::Screen(DisplayDriver *dDriver, BPoint res, uint32 colorspace, const int32 &ID)
{
fID = ID;
fDDriver = dDriver;
SetResolution(res, colorspace);
}
Screen::~Screen(void){
Screen::~Screen(void)
{
//printf("~Screen( %ld )\n", fID);
}
void Screen::SetColorSpace(const uint32 &colorspace){
// fDDriver->SetColorSpace(colorspace);
}
uint32 Screen::ColorSpace(void) const{
// return fDDriver->ColorSpace();
}
bool Screen::SupportsResolution(BPoint res, uint32 colorspace){
bool Screen::SupportsResolution(BPoint res, uint32 colorspace)
{
// TODO: remove/improve
return true;
display_mode *dm = NULL;
@ -60,7 +53,8 @@ bool Screen::SupportsResolution(BPoint res, uint32 colorspace){
fDDriver->GetModeList(&dm, &count);
for (uint32 i=0; i < count; i++){
for (uint32 i=0; i < count; i++)
{
if (dm[i].virtual_width == (uint16)res.x &&
dm[i].virtual_height == (uint16)res.y &&
dm[i].space == colorspace)
@ -71,7 +65,8 @@ bool Screen::SupportsResolution(BPoint res, uint32 colorspace){
return false;
}
bool Screen::SetResolution(BPoint res, uint32 colorspace){
bool Screen::SetResolution(BPoint res, uint32 colorspace)
{
if (!SupportsResolution(res, colorspace))
return false;
@ -81,12 +76,13 @@ bool Screen::SetResolution(BPoint res, uint32 colorspace){
mode.virtual_height = (uint16)res.y;
mode.space = colorspace;
// fDDriver->SetMode(&mode);
fDDriver->SetMode(mode);
return true;
}
BPoint Screen::Resolution() const{
BPoint Screen::Resolution() const
{
display_mode mode;
fDDriver->GetMode(&mode);
@ -94,7 +90,8 @@ BPoint Screen::Resolution() const{
return BPoint(mode.virtual_width, mode.virtual_height);
}
int32 Screen::ScreenNumber(void) const{
int32 Screen::ScreenNumber(void) const
{
return fID;
}

View File

@ -28,35 +28,29 @@
#define _SCREEN_H_
#include <Point.h>
//#include "DisplayDriver.h"
class DisplayDriver;
class Screen{
class Screen
{
public:
Screen(DisplayDriver *dDriver, BPoint res,
uint32 colorspace, const int32 &ID);
Screen(){ ; }
~Screen(void);
void SetColorSpace(const uint32 &colorspace);
uint32 ColorSpace(void) const;
void SetID(int32 ID){ fID = ID; }
Screen(DisplayDriver *dDriver, BPoint res, uint32 colorspace, const int32 &ID);
Screen(){ ; }
~Screen(void);
void SetID(int32 ID){ fID = ID; }
// TODO: get/set prototype methods for graphic card features
bool SupportsResolution(BPoint res, uint32 colorspace);
bool SetResolution(BPoint res, uint32 colorspace);
BPoint Resolution() const;
int32 ScreenNumber(void) const;
DisplayDriver* DDriver() const { return fDDriver; }
bool SupportsResolution(BPoint res, uint32 colorspace);
bool SetResolution(BPoint res, uint32 colorspace);
BPoint Resolution() const;
int32 ScreenNumber(void) const;
DisplayDriver* DDriver() const { return fDDriver; }
private:
// TODO: members in witch we should store data.
int32 fID;
DisplayDriver *fDDriver;
// TODO: members in which we should store data.
int32 fID;
DisplayDriver *fDDriver;
};
#endif

View File

@ -79,7 +79,7 @@ VDView::VDView(BRect bounds)
: BView(bounds,"viewdriver_view",B_FOLLOW_ALL, B_WILL_DRAW)
{
SetViewColor(B_TRANSPARENT_32_BIT);
viewbmp=new BBitmap(bounds,B_CMAP8,true);
viewbmp=new BBitmap(bounds,B_RGBA32,true);
// This link for sending mouse messages to the OBAppServer.
// This is only to take the place of the Input Server.
@ -416,7 +416,7 @@ void VDWindow::MessageReceived(BMessage *msg)
view->serverlink->Flush();
break;
}
case VDWIN_SHOWCURSOR:
/* case VDWIN_SHOWCURSOR:
{
if(view->hide_cursor>0)
view->hide_cursor--;
@ -487,7 +487,7 @@ void VDWindow::MessageReceived(BMessage *msg)
}
break;
}
default:
*/ default:
BWindow::MessageReceived(msg);
break;
}
@ -537,12 +537,10 @@ ViewDriver::ViewDriver(void)
framebuffer=screenwin->view->viewbmp;
serverlink=screenwin->view->serverlink;
hide_cursor=0;
_buffer_width=640;
_buffer_height=480;
_buffer_depth=8;
_buffer_mode=B_8_BIT_640x480;
_bytes_per_row=framebuffer->BytesPerRow();
_displaymode.virtual_width=640;
_displaymode.virtual_height=480;
_displaymode.space=B_RGBA32;
// We add this because if we see the default workspace color, then we have at least
// a reasonable idea that everything is kosher.
@ -611,12 +609,7 @@ void ViewDriver::SetMode(const display_mode &mode)
}
delete framebuffer;
// don't forget to update the internal vars!
_buffer_width=mode.virtual_width;
_buffer_height=mode.virtual_height;
_buffer_mode=mode.space;
screenwin->view->viewbmp=tempbmp;
framebuffer=screenwin->view->viewbmp;
drawview=new BView(framebuffer->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW);
@ -628,86 +621,6 @@ void ViewDriver::SetMode(const display_mode &mode)
drawview->Sync();
framebuffer->Unlock();
_bytes_per_row=framebuffer->BytesPerRow();
screenwin->view->Invalidate();
screenwin->Unlock();
}
void ViewDriver::SetMode(const int32 &space)
{
if(!is_initialized)
return;
screenwin->Lock();
int16 w=640,h=480;
color_space s=B_CMAP8;
switch(space)
{
case B_32_BIT_800x600:
case B_16_BIT_800x600:
case B_8_BIT_800x600:
{
w=800; h=600;
break;
}
case B_32_BIT_1024x768:
case B_16_BIT_1024x768:
case B_8_BIT_1024x768:
{
w=1024; h=768;
break;
}
default:
break;
}
screenwin->ResizeTo(w-1,h-1);
switch(space)
{
case B_32_BIT_640x480:
case B_32_BIT_800x600:
case B_32_BIT_1024x768:
s=B_RGBA32;
_buffer_depth=32;
break;
case B_16_BIT_640x480:
case B_16_BIT_800x600:
case B_16_BIT_1024x768:
s=B_RGBA15;
_buffer_depth=15;
break;
case B_8_BIT_640x480:
case B_8_BIT_800x600:
case B_8_BIT_1024x768:
s=B_CMAP8;
_buffer_depth=8;
break;
default:
_buffer_depth=8;
break;
}
delete framebuffer;
// don't forget to update the internal vars!
_buffer_width=w;
_buffer_height=h;
_buffer_mode=space;
screenwin->view->viewbmp=new BBitmap(BRect(0,0,w-1,h-1),s,true);
framebuffer=screenwin->view->viewbmp;
drawview=new BView(framebuffer->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW);
framebuffer->AddChild(drawview);
framebuffer->Lock();
drawview->SetHighColor(workspace_default_color.GetColor32());
drawview->FillRect(drawview->Bounds());
drawview->Sync();
framebuffer->Unlock();
_bytes_per_row=framebuffer->BytesPerRow();
screenwin->view->Invalidate();
screenwin->Unlock();
}
@ -1759,7 +1672,10 @@ status_t ViewDriver::WaitForRetrace(bigtime_t timeout=B_INFINITE_TIMEOUT)
void ViewDriver::CopyBitmap(ServerBitmap *bitmap, const BRect &source, const BRect &dest, const DrawData *d)
{
if(!is_initialized || !bitmap || !d)
{
printf("CopyBitmap returned - not init or NULL bitmap\n");
return;
}
SetDrawData(d);
@ -1775,6 +1691,8 @@ void ViewDriver::CopyBitmap(ServerBitmap *bitmap, const BRect &source, const BRe
framebuffer->Lock();
drawview->DrawBitmap(mediator,source,dest);
drawview->Sync();
screenwin->view->Invalidate(dest);
framebuffer->Unlock();
screenwin->Unlock();
@ -1783,11 +1701,20 @@ void ViewDriver::CopyBitmap(ServerBitmap *bitmap, const BRect &source, const BRe
void ViewDriver::CopyToBitmap(ServerBitmap *destbmp, const BRect &sourcerect)
{
if(!is_initialized || !destbmp)
return;
// TODO: BUG: CRASH: There is a crash on memcpy whenever the cursor is saved and it
// is clipped to the bottom edge of the screen.
if(destbmp->BitsPerPixel() != _buffer_depth)
if(!is_initialized || !destbmp)
{
printf("CopyToBitmap returned - not init or NULL bitmap\n");
return;
}
if(((uint32)destbmp->ColorSpace() & 0x000F) != (_displaymode.space & 0x000F))
{
printf("CopyToBitmap returned - unequal buffer pixel depth\n");
return;
}
BRect destrect(destbmp->Bounds()), source(sourcerect);
@ -1797,7 +1724,6 @@ void ViewDriver::CopyToBitmap(ServerBitmap *destbmp, const BRect &sourcerect)
if(source.Width() > destrect.Width())
source.right=source.left+destrect.Width();
if(source.Height() > destrect.Height())
source.bottom=source.top+destrect.Height();
@ -1849,14 +1775,14 @@ void ViewDriver::CopyToBitmap(ServerBitmap *destbmp, const BRect &sourcerect)
uint32 line_length = uint32 ((destrect.right - destrect.left+1)*colorspace_size);
uint32 lines = uint32 (destrect.bottom-destrect.top+1);
for (uint32 pos_y = 0; pos_y != lines; pos_y++)
{
for (uint32 pos_y=0; pos_y<lines; pos_y++)
{
memcpy(dest_bits,src_bits,line_length);
// Increment offsets
src_bits += src_width;
dest_bits += dest_width;
src_bits += src_width;
dest_bits += dest_width;
}
}

View File

@ -112,7 +112,6 @@ public:
virtual void StrokeLineArray(BPoint *pts, const int32 &numlines, const DrawData *d, RGBColor *colors);
void SetMode(const int32 &mode);
void SetMode(const display_mode &mode);
bool DumpToFile(const char *path);