renamed class members to fit our guidelines (more or less)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17518 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-05-20 22:10:00 +00:00
parent 57c361471e
commit 2b73985eb0
2 changed files with 113 additions and 103 deletions

View File

@ -133,31 +133,38 @@ virtual void _ReservedDirectWindow4();
BDirectWindow(BDirectWindow &); BDirectWindow(BDirectWindow &);
BDirectWindow &operator=(BDirectWindow &); BDirectWindow &operator=(BDirectWindow &);
bool daemon_killer; bool fDaemonKiller;
bool connection_enable; bool fConnectionEnable;
bool full_screen_enable; bool fIsFullScreen;
bool direct_driver_ready; bool fDirectDriverReady;
bool in_direct_connect; bool fInDirectConnect;
int32 direct_lock;
sem_id direct_sem; int32 fDirectLock;
uint32 direct_lock_count; sem_id fDirectSem;
thread_id direct_lock_owner; uint32 fDirectLockCount;
char *direct_lock_stack; thread_id fDirectLockOwner;
sem_id disable_sem; char *fDirectLockStack;
sem_id disable_sem_ack;
uint32 dw_init_status; sem_id fDisableSem;
uint32 info_area_size; sem_id fDisableSemAck;
uint32 direct_driver_type;
uint32 direct_driver_token; uint32 fInitStatus;
area_id cloned_clipping_area; uint32 fInfoAreaSize;
area_id source_clipping_area;
thread_id direct_daemon_id; uint32 fDirectDriverType;
direct_buffer_info *buffer_desc; uint32 fDirectDriverToken;
BDirectDriver *direct_driver;
struct priv_ext *extension; area_id fClonedClippingArea;
area_id fSourceClippingArea;
thread_id fDirectDaemonId;
direct_buffer_info *fBufferDesc;
BDirectDriver *direct_driver;
struct priv_ext *extension;
uint32 _reserved_[15]; uint32 _reserved_[15];
static int32 DirectDaemonFunc(void *arg); static int32 _DaemonStarter(void *arg);
int32 DirectDaemonFunc();
bool LockDirect() const; bool LockDirect() const;
void UnlockDirect() const; void UnlockDirect() const;
void InitData(); void InitData();

View File

