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
+1 -5
View File
@@ -673,11 +673,7 @@ void AppServer::DispatchMessage(PortMessage *msg)
PortLink replylink(replyport); PortLink replylink(replyport);
replylink.SetOpCode(AS_GET_SCREEN_MODE); replylink.SetOpCode(AS_GET_SCREEN_MODE);
replylink.Attach<int16>(dmode.virtual_width); replylink.Attach<display_mode>(dmode);
replylink.Attach<int16>(dmode.virtual_height);
// Eventually, GetDepth() will get replaced
replylink.Attach<int16>(fDriver->GetDepth());
replylink.Flush(); replylink.Flush();
break; break;
} }
+3 -4
View File
@@ -97,10 +97,9 @@ void BitmapDriver::SetTarget(ServerBitmap *target)
if(target) if(target)
{ {
_buffer_depth=target->Width(); _displaymode.virtual_width=target->Width();
_buffer_height=target->Height(); _displaymode.virtual_height=target->Height();
_buffer_depth=target->BitsPerPixel(); _displaymode.space=target->ColorSpace();
_bytes_per_row=target->BytesPerRow();
// Setting mode not necessary. Can get color space stuff via ServerBitmap->ColorSpace // Setting mode not necessary. Can get color space stuff via ServerBitmap->ColorSpace
} }
+11 -60
View File
@@ -242,14 +242,10 @@ DisplayDriver::DisplayDriver(void)
{ {
_locker=new BLocker(); _locker=new BLocker();
_buffer_depth=0;
_buffer_width=0;
_buffer_height=0;
_buffer_mode=-1;
_is_cursor_hidden=false; _is_cursor_hidden=false;
_is_cursor_obscured=false; _is_cursor_obscured=false;
_cursor=NULL; _cursor=NULL;
_cursorsave=NULL;
_dpms_caps=B_DPMS_ON; _dpms_caps=B_DPMS_ON;
_dpms_state=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].MinY() == segmentArray[i].MaxY())
{ {
if ( (segmentArray[i].MinX() < _buffer_width) && if ( (segmentArray[i].MinX() < _displaymode.virtual_width) &&
(segmentArray[i].MaxX() >= 0) ) (segmentArray[i].MaxX() >= 0) )
(driver->*setLine)(ROUND(segmentArray[i].MinX()), (driver->*setLine)(ROUND(segmentArray[i].MinX()),
ROUND(segmentArray[i].MaxX()), y); ROUND(segmentArray[i].MaxX()), y);
@@ -1362,7 +1358,7 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, DisplayDriver* dri
} }
else else
{ {
if ( (segmentArray[i].GetX(y) < _buffer_width) && if ( (segmentArray[i].GetX(y) < _displaymode.virtual_width) &&
(segmentArray[i+1].GetX(y) >= 0) ) (segmentArray[i+1].GetX(y) >= 0) )
(driver->*setLine)(ROUND(segmentArray[i].GetX(y)), (driver->*setLine)(ROUND(segmentArray[i].GetX(y)),
ROUND(segmentArray[i+1].GetX(y)), y); ROUND(segmentArray[i+1].GetX(y)), y);
@@ -1598,12 +1594,7 @@ void DisplayDriver::HideCursor(void)
_is_cursor_hidden=true; _is_cursor_hidden=true;
if(_cursorsave) if(_cursorsave)
{
CopyBitmap(_cursorsave,_cursorsave->Bounds(),cursorframe, &_drawdata); CopyBitmap(_cursorsave,_cursorsave->Bounds(),cursorframe, &_drawdata);
delete _cursorsave;
_cursorsave=NULL;
}
Unlock(); Unlock();
} }
@@ -1654,15 +1645,18 @@ void DisplayDriver::MoveCursorTo(const float &x, const float &y)
return; return;
} }
// if(!_cursorsave) if(!_cursorsave)
// _cursorsave=new ServerBitmap(_cursor); _cursorsave=new UtilityBitmap(_cursor->Bounds(),(color_space)_displaymode.space,0);
_drawdata.draw_mode=B_OP_COPY;
CopyBitmap(_cursorsave,_cursor->Bounds(),saveframe,&_drawdata); CopyBitmap(_cursorsave,_cursor->Bounds(),saveframe,&_drawdata);
CopyToBitmap(_cursorsave,cursorframe); CopyToBitmap(_cursorsave,cursorframe);
saveframe=cursorframe; saveframe=cursorframe;
_drawdata.draw_mode=B_OP_ALPHA;
CopyBitmap(_cursor,_cursor->Bounds(),cursorframe,&_drawdata); CopyBitmap(_cursor,_cursor->Bounds(),cursorframe,&_drawdata);
_drawdata.draw_mode=B_OP_COPY;
Unlock(); Unlock();
} }
@@ -1719,12 +1713,7 @@ void DisplayDriver::ObscureCursor(void)
_is_cursor_obscured=true; _is_cursor_obscured=true;
if(_cursorsave) if(_cursorsave)
{
CopyBitmap(_cursorsave,_cursorsave->Bounds(),cursorframe, &_drawdata); CopyBitmap(_cursorsave,_cursorsave->Bounds(),cursorframe, &_drawdata);
delete _cursorsave;
_cursorsave=NULL;
}
Unlock(); Unlock();
@@ -1753,8 +1742,6 @@ void DisplayDriver::SetCursor(ServerCursor *cursor)
if(visible) if(visible)
CopyBitmap(_cursorsave,_cursorsave->Bounds(),cursorframe, &_drawdata); CopyBitmap(_cursorsave,_cursorsave->Bounds(),cursorframe, &_drawdata);
delete _cursor; delete _cursor;
delete _cursorsave;
_cursorsave=NULL;
} }
_cursor=new ServerCursor(cursor); _cursor=new ServerCursor(cursor);
@@ -1768,7 +1755,9 @@ void DisplayDriver::SetCursor(ServerCursor *cursor)
if(visible) if(visible)
{ {
CopyToBitmap(_cursorsave, cursorframe); CopyToBitmap(_cursorsave, cursorframe);
_drawdata.draw_mode=B_OP_ALPHA;
CopyBitmap(_cursor, _cursor->Bounds(), cursorframe, &_drawdata); CopyBitmap(_cursor, _cursor->Bounds(), cursorframe, &_drawdata);
_drawdata.draw_mode=B_OP_COPY;
} }
Unlock(); 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. \brief Sets the screen mode to specified resolution and color depth.
\param mode Data structure as defined in Screen.h \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 \brief Returns whether or not the cursor is currently obscured
\return True if obscured, false if not. \return True if obscured, false if not.
+14 -17
View File
@@ -32,27 +32,20 @@
#include "ServerScreen.h" #include "ServerScreen.h"
#include "DisplayDriver.h" #include "DisplayDriver.h"
Screen::Screen(DisplayDriver *dDriver, BPoint res, uint32 colorspace, Screen::Screen(DisplayDriver *dDriver, BPoint res, uint32 colorspace, const int32 &ID)
const int32 &ID)
{ {
fID = ID; fID = ID;
fDDriver = dDriver; fDDriver = dDriver;
SetResolution(res, colorspace); SetResolution(res, colorspace);
} }
Screen::~Screen(void){ Screen::~Screen(void)
{
//printf("~Screen( %ld )\n", fID); //printf("~Screen( %ld )\n", fID);
} }
void Screen::SetColorSpace(const uint32 &colorspace){ bool Screen::SupportsResolution(BPoint res, uint32 colorspace)
// fDDriver->SetColorSpace(colorspace); {
}
uint32 Screen::ColorSpace(void) const{
// return fDDriver->ColorSpace();
}
bool Screen::SupportsResolution(BPoint res, uint32 colorspace){
// TODO: remove/improve // TODO: remove/improve
return true; return true;
display_mode *dm = NULL; display_mode *dm = NULL;
@@ -60,7 +53,8 @@ bool Screen::SupportsResolution(BPoint res, uint32 colorspace){
fDDriver->GetModeList(&dm, &count); 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 && if (dm[i].virtual_width == (uint16)res.x &&
dm[i].virtual_height == (uint16)res.y && dm[i].virtual_height == (uint16)res.y &&
dm[i].space == colorspace) dm[i].space == colorspace)
@@ -71,7 +65,8 @@ bool Screen::SupportsResolution(BPoint res, uint32 colorspace){
return false; return false;
} }
bool Screen::SetResolution(BPoint res, uint32 colorspace){ bool Screen::SetResolution(BPoint res, uint32 colorspace)
{
if (!SupportsResolution(res, colorspace)) if (!SupportsResolution(res, colorspace))
return false; return false;
@@ -81,12 +76,13 @@ bool Screen::SetResolution(BPoint res, uint32 colorspace){
mode.virtual_height = (uint16)res.y; mode.virtual_height = (uint16)res.y;
mode.space = colorspace; mode.space = colorspace;
// fDDriver->SetMode(&mode); fDDriver->SetMode(mode);
return true; return true;
} }
BPoint Screen::Resolution() const{ BPoint Screen::Resolution() const
{
display_mode mode; display_mode mode;
fDDriver->GetMode(&mode); fDDriver->GetMode(&mode);
@@ -94,7 +90,8 @@ BPoint Screen::Resolution() const{
return BPoint(mode.virtual_width, mode.virtual_height); return BPoint(mode.virtual_width, mode.virtual_height);
} }
int32 Screen::ScreenNumber(void) const{ int32 Screen::ScreenNumber(void) const
{
return fID; return fID;
} }
+16 -22
View File
@@ -28,35 +28,29 @@
#define _SCREEN_H_ #define _SCREEN_H_
#include <Point.h> #include <Point.h>
//#include "DisplayDriver.h"
class DisplayDriver; class DisplayDriver;
class Screen{ class Screen
{
public: public:
Screen(DisplayDriver *dDriver, BPoint res, Screen(DisplayDriver *dDriver, BPoint res, uint32 colorspace, const int32 &ID);
uint32 colorspace, const int32 &ID); Screen(){ ; }
Screen(){ ; } ~Screen(void);
~Screen(void);
void SetID(int32 ID){ fID = ID; }
void SetColorSpace(const uint32 &colorspace);
uint32 ColorSpace(void) const;
void SetID(int32 ID){ fID = ID; }
// TODO: get/set prototype methods for graphic card features // TODO: get/set prototype methods for graphic card features
bool SupportsResolution(BPoint res, uint32 colorspace); bool SupportsResolution(BPoint res, uint32 colorspace);
bool SetResolution(BPoint res, uint32 colorspace); bool SetResolution(BPoint res, uint32 colorspace);
BPoint Resolution() const; BPoint Resolution() const;
int32 ScreenNumber(void) const; int32 ScreenNumber(void) const;
DisplayDriver* DDriver() const { return fDDriver; } DisplayDriver* DDriver() const { return fDDriver; }
private: private:
// TODO: members in which we should store data.
// TODO: members in witch we should store data. int32 fID;
DisplayDriver *fDDriver;
int32 fID;
DisplayDriver *fDDriver;
}; };
#endif #endif
+30 -104
View File
@@ -79,7 +79,7 @@ VDView::VDView(BRect bounds)
: BView(bounds,"viewdriver_view",B_FOLLOW_ALL, B_WILL_DRAW) : BView(bounds,"viewdriver_view",B_FOLLOW_ALL, B_WILL_DRAW)
{ {
SetViewColor(B_TRANSPARENT_32_BIT); 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 link for sending mouse messages to the OBAppServer.
// This is only to take the place of the Input Server. // This is only to take the place of the Input Server.
@@ -416,7 +416,7 @@ void VDWindow::MessageReceived(BMessage *msg)
view->serverlink->Flush(); view->serverlink->Flush();
break; break;
} }
case VDWIN_SHOWCURSOR: /* case VDWIN_SHOWCURSOR:
{ {
if(view->hide_cursor>0) if(view->hide_cursor>0)
view->hide_cursor--; view->hide_cursor--;
@@ -487,7 +487,7 @@ void VDWindow::MessageReceived(BMessage *msg)
} }
break; break;
} }
default: */ default:
BWindow::MessageReceived(msg); BWindow::MessageReceived(msg);
break; break;
} }
@@ -537,12 +537,10 @@ ViewDriver::ViewDriver(void)
framebuffer=screenwin->view->viewbmp; framebuffer=screenwin->view->viewbmp;
serverlink=screenwin->view->serverlink; serverlink=screenwin->view->serverlink;
hide_cursor=0; hide_cursor=0;
_buffer_width=640; _displaymode.virtual_width=640;
_buffer_height=480; _displaymode.virtual_height=480;
_buffer_depth=8; _displaymode.space=B_RGBA32;
_buffer_mode=B_8_BIT_640x480;
_bytes_per_row=framebuffer->BytesPerRow();
// We add this because if we see the default workspace color, then we have at least // We add this because if we see the default workspace color, then we have at least
// a reasonable idea that everything is kosher. // a reasonable idea that everything is kosher.
@@ -611,12 +609,7 @@ void ViewDriver::SetMode(const display_mode &mode)
} }
delete framebuffer; 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; screenwin->view->viewbmp=tempbmp;
framebuffer=screenwin->view->viewbmp; framebuffer=screenwin->view->viewbmp;
drawview=new BView(framebuffer->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW); 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(); drawview->Sync();
framebuffer->Unlock(); 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->view->Invalidate();
screenwin->Unlock(); 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) void ViewDriver::CopyBitmap(ServerBitmap *bitmap, const BRect &source, const BRect &dest, const DrawData *d)
{ {
if(!is_initialized || !bitmap || !d) if(!is_initialized || !bitmap || !d)
{
printf("CopyBitmap returned - not init or NULL bitmap\n");
return; return;
}
SetDrawData(d); SetDrawData(d);
@@ -1775,6 +1691,8 @@ void ViewDriver::CopyBitmap(ServerBitmap *bitmap, const BRect &source, const BRe
framebuffer->Lock(); framebuffer->Lock();
drawview->DrawBitmap(mediator,source,dest); drawview->DrawBitmap(mediator,source,dest);
drawview->Sync();
screenwin->view->Invalidate(dest);
framebuffer->Unlock(); framebuffer->Unlock();
screenwin->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) void ViewDriver::CopyToBitmap(ServerBitmap *destbmp, const BRect &sourcerect)
{ {
if(!is_initialized || !destbmp) // TODO: BUG: CRASH: There is a crash on memcpy whenever the cursor is saved and it
return; // 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; return;
}
if(((uint32)destbmp->ColorSpace() & 0x000F) != (_displaymode.space & 0x000F))
{
printf("CopyToBitmap returned - unequal buffer pixel depth\n");
return;
}
BRect destrect(destbmp->Bounds()), source(sourcerect); BRect destrect(destbmp->Bounds()), source(sourcerect);
@@ -1797,7 +1724,6 @@ void ViewDriver::CopyToBitmap(ServerBitmap *destbmp, const BRect &sourcerect)
if(source.Width() > destrect.Width()) if(source.Width() > destrect.Width())
source.right=source.left+destrect.Width(); source.right=source.left+destrect.Width();
if(source.Height() > destrect.Height()) if(source.Height() > destrect.Height())
source.bottom=source.top+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 line_length = uint32 ((destrect.right - destrect.left+1)*colorspace_size);
uint32 lines = uint32 (destrect.bottom-destrect.top+1); 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); memcpy(dest_bits,src_bits,line_length);
// Increment offsets // Increment offsets
src_bits += src_width; src_bits += src_width;
dest_bits += dest_width; dest_bits += dest_width;
} }
} }
-1
View File
@@ -112,7 +112,6 @@ public:
virtual void StrokeLineArray(BPoint *pts, const int32 &numlines, const DrawData *d, RGBColor *colors); virtual void StrokeLineArray(BPoint *pts, const int32 &numlines, const DrawData *d, RGBColor *colors);
void SetMode(const int32 &mode);
void SetMode(const display_mode &mode); void SetMode(const display_mode &mode);
bool DumpToFile(const char *path); bool DumpToFile(const char *path);