Partly converted the header to our coding style, added some debug output, started to clean up

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15664 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2005-12-24 13:06:05 +00:00
parent 6edaa0f6a6
commit ed58e05e18
2 changed files with 213 additions and 198 deletions
+28 -28
View File
@@ -141,7 +141,7 @@ virtual void SuspensionHook(bool active);
virtual status_t Perform(perform_code d, void *arg); virtual status_t Perform(perform_code d, void *arg);
private: private:
typedef BWindow inherited; typedef BWindow inherited;
@@ -154,39 +154,39 @@ virtual void _ReservedWindowScreen4();
BWindowScreen(BWindowScreen &); BWindowScreen(BWindowScreen &);
BWindowScreen &operator=(BWindowScreen &); BWindowScreen &operator=(BWindowScreen &);
char addon_state; char fAddonState;
char space_mode; char space_mode;
void *io_buffer; void *io_buffer;
bool direct_enable; bool direct_enable;
bool work_state; bool fWorkState;
bool window_state; bool fWindowState;
bool activate_state; bool fActivateState;
int32 lock_state; int32 fLockState;
int32 screen_index; int32 fScreenIndex;
int32 memory_area, io_area; int32 memory_area, io_area;
display_mode *old_space; display_mode *fOldDisplayMode;
display_mode *new_space; display_mode *fDisplayMode;
uint32 space0; uint32 space0;
sem_id activate_sem; sem_id fActivateSem;
sem_id debug_sem; sem_id fDebugSem;
image_id addon_image; image_id fAddonImage;
rgb_color colorList[256]; rgb_color fColorList[256];
GetAccelerantHook m_gah; GetAccelerantHook m_gah;
graphics_card_info card_info; graphics_card_info fCardInfo;
graphics_card_hook hooks[B_HOOK_COUNT]; graphics_card_hook hooks[B_HOOK_COUNT];
_direct_screen_info_ info; _direct_screen_info_ info;
frame_buffer_info format_info; frame_buffer_info fFrameBufferInfo;
char *debug_buffer; char *fDebugBuffer;
bool debug_state; bool fDebugState;
bool debug_first; bool fDebugFirst;
int32 debug_list_count; int32 fDebugListCount;
int32 debug_workspace; int32 fDebugWorkspace;
thread_id *debug_list; thread_id *fDebugList;
uint32 _attributes; uint32 fAttributes;
uint32 mode_count; uint32 fModeCount;
display_mode *mode_list; display_mode *fModeList;
engine_token *et; engine_token *et;
wait_engine_idle m_wei; wait_engine_idle m_wei;
acquire_engine m_ae; acquire_engine m_ae;
@@ -199,10 +199,10 @@ virtual void _ReservedWindowScreen4();
uint32 _reserved_[21]; uint32 _reserved_[21];
static BRect CalcFrame(int32 index, int32 space, display_mode *dmode); static BRect CalcFrame(int32 index, int32 space, display_mode *dmode);
int32 SetFullscreen(int32 enable); status_t SetFullscreen(bool enable);
status_t InitData(uint32 space, uint32 attributes); status_t InitData(uint32 space, uint32 attributes);
status_t SetActiveState(int32 state); status_t SetActiveState(int32 state);
status_t SetLockState(int32 state); status_t SetLockState(int32 state);
void GetCardInfo(); void GetCardInfo();
void Suspend(); void Suspend();
void Resume(); void Resume();
+185 -170
View File
@@ -28,6 +28,7 @@
using BPrivate::AppServerLink; using BPrivate::AppServerLink;
#define TRACE_WINDOWSCREEN 1
#if TRACE_WINDOWSCREEN #if TRACE_WINDOWSCREEN
#define CALLED() printf("%s\n", __PRETTY_FUNCTION__); #define CALLED() printf("%s\n", __PRETTY_FUNCTION__);
#else #else
@@ -285,8 +286,8 @@ set_mouse_position(int32 x, int32 y)
BWindowScreen::BWindowScreen(const char *title, uint32 space, BWindowScreen::BWindowScreen(const char *title, uint32 space,
status_t *error, bool debug_enable) status_t *error, bool debug_enable)
: BWindow(BScreen().Frame(), title, B_TITLED_WINDOW, : BWindow(BScreen().Frame().InsetByCopy(100, 100), title, B_TITLED_WINDOW,
kWindowScreenFlag | B_NOT_MINIMIZABLE | B_NOT_CLOSABLE kWindowScreenFlag | B_NOT_MINIMIZABLE /*| B_NOT_CLOSABLE*/
| B_NOT_ZOOMABLE | B_NOT_MOVABLE | B_NOT_RESIZABLE, | B_NOT_ZOOMABLE | B_NOT_MOVABLE | B_NOT_RESIZABLE,
B_CURRENT_WORKSPACE) B_CURRENT_WORKSPACE)
{ {
@@ -303,8 +304,8 @@ BWindowScreen::BWindowScreen(const char *title, uint32 space,
BWindowScreen::BWindowScreen(const char *title, uint32 space, BWindowScreen::BWindowScreen(const char *title, uint32 space,
uint32 attributes, status_t *error) uint32 attributes, status_t *error)
: BWindow(BScreen().Frame(), title, B_TITLED_WINDOW, : BWindow(BScreen().Frame().InsetByCopy(100, 100), title, B_TITLED_WINDOW,
kWindowScreenFlag | B_NOT_MINIMIZABLE | B_NOT_CLOSABLE kWindowScreenFlag | B_NOT_MINIMIZABLE /*| B_NOT_CLOSABLE*/
| B_NOT_ZOOMABLE | B_NOT_MOVABLE | B_NOT_RESIZABLE, | B_NOT_ZOOMABLE | B_NOT_MOVABLE | B_NOT_RESIZABLE,
B_CURRENT_WORKSPACE) B_CURRENT_WORKSPACE)
{ {
@@ -317,27 +318,29 @@ BWindowScreen::BWindowScreen(const char *title, uint32 space,
BWindowScreen::~BWindowScreen() BWindowScreen::~BWindowScreen()
{ {
CALLED();
Disconnect(); Disconnect();
if (addon_state == 1) if (fAddonState == 1)
unload_add_on(addon_image); unload_add_on(fAddonImage);
SetFullscreen(0); SetFullscreen(false);
delete_sem(activate_sem); delete_sem(fActivateSem);
delete_sem(debug_sem); delete_sem(fDebugSem);
if (debug_state) if (fDebugState)
activate_workspace(debug_workspace); activate_workspace(fDebugWorkspace);
free(new_space); free(fDisplayMode);
free(old_space); free(fOldDisplayMode);
free(mode_list); free(fModeList);
} }
void void
BWindowScreen::Quit(void) BWindowScreen::Quit(void)
{ {
CALLED();
Disconnect(); Disconnect();
BWindow::Quit(); BWindow::Quit();
} }
@@ -353,9 +356,10 @@ BWindowScreen::ScreenConnected(bool active)
void void
BWindowScreen::Disconnect() BWindowScreen::Disconnect()
{ {
if (lock_state == 1) { CALLED();
if (debug_state) if (fLockState == 1) {
debug_first = true; if (fDebugState)
fDebugFirst = true;
SetActiveState(0); SetActiveState(0);
} }
} }
@@ -365,8 +369,8 @@ void
BWindowScreen::WindowActivated(bool active) BWindowScreen::WindowActivated(bool active)
{ {
CALLED(); CALLED();
window_state = active; fWindowState = active;
if(active && lock_state == 0 && work_state) if(active && fLockState == 0 && fWorkState)
SetActiveState(1); SetActiveState(1);
} }
@@ -375,19 +379,17 @@ void
BWindowScreen::WorkspaceActivated(int32 ws, bool state) BWindowScreen::WorkspaceActivated(int32 ws, bool state)
{ {
CALLED(); CALLED();
work_state = state; fWorkState = state;
if (state) { if (state) {
if (lock_state == 0 && window_state) { if (fLockState == 0 && fWindowState) {
SetActiveState(1); SetActiveState(1);
if (!IsHidden()) { if (!IsHidden()) {
Activate(true); Activate(true);
WindowActivated(true); WindowActivated(true);
} }
} }
} else { } else if (fLockState)
if (lock_state) SetActiveState(0);
SetActiveState(0);
}
} }
@@ -401,9 +403,10 @@ BWindowScreen::ScreenChanged(BRect screen_size, color_space depth)
void void
BWindowScreen::Hide() BWindowScreen::Hide()
{ {
if (lock_state == 1) { CALLED();
if (debug_state) if (fLockState == 1) {
debug_first = true; if (fDebugState)
fDebugFirst = true;
SetActiveState(0); SetActiveState(0);
} }
@@ -415,9 +418,9 @@ void
BWindowScreen::Show() BWindowScreen::Show()
{ {
BWindow::Show(); BWindow::Show();
if (!activate_state) { if (!fActivateState) {
release_sem(activate_sem); release_sem(fActivateSem);
activate_state = true; fActivateState = true;
} }
} }
@@ -429,16 +432,16 @@ BWindowScreen::SetColorList(rgb_color *list, int32 first_index, int32 last_index
return; return;
if (Lock()) { if (Lock()) {
if (!activate_state) { if (!fActivateState) {
//If we aren't active, we just change our local palette //If we aren't active, we just change our local palette
for (int32 x = first_index; x <= last_index; x++) for (int32 x = first_index; x <= last_index; x++)
colorList[x] = list[x]; fColorList[x] = list[x];
} else { } else {
uint32 colorCount = last_index - first_index + 1; uint32 colorCount = last_index - first_index + 1;
if (addon_state == 1) { if (fAddonState == 1) {
set_indexed_colors sic = (set_indexed_colors)m_gah(B_SET_INDEXED_COLORS, NULL); set_indexed_colors sic = (set_indexed_colors)m_gah(B_SET_INDEXED_COLORS, NULL);
if (sic != NULL) if (sic != NULL)
sic(colorCount, first_index, (uint8*)colorList, 0); sic(colorCount, first_index, (uint8 *)fColorList, 0);
} }
BScreen screen(this); BScreen screen(this);
@@ -446,7 +449,7 @@ BWindowScreen::SetColorList(rgb_color *list, int32 first_index, int32 last_index
// Update our local palette too. We're doing this between two // Update our local palette too. We're doing this between two
// WaitForRetrace() calls so nobody will notice. // WaitForRetrace() calls so nobody will notice.
for (int32 x = first_index; x <= last_index; x++) for (int32 x = first_index; x <= last_index; x++)
colorList[x] = list[x]; fColorList[x] = list[x];
// TODO: Tell the app_server about our changes // TODO: Tell the app_server about our changes
@@ -472,14 +475,15 @@ BWindowScreen::SetSpace(uint32 space)
bool bool
BWindowScreen::CanControlFrameBuffer() BWindowScreen::CanControlFrameBuffer()
{ {
return (addon_state <= 1 && (card_info.flags & B_FRAME_BUFFER_CONTROL)); return (fAddonState == 1 && (fCardInfo.flags & B_FRAME_BUFFER_CONTROL));
} }
status_t status_t
BWindowScreen::SetFrameBuffer(int32 width, int32 height) BWindowScreen::SetFrameBuffer(int32 width, int32 height)
{ {
display_mode highMode = *new_space; CALLED();
display_mode highMode = *fDisplayMode;
highMode.virtual_height = (int16)height; highMode.virtual_height = (int16)height;
highMode.virtual_width = (int16)width; highMode.virtual_width = (int16)width;
@@ -502,15 +506,16 @@ BWindowScreen::SetFrameBuffer(int32 width, int32 height)
status_t status_t
BWindowScreen::MoveDisplayArea(int32 x, int32 y) BWindowScreen::MoveDisplayArea(int32 x, int32 y)
{ {
CALLED();
status_t status = B_ERROR; status_t status = B_ERROR;
// TODO: Ask app server to move the frame buffer area // TODO: Ask app server to move the frame buffer area
if (status == B_OK) { if (status == B_OK) {
format_info.display_x = x; fFrameBufferInfo.display_x = x;
format_info.display_y = y; fFrameBufferInfo.display_y = y;
new_space->h_display_start = x; fDisplayMode->h_display_start = x;
new_space->v_display_start = y; fDisplayMode->v_display_start = y;
} }
return status; return status;
} }
@@ -527,22 +532,22 @@ BWindowScreen::IOBase()
rgb_color * rgb_color *
BWindowScreen::ColorList() BWindowScreen::ColorList()
{ {
return colorList; return fColorList;
} }
frame_buffer_info * frame_buffer_info *
BWindowScreen::FrameBufferInfo() BWindowScreen::FrameBufferInfo()
{ {
return &format_info; return &fFrameBufferInfo;
} }
graphics_card_hook graphics_card_hook
BWindowScreen::CardHookAt(int32 index) BWindowScreen::CardHookAt(int32 index)
{ {
if (addon_state != 1) if (fAddonState != 1)
return 0; return NULL;
graphics_card_hook hook = NULL; graphics_card_hook hook = NULL;
@@ -591,7 +596,7 @@ BWindowScreen::CardHookAt(int32 index)
graphics_card_info * graphics_card_info *
BWindowScreen::CardInfo() BWindowScreen::CardInfo()
{ {
return &card_info; return &fCardInfo;
} }
@@ -599,13 +604,15 @@ void
BWindowScreen::RegisterThread(thread_id id) BWindowScreen::RegisterThread(thread_id id)
{ {
CALLED(); CALLED();
while (acquire_sem(debug_sem) == B_INTERRUPTED) while (acquire_sem(fDebugSem) == B_INTERRUPTED)
; ;
++debug_list_count; void *newDebugList = realloc(fDebugList, (fDebugListCount + 1) * sizeof(thread_id));
debug_list = (thread_id *)realloc(debug_list, debug_list_count * sizeof(thread_id)); if (newDebugList != NULL) {
debug_list[debug_list_count - 1] = id; fDebugList = (thread_id *)newDebugList;
fDebugList[fDebugListCount] = id;
release_sem(debug_sem); fDebugListCount++;
}
release_sem(fDebugSem);
} }
@@ -620,14 +627,14 @@ void
BWindowScreen::Suspend(char *label) BWindowScreen::Suspend(char *label)
{ {
CALLED(); CALLED();
if (debug_state) { if (fDebugState) {
fprintf(stderr, "## Debugger(\"%s\").", label); fprintf(stderr, "## Debugger(\"%s\").", label);
fprintf(stderr, " Press Alt-F%ld or Cmd-F%ld to resume.\n", space0 + 1, space0 + 1); fprintf(stderr, " Press Alt-F%ld or Cmd-F%ld to resume.\n", space0 + 1, space0 + 1);
if (IsLocked()) if (IsLocked())
Unlock(); Unlock();
activate_workspace(debug_workspace); activate_workspace(fDebugWorkspace);
// Suspend ourself // Suspend ourself
suspend_thread(find_thread(NULL)); suspend_thread(find_thread(NULL));
@@ -670,10 +677,10 @@ BWindowScreen::CalcFrame(int32 index, int32 space, display_mode *dmode)
} }
int32 status_t
BWindowScreen::SetFullscreen(int32 enable) BWindowScreen::SetFullscreen(bool enable)
{ {
int32 retval = -1; status_t retval = B_ERROR;
// TODO: Set fullscreen // TODO: Set fullscreen
@@ -686,44 +693,53 @@ BWindowScreen::InitData(uint32 space, uint32 attributes)
{ {
CALLED(); CALLED();
BScreen screen(this); fDebugState = attributes & B_ENABLE_DEBUGGER;
debug_state = attributes & B_ENABLE_DEBUGGER; fDebugListCount = 0;
debug_list_count = 0; fDebugList = NULL;
debug_list = 0; fDebugFirst = true;
debug_first = true;
debug_sem = create_sem(1, "WindowScreen debug sem"); fAttributes = attributes;
old_space = (display_mode *)calloc(1, sizeof(display_mode)); fScreenIndex = current_workspace();
new_space = (display_mode *)calloc(1, sizeof(display_mode)); fLockState = 0;
fAddonState = 0;
screen.GetModeList(&mode_list, &mode_count);
_attributes = attributes;
display_mode *n_space = new_space;
screen_index = 0;
lock_state = 0;
addon_state = 0;
direct_enable = 0; direct_enable = 0;
window_state = 0; fWindowState = 0;
fDebugWorkspace = 0;
BScreen screen(this);
status_t status = screen.GetModeList(&fModeList, &fModeCount);
if (status < B_OK) {
printf("BScreen::GetModeList() returned %s\n", strerror(status));
return status;
}
display_mode newMode;
status = GetModeFromSpace(space, &newMode);
if (status < B_OK) {
printf("GetModeFromSpace() returned %s\n", strerror(status));
return status;
}
space_mode = 1; space_mode = 1;
GetModeFromSpace(space, n_space);
space0 = 0; space0 = 0;
SetWorkspaces(B_CURRENT_WORKSPACE); SetWorkspaces(B_CURRENT_WORKSPACE);
SetFullscreen(1); SetFullscreen(true);
work_state = 1; memcpy(fColorList, screen.ColorMap()->color_list, 256);
debug_workspace = 0;
memcpy(colorList, screen.ColorMap()->color_list, 256);
GetCardInfo(); GetCardInfo();
activate_sem = create_sem(0, "WindowScreen start lock"); fActivateSem = create_sem(0, "WindowScreen start lock");
activate_state = 0; fActivateState = 0;
fDebugSem = create_sem(1, "WindowScreen debug sem");
fOldDisplayMode = (display_mode *)calloc(1, sizeof(display_mode));
fDisplayMode = (display_mode *)calloc(1, sizeof(display_mode));
memcpy(fDisplayMode, &newMode, sizeof(newMode));
fWorkState = 1;
return B_OK; return B_OK;
} }
@@ -735,21 +751,21 @@ BWindowScreen::SetActiveState(int32 state)
CALLED(); CALLED();
status_t status = B_ERROR; status_t status = B_ERROR;
if (state == 1) { if (state == 1) {
be_app->HideCursor(); //be_app->HideCursor();
if (be_app->IsCursorHidden() if (/*be_app->IsCursorHidden() && */(status = SetLockState(1)) == B_OK) {
&& (status = SetLockState(1)) == B_OK) { status = AssertDisplayMode(fDisplayMode);
status = AssertDisplayMode(new_space); printf("AssertDisplayMode() returned %s\n", strerror(status));
if (status == B_OK) { if (status == B_OK) {
if (!activate_state) { if (!fActivateState) {
while (acquire_sem(activate_sem) == B_INTERRUPTED) while (acquire_sem(fActivateSem) == B_INTERRUPTED)
; ;
} }
SetColorList(colorList); SetColorList(fColorList);
if (debug_state && !debug_first) { if (fDebugState && !fDebugFirst) {
SuspensionHook(true); SuspensionHook(true);
Resume(); Resume();
} else { } else {
debug_first = true; fDebugFirst = true;
ScreenConnected(true); ScreenConnected(true);
} }
if (status == B_OK) if (status == B_OK)
@@ -761,7 +777,7 @@ BWindowScreen::SetActiveState(int32 state)
be_app->ShowCursor(); be_app->ShowCursor();
} }
} else { } else {
if (debug_state && !debug_first) { if (fDebugState && !fDebugFirst) {
Suspend(); Suspend();
SuspensionHook(false); SuspensionHook(false);
} else } else
@@ -770,11 +786,13 @@ BWindowScreen::SetActiveState(int32 state)
status = SetLockState(0); status = SetLockState(0);
if (status == B_OK) { if (status == B_OK) {
be_app->ShowCursor(); be_app->ShowCursor();
if (activate_state) { if (fActivateState) {
// TODO: Set palette // TODO: Set palette
} }
} }
} }
printf("SetActiveState() returning %s\n", strerror(status));
return status; return status;
} }
@@ -783,7 +801,7 @@ status_t
BWindowScreen::SetLockState(int32 state) BWindowScreen::SetLockState(int32 state)
{ {
CALLED(); CALLED();
if (addon_state == 1 && state == 1) { if (fAddonState == 1 && state == 1) {
m_wei(); m_wei();
fill_rect_global = NULL; fill_rect_global = NULL;
blit_rect_global = NULL; blit_rect_global = NULL;
@@ -795,26 +813,26 @@ BWindowScreen::SetLockState(int32 state)
release_engine_global = NULL; release_engine_global = NULL;
} }
status_t status = B_ERROR; status_t status = B_OK;
// TODO: Set lock state (whatever it means) // TODO: Set lock state (whatever it means)
if (status == B_OK) { if (status == B_OK) {
lock_state = state; fLockState = state;
if (state == 1) { if (state == 1) {
if (addon_state == 0) { if (fAddonState == 0) {
status = InitClone(); status = InitClone();
printf("InitClone() returned %s\n", strerror(status));
if (status == B_OK) { if (status == B_OK) {
addon_state = 1; fAddonState = 1;
m_wei = (wait_engine_idle)m_gah(B_WAIT_ENGINE_IDLE, NULL); m_wei = (wait_engine_idle)m_gah(B_WAIT_ENGINE_IDLE, NULL);
m_re = (release_engine)m_gah(B_RELEASE_ENGINE, NULL); m_re = (release_engine)m_gah(B_RELEASE_ENGINE, NULL);
m_ae = (acquire_engine)m_gah(B_ACQUIRE_ENGINE, NULL); m_ae = (acquire_engine)m_gah(B_ACQUIRE_ENGINE, NULL);
} else } else
addon_state = -1; fAddonState = -1;
} }
if (addon_state == 1 && state == 1) { if (fAddonState == 1 && state == 1) {
fill_rect_global = fill_rect; fill_rect_global = fill_rect;
blit_rect_global = blit_rect; blit_rect_global = blit_rect;
trans_blit_rect_global = trans_blit_rect; trans_blit_rect_global = trans_blit_rect;
@@ -842,59 +860,56 @@ BWindowScreen::GetCardInfo()
if (screen.GetMode(&mode) < B_OK) if (screen.GetMode(&mode) < B_OK)
return; return;
uint32 bits_per_pixel; uint32 bitsPerPixel;
switch(mode.space & 0x0fff) { switch(mode.space & 0x0fff) {
case B_CMAP8: case B_CMAP8:
bits_per_pixel = 8; bitsPerPixel = 8;
break; break;
case B_RGB16: case B_RGB16:
bits_per_pixel = 16; bitsPerPixel = 16;
break; break;
case B_RGB32: case B_RGB32:
bits_per_pixel = 32; bitsPerPixel = 32;
break; break;
default: default:
bits_per_pixel = 0; bitsPerPixel = 0;
break; break;
} }
card_info.version = 2; fCardInfo.version = 2;
card_info.id = 0; fCardInfo.id = 0;
card_info.bits_per_pixel = bits_per_pixel; fCardInfo.bits_per_pixel = bitsPerPixel;
card_info.width = mode.virtual_width; fCardInfo.width = mode.virtual_width;
card_info.height = mode.virtual_height; fCardInfo.height = mode.virtual_height;
if (mode.space & 0x10) if (mode.space & 0x10)
strncpy(card_info.rgba_order, "rgba", 4); strncpy(fCardInfo.rgba_order, "rgba", 4);
else else
strncpy(card_info.rgba_order, "bgra", 4); strncpy(fCardInfo.rgba_order, "bgra", 4);
card_info.flags = 0; fCardInfo.flags = 0;
if (mode.flags & B_SCROLL) if (mode.flags & B_SCROLL)
card_info.flags |= B_FRAME_BUFFER_CONTROL; fCardInfo.flags |= B_FRAME_BUFFER_CONTROL;
if (mode.flags & B_PARALLEL_ACCESS) if (mode.flags & B_PARALLEL_ACCESS)
card_info.flags |= B_PARALLEL_BUFFER_ACCESS; fCardInfo.flags |= B_PARALLEL_BUFFER_ACCESS;
screen_id id = screen.ID();
status_t result = B_ERROR; status_t result = B_ERROR;
frame_buffer_config config; frame_buffer_config config;
AppServerLink link; AppServerLink link;
link.StartMessage(AS_GET_FRAME_BUFFER_CONFIG); link.StartMessage(AS_GET_FRAME_BUFFER_CONFIG);
link.Attach<screen_id>(id); link.Attach<screen_id>(screen.ID());
if (link.FlushWithReply(result) == B_OK && result == B_OK) if (link.FlushWithReply(result) == B_OK && result == B_OK)
link.Read<frame_buffer_config>(&config); link.Read<frame_buffer_config>(&config);
if (result == B_OK) { if (result == B_OK) {
card_info.id = id.id; fCardInfo.id = screen.ID().id;
card_info.frame_buffer = config.frame_buffer; fCardInfo.frame_buffer = config.frame_buffer;
card_info.bytes_per_row = config.bytes_per_row; fCardInfo.bytes_per_row = config.bytes_per_row;
} }
memcpy(&card_info_global, &card_info, sizeof(graphics_card_info)); memcpy(&card_info_global, &fCardInfo, sizeof(graphics_card_info));
} }
@@ -903,21 +918,21 @@ BWindowScreen::Suspend()
{ {
CALLED(); CALLED();
while (acquire_sem(debug_sem) == B_INTERRUPTED) while (acquire_sem(fDebugSem) == B_INTERRUPTED)
; ;
// Suspend all the registered threads // Suspend all the registered threads
for (int i = 0; i < debug_list_count; i++) { for (int32 i = 0; i < fDebugListCount; i++) {
snooze(10000); snooze(10000);
suspend_thread(debug_list[i]); suspend_thread(fDebugList[i]);
} }
graphics_card_info *info = CardInfo(); graphics_card_info *info = CardInfo();
size_t fbSize = info->bytes_per_row * info->height; size_t fbSize = info->bytes_per_row * info->height;
// Save the content of the frame buffer into the local buffer // Save the content of the frame buffer into the local buffer
debug_buffer = (char *)malloc(fbSize); fDebugBuffer = (char *)malloc(fbSize);
memcpy(debug_buffer, info->frame_buffer, fbSize); memcpy(fDebugBuffer, info->frame_buffer, fbSize);
} }
@@ -928,14 +943,14 @@ BWindowScreen::Resume()
graphics_card_info *info = CardInfo(); graphics_card_info *info = CardInfo();
// Copy the content of the debug_buffer back into the frame buffer. // Copy the content of the debug_buffer back into the frame buffer.
memcpy(info->frame_buffer, debug_buffer, info->bytes_per_row * info->height); memcpy(info->frame_buffer, fDebugBuffer, info->bytes_per_row * info->height);
free(debug_buffer); free(fDebugBuffer);
// Resume all the registered threads // Resume all the registered threads
for (int i = 0; i < debug_list_count; i++) for (int32 i = 0; i < fDebugListCount; i++)
resume_thread(debug_list[i]); resume_thread(fDebugList[i]);
release_sem(debug_sem); release_sem(fDebugSem);
} }
@@ -944,24 +959,24 @@ BWindowScreen::GetModeFromSpace(uint32 space, display_mode *dmode)
{ {
CALLED(); CALLED();
uint32 out_space; uint32 destSpace;
int32 width, height; int32 width, height;
status_t ret = B_ERROR; status_t status = B_ERROR;
mode2parms(space, &out_space, &width, &height); mode2parms(space, &destSpace, &width, &height);
// mode2parms converts the space to actual width, height and color_space, e.g B_8_BIT_640x480 // mode2parms converts the space to actual width, height and color_space, e.g B_8_BIT_640x480
for (uint32 i = 0; i < mode_count; i++) { for (uint32 i = 0; i < fModeCount; i++) {
if (mode_list[i].space == out_space && mode_list[i].virtual_width == width if (fModeList[i].space == destSpace && fModeList[i].virtual_width == width
&& mode_list[i].virtual_height == height) { && fModeList[i].virtual_height == height) {
memcpy(dmode, &mode_list[i], sizeof(display_mode)); memcpy(dmode, &fModeList[i], sizeof(display_mode));
ret = B_OK; status = B_OK;
break; break;
} }
} }
return ret; return status;
} }
@@ -971,7 +986,7 @@ BWindowScreen::InitClone()
CALLED(); CALLED();
AppServerLink link; AppServerLink link;
link.StartMessage(AS_GET_ACCELERANT_NAME); link.StartMessage(AS_GET_ACCELERANT_NAME);
link.Attach<int32>(screen_index); link.Attach<int32>(fScreenIndex);
status_t status = B_ERROR; status_t status = B_ERROR;
if (link.FlushWithReply(status) < B_OK || status < B_OK) if (link.FlushWithReply(status) < B_OK || status < B_OK)
@@ -979,28 +994,28 @@ BWindowScreen::InitClone()
BString accelerantName; BString accelerantName;
link.ReadString(accelerantName); link.ReadString(accelerantName);
addon_image = load_add_on(accelerantName.String()); fAddonImage = load_add_on(accelerantName.String());
if (addon_image < B_OK) if (fAddonImage < B_OK)
return addon_image; return fAddonImage;
status = get_image_symbol(addon_image, "get_accelerant_hook", B_SYMBOL_TYPE_ANY, (void **)&m_gah); status = get_image_symbol(fAddonImage, "get_accelerant_hook", B_SYMBOL_TYPE_ANY, (void **)&m_gah);
if (status < B_OK) { if (status < B_OK) {
unload_add_on(addon_image); unload_add_on(fAddonImage);
addon_image = -1; fAddonImage = -1;
return status; return status;
} }
clone_accelerant clone = (clone_accelerant)m_gah(B_CLONE_ACCELERANT, 0); clone_accelerant clone = (clone_accelerant)m_gah(B_CLONE_ACCELERANT, 0);
if (!clone) { if (clone == NULL) {
unload_add_on(addon_image); unload_add_on(fAddonImage);
addon_image = -1; fAddonImage = -1;
return status; return status;
} }
status = B_ERROR; status = B_ERROR;
link.StartMessage(AS_GET_DRIVER_NAME); link.StartMessage(AS_GET_DRIVER_NAME);
link.Attach<int32>(screen_index); link.Attach<int32>(fScreenIndex);
if (link.FlushWithReply(status) == B_OK && status == B_OK) { if (link.FlushWithReply(status) == B_OK && status == B_OK) {
BString driverName; BString driverName;
link.ReadString(driverName); link.ReadString(driverName);
@@ -1008,8 +1023,8 @@ BWindowScreen::InitClone()
} }
if (status < B_OK) { if (status < B_OK) {
unload_add_on(addon_image); unload_add_on(fAddonImage);
addon_image = -1; fAddonImage = -1;
} }
return status; return status;
@@ -1019,25 +1034,25 @@ BWindowScreen::InitClone()
status_t status_t
BWindowScreen::AssertDisplayMode(display_mode *dmode) BWindowScreen::AssertDisplayMode(display_mode *dmode)
{ {
status_t result = B_ERROR; status_t result = B_OK;
// TODO: Assert display mode: negotiation with app server // TODO: Assert display mode: negotiation with app server
// if the result is B_OK, we copy the dmode to new_space
if (result == B_OK) { if (result == B_OK) {
memcpy(new_space, dmode, sizeof(display_mode)); memcpy(fDisplayMode, dmode, sizeof(display_mode));
space_mode = 1; space_mode = 1;
} }
GetCardInfo(); GetCardInfo();
format_info.bits_per_pixel = card_info.bits_per_pixel; fFrameBufferInfo.bits_per_pixel = fCardInfo.bits_per_pixel;
format_info.bytes_per_row = card_info.bytes_per_row; fFrameBufferInfo.bytes_per_row = fCardInfo.bytes_per_row;
format_info.width = card_info.width; fFrameBufferInfo.width = fCardInfo.width;
format_info.height = card_info.height; fFrameBufferInfo.height = fCardInfo.height;
format_info.display_width = card_info.width; fFrameBufferInfo.display_width = fCardInfo.width;
format_info.display_height = card_info.height; fFrameBufferInfo.display_height = fCardInfo.height;
format_info.display_x = 0; fFrameBufferInfo.display_x = 0;
format_info.display_y = 0; fFrameBufferInfo.display_y = 0;
return result; return result;
} }