@ -225,13 +225,13 @@ BDirectWindow::GetClippingRegion(BRegion *region, BPoint *origin) const
if (IsLocked() || !LockDirect()) if (IsLocked() || !LockDirect())
return B_ERROR; return B_ERROR;
if (in_direct_connect) { if (fInDirectConnect) {
UnlockDirect(); UnlockDirect();
return B_ERROR; return B_ERROR;
} }
// BPoint's coordinates are floats. We can only work // BPoint's coordinates are floats. We can only work
// with integers. // with integers._DaemonStarter
int32 originX, originY; int32 originX, originY;
if (origin == NULL) { if (origin == NULL) {
originX = 0; originX = 0;
@ -246,11 +246,11 @@ BDirectWindow::GetClippingRegion(BRegion *region, BPoint *origin) const
// Otherwise, we would need to call BRegion::Include(clipping_rect) // Otherwise, we would need to call BRegion::Include(clipping_rect)
// for every clipping_rect in our clip_list, and that would be much // for every clipping_rect in our clip_list, and that would be much
// more overkill than this (tested ). // more overkill than this (tested ).
region->set_size(buffer_desc->clip_list_count); region->set_size(fBufferDesc->clip_list_count);
region->count = buffer_desc->clip_list_count; region->count = fBufferDesc->clip_list_count;
region->bound = buffer_desc->clip_bounds; region->bound = fBufferDesc->clip_bounds;
for (uint32 c = 0; c < buffer_desc->clip_list_count; c++) for (uint32 c = 0; c < fBufferDesc->clip_list_count; c++)
region->data[c] = buffer_desc->clip_list[c]; region->data[c] = fBufferDesc->clip_list[c];
// adjust bounds by the given origin point // adjust bounds by the given origin point
region->OffsetBy(-originX, -originY); region->OffsetBy(-originX, -originY);
@ -266,6 +266,9 @@ BDirectWindow::GetClippingRegion(BRegion *region, BPoint *origin) const
status_t status_t
BDirectWindow::SetFullScreen(bool enable) BDirectWindow::SetFullScreen(bool enable)
{ {
if (fIsFullScreen == enable)
return B_OK;
status_t status = B_ERROR; status_t status = B_ERROR;
if (Lock()) { if (Lock()) {
fLink->StartMessage(AS_DIRECT_WINDOW_SET_FULLSCREEN); fLink->StartMessage(AS_DIRECT_WINDOW_SET_FULLSCREEN);
@ -273,7 +276,7 @@ BDirectWindow::SetFullScreen(bool enable)
if (fLink->FlushWithReply(status) == B_OK if (fLink->FlushWithReply(status) == B_OK
&& status == B_OK) && status == B_OK)
full_screen_enable = enable; fIsFullScreen = enable;
Unlock(); Unlock();
} }
return status; return status;
@ -283,7 +286,7 @@ BDirectWindow::SetFullScreen(bool enable)
bool bool
BDirectWindow::IsFullScreen() const BDirectWindow::IsFullScreen() const
{ {
return full_screen_enable; return fIsFullScreen;
} }
@ -306,42 +309,47 @@ BDirectWindow::SupportsWindowMode(screen_id id)
// #pragma mark - Private methods // #pragma mark - Private methods
/* static */
int32
BDirectWindow::_DaemonStarter(void *arg)
{
return static_cast<BDirectWindow *>(arg)->DirectDaemonFunc();
}
int32 int32
BDirectWindow::DirectDaemonFunc(void *arg) BDirectWindow::DirectDaemonFunc()
{ {
BDirectWindow *object = static_cast<BDirectWindow *>(arg); while (!fDaemonKiller) {
while (!object->daemon_killer) {
// This sem is released by the app_server when our // This sem is released by the app_server when our
// clipping region changes, or when our window is moved, // clipping region changes, or when our window is moved,
// resized, etc. etc. // resized, etc. etc.
status_t status; status_t status;
do { do {
status = acquire_sem(object->disable_sem); status = acquire_sem(fDisableSem);
} while (status == B_INTERRUPTED); } while (status == B_INTERRUPTED);
if (status < B_OK) if (status < B_OK)
return -1; return -1;
if (object->LockDirect()) { if (LockDirect()) {
if ((object->buffer_desc->buffer_state & B_DIRECT_MODE_MASK) == B_DIRECT_START) if ((fBufferDesc->buffer_state & B_DIRECT_MODE_MASK) == B_DIRECT_START)
object->connection_enable = true; fConnectionEnable = true;
object->in_direct_connect = true; fInDirectConnect = true;
object->DirectConnected(object->buffer_desc); DirectConnected(fBufferDesc);
object->in_direct_connect = false; fInDirectConnect = false;
if ((object->buffer_desc->buffer_state & B_DIRECT_MODE_MASK) == B_DIRECT_STOP) if ((fBufferDesc->buffer_state & B_DIRECT_MODE_MASK) == B_DIRECT_STOP)
object->connection_enable = false; fConnectionEnable = false;
object->UnlockDirect(); UnlockDirect();
} }
// The app_server then waits (with a timeout) on this sem. // The app_server then waits (with a timeout) on this sem.
// If we aren't quick enough to release this sem, our app // If we aren't quick enough to release this sem, our app
// will be terminated by the app_server // will be terminated by the app_server
if (release_sem(object->disable_sem_ack) != B_OK) if (release_sem(fDisableSemAck) != B_OK)
return -1; return -1;
} }
@ -365,15 +373,15 @@ BDirectWindow::LockDirect() const
#if DW_NEEDS_LOCKING #if DW_NEEDS_LOCKING
BDirectWindow *casted = const_cast<BDirectWindow *>(this); BDirectWindow *casted = const_cast<BDirectWindow *>(this);
if (atomic_add(&casted->direct_lock, 1) > 0) { if (atomic_add(&casted->fDirectLock, 1) > 0) {
do { do {
status = acquire_sem(direct_sem); status = acquire_sem(fDirectSem);
} while (status == B_INTERRUPTED); } while (status == B_INTERRUPTED);
} }
if (status == B_OK) { if (status == B_OK) {
casted->direct_lock_owner = find_thread(NULL); casted->fDirectLockOwner = find_thread(NULL);
casted->direct_lock_count++; casted->fDirectLockCount++;
} }
#endif #endif
@ -387,10 +395,10 @@ BDirectWindow::UnlockDirect() const
#if DW_NEEDS_LOCKING #if DW_NEEDS_LOCKING
BDirectWindow *casted = const_cast<BDirectWindow *>(this); BDirectWindow *casted = const_cast<BDirectWindow *>(this);
if (atomic_add(&casted->direct_lock, -1) > 1) if (atomic_add(&casted->fDirectLock, -1) > 1)
release_sem(direct_sem); release_sem(casted->fDirectSem);
casted->direct_lock_count--; casted->fDirectLockCount--;
#endif #endif
} }
@ -398,64 +406,59 @@ BDirectWindow::UnlockDirect() const
void void
BDirectWindow::InitData() BDirectWindow::InitData()
{ {
connection_enable = false; fConnectionEnable = false;
full_screen_enable = false; fIsFullScreen = false;
in_direct_connect = false; fInDirectConnect = false;
dw_init_status = 0; fInitStatus = 0;
direct_driver_ready = false; fDirectDriverReady = false;
direct_driver_type = 0; fDirectDriverType = 0;
direct_driver_token = 0; fDirectDriverToken = 0;
direct_driver = NULL; direct_driver = NULL;
if (!Lock())
return;
struct direct_window_sync_data syncData;
fLink->StartMessage(AS_DIRECT_WINDOW_GET_SYNC_DATA);
status_t status = B_ERROR; status_t status = B_ERROR;
if (fLink->FlushWithReply(status) == B_OK struct direct_window_sync_data syncData;
&& status == B_OK) { if (Lock()) {
fLink->Read<direct_window_sync_data>(&syncData); fLink->StartMessage(AS_DIRECT_WINDOW_GET_SYNC_DATA);
if (fLink->FlushWithReply(status) == B_OK
&& status == B_OK) {
fLink->Read<direct_window_sync_data>(&syncData);
}
Unlock();
} }
Unlock();
if (status < B_OK) if (status < B_OK)
return; return;
#if DW_NEEDS_LOCKING #if DW_NEEDS_LOCKING
direct_lock = 0; fDirectLock = 0;
direct_lock_count = 0; fDirectLockCount = 0;
direct_lock_owner = -1; fDirectLockOwner = -1;
direct_lock_stack = NULL; fDirectLockStack = NULL;
direct_sem = create_sem(1, "direct sem"); fDirectSem = create_sem(1, "direct sem");
if (direct_sem > 0) if (fDirectSem > 0)
dw_init_status |= DW_STATUS_SEM_CREATED; fInitStatus |= DW_STATUS_SEM_CREATED;
#endif #endif
source_clipping_area = syncData.area; fSourceClippingArea = syncData.area;
disable_sem = syncData.disable_sem; fDisableSem = syncData.disable_sem;
disable_sem_ack = syncData.disable_sem_ack; fDisableSemAck = syncData.disable_sem_ack;
cloned_clipping_area = clone_area("Clone direct area", (void**)&buffer_desc, fClonedClippingArea = clone_area("Clone direct area", (void**)&fBufferDesc,
B_ANY_ADDRESS, B_READ_AREA, source_clipping_area); B_ANY_ADDRESS, B_READ_AREA, fSourceClippingArea);
if (cloned_clipping_area > 0) { if (fSourceClippingArea > 0) {
dw_init_status |= DW_STATUS_AREA_CLONED; fInitStatus |= DW_STATUS_AREA_CLONED;
direct_daemon_id = spawn_thread(DirectDaemonFunc, "direct daemon", fDirectDaemonId = spawn_thread(_DaemonStarter, "direct daemon",
B_DISPLAY_PRIORITY, this); B_DISPLAY_PRIORITY, this);
if (direct_daemon_id > 0) { if (fDirectDaemonId > 0) {
daemon_killer = false; fDaemonKiller = false;
if (resume_thread(direct_daemon_id) == B_OK) if (resume_thread(fDirectDaemonId) == B_OK)
dw_init_status |= DW_STATUS_THREAD_STARTED; fInitStatus |= DW_STATUS_THREAD_STARTED;
else else
kill_thread(direct_daemon_id); kill_thread(fDirectDaemonId);
} }
} }
} }
@ -467,27 +470,27 @@ BDirectWindow::DisposeData()
// wait until the connection terminates: we can't destroy // wait until the connection terminates: we can't destroy
// the object until the client receives the B_DIRECT_STOP // the object until the client receives the B_DIRECT_STOP
// notification, or bad things will happen // notification, or bad things will happen
while (connection_enable) while (fConnectionEnable)
snooze(50000); snooze(50000);
LockDirect(); LockDirect();
if (dw_init_status & DW_STATUS_THREAD_STARTED) { if (fInitStatus & DW_STATUS_THREAD_STARTED) {
daemon_killer = true; fDaemonKiller = true;
// Release this sem, otherwise the Direct daemon thread // Release this sem, otherwise the Direct daemon thread
// will wait forever on it // will wait forever on it
release_sem(disable_sem); release_sem(fDisableSem);
status_t retVal; status_t retVal;
wait_for_thread(direct_daemon_id, &retVal); wait_for_thread(fDirectDaemonId, &retVal);
} }
#if DW_NEEDS_LOCKING #if DW_NEEDS_LOCKING
if (dw_init_status & DW_STATUS_SEM_CREATED) if (fInitStatus & DW_STATUS_SEM_CREATED)
delete_sem(direct_sem); delete_sem(fDirectSem);
#endif #endif
if (dw_init_status & DW_STATUS_AREA_CLONED) if (fInitStatus & DW_STATUS_AREA_CLONED)
delete_area(cloned_clipping_area); delete_area(fClonedClippingArea);
} }