debug code looks nicer...

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4580 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca 2003-09-08 21:48:35 +00:00
parent 1f0ca0978a
commit 3ecfa8e102
3 changed files with 64 additions and 98 deletions

View File

@ -39,9 +39,11 @@
#define USE_VIEW_FILL_HACK #define USE_VIEW_FILL_HACK
//#define DEBUG_DECORATOR //#define DEBUG_DECORATOR
#ifdef DEBUG_DECORATOR #ifdef DEBUG_DECORATOR
#include <stdio.h> # include <stdio.h>
# define STRACE(x) printf x
#else
# define STRACE(x) ;
#endif #endif
DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags) DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
@ -68,18 +70,16 @@ DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 w
// This flag is used to determine whether or not we're moving the tab // This flag is used to determine whether or not we're moving the tab
slidetab=false; slidetab=false;
#ifdef DEBUG_DECORATOR // tab_highcol=_colors->window_tab;
printf("DefaultDecorator:\n"); // tab_lowcol=_colors->window_tab;
printf("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom);
#endif STRACE(("DefaultDecorator:\n"));
STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom));
} }
DefaultDecorator::~DefaultDecorator(void) DefaultDecorator::~DefaultDecorator(void)
{ {
#ifdef DEBUG_DECORATOR STRACE(("DefaultDecorator: ~DefaultDecorator()\n"));
printf("DefaultDecorator: ~DefaultDecorator()\n");
#endif
delete [] framecolors; delete [] framecolors;
} }
@ -170,10 +170,7 @@ click_type DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
void DefaultDecorator::_DoLayout(void) void DefaultDecorator::_DoLayout(void)
{ {
#ifdef DEBUG_DECORATOR STRACE(("DefaultDecorator: Do Layout\n"));
printf("DefaultDecorator: Do Layout\n");
#endif
// Here we determine the size of every rectangle that we use // Here we determine the size of every rectangle that we use
// internally when we are given the size of the client rectangle. // internally when we are given the size of the client rectangle.
@ -281,10 +278,7 @@ void DefaultDecorator::MoveBy(float x, float y)
void DefaultDecorator::MoveBy(BPoint pt) void DefaultDecorator::MoveBy(BPoint pt)
{ {
#ifdef DEBUG_DECORATOR STRACE(("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y));
printf("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y);
#endif
// Move all internal rectangles the appropriate amount // Move all internal rectangles the appropriate amount
_frame.OffsetBy(pt); _frame.OffsetBy(pt);
_closerect.OffsetBy(pt); _closerect.OffsetBy(pt);
@ -301,10 +295,7 @@ void DefaultDecorator::MoveBy(BPoint pt)
BRegion * DefaultDecorator::GetFootprint(void) BRegion * DefaultDecorator::GetFootprint(void)
{ {
#ifdef DEBUG_DECORATOR STRACE(("DefaultDecorator: Get Footprint\n"));
printf("DefaultDecorator: Get Footprint\n");
#endif
// This function calculates the decorator's footprint in coordinates // This function calculates the decorator's footprint in coordinates
// relative to the layer. This is most often used to set a WinBorder // relative to the layer. This is most often used to set a WinBorder
// object's visible region. // object's visible region.
@ -321,10 +312,7 @@ BRect DefaultDecorator::SlideTab(float dx, float dy=0){
void DefaultDecorator::_DrawTitle(BRect r) void DefaultDecorator::_DrawTitle(BRect r)
{ {
#ifdef DEBUG_DECORATOR STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
printf("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
#endif
// Designed simply to redraw the title when it has changed on // Designed simply to redraw the title when it has changed on
// the client side. // the client side.
_layerdata.highcolor=_colors->window_tab_text; _layerdata.highcolor=_colors->window_tab_text;
@ -373,9 +361,7 @@ void DefaultDecorator::_SetFocus(void)
void DefaultDecorator::Draw(BRect update) void DefaultDecorator::Draw(BRect update)
{ {
#ifdef DEBUG_DECORATOR STRACE(("DefaultDecorator: Draw(%.1f,%.1f,%.1f,%.1f)\n",update.left,update.top,update.right,update.bottom));
printf("DefaultDecorator: Draw(%.1f,%.1f,%.1f,%.1f)\n",update.left,update.top,update.right,update.bottom);
#endif
// We need to draw a few things: the tab, the resize thumb, the borders, // We need to draw a few things: the tab, the resize thumb, the borders,
// and the buttons // and the buttons
@ -394,10 +380,7 @@ void DefaultDecorator::Draw(void)
void DefaultDecorator::_DrawZoom(BRect r) void DefaultDecorator::_DrawZoom(BRect r)
{ {
#ifdef DEBUG_DECORATOR STRACE(("_DrawZoom(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
printf("_DrawZoom(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
#endif
// If this has been implemented, then the decorator has a Zoom button // If this has been implemented, then the decorator has a Zoom button
// which should be drawn based on the state of the member zoomstate // which should be drawn based on the state of the member zoomstate
BRect zr( r ); BRect zr( r );
@ -414,20 +397,14 @@ void DefaultDecorator::_DrawZoom(BRect r)
void DefaultDecorator::_DrawClose(BRect r) void DefaultDecorator::_DrawClose(BRect r)
{ {
#ifdef DEBUG_DECORATOR STRACE(("_DrawClose(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
printf("_DrawClose(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
#endif
// Just like DrawZoom, but for a close button // Just like DrawZoom, but for a close button
DrawBlendedRect( r, GetClose()); DrawBlendedRect( r, GetClose());
} }
void DefaultDecorator::_DrawTab(BRect r) void DefaultDecorator::_DrawTab(BRect r)
{ {
#ifdef DEBUG_DECORATOR STRACE(("_DrawTab(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
printf("_DrawTab(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom);
#endif
// If a window has a tab, this will draw it and any buttons which are // If a window has a tab, this will draw it and any buttons which are
// in it. // in it.
if(_look==B_NO_BORDER_WINDOW_LOOK) if(_look==B_NO_BORDER_WINDOW_LOOK)
@ -547,7 +524,8 @@ void DefaultDecorator::DrawBlendedRect(BRect r, bool down)
void DefaultDecorator::_DrawFrame(BRect invalid) void DefaultDecorator::_DrawFrame(BRect invalid)
{ {
STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
invalid.right, invalid.bottom));
// We need to test each side to determine whether or not it needs drawn. Additionally, // We need to test each side to determine whether or not it needs drawn. Additionally,
// we must clip the lines drawn by this function to the invalid rectangle we are given // we must clip the lines drawn by this function to the invalid rectangle we are given

View File

@ -51,6 +51,12 @@
#include "Utils.h" #include "Utils.h"
//#define DEBUG_SERVERAPP //#define DEBUG_SERVERAPP
#ifdef DEBUG_SERVERAPP
# include <stdio.h>
# define STRACE(x) printf x
#else
# define STRACE(x) ;
#endif
/*! /*!
\brief Constructor \brief Constructor
@ -94,19 +100,15 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *s
_driver=GetGfxDriver(ActiveScreen()); _driver=GetGfxDriver(ActiveScreen());
_cursorhidden=false; _cursorhidden=false;
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s:\n",_signature.String()));
printf("ServerApp %s:\n",_signature.String()); STRACE(("\tBApp port: %ld\n",_sender));
printf("\tBApp port: %ld\n",_sender); STRACE(("\tReceiver port: %ld\n",_receiver));
printf("\tReceiver port: %ld\n",_receiver);
#endif
} }
//! Does all necessary teardown for application //! Does all necessary teardown for application
ServerApp::~ServerApp(void) ServerApp::~ServerApp(void)
{ {
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s:~ServerApp()\n",_signature.String()));
printf("ServerApp %s:~ServerApp()\n",_signature.String());
#endif
int32 i; int32 i;
ServerWindow *tempwin; ServerWindow *tempwin;
@ -235,9 +237,7 @@ int32 ServerApp::MonitorApp(void *data)
switch (msgCode){ switch (msgCode){
case AS_QUIT_APP: case AS_QUIT_APP:
{ {
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s:Server shutdown notification received\n",app->_signature.String()));
printf("ServerApp %s:Server shutdown notification received\n",app->_signature.String());
#endif
// If we are using the real, accelerated version of the // If we are using the real, accelerated version of the
// DisplayDriver, we do NOT want the user to be able shut down // DisplayDriver, we do NOT want the user to be able shut down
// the server. The results would NOT be pretty // the server. The results would NOT be pretty
@ -281,9 +281,7 @@ int32 ServerApp::MonitorApp(void *data)
} }
default: default:
{ {
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s: Got a Message to dispatch\n",app->_signature.String()));
printf("ServerApp %s: Got a Message to dispatch\n",app->_signature.String());
#endif
app->_DispatchMessage(msgCode, NULL); app->_DispatchMessage(msgCode, NULL);
break; break;
} }
@ -352,9 +350,8 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
ses->ReadData( &sendPort, sizeof(port_id) ); ses->ReadData( &sendPort, sizeof(port_id) );
title = ses->ReadString(); title = ses->ReadString();
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s: Got 'New Window' message, trying to do smething...\n",
printf("ServerApp %s: Got 'New Window' message, trying to do smething...\n"); _signature.String()));
#endif
// ServerWindow constructor will reply with port_id of a newly created port // ServerWindow constructor will reply with port_id of a newly created port
ServerWindow *newwin = new ServerWindow( frame, title, ServerWindow *newwin = new ServerWindow( frame, title,
@ -363,10 +360,8 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
//AddWindowToDesktop( newwin, workspace, ActiveScreen() ); //AddWindowToDesktop( newwin, workspace, ActiveScreen() );
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n",
printf("ServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n", _signature.String(),title,frame.left,frame.top,frame.right,frame.bottom));
_signature.String(),title,frame.left,frame.top,frame.right,frame.bottom);
#endif
delete title; delete title;
@ -386,9 +381,7 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
w=(ServerWindow*)_winlist->ItemAt(i); w=(ServerWindow*)_winlist->ItemAt(i);
if(w->_token==winid) if(w->_token==winid)
{ {
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s: Deleting window %s\n",_signature.String(),w->Title()));
printf("ServerApp %s: Deleting window %s\n",_signature.String(),w->Title());
#endif
_winlist->RemoveItem(w); _winlist->RemoveItem(w);
delete w; delete w;
break; break;
@ -425,10 +418,10 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
s.id=*((int32*)index); s.id=*((int32*)index);
ServerBitmap *sbmp=bitmapmanager->CreateBitmap(r,cs,f,bpr,s); ServerBitmap *sbmp=bitmapmanager->CreateBitmap(r,cs,f,bpr,s);
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n", STRACE(("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n",
_signature.String(),r.left,r.top,r.right,r.bottom); _signature.String(),r.left,r.top,r.right,r.bottom));
#endif
if(sbmp) if(sbmp)
{ {
// list for doing faster lookups for a bitmap than what the BitmapManager // list for doing faster lookups for a bitmap than what the BitmapManager
@ -463,9 +456,8 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
ServerBitmap *sbmp=_FindBitmap(*((int32*)index)); ServerBitmap *sbmp=_FindBitmap(*((int32*)index));
if(sbmp) if(sbmp)
{ {
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s: Deleting Bitmap %ld\n",_signature.String(),*((int32*)index)));
printf("ServerApp %s: Deleting Bitmap %ld\n",_signature.String(),*((int32*)index));
#endif
_bmplist->RemoveItem(sbmp); _bmplist->RemoveItem(sbmp);
bitmapmanager->DeleteBitmap(sbmp); bitmapmanager->DeleteBitmap(sbmp);
write_port(replyport,SERVER_TRUE,NULL,0); write_port(replyport,SERVER_TRUE,NULL,0);
@ -478,33 +470,29 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
case AS_CREATE_PICTURE: case AS_CREATE_PICTURE:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s: Create Picture unimplemented\n",_signature.String()));
printf("ServerApp %s: Create Picture unimplemented\n",_signature.String());
#endif
break; break;
} }
case AS_DELETE_PICTURE: case AS_DELETE_PICTURE:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s: Delete Picture unimplemented\n",_signature.String()));
printf("ServerApp %s: Delete Picture unimplemented\n",_signature.String());
#endif
break; break;
} }
case AS_CLONE_PICTURE: case AS_CLONE_PICTURE:
{ {
// TODO: Implement // TODO: Implement
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s: Clone Picture unimplemented\n",_signature.String()));
printf("ServerApp %s: Clone Picture unimplemented\n",_signature.String());
#endif
break; break;
} }
case AS_DOWNLOAD_PICTURE: case AS_DOWNLOAD_PICTURE:
{ {
// TODO; Implement // TODO; Implement
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s: Download Picture unimplemented\n",_signature.String()));
printf("ServerApp %s: Download Picture unimplemented\n",_signature.String());
#endif
break; break;
} }
case AS_SET_SCREEN_MODE: case AS_SET_SCREEN_MODE:
@ -663,9 +651,8 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
} }
default: default:
{ {
#ifdef DEBUG_SERVERAPP STRACE(("ServerApp %s received unhandled message code offset %s\n",_signature.String(),MsgCodeToString(code)));
printf("ServerApp %s received unhandled message code offset %lx\n",_signature.String(),MsgCodeToString(code));
#endif
break; break;
} }
} }

View File

@ -51,6 +51,13 @@
#include "LayerData.h" #include "LayerData.h"
#include "PNGDump.h" #include "PNGDump.h"
#ifdef DEBUG_DRIVER_MODULE
# include <stdio.h>
# define STRACE(x) printf x
#else
# define STRACE(x) ;
#endif
enum enum
{ {
VDWIN_CLEAR=100, VDWIN_CLEAR=100,
@ -653,10 +660,8 @@ void ViewDriver::CopyBits(BRect src, BRect dest)
void ViewDriver::CopyRegion(BRegion *src, const BPoint &lefttop) void ViewDriver::CopyRegion(BRegion *src, const BPoint &lefttop)
{ {
#ifdef DEBUG_DRIVER_MODULE STRACE(("ViewDriver:: CopyRegion not completely tested\n"));
printf("ViewDriver:: CopyRegion not completely tested\n");
#endif
screenwin->Lock(); screenwin->Lock();
framebuffer->Lock(); framebuffer->Lock();
@ -748,9 +753,7 @@ printf("Overlap\n");
void ViewDriver::DrawBitmap(ServerBitmap *bitmap, BRect src, BRect dest) void ViewDriver::DrawBitmap(ServerBitmap *bitmap, BRect src, BRect dest)
{ {
#ifdef DEBUG_DRIVER_MODULE STRACE(("ViewDriver:: DrawBitmap unimplemented()\n"));
printf("ViewDriver:: DrawBitmap unimplemented()\n");
#endif
} }
void ViewDriver::DrawChar(char c, BPoint pt, LayerData *d) void ViewDriver::DrawChar(char c, BPoint pt, LayerData *d)
@ -763,9 +766,7 @@ void ViewDriver::DrawChar(char c, BPoint pt, LayerData *d)
/* /*
void ViewDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL) void ViewDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL)
{ {
#ifdef DEBUG_DRIVER_MODULE STRACE(("ViewDriver:: DrawString(\"%s\",%ld,BPoint(%f,%f))\n",string,length,pt.x,pt.y));
printf("ViewDriver:: DrawString(\"%s\",%ld,BPoint(%f,%f))\n",string,length,pt.x,pt.y);
#endif
if(!d) if(!d)
return; return;
BRect r; BRect r;