Tweaked API to fix a related crash

ViewDriver's Get methods return proper values


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2735 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-02-17 15:02:38 +00:00
parent 121b19e599
commit bfc47a9d3b
6 changed files with 38 additions and 20 deletions

View File

@ -34,13 +34,15 @@ extern RGBColor workspace_default_color;
\brief Sets up internal variables needed by the Workspace
\param gcinfo The graphics card info
\param fbinfo The frame buffer info
\param gfxdriver DisplayDriver for the associated RootLayer
*/
Workspace::Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo)
Workspace::Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo, DisplayDriver *gfxdriver)
{
_gcinfo=gcinfo;
_fbinfo=fbinfo;
_rootlayer=new RootLayer(BRect(0,0,fbinfo.display_width-1,fbinfo.display_height-1), "Workspace Root");
_rootlayer=new RootLayer(BRect(0,0,fbinfo.display_width-1,fbinfo.display_height-1),
"Workspace Root",gfxdriver);
_rootlayer->SetColor(workspace_default_color);
}
@ -150,7 +152,7 @@ Screen::Screen(DisplayDriver *gfxmodule, uint8 workspaces)
_workspacecount = workspaces;
for (int i=0; i<workspaces; i++)
{
_workspacelist->AddItem(new Workspace(_gcinfo,_fbinfo));
_workspacelist->AddItem(new Workspace(_gcinfo,_fbinfo,_driver));
}
_resolution=_driver->GetMode();
_currentworkspace=0;
@ -183,7 +185,7 @@ Screen::~Screen(void)
*/
void Screen::AddWorkspace(int32 index)
{
Workspace *workspace = new Workspace(_gcinfo,_fbinfo);
Workspace *workspace = new Workspace(_gcinfo,_fbinfo,_driver);
if ( (index == -1) || !_workspacelist->AddItem(workspace,index) )
_workspacelist->AddItem(workspace);
}

View File

@ -40,7 +40,7 @@ class RGBColor;
class Workspace
{
public:
Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo);
Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo, DisplayDriver *gfxdriver);
~Workspace(void);
void SetBGColor(const RGBColor &c);
RGBColor BGColor();

View File

@ -45,7 +45,11 @@ Server app_server :
ViewDriver.cpp
WinBorder.cpp
;
LinkSharedOSLibs app_server : be root game translation
LINKFLAGS on app_server ?= $(LINKFLAGS) ;
LINKFLAGS on app_server += -lbe ;
LinkSharedOSLibs app_server : root game translation
<boot!home!config!lib>libopenbeos.so
<boot!home!config!lib>libfreetype.so ;

View File

@ -31,20 +31,19 @@
/*!
\brief Sets up internal variables needed by the RootLayer
\param frame
\param name
\param rect Frame of the root layer
\param layername Name of the root layer. Not really used.
\param gfxdriver Pointer to the related graphics driver
*/
RootLayer::RootLayer(BRect rect, const char *layername)
RootLayer::RootLayer(BRect rect, const char *layername, DisplayDriver *gfxdriver)
: Layer(rect,layername,B_FOLLOW_NONE,0, NULL)
{
_driver=GetGfxDriver();
_driver=gfxdriver;
_invalid=new BRegion(Bounds());
_is_dirty=true;
}
/*!
\brief Frees all allocated heap memory (which happens to be none) ;)
*/
//! Frees all allocated heap memory (which happens to be none) ;)
RootLayer::~RootLayer()
{
}

View File

@ -34,7 +34,7 @@
class RootLayer : public Layer
{
public:
RootLayer(BRect rect, const char *layername);
RootLayer(BRect rect, const char *layername, DisplayDriver *gfxdriver);
~RootLayer();
void RequestDraw();
void RequestDraw(const BRect &r);

View File

@ -25,8 +25,6 @@
//
//------------------------------------------------------------------------------
// TODO: Update this to have GetMode, GetWidth, etc return the proper values
#include <stdio.h>
#include <iostream.h>
#include <Message.h>
@ -65,7 +63,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_RGB32,true);
viewbmp=new BBitmap(bounds,B_CMAP8,true);
// This link for sending mouse messages to the OBAppServer.
// This is only to take the place of the Input Server. I suppose I could write
@ -74,7 +72,7 @@ VDView::VDView(BRect bounds)
serverlink=new PortLink(find_port(SERVER_INPUT_PORT));
// Create a cursor which isn't just a box
cursor=new BBitmap(BRect(0,0,20,20),B_RGBA32,true);
cursor=new BBitmap(BRect(0,0,20,20),B_CMAP8,true);
BView *v=new BView(cursor->Bounds(),"v", B_FOLLOW_NONE, B_WILL_DRAW);
hide_cursor=0;
@ -333,6 +331,10 @@ ViewDriver::ViewDriver(void)
framebuffer=screenwin->view->viewbmp;
serverlink=screenwin->view->serverlink;
hide_cursor=0;
_SetWidth(640);
_SetHeight(480);
_SetDepth(8);
_SetMode(B_8_BIT_640x480);
}
ViewDriver::~ViewDriver(void)
@ -374,7 +376,7 @@ void ViewDriver::SetMode(int32 space)
{
screenwin->Lock();
int16 w=640,h=480;
color_space s;
color_space s=B_CMAP8;
switch(space)
{
@ -403,24 +405,33 @@ void ViewDriver::SetMode(int32 space)
case B_32_BIT_800x600:
case B_32_BIT_1024x768:
s=B_RGBA32;
_SetDepth(32);
break;
case B_16_BIT_640x480:
case B_16_BIT_800x600:
case B_16_BIT_1024x768:
s=B_RGBA15;
_SetDepth(15);
break;
case B_8_BIT_640x480:
case B_8_BIT_800x600:
case B_8_BIT_1024x768:
s=B_CMAP8;
_SetDepth(8);
break;
default:
_SetDepth(8);
break;
}
delete framebuffer;
// don't forget to update the internal vars!
_SetWidth(w);
_SetHeight(h);
_SetMode(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);
@ -431,6 +442,8 @@ void ViewDriver::SetMode(int32 space)
drawview->FillRect(drawview->Bounds());
drawview->Sync();
framebuffer->Unlock();
_SetBytesPerRow(framebuffer->BytesPerRow());
screenwin->view->Invalidate();
screenwin->Unlock();
}