Added optional debug output

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21035 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2007-05-05 20:03:31 +00:00
parent 45bf6259ad
commit 5115ca0858

View File

@ -16,6 +16,12 @@
#include <DirectWindowPrivate.h>
#include <ServerProtocol.h>
//#define DEBUG 1
#if DEBUG
#include <string.h>
#include <stdio.h>
#endif
// We don't need this kind of locking, since the directDaemonFunc
// doesn't access critical shared data.
@ -28,6 +34,60 @@ enum dw_status_bits {
};
#if DEBUG
static void
print_direct_buffer_state(const direct_buffer_state &state)
{
if (state == 0)
return;
char string[128];
int modeState = state & B_DIRECT_MODE_MASK;
if (state == B_DIRECT_START)
strcpy(string, "B_DIRECT_START");
else if (state == B_DIRECT_MODIFY)
strcpy(string, "B_DIRECT_MODIFY");
else if (state == B_DIRECT_STOP)
strcpy(string, "B_DIRECT_STOP");
if (state & B_CLIPPING_MODIFIED)
strcat(string, " | B_CLIPPING_MODIFIED");
if (state & B_BUFFER_RESIZED)
strcat(string, " | B_BUFFER_RESIZED");
if (state & B_BUFFER_MOVED)
strcat(string, " | B_BUFFER_MOVED");
if (state & B_BUFFER_RESET)
strcat(string, " | B_BUFFER_RESET");
printf("direct_buffer_state: %s", string);
}
static void
print_direct_driver_state(const direct_driver_state &state)
{
if (state == 0)
return;
char string[64];
if (state == B_DRIVER_CHANGED)
strcpy(string, "B_DRIVER_CHANGED");
else if (state == B_MODE_CHANGED)
strcpy(string, "B_MODE_CHANGED");
printf("direct_driver_state: %s\n", string);
}
static void
print_direct_buffer_info(const direct_buffer_info &info)
{
print_direct_buffer_state(info.buffer_state);
print_direct_driver_state(info.driver_state);
}
#endif
BDirectWindow::BDirectWindow(BRect frame, const char *title, window_type type,
uint32 flags, uint32 workspace)
: BWindow(frame, title, type, flags, workspace)
@ -335,11 +395,15 @@ BDirectWindow::DirectDaemonFunc()
if (status < B_OK)
return -1;
#if DEBUG
print_direct_buffer_info(*fBufferDesc);
#endif
if (LockDirect()) {
if ((fBufferDesc->buffer_state & B_DIRECT_MODE_MASK) == B_DIRECT_START)
fConnectionEnable = true;
fInDirectConnect = true;
fInDirectConnect = true;
DirectConnected(fBufferDesc);
fInDirectConnect = false;