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
+6 -4
View File
@@ -34,13 +34,15 @@ extern RGBColor workspace_default_color;
\brief Sets up internal variables needed by the Workspace \brief Sets up internal variables needed by the Workspace
\param gcinfo The graphics card info \param gcinfo The graphics card info
\param fbinfo The frame buffer 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; _gcinfo=gcinfo;
_fbinfo=fbinfo; _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); _rootlayer->SetColor(workspace_default_color);
} }
@@ -150,7 +152,7 @@ Screen::Screen(DisplayDriver *gfxmodule, uint8 workspaces)
_workspacecount = workspaces; _workspacecount = workspaces;
for (int i=0; i<workspaces; i++) for (int i=0; i<workspaces; i++)
{ {
_workspacelist->AddItem(new Workspace(_gcinfo,_fbinfo)); _workspacelist->AddItem(new Workspace(_gcinfo,_fbinfo,_driver));
} }
_resolution=_driver->GetMode(); _resolution=_driver->GetMode();
_currentworkspace=0; _currentworkspace=0;
@@ -183,7 +185,7 @@ Screen::~Screen(void)
*/ */
void Screen::AddWorkspace(int32 index) 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) ) if ( (index == -1) || !_workspacelist->AddItem(workspace,index) )
_workspacelist->AddItem(workspace); _workspacelist->AddItem(workspace);
} }
+1 -1
View File
@@ -40,7 +40,7 @@ class RGBColor;
class Workspace class Workspace
{ {
public: 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); ~Workspace(void);
void SetBGColor(const RGBColor &c); void SetBGColor(const RGBColor &c);
RGBColor BGColor(); RGBColor BGColor();
+5 -1
View File
@@ -45,7 +45,11 @@ Server app_server :
ViewDriver.cpp ViewDriver.cpp
WinBorder.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>libopenbeos.so
<boot!home!config!lib>libfreetype.so ; <boot!home!config!lib>libfreetype.so ;
+6 -7
View File
@@ -31,20 +31,19 @@
/*! /*!
\brief Sets up internal variables needed by the RootLayer \brief Sets up internal variables needed by the RootLayer
\param frame \param rect Frame of the root layer
\param name \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) : Layer(rect,layername,B_FOLLOW_NONE,0, NULL)
{ {
_driver=GetGfxDriver(); _driver=gfxdriver;
_invalid=new BRegion(Bounds()); _invalid=new BRegion(Bounds());
_is_dirty=true; _is_dirty=true;
} }
/*! //! Frees all allocated heap memory (which happens to be none) ;)
\brief Frees all allocated heap memory (which happens to be none) ;)
*/
RootLayer::~RootLayer() RootLayer::~RootLayer()
{ {
} }
+1 -1
View File
@@ -34,7 +34,7 @@
class RootLayer : public Layer class RootLayer : public Layer
{ {
public: public:
RootLayer(BRect rect, const char *layername); RootLayer(BRect rect, const char *layername, DisplayDriver *gfxdriver);
~RootLayer(); ~RootLayer();
void RequestDraw(); void RequestDraw();
void RequestDraw(const BRect &r); void RequestDraw(const BRect &r);
+19 -6
View File
@@ -25,8 +25,6 @@
// //
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// TODO: Update this to have GetMode, GetWidth, etc return the proper values
#include <stdio.h> #include <stdio.h>
#include <iostream.h> #include <iostream.h>
#include <Message.h> #include <Message.h>
@@ -65,7 +63,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_RGB32,true); viewbmp=new BBitmap(bounds,B_CMAP8,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. I suppose I could write // 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)); serverlink=new PortLink(find_port(SERVER_INPUT_PORT));
// Create a cursor which isn't just a box // 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); BView *v=new BView(cursor->Bounds(),"v", B_FOLLOW_NONE, B_WILL_DRAW);
hide_cursor=0; hide_cursor=0;
@@ -333,6 +331,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;
_SetWidth(640);
_SetHeight(480);
_SetDepth(8);
_SetMode(B_8_BIT_640x480);
} }
ViewDriver::~ViewDriver(void) ViewDriver::~ViewDriver(void)
@@ -374,7 +376,7 @@ void ViewDriver::SetMode(int32 space)
{ {
screenwin->Lock(); screenwin->Lock();
int16 w=640,h=480; int16 w=640,h=480;
color_space s; color_space s=B_CMAP8;
switch(space) switch(space)
{ {
@@ -403,24 +405,33 @@ void ViewDriver::SetMode(int32 space)
case B_32_BIT_800x600: case B_32_BIT_800x600:
case B_32_BIT_1024x768: case B_32_BIT_1024x768:
s=B_RGBA32; s=B_RGBA32;
_SetDepth(32);
break; break;
case B_16_BIT_640x480: case B_16_BIT_640x480:
case B_16_BIT_800x600: case B_16_BIT_800x600:
case B_16_BIT_1024x768: case B_16_BIT_1024x768:
s=B_RGBA15; s=B_RGBA15;
_SetDepth(15);
break; break;
case B_8_BIT_640x480: case B_8_BIT_640x480:
case B_8_BIT_800x600: case B_8_BIT_800x600:
case B_8_BIT_1024x768: case B_8_BIT_1024x768:
s=B_CMAP8; s=B_CMAP8;
_SetDepth(8);
break; break;
default: default:
_SetDepth(8);
break; break;
} }
delete framebuffer; 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); screenwin->view->viewbmp=new BBitmap(BRect(0,0,w-1,h-1),s,true);
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);
@@ -431,6 +442,8 @@ void ViewDriver::SetMode(int32 space)
drawview->FillRect(drawview->Bounds()); drawview->FillRect(drawview->Bounds());
drawview->Sync(); drawview->Sync();
framebuffer->Unlock(); framebuffer->Unlock();
_SetBytesPerRow(framebuffer->BytesPerRow());
screenwin->view->Invalidate(); screenwin->view->Invalidate();
screenwin->Unlock(); screenwin->Unlock();
} }