some more forgotten style changes

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20117 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2007-02-09 10:29:13 +00:00
parent d70beedc0a
commit d619599aa3
2 changed files with 77 additions and 91 deletions
+69 -83
View File
@@ -422,11 +422,11 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
fCurrentSettings.width = (int32)frame.right+1-LEFT_WIDTH; fCurrentSettings.width = (int32)frame.right+1-LEFT_WIDTH;
fCurrentSettings.height = (int32)frame.bottom+1-TOP_LEFT_LIMIT; fCurrentSettings.height = (int32)frame.bottom+1-TOP_LEFT_LIMIT;
previous_fullscreen_mode = WINDOW_MODE; previous_fullscreen_mode = WINDOW_MODE;
next_set.Set(&fCurrentSettings); fNextSettings.Set(&fCurrentSettings);
/* initialise various global parameters */ /* initialise various global parameters */
fInstantLoadLevel = 0; fInstantLoadLevel = 0;
second_thread_threshold = 0.5; fSecondThreadThreshold = 0.5;
last_dynamic_delay = 0.0; last_dynamic_delay = 0.0;
crc_alea = CRC_START; crc_alea = CRC_START;
@@ -864,8 +864,8 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
/* allocate the semaphores */ /* allocate the semaphores */
fDrawingLock = create_sem(1, "chart locker"); fDrawingLock = create_sem(1, "chart locker");
second_thread_lock = create_sem(0, "chart second locker"); fSecondThreadLock = create_sem(0, "chart second locker");
second_thread_release = create_sem(0, "chart second release"); fSecondThreadRelease = create_sem(0, "chart second release");
/* spawn the asynchronous animation threads */ /* spawn the asynchronous animation threads */
fKillThread = false; fKillThread = false;
@@ -883,22 +883,22 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
ChartWindow::~ChartWindow() ChartWindow::~ChartWindow()
{ {
int32 result; status_t result;
/* setting this flag force both animation threads to quit */ /* setting this flag force both animation threads to quit */
fKillThread = true; fKillThread = true;
/* wait for the two animation threads to quit */ /* wait for the two animation threads to quit */
wait_for_thread(fAnimationThread, &result); wait_for_thread(fAnimationThread, &result);
wait_for_thread(fSecondAnimationThread, &result); wait_for_thread(fSecondAnimationThread, &result);
/* free the offscreen bitmap if any */ /* free the offscreen bitmap if any */
if (fOffscreen != NULL) delete fOffscreen;
delete fOffscreen;
/* release the semaphores used for synchronisation */ /* release the semaphores used for synchronisation */
delete_sem(fDrawingLock); delete_sem(fDrawingLock);
delete_sem(second_thread_lock); delete_sem(fSecondThreadLock);
delete_sem(second_thread_release); delete_sem(fSecondThreadRelease);
/* free the buffers used to store the starlists */ /* free the buffers used to store the starlists */
free(stars.list); free(stars.list);
@@ -914,7 +914,7 @@ bool
ChartWindow::QuitRequested() ChartWindow::QuitRequested()
{ {
be_app->PostMessage(B_QUIT_REQUESTED); be_app->PostMessage(B_QUIT_REQUESTED);
return(TRUE); return BWindow::QuitRequested();
} }
@@ -924,8 +924,6 @@ ChartWindow::MessageReceived(BMessage *message)
int32 index, color; int32 index, color;
BHandler *handler; BHandler *handler;
BCheckBox *check_box; BCheckBox *check_box;
//BTextControl *text_ctrl;
//BColorControl *color_ctrl;
BSlider *slider; BSlider *slider;
message->FindPointer("source", (void**)&handler); message->FindPointer("source", (void**)&handler);
@@ -951,37 +949,37 @@ ChartWindow::MessageReceived(BMessage *message)
case ANIM_SLOW_MOVE_MSG : case ANIM_SLOW_MOVE_MSG :
case ANIM_FAST_MOVE_MSG : case ANIM_FAST_MOVE_MSG :
case ANIM_FREE_MOVE_MSG : case ANIM_FREE_MOVE_MSG :
next_set.animation = ANIMATION_OFF + (message->what - ANIM_OFF_MSG); fNextSettings.animation = ANIMATION_OFF + (message->what - ANIM_OFF_MSG);
break; break;
case DISP_OFF_MSG : case DISP_OFF_MSG :
case DISP_BITMAP_MSG : case DISP_BITMAP_MSG :
case DISP_DIRECT_MSG : case DISP_DIRECT_MSG :
next_set.display = DISPLAY_OFF + (message->what - DISP_OFF_MSG); fNextSettings.display = DISPLAY_OFF + (message->what - DISP_OFF_MSG);
break; break;
case SPACE_CHAOS_MSG : case SPACE_CHAOS_MSG :
case SPACE_AMAS_MSG : case SPACE_AMAS_MSG :
case SPACE_SPIRAL_MSG : case SPACE_SPIRAL_MSG :
next_set.space_model = SPACE_CHAOS + (message->what - SPACE_CHAOS_MSG); fNextSettings.space_model = SPACE_CHAOS + (message->what - SPACE_CHAOS_MSG);
break; break;
case FULL_SCREEN_MSG : case FULL_SCREEN_MSG :
check_box = dynamic_cast<BCheckBox*>(handler); check_box = dynamic_cast<BCheckBox*>(handler);
if (check_box->Value()) if (check_box->Value())
next_set.fullscreen_mode = FULLSCREEN_MODE; fNextSettings.fullscreen_mode = FULLSCREEN_MODE;
else else
next_set.fullscreen_mode = WINDOW_MODE; fNextSettings.fullscreen_mode = WINDOW_MODE;
break; break;
case AUTO_DEMO_MSG : case AUTO_DEMO_MSG :
next_set.fullscreen_mode = FULLDEMO_MODE; fNextSettings.fullscreen_mode = FULLDEMO_MODE;
next_set.animation = ANIMATION_FREE_MOVE; fNextSettings.animation = ANIMATION_FREE_MOVE;
next_set.special = SPECIAL_COMET; fNextSettings.special = SPECIAL_COMET;
LaunchSound(); LaunchSound();
break; break;
case BACK_DEMO_MSG : case BACK_DEMO_MSG :
next_set.fullscreen_mode = previous_fullscreen_mode; fNextSettings.fullscreen_mode = previous_fullscreen_mode;
break; break;
case SECOND_THREAD_MSG : case SECOND_THREAD_MSG :
check_box = dynamic_cast<BCheckBox*>(handler); check_box = dynamic_cast<BCheckBox*>(handler);
next_set.second_thread = check_box->Value(); fNextSettings.second_thread = (check_box->Value()?true:false);
break; break;
case COLORS_RED_MSG : case COLORS_RED_MSG :
case COLORS_GREEN_MSG : case COLORS_GREEN_MSG :
@@ -992,28 +990,28 @@ ChartWindow::MessageReceived(BMessage *message)
case COLORS_WHITE_MSG : case COLORS_WHITE_MSG :
index = message->what - COLORS_RED_MSG; index = message->what - COLORS_RED_MSG;
check_box = dynamic_cast<BCheckBox*>(handler); check_box = dynamic_cast<BCheckBox*>(handler);
next_set.colors[index] = (check_box->Value()?true:false); fNextSettings.colors[index] = (check_box->Value()?true:false);
break; break;
case SPECIAL_NONE_MSG : case SPECIAL_NONE_MSG :
case SPECIAL_COMET_MSG : case SPECIAL_COMET_MSG :
case SPECIAL_NOVAS_MSG : case SPECIAL_NOVAS_MSG :
case SPECIAL_BATTLE_MSG : case SPECIAL_BATTLE_MSG :
next_set.special = SPECIAL_NONE + (message->what - SPECIAL_NONE_MSG); fNextSettings.special = SPECIAL_NONE + (message->what - SPECIAL_NONE_MSG);
break; break;
case COLOR_PALETTE_MSG : case COLOR_PALETTE_MSG :
message->FindInt32("be:value", &color); message->FindInt32("be:value", &color);
next_set.back_color.red = (color >> 24); fNextSettings.back_color.red = (color >> 24);
next_set.back_color.green = (color >> 16); fNextSettings.back_color.green = (color >> 16);
next_set.back_color.blue = (color >> 8); fNextSettings.back_color.blue = (color >> 8);
next_set.back_color.alpha = color; fNextSettings.back_color.alpha = color;
break; break;
case STAR_DENSITY_MSG : case STAR_DENSITY_MSG :
slider = dynamic_cast<BSlider*>(handler); slider = dynamic_cast<BSlider*>(handler);
next_set.star_density = slider->Value(); fNextSettings.star_density = slider->Value();
break; break;
case REFRESH_RATE_MSG : case REFRESH_RATE_MSG :
slider = dynamic_cast<BSlider*>(handler); slider = dynamic_cast<BSlider*>(handler);
next_set.refresh_rate = exp(slider->Value()*0.001*(log(REFRESH_RATE_MAX/REFRESH_RATE_MIN)))* fNextSettings.refresh_rate = exp(slider->Value()*0.001*(log(REFRESH_RATE_MAX/REFRESH_RATE_MIN)))*
REFRESH_RATE_MIN; REFRESH_RATE_MIN;
break; break;
/* open the three floating window used to do live setting of /* open the three floating window used to do live setting of
@@ -1040,13 +1038,11 @@ ChartWindow::MessageReceived(BMessage *message)
void void
ChartWindow::ScreenChanged(BRect screen_size, color_space depth) ChartWindow::ScreenChanged(BRect screen_size, color_space depth)
{ {
BScreen my_screen(this);
/* this is the same principle than the one described for /* this is the same principle than the one described for
MessageReceived, to inform the engine that the depth of MessageReceived, to inform the engine that the depth of
the screen changed (needed only for offscreen bitmap. the screen changed (needed only for offscreen bitmap.
In DirectWindow, you get a direct notification). */ In DirectWindow, you get a direct notification). */
next_set.depth = my_screen.ColorSpace(); fNextSettings.depth = BScreen(this).ColorSpace();
} }
@@ -1057,8 +1053,8 @@ ChartWindow::FrameResized(float new_width, float new_height)
MessageReceived, to inform the engine that the window MessageReceived, to inform the engine that the window
size changed (needed only for offscreen bitmap. In size changed (needed only for offscreen bitmap. In
DirectWindow, you get a direct notification). */ DirectWindow, you get a direct notification). */
next_set.width = (int32)Frame().Width()+1-LEFT_WIDTH; fNextSettings.width = (int32)Frame().Width()+1-LEFT_WIDTH;
next_set.height = (int32)Frame().Height()+1-TOP_LEFT_LIMIT; fNextSettings.height = (int32)Frame().Height()+1-TOP_LEFT_LIMIT;
} }
@@ -1242,11 +1238,12 @@ ChartWindow::OpenRefresh(BPoint here)
void void
ChartWindow::DrawInstantLoad(float frame_per_second) ChartWindow::DrawInstantLoad(float frame_per_second)
{ {
int32 level, i; int32 i;
bigtime_t timeout; bigtime_t timeout;
level = (int32)((frame_per_second + 6.0) * (1.0/12.0)); int32 level = (int32)((frame_per_second + 6.0) * (1.0/12.0));
if (level > 50) level = 50; if (level > 50)
level = 50;
/* if the load level is inchanged, nothing more to do... */ /* if the load level is inchanged, nothing more to do... */
if (level == fInstantLoadLevel) if (level == fInstantLoadLevel)
@@ -1339,10 +1336,8 @@ ChartWindow::PrintStatNumbers(float fps)
void void
ChartWindow::InitGeometry() ChartWindow::InitGeometry()
{ {
float dz;
/* calculate some parameters required for the 3d processing */ /* calculate some parameters required for the 3d processing */
dz = sqrt(1.0 - (DH_REF*DH_REF + DV_REF*DV_REF) * (0.5 + 0.5/Z_CUT_RATIO) * (0.5 + 0.5/Z_CUT_RATIO)); float dz = sqrt(1.0 - (DH_REF*DH_REF + DV_REF*DV_REF) * (0.5 + 0.5/Z_CUT_RATIO) * (0.5 + 0.5/Z_CUT_RATIO));
depth_ref = dz / (1.0 - 1.0/Z_CUT_RATIO); depth_ref = dz / (1.0 - 1.0/Z_CUT_RATIO);
/* set the position of the pyramid of vision, so that it was always /* set the position of the pyramid of vision, so that it was always
@@ -1372,7 +1367,6 @@ ChartWindow::InitGeometry()
void void
ChartWindow::ChangeSetting(setting new_set) ChartWindow::ChangeSetting(setting new_set)
{ {
//star *s;
int32 i, color_count, old_step; int32 i, color_count, old_step;
int32 color_index[7]; int32 color_index[7];
@@ -2126,7 +2120,7 @@ ChartWindow::Animation(void *data)
timer += w->frame_delay; timer += w->frame_delay;
/* change the settings, if needed */ /* change the settings, if needed */
w->ChangeSetting(w->next_set); w->ChangeSetting(w->fNextSettings);
/* draw the next frame */ /* draw the next frame */
if (w->fCurrentSettings.display == DISPLAY_BITMAP) { if (w->fCurrentSettings.display == DISPLAY_BITMAP) {
@@ -2208,31 +2202,28 @@ ChartWindow::Animation(void *data)
long long
ChartWindow::Animation2(void *data) ChartWindow::Animation2(void *data)
{ {
bigtime_t before, after; ChartWindow *w = (ChartWindow*)data;
ChartWindow *w;
w = (ChartWindow*)data;
while (!w->fKillThread) { while (!w->fKillThread) {
/* This thread need to both wait for its master to unblock /* This thread need to both wait for its master to unblock
him to do some real work, or for the main control to him to do some real work, or for the main control to
set the fKillThread flag, asking it to quit. */ set the fKillThread flag, asking it to quit. */
status_t status; status_t status;
do { do {
status = acquire_sem_etc(w->second_thread_lock, 1, B_TIMEOUT, 500000); status = acquire_sem_etc(w->fSecondThreadLock, 1, B_TIMEOUT, 500000);
if (w->fKillThread) if (w->fKillThread)
return 0; return 0;
} while (status == B_TIMED_OUT || status == B_INTERRUPTED); } while (status == B_TIMED_OUT || status == B_INTERRUPTED);
/* the duration of the processing is needed to control the /* the duration of the processing is needed to control the
dynamic load split (see RefreshStar) */ dynamic load split (see RefreshStar) */
before = system_time(); bigtime_t before = system_time();
RefreshStarPacket(w->second_thread_buffer, &w->stars2, &w->geo); RefreshStarPacket(w->fSecondThreadBuffer, &w->fStars2, &w->geo);
RefreshStarPacket(w->second_thread_buffer, &w->specials2, &w->geo); RefreshStarPacket(w->fSecondThreadBuffer, &w->fSpecials2, &w->geo);
after = system_time(); bigtime_t after = system_time();
w->second_thread_delay = after-before; w->fSecondThreadDelay = after-before;
release_sem(w->second_thread_release); release_sem(w->fSecondThreadRelease);
} }
return 0; return 0;
} }
@@ -2706,11 +2697,6 @@ ChartWindow::SyncGeo()
void void
ChartWindow::RefreshStars(buffer *buf, float time_step) ChartWindow::RefreshStars(buffer *buf, float time_step)
{ {
float ratio;
int32 star_threshold, special_threshold;
bigtime_t before, after;
star_packet stars1, specials1;
/* do the specials animation (single-threaded) */ /* do the specials animation (single-threaded) */
AnimSpecials(time_step); AnimSpecials(time_step);
@@ -2720,63 +2706,63 @@ ChartWindow::RefreshStars(buffer *buf, float time_step)
dynamic load split between the two threads, when dynamic load split between the two threads, when
needed. */ needed. */
if (fCurrentSettings.second_thread) { if (fCurrentSettings.second_thread) {
star_threshold = (int32)((float)stars.count * second_thread_threshold + 0.5); int32 star_threshold = (int32)((float)stars.count * fSecondThreadThreshold + 0.5);
special_threshold = (int32)((float)specials.count * second_thread_threshold + 0.5); int32 special_threshold = (int32)((float)specials.count * fSecondThreadThreshold + 0.5);
/* split the work load (star and special animation) /* split the work load (star and special animation)
between the two threads, proportionnaly to the between the two threads, proportionnaly to the
last split factor determined during the last last split factor determined during the last
cycle. */ cycle. */
star_packet stars1;
stars1.list = stars.list; stars1.list = stars.list;
stars1.count = star_threshold; stars1.count = star_threshold;
stars1.erase_count = star_threshold; stars1.erase_count = star_threshold;
if (stars1.erase_count > stars.erase_count) if (stars1.erase_count > stars.erase_count)
stars1.erase_count = stars.erase_count; stars1.erase_count = stars.erase_count;
stars2.list = stars.list + star_threshold; fStars2.list = stars.list + star_threshold;
stars2.count = stars.count - star_threshold; fStars2.count = stars.count - star_threshold;
stars2.erase_count = stars.erase_count - star_threshold; fStars2.erase_count = stars.erase_count - star_threshold;
if (stars2.erase_count < 0) if (fStars2.erase_count < 0)
stars2.erase_count = 0; fStars2.erase_count = 0;
star_packet specials1;
specials1.list = specials.list; specials1.list = specials.list;
specials1.count = special_threshold; specials1.count = special_threshold;
specials1.erase_count = special_threshold; specials1.erase_count = special_threshold;
if (specials1.erase_count > specials.erase_count) if (specials1.erase_count > specials.erase_count)
specials1.erase_count = specials.erase_count; specials1.erase_count = specials.erase_count;
specials2.list = specials.list + special_threshold; fSpecials2.list = specials.list + special_threshold;
specials2.count = specials.count - special_threshold; fSpecials2.count = specials.count - special_threshold;
specials2.erase_count = specials.erase_count - special_threshold; fSpecials2.erase_count = specials.erase_count - special_threshold;
if (specials2.erase_count < 0) if (fSpecials2.erase_count < 0)
specials2.erase_count = 0; fSpecials2.erase_count = 0;
second_thread_buffer = buf; fSecondThreadBuffer = buf;
/* release the slave thread */ /* release the slave thread */
release_sem(second_thread_lock); release_sem(fSecondThreadLock);
/* do its own part (time it) */ /* do its own part (time it) */
before = system_time(); bigtime_t before = system_time();
RefreshStarPacket(buf, &stars1, &geo); RefreshStarPacket(buf, &stars1, &geo);
RefreshStarPacket(buf, &specials1, &geo); RefreshStarPacket(buf, &specials1, &geo);
after = system_time(); bigtime_t after = system_time();
/* wait for completion of the second thread */ /* wait for completion of the second thread */
while (acquire_sem(second_thread_release) == B_INTERRUPTED) while (acquire_sem(fSecondThreadRelease) == B_INTERRUPTED)
; ;
/* calculate the new optimal split ratio depending /* calculate the new optimal split ratio depending
of the previous one and the time used by both of the previous one and the time used by both
threads to do their work. */ threads to do their work. */
ratio = ((float)second_thread_delay/(float)(after-before)) * float ratio = ((float)fSecondThreadDelay/(float)(after-before)) *
(second_thread_threshold/(1.0-second_thread_threshold)); (fSecondThreadThreshold/(1.0-fSecondThreadThreshold));
second_thread_threshold = ratio / (1.0+ratio); fSecondThreadThreshold = ratio / (1.0+ratio);
} else {
} /* In single-threaded mode, nothing fancy to be done. */
/* In single-threaded mode, nothing fancy to be done. */
else {
RefreshStarPacket(buf, &stars, &geo); RefreshStarPacket(buf, &stars, &geo);
RefreshStarPacket(buf, &specials, &geo); RefreshStarPacket(buf, &specials, &geo);
} }
+8 -8
View File
@@ -340,7 +340,7 @@ inline void CrcStep();
/* Various private instance variables. */ /* Various private instance variables. */
/* the next setting, as modified by the UI */ /* the next setting, as modified by the UI */
setting next_set; setting fNextSettings;
/* a boolean used to enable a work-around for a bug in /* a boolean used to enable a work-around for a bug in
the DirectWindow flags setting. Only needed for the the DirectWindow flags setting. Only needed for the
@@ -416,13 +416,13 @@ inline void CrcStep();
thread_id fSecondAnimationThread; thread_id fSecondAnimationThread;
/* context of the second processing thread (when used). */ /* context of the second processing thread (when used). */
float second_thread_threshold; float fSecondThreadThreshold;
buffer *second_thread_buffer; buffer *fSecondThreadBuffer;
sem_id second_thread_lock; sem_id fSecondThreadLock;
sem_id second_thread_release; sem_id fSecondThreadRelease;
bigtime_t second_thread_delay; bigtime_t fSecondThreadDelay;
star_packet stars2; star_packet fStars2;
star_packet specials2; star_packet fSpecials2;
/* Flag used to terminate the processing threads */ /* Flag used to terminate the processing threads */
bool fKillThread; bool fKillThread;