Commit 4799ac2b authored by Nathan Heisey's avatar Nathan Heisey

Partially cleaned out code

parent 491df9d7
...@@ -177,11 +177,6 @@ public: ...@@ -177,11 +177,6 @@ public:
} }
} }
/* Modes methods */
void SetPrevMode(display_mode *prevMode) { _saved_mode = prevMode; }
display_mode* GetPrevMode() { return _saved_mode; }
/* FIXME: Bad coding practice, but I can't include SDL_BWin.h here. Is /* FIXME: Bad coding practice, but I can't include SDL_BWin.h here. Is
there another way to do this? */ there another way to do this? */
void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */ void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */
...@@ -225,7 +220,7 @@ private: ...@@ -225,7 +220,7 @@ private:
win = GetSDLWindow(winID); win = GetSDLWindow(winID);
SDL_SendMouseMotion(win, 0, x, y); SDL_SendMouseMotion(win, 0, x, y);
/* FIXME: Attempt at fixing rendering problems */ /* Tell the application that the mouse passed over, redraw needed */
BE_UpdateWindowFramebuffer(NULL,win,NULL,-1); BE_UpdateWindowFramebuffer(NULL,win,NULL,-1);
} }
...@@ -328,9 +323,6 @@ private: ...@@ -328,9 +323,6 @@ private:
} }
win = GetSDLWindow(winID); win = GetSDLWindow(winID);
SDL_SendWindowEvent(win, SDL_WINDOWEVENT_MOVED, xPos, yPos); SDL_SendWindowEvent(win, SDL_WINDOWEVENT_MOVED, xPos, yPos);
/* FIXME: Attempt at fixing rendering problems */
// BE_UpdateWindowFramebuffer(NULL,win,NULL,-1); Handled by DirectConnected
} }
void _HandleWindowResized(BMessage *msg) { void _HandleWindowResized(BMessage *msg) {
...@@ -347,9 +339,6 @@ private: ...@@ -347,9 +339,6 @@ private:
} }
win = GetSDLWindow(winID); win = GetSDLWindow(winID);
SDL_SendWindowEvent(win, SDL_WINDOWEVENT_RESIZED, w, h); SDL_SendWindowEvent(win, SDL_WINDOWEVENT_RESIZED, w, h);
/* FIXME: Attempt at fixing rendering problems */
// BE_UpdateWindowFramebuffer(NULL,win,NULL,-1); Handled by DirectConnected
} }
bool _GetWinID(BMessage *msg, int32 *winID) { bool _GetWinID(BMessage *msg, int32 *winID) {
...@@ -379,7 +368,7 @@ private: ...@@ -379,7 +368,7 @@ private:
/* Members */ /* Members */
vector<SDL_Window*> _window_map; /* Keeps track of SDL_Windows by index-id */ vector<SDL_Window*> _window_map; /* Keeps track of SDL_Windows by index-id*/
display_mode *_saved_mode; display_mode *_saved_mode;
BGLView *_current_context; BGLView *_current_context;
......
...@@ -53,7 +53,7 @@ enum WinCommands { ...@@ -53,7 +53,7 @@ enum WinCommands {
BWIN_HIDE_WINDOW, BWIN_HIDE_WINDOW,
BWIN_MAXIMIZE_WINDOW, BWIN_MAXIMIZE_WINDOW,
BWIN_MINIMIZE_WINDOW, BWIN_MINIMIZE_WINDOW,
BWIN_RESTORE_WINDOW, /* TODO: IMPLEMENT THIS! */ BWIN_RESTORE_WINDOW,
BWIN_SET_TITLE, BWIN_SET_TITLE,
BWIN_FULLSCREEN BWIN_FULLSCREEN
}; };
...@@ -185,9 +185,6 @@ class SDL_BWin:public BDirectWindow ...@@ -185,9 +185,6 @@ class SDL_BWin:public BDirectWindow
_bits = (uint8*) info->bits; _bits = (uint8*) info->bits;
_row_bytes = info->bytes_per_row; _row_bytes = info->bytes_per_row;
_bounds = info->window_bounds; _bounds = info->window_bounds;
printf("Bounds = (%i,%i,%i,%i), Frame = (%0.f,%0.f,%0.f,%0.f)\n", _bounds.left,
_bounds.top, _bounds.right, _bounds.bottom, Frame().left, Frame().top,
Frame().right, Frame().bottom);
_bytes_per_px = info->bits_per_pixel / 8; _bytes_per_px = info->bits_per_pixel / 8;
_buffer_dirty = true; _buffer_dirty = true;
} }
...@@ -230,7 +227,8 @@ printf("Bounds = (%i,%i,%i,%i), Frame = (%0.f,%0.f,%0.f,%0.f)\n", _bounds.left, ...@@ -230,7 +227,8 @@ printf("Bounds = (%i,%i,%i,%i), Frame = (%0.f,%0.f,%0.f,%0.f)\n", _bounds.left,
virtual void FrameResized(float width, float height) { virtual void FrameResized(float width, float height) {
/* Post a message to the BApp so that it can handle the window event */ /* Post a message to the BApp so that it can handle the window event */
BMessage msg(BAPP_WINDOW_RESIZED); BMessage msg(BAPP_WINDOW_RESIZED);
msg.AddInt32("window-w", (int)width + 1); /* TODO: Check that +1 is needed */
msg.AddInt32("window-w", (int)width + 1);
msg.AddInt32("window-h", (int)height + 1); msg.AddInt32("window-h", (int)height + 1);
_PostWindowEvent(msg); _PostWindowEvent(msg);
...@@ -409,15 +407,12 @@ printf("Bounds = (%i,%i,%i,%i), Frame = (%0.f,%0.f,%0.f,%0.f)\n", _bounds.left, ...@@ -409,15 +407,12 @@ printf("Bounds = (%i,%i,%i,%i), Frame = (%0.f,%0.f,%0.f,%0.f)\n", _bounds.left,
uint32 GetRowBytes() { return _row_bytes; } uint32 GetRowBytes() { return _row_bytes; }
int32 GetFbX() { return _bounds.left; } int32 GetFbX() { return _bounds.left; }
int32 GetFbY() { return _bounds.top; } int32 GetFbY() { return _bounds.top; }
// int32 GetFbHeight() { return _bounds.bottom - _bounds.top + 1; }
// int32 GetFbWidth() { return _bounds.right - _bounds.left + 1; }
bool ConnectionEnabled() { return !_connection_disabled; } bool ConnectionEnabled() { return !_connection_disabled; }
bool Connected() { return _connected; } bool Connected() { return _connected; }
clipping_rect *GetClips() { return _clips; } clipping_rect *GetClips() { return _clips; }
int32 GetNumClips() { return _num_clips; } int32 GetNumClips() { return _num_clips; }
uint8* GetBufferPx() { return _bits; } uint8* GetBufferPx() { return _bits; }
int32 GetBytesPerPx() { return _bytes_per_px; } int32 GetBytesPerPx() { return _bytes_per_px; }
// uint8* GetWindowFramebuffer() { return _window_buffer; }
bool CanTrashWindowBuffer() { return _trash_window_buffer; } bool CanTrashWindowBuffer() { return _trash_window_buffer; }
bool BufferExists() { return _buffer_created; } bool BufferExists() { return _buffer_created; }
bool BufferIsDirty() { return _buffer_dirty; } bool BufferIsDirty() { return _buffer_dirty; }
...@@ -429,7 +424,6 @@ printf("Bounds = (%i,%i,%i,%i), Frame = (%0.f,%0.f,%0.f,%0.f)\n", _bounds.left, ...@@ -429,7 +424,6 @@ printf("Bounds = (%i,%i,%i,%i), Frame = (%0.f,%0.f,%0.f,%0.f)\n", _bounds.left,
/* Setter methods */ /* Setter methods */
void SetID(int32 id) { _id = id; } void SetID(int32 id) { _id = id; }
void SetBufferExists(bool bufferExists) { _buffer_created = bufferExists; } void SetBufferExists(bool bufferExists) { _buffer_created = bufferExists; }
// void SetWindowFramebuffer(uint8* fb) { _window_buffer = fb; }
void LockBuffer() { _buffer_locker->Lock(); } void LockBuffer() { _buffer_locker->Lock(); }
void UnlockBuffer() { _buffer_locker->Unlock(); } void UnlockBuffer() { _buffer_locker->Unlock(); }
void SetBufferDirty(bool bufferDirty) { _buffer_dirty = bufferDirty; } void SetBufferDirty(bool bufferDirty) { _buffer_dirty = bufferDirty; }
...@@ -575,27 +569,12 @@ private: ...@@ -575,27 +569,12 @@ private:
void _SetFullScreen(BMessage *msg) { void _SetFullScreen(BMessage *msg) {
bool fullscreen; bool fullscreen;
BRect rc1 = Bounds(),
rc2 = Frame();
printf(__FILE__": %d - bounds = (%.0f,%.0f,%.0f,%.0f), frame = (%.0f,%.0f,%.0f,%.0f\n", __LINE__, rc1.left, rc1.top, rc1.right, rc1.bottom,
rc2.left, rc2.top, rc2.right, rc2.bottom);
if( if(
msg->FindBool("fullscreen", &fullscreen) != B_OK msg->FindBool("fullscreen", &fullscreen) != B_OK
) { ) {
return; return;
} }
if(fullscreen) {
printf("Setting fullscreen...\n");
} else {
printf("Unsetting fullscreen...\n");
}
#if 1
SetFullScreen(fullscreen); SetFullScreen(fullscreen);
#endif
printf(__FILE__": %d - bounds = (%.0f,%.0f,%.0f,%.0f), frame = (%.0f,%.0f,%.0f,%.0f\n", __LINE__, rc1.left, rc1.top, rc1.right, rc1.bottom,
rc2.left, rc2.top, rc2.right, rc2.bottom);
} }
/* Members */ /* Members */
...@@ -615,7 +594,8 @@ rc2.left, rc2.top, rc2.right, rc2.bottom); ...@@ -615,7 +594,8 @@ rc2.left, rc2.top, rc2.right, rc2.bottom);
bool _connected, bool _connected,
_connection_disabled, _connection_disabled,
_buffer_created, _buffer_created,
_buffer_dirty; _buffer_dirty,
_trash_window_buffer;
uint8 *_bits; uint8 *_bits;
uint32 _row_bytes; uint32 _row_bytes;
clipping_rect _bounds; clipping_rect _bounds;
...@@ -623,11 +603,24 @@ rc2.left, rc2.top, rc2.right, rc2.bottom); ...@@ -623,11 +603,24 @@ rc2.left, rc2.top, rc2.right, rc2.bottom);
clipping_rect *_clips; clipping_rect *_clips;
int32 _num_clips; int32 _num_clips;
int32 _bytes_per_px; int32 _bytes_per_px;
// uint8 *_window_buffer; /* A copy of the window buffer */
bool _trash_window_buffer;
thread_id _draw_thread_id; thread_id _draw_thread_id;
BBitmap *_bitmap; BBitmap *_bitmap;
}; };
/* FIXME:
* An explanation of framebuffer flags.
*
* _connected - Original variable used to let the drawing thread know
* when changes are being made to the other framebuffer
* members.
* _connection_disabled - Used to signal to the drawing thread that the window
* is closing, and the thread should exit.
* _buffer_created - True if the current buffer is valid
* _buffer_dirty - True if the window should be redrawn.
* _trash_window_buffer - True if the window buffer needs to be trashed partway
* through a draw cycle. Occurs when the previous
* buffer provided by DirectConnected() is invalidated.
*/
#endif #endif
...@@ -35,7 +35,6 @@ extern "C" { ...@@ -35,7 +35,6 @@ extern "C" {
#endif #endif
int BE_SetClipboardText(_THIS, const char *text) { int BE_SetClipboardText(_THIS, const char *text) {
#if 0
BMessage *clip = NULL; BMessage *clip = NULL;
if(be_clipboard->Lock()) { if(be_clipboard->Lock()) {
be_clipboard->Clear(); be_clipboard->Clear();
...@@ -48,20 +47,17 @@ int BE_SetClipboardText(_THIS, const char *text) { ...@@ -48,20 +47,17 @@ int BE_SetClipboardText(_THIS, const char *text) {
} }
be_clipboard->Unlock(); be_clipboard->Unlock();
} }
#else
return -1;
#endif
} }
char *BE_GetClipboardText(_THIS) { char *BE_GetClipboardText(_THIS) {
#if 0
BMessage *clip = NULL; BMessage *clip = NULL;
const char *text; const char *text;
ssize_t length; ssize_t length;
if(be_clipboard->Lock()) { if(be_clipboard->Lock()) {
if((clip = be_clipboard->Data())) { if((clip = be_clipboard->Data())) {
/* Presumably the string of characters is ascii-format */ /* Presumably the string of characters is ascii-format */
clip->FindData("text/plain", B_MIME_TYPE, (void**)&text, &length); clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text,
&length);
} else { } else {
be_clipboard->Unlock(); be_clipboard->Unlock();
return NULL; return NULL;
...@@ -76,13 +72,9 @@ char *BE_GetClipboardText(_THIS) { ...@@ -76,13 +72,9 @@ char *BE_GetClipboardText(_THIS) {
SDL_strlcpy(result, text, length); SDL_strlcpy(result, text, length);
return result; return result;
#else
return NULL;
#endif;
} }
SDL_bool BE_HasClipboardText(_THIS) { SDL_bool BE_HasClipboardText(_THIS) {
#if 0
BMessage *clip = NULL; BMessage *clip = NULL;
const char *text; const char *text;
ssize_t length; ssize_t length;
...@@ -91,15 +83,13 @@ SDL_bool BE_HasClipboardText(_THIS) { ...@@ -91,15 +83,13 @@ SDL_bool BE_HasClipboardText(_THIS) {
if(be_clipboard->Lock()) { if(be_clipboard->Lock()) {
if((clip = be_clipboard->Data())) { if((clip = be_clipboard->Data())) {
/* Presumably the string of characters is ascii-format */ /* Presumably the string of characters is ascii-format */
clip->FindData("text/plain", B_MIME_TYPE, (void**)&text, &length); clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text,
&length);
if( text ) retval = SDL_TRUE; if( text ) retval = SDL_TRUE;
} }
be_clipboard->Unlock(); be_clipboard->Unlock();
} }
return retval; return retval;
#else
return SDL_FALSE;
#endif
} }
......
...@@ -26,6 +26,7 @@ extern "C" { ...@@ -26,6 +26,7 @@ extern "C" {
#endif #endif
void BE_PumpEvents(_THIS) { void BE_PumpEvents(_THIS) {
/* Since the event thread is its own thread, this isn't really necessary */
} }
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -126,9 +126,7 @@ int32 BE_DrawThread(void *data) { ...@@ -126,9 +126,7 @@ int32 BE_DrawThread(void *data) {
if( bwin->Connected() && bwin->BufferExists() && bwin->BufferIsDirty() ) { if( bwin->Connected() && bwin->BufferExists() && bwin->BufferIsDirty() ) {
bwin->LockBuffer(); bwin->LockBuffer();
BBitmap *bitmap = NULL; BBitmap *bitmap = NULL;
// while(!bitmap) { bitmap = bwin->GetBitmap();
bitmap = bwin->GetBitmap();
// }
int32 windowPitch = bitmap->BytesPerRow(); int32 windowPitch = bitmap->BytesPerRow();
int32 bufferPitch = bwin->GetRowBytes(); int32 bufferPitch = bwin->GetRowBytes();
uint8 *windowpx; uint8 *windowpx;
...@@ -163,14 +161,12 @@ int32 BE_DrawThread(void *data) { ...@@ -163,14 +161,12 @@ int32 BE_DrawThread(void *data) {
goto escape; /* Break out before the buffer is killed */ goto escape; /* Break out before the buffer is killed */
} }
// printf("memcpy(0x%x, 0x%x, %i) ", bufferpx, windowpx, width * BPP);
memcpy(bufferpx, windowpx, width * BPP); memcpy(bufferpx, windowpx, width * BPP);
bufferpx += bufferPitch; bufferpx += bufferPitch;
windowpx += windowPitch; windowpx += windowPitch;
} }
// printf("\t-\t");
} }
// printf("\n");
bwin->SetBufferDirty(false); bwin->SetBufferDirty(false);
escape: escape:
bwin->UnlockBuffer(); bwin->UnlockBuffer();
......
...@@ -37,10 +37,11 @@ extern "C" { ...@@ -37,10 +37,11 @@ extern "C" {
#endif #endif
#define WRAP_BMODE 1 #define WRAP_BMODE 1 /* FIXME: Some debate as to whether this is necessary */
#if WRAP_BMODE #if WRAP_BMODE
/* This wrapper is here so that the driverdata can be freed */ /* This wrapper is here so that the driverdata can be freed without freeing
the display_mode structure */
typedef struct SDL_DisplayModeData { typedef struct SDL_DisplayModeData {
display_mode *bmode; display_mode *bmode;
}; };
...@@ -55,10 +56,10 @@ static inline SDL_BApp *_GetBeApp() { ...@@ -55,10 +56,10 @@ static inline SDL_BApp *_GetBeApp() {
} }
static inline display_mode * _ExtractBMode(SDL_DisplayMode *mode) { static inline display_mode * _ExtractBMode(SDL_DisplayMode *mode) {
#if 0 #if WRAP_BMODE
return (display_mode*)(mode->driverdata);
#else
return ((SDL_DisplayModeData*)mode->driverdata)->bmode; return ((SDL_DisplayModeData*)mode->driverdata)->bmode;
#else
return (display_mode*)(mode->driverdata);
#endif #endif
} }
...@@ -68,6 +69,68 @@ static float get_refresh_rate(display_mode &mode) { ...@@ -68,6 +69,68 @@ static float get_refresh_rate(display_mode &mode) {
/ float(mode.timing.h_total * mode.timing.v_total); / float(mode.timing.h_total * mode.timing.v_total);
} }
#if 0
/* TODO:
* This is a useful debugging tool. Uncomment and insert into code as needed.
*/
void _SpoutModeData(display_mode *bmode) {
printf("BMode:\n");
printf("\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height);
printf("\th,v = (%i,%i)\n", bmode->h_display_start,
bmode->v_display_start);
if(bmode->flags) {
printf("\tFlags:\n");
if(bmode->flags & B_SCROLL) {
printf("\t\tB_SCROLL\n");
}
if(bmode->flags & B_8_BIT_DAC) {
printf("\t\tB_8_BIT_DAC\n");
}
if(bmode->flags & B_HARDWARE_CURSOR) {
printf("\t\tB_HARDWARE_CURSOR\n");
}
if(bmode->flags & B_PARALLEL_ACCESS) {
printf("\t\tB_PARALLEL_ACCESS\n");
}
if(bmode->flags & B_DPMS) {
printf("\t\tB_DPMS\n");
}
if(bmode->flags & B_IO_FB_NA) {
printf("\t\tB_IO_FB_NA\n");
}
}
printf("\tTiming:\n");
printf("\t\tpx clock: %i\n", bmode->timing.pixel_clock);
printf("\t\th - display: %i sync start: %i sync end: %i total: %i\n",
bmode->timing.h_display, bmode->timing.h_sync_start,
bmode->timing.h_sync_end, bmode->timing.h_total);
printf("\t\tv - display: %i sync start: %i sync end: %i total: %i\n",
bmode->timing.v_display, bmode->timing.v_sync_start,
bmode->timing.v_sync_end, bmode->timing.v_total);
if(bmode->timing.flags) {
printf("\t\tFlags:\n");
if(bmode->timing.flags & B_BLANK_PEDESTAL) {
printf("\t\t\tB_BLANK_PEDESTAL\n");
}
if(bmode->timing.flags & B_TIMING_INTERLACED) {
printf("\t\t\tB_TIMING_INTERLACED\n");
}
if(bmode->timing.flags & B_POSITIVE_HSYNC) {
printf("\t\t\tB_POSITIVE_HSYNC\n");
}
if(bmode->timing.flags & B_POSITIVE_VSYNC) {
printf("\t\t\tB_POSITIVE_VSYNC\n");
}
if(bmode->timing.flags & B_SYNC_ON_GREEN) {
printf("\t\t\tB_SYNC_ON_GREEN\n");
}
}
}
#endif
static inline int32 ColorSpaceToBitsPerPixel(uint32 colorspace) static inline int32 ColorSpaceToBitsPerPixel(uint32 colorspace)
{ {
int bitsperpixel; int bitsperpixel;
...@@ -123,17 +186,21 @@ static inline int32 BPPToSDLPxFormat(int32 bpp) { ...@@ -123,17 +186,21 @@ static inline int32 BPPToSDLPxFormat(int32 bpp) {
} }
} }
static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode, static inline void _BDisplayModeToSdlDisplayMode(display_mode *bmode,
SDL_DisplayMode *mode) { SDL_DisplayMode *mode) {
mode->w = bmode->virtual_width; mode->w = bmode->virtual_width;
mode->h = bmode->virtual_height; mode->h = bmode->virtual_height;
mode->refresh_rate = (int)get_refresh_rate(*bmode); mode->refresh_rate = (int)get_refresh_rate(*bmode);
#if WRAP_BMODE #if WRAP_BMODE
SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, sizeof(SDL_DisplayModeData)); SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1,
sizeof(SDL_DisplayModeData));
data->bmode = bmode; data->bmode = bmode;
mode->driverdata = data; mode->driverdata = data;
#else #else
mode->driverdata = bmode; mode->driverdata = bmode;
#endif #endif
...@@ -143,13 +210,14 @@ static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode, ...@@ -143,13 +210,14 @@ static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode,
} }
/* Later, there may be more than one monitor available */ /* Later, there may be more than one monitor available */
void BE_AddDisplay(BScreen *screen) { void _AddDisplay(BScreen *screen) {
SDL_VideoDisplay display; SDL_VideoDisplay display;
SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1, sizeof(SDL_DisplayMode)); SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1,
sizeof(SDL_DisplayMode));
display_mode *bmode = (display_mode*)SDL_calloc(1, sizeof(display_mode)); display_mode *bmode = (display_mode*)SDL_calloc(1, sizeof(display_mode));
screen->GetMode(bmode); screen->GetMode(bmode);
BE_BDisplayModeToSdlDisplayMode(bmode, mode); _BDisplayModeToSdlDisplayMode(bmode, mode);
SDL_zero(display); SDL_zero(display);
display.desktop_mode = *mode; display.desktop_mode = *mode;
...@@ -158,23 +226,20 @@ void BE_AddDisplay(BScreen *screen) { ...@@ -158,23 +226,20 @@ void BE_AddDisplay(BScreen *screen) {
SDL_AddVideoDisplay(&display); SDL_AddVideoDisplay(&display);
} }
/*
* Functions called by SDL
*/
int BE_InitModes(_THIS) { int BE_InitModes(_THIS) {
BScreen screen; BScreen screen;
/* Save the current display mode */
// display_mode *prevMode;
// screen.GetMode(prevMode);
// _GetBeApp()->SetPrevMode(prevMode);
/* Only one possible video display right now */ /* TODO: When Haiku supports multiple display screens, call
BE_AddDisplay(&screen); _AddDisplayScreen() for each of them. */
_AddDisplay(&screen);
} }
int BE_QuitModes(_THIS) { int BE_QuitModes(_THIS) {
/* Restore the previous video mode */ /* FIXME: Nothing really needs to be done here at the moment? */
BScreen screen;
// display_mode *savedMode = _GetBeApp()->GetPrevMode();
// screen.SetMode(savedMode);
return 0; return 0;
} }
...@@ -206,7 +271,7 @@ void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { ...@@ -206,7 +271,7 @@ void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) {
for(i = 0; i < count; ++i) { for(i = 0; i < count; ++i) {
//FIXME: Apparently there are errors with colorspace changes //FIXME: Apparently there are errors with colorspace changes
if (bmodes[i].space == this_bmode.space) { if (bmodes[i].space == this_bmode.space) {
BE_BDisplayModeToSdlDisplayMode(&bmodes[i], &mode); _BDisplayModeToSdlDisplayMode(&bmodes[i], &mode);
SDL_AddDisplayMode(display, &mode); SDL_AddDisplayMode(display, &mode);
} }
} }
...@@ -214,158 +279,8 @@ void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { ...@@ -214,158 +279,8 @@ void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) {
} }
static int get_combine_mode(display_mode &mode) {
if ((mode.flags & B_SCROLL) == 0)
return 0;
if (mode.virtual_width == mode.timing.h_display * 2)
return 1;
if (mode.virtual_height == mode.timing.v_display * 2)
return 2;
return 0;
}
#if 0
bool _GetDisplayMode(const screen_mode& mode, display_mode& displayMode)
{
uint16 virtualWidth, virtualHeight;
int32 bestIndex = -1;
float bestDiff = 999;
virtualWidth = mode.combine == kCombineHorizontally
? mode.width * 2 : mode.width;
virtualHeight = mode.combine == kCombineVertically
? mode.height * 2 : mode.height;
// try to find mode in list provided by driver
for (uint32 i = 0; i < fModeCount; i++) {
if (fModeList[i].virtual_width != virtualWidth
|| fModeList[i].virtual_height != virtualHeight
|| (color_space)fModeList[i].space != mode.space)
continue;
// Accept the mode if the computed refresh rate of the mode is within
// 0.6 percent of the refresh rate specified by the caller. Note that
// refresh rates computed from mode parameters is not exact; especially
// some of the older modes such as 640x480, 800x600, and 1024x768.
// The tolerance of 0.6% was obtained by examining the various possible
// modes.
float refreshDiff = fabs(get_refresh_rate(fModeList[i]) - mode.refresh);
if (refreshDiff < 0.006 * mode.refresh) {
// Accept this mode.
displayMode = fModeList[i];
displayMode.h_display_start = 0;
displayMode.v_display_start = 0;
// Since the computed refresh rate of the selected mode might differ
// from selected refresh rate by a few tenths (e.g. 60.2 instead of
// 60.0), tweak the pixel clock so the the refresh rate of the mode
// matches the selected refresh rate.
displayMode.timing.pixel_clock = uint32(((displayMode.timing.h_total
* displayMode.timing.v_total * mode.refresh) / 1000.0) + 0.5);
return true;
}
// Mode not acceptable.
if (refreshDiff < bestDiff) {
bestDiff = refreshDiff;
bestIndex = i;
}
}
// we didn't find the exact mode, but something very similar?
if (bestIndex == -1)
return false;
displayMode = fModeList[bestIndex];
displayMode.h_display_start = 0;
displayMode.v_display_start = 0;
// For the mode selected by the width, height, and refresh rate, compute
// the video timing parameters for the mode by using the VESA Generalized
// Timing Formula (GTF).
ComputeGTFVideoTiming(displayMode.timing.h_display,
displayMode.timing.v_display, mode.refresh, displayMode.timing);
return true;
}
#endif
void _SpoutModeData(display_mode *bmode) {
printf("BMode:\n");
printf("\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height);
printf("\th,v = (%i,%i)\n", bmode->h_display_start,
bmode->v_display_start);
printf("\tcombine mode = %i\n", get_combine_mode(*bmode));
if(bmode->flags) {
printf("\tFlags:\n");
if(bmode->flags & B_SCROLL) {
printf("\t\tB_SCROLL\n");
}
if(bmode->flags & B_8_BIT_DAC) {
printf("\t\tB_8_BIT_DAC\n");
}
if(bmode->flags & B_HARDWARE_CURSOR) {
printf("\t\tB_HARDWARE_CURSOR\n");
}
if(bmode->flags & B_PARALLEL_ACCESS) {
printf("\t\tB_PARALLEL_ACCESS\n");
}
if(bmode->flags & B_DPMS) {
printf("\t\tB_DPMS\n");
}
if(bmode->flags & B_IO_FB_NA) {
printf("\t\tB_IO_FB_NA\n");
}
}
printf("\tTiming:\n");
printf("\t\tpx clock: %i\n", bmode->timing.pixel_clock);
printf("\t\th - display: %i sync start: %i sync end: %i total: %i\n",
bmode->timing.h_display, bmode->timing.h_sync_start,
bmode->timing.h_sync_end, bmode->timing.h_total);
printf("\t\tv - display: %i sync start: %i sync end: %i total: %i\n",
bmode->timing.v_display, bmode->timing.v_sync_start,
bmode->timing.v_sync_end, bmode->timing.v_total);
if(bmode->timing.flags) {
printf("\t\tFlags:\n");
if(bmode->timing.flags & B_BLANK_PEDESTAL) {
printf("\t\t\tB_BLANK_PEDESTAL\n");
}
if(bmode->timing.flags & B_TIMING_INTERLACED) {
printf("\t\t\tB_TIMING_INTERLACED\n");
}
if(bmode->timing.flags & B_POSITIVE_HSYNC) {
printf("\t\t\tB_POSITIVE_HSYNC\n");
}
if(bmode->timing.flags & B_POSITIVE_VSYNC) {
printf("\t\t\tB_POSITIVE_VSYNC\n");
}
if(bmode->timing.flags & B_SYNC_ON_GREEN) {
printf("\t\t\tB_SYNC_ON_GREEN\n");
}
}
}
int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){ int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
/* Get the current screen */ /* Get the current screen */
printf(__FILE__": %d\n", __LINE__);
BScreen bscreen; BScreen bscreen;
if(!bscreen.IsValid()) { if(!bscreen.IsValid()) {
printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__); printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__);
...@@ -375,24 +290,18 @@ printf(__FILE__": %d\n", __LINE__); ...@@ -375,24 +290,18 @@ printf(__FILE__": %d\n", __LINE__);
display_mode *bmode = _ExtractBMode(mode); display_mode *bmode = _ExtractBMode(mode);
_SpoutModeData(bmode); /* FIXME: Is the first option always going to be the right one? */
printf("\n"); uint32 c = 0, i;
uint32 c = 0, i, x = 0; display_mode *bmode_list;
#define RES 0 bscreen.GetModeList(&bmode_list, &c);
display_mode *bmode_list; for(i = 0; i < c; ++i) {
bscreen.GetModeList(&bmode_list, &c); if( bmode_list[i].space == bmode->space &&
for(i = 0; i < c; ++i) { bmode_list[i].virtual_width == bmode->virtual_width &&
if( bmode_list[i].space == bmode->space && bmode_list[i].virtual_height == bmode->virtual_height ) {
bmode_list[i].virtual_width == bmode->virtual_width &&
bmode_list[i].virtual_height == bmode->virtual_height ) {
if(x == RES)
bmode = &bmode_list[i]; bmode = &bmode_list[i];
break;
++x; }
_SpoutModeData(&bmode_list[i]);
// break;
} }
}
if(bscreen.SetMode(bmode) != B_OK) { if(bscreen.SetMode(bmode) != B_OK) {
SDL_SetError("Bad video mode\n"); SDL_SetError("Bad video mode\n");
...@@ -401,11 +310,11 @@ for(i = 0; i < c; ++i) { ...@@ -401,11 +310,11 @@ for(i = 0; i < c; ++i) {
free(bmode_list); free(bmode_list);
#if SDL_VIDEO_OPENGL #if SDL_VIDEO_OPENGL
/* The OpenGL context may need to be rebooted */ /* FIXME: Is there some way to reboot the OpenGL context? This doesn't
help */
// BE_GL_RebootContexts(_this); // BE_GL_RebootContexts(_this);
#endif #endif
printf(__FILE__": %d\n", __LINE__);
return 0; return 0;
} }
......
...@@ -45,6 +45,7 @@ static inline SDL_BApp *_GetBeApp() { ...@@ -45,6 +45,7 @@ static inline SDL_BApp *_GetBeApp() {
/* Passing a NULL path means load pointers from the application */ /* Passing a NULL path means load pointers from the application */
int BE_GL_LoadLibrary(_THIS, const char *path) int BE_GL_LoadLibrary(_THIS, const char *path)
{ {
/* FIXME: Is this working correctly? */
image_info info; image_info info;
int32 cookie = 0; int32 cookie = 0;
while (get_next_image_info(0, &cookie, &info) == B_OK) { while (get_next_image_info(0, &cookie, &info) == B_OK) {
...@@ -58,64 +59,6 @@ int BE_GL_LoadLibrary(_THIS, const char *path) ...@@ -58,64 +59,6 @@ int BE_GL_LoadLibrary(_THIS, const char *path)
SDL_arraysize(_this->gl_config.driver_path)); SDL_arraysize(_this->gl_config.driver_path));
} }
} }
#if 0
printf("\n\nLibrary loading: %s\n\n", path);
if (path == NULL) {
if (_this->gl_config.dll_handle == NULL) {
image_info info;
int32 cookie = 0;
while (get_next_image_info(0, &cookie, &info) == B_OK) {
printf(__FILE__": %d - Inside while\n",__LINE__);
void *location = NULL;
if (get_image_symbol
((image_id) cookie, "glBegin",
B_SYMBOL_TYPE_ANY, &location) == B_OK) {
_this->gl_config.dll_handle = (void *) cookie;
_this->gl_config.driver_loaded = 1;
SDL_strlcpy(_this->gl_config.driver_path,
"libGL.so",
SDL_arraysize(_this->
gl_config.driver_path));
}
}
}
} else {
/*
FIXME None of BeOS libGL.so implementations have exported functions
to load BGLView, which should be reloaded from new lib.
So for now just "load" linked libGL.so :(
*/
if (_this->gl_config.dll_handle == NULL) {
return BE_GL_LoadLibrary(_this, NULL);
}
/* Unload old first */
/*if (_this->gl_config.dll_handle != NULL) { */
/* Do not try to unload application itself (if LoadLibrary was called before with NULL ;) */
/* image_info info;
if (get_image_info((image_id)_this->gl_config.dll_handle, &info) == B_OK) {
if (info.type != B_APP_IMAGE) {
unload_add_on((image_id)_this->gl_config.dll_handle);
}
}
}
if ((_this->gl_config.dll_handle = (void*)load_add_on(path)) != (void*)B_ERROR) {
_this->gl_config.driver_loaded = 1;
SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path));
} */
}
if (_this->gl_config.dll_handle != NULL) {
return 0;
} else {
printf(__FILE__": %d- gl_config.driver_loaded = 0\n", __LINE__);
_this->gl_config.dll_handle = NULL;
_this->gl_config.driver_loaded = 0;
*_this->gl_config.driver_path = '\0';
return -1;
}
#endif
} }
void *BE_GL_GetProcAddress(_THIS, const char *proc) void *BE_GL_GetProcAddress(_THIS, const char *proc)
...@@ -161,28 +104,29 @@ SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window) { ...@@ -161,28 +104,29 @@ SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window) {
void BE_GL_DeleteContext(_THIS, SDL_GLContext context) { void BE_GL_DeleteContext(_THIS, SDL_GLContext context) {
/* Currently, automatically unlocks the view */ /* Currently, automatically unlocks the view */
printf(__FILE__": %d\n", __LINE__);
((SDL_BWin*)context)->RemoveGLView(); ((SDL_BWin*)context)->RemoveGLView();
} }
int BE_GL_SetSwapInterval(_THIS, int interval) { int BE_GL_SetSwapInterval(_THIS, int interval) {
printf(__FILE__": %d- swap interval set\n", __LINE__); /* TODO: Implement this, if necessary? */
return 0; return 0;
} }
int BE_GL_GetSwapInterval(_THIS) { int BE_GL_GetSwapInterval(_THIS) {
printf(__FILE__": %d- swap interval requested\n", __LINE__); /* TODO: Implement this, if necessary? */
return 0; return 0;
} }
void BE_GL_UnloadLibrary(_THIS) { void BE_GL_UnloadLibrary(_THIS) {
printf(__FILE__": %d- Library unloaded\n", __LINE__); /* TODO: Implement this, if necessary? */
} }
/* FIXME: This function is meant to clear the OpenGL context when the video
mode changes (see SDL_bmodes.cc), but it doesn't seem to help, and is not
currently in use. */
void BE_GL_RebootContexts(_THIS) { void BE_GL_RebootContexts(_THIS) {
SDL_Window *window = _this->windows; SDL_Window *window = _this->windows;
while(window) { while(window) {
......
...@@ -53,23 +53,11 @@ BE_CreateDevice(int devindex) ...@@ -53,23 +53,11 @@ BE_CreateDevice(int devindex)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
#if 0
if (device) {
data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
} else {
data = NULL;
}
if (!data) {
SDL_OutOfMemory();
if (device) {
SDL_free(device);
}
return NULL;
}
#endif
device->driverdata = NULL; /*data;*/
/* TODO: Figure out what sort of initialization needs to go here */ device->driverdata = NULL; /* FIXME: Is this the cause of some of the
SDL_Quit() errors? */
/* TODO: Figure out if any initialization needs to go here */
/* Set the function pointers */ /* Set the function pointers */
device->VideoInit = BE_VideoInit; device->VideoInit = BE_VideoInit;
...@@ -105,7 +93,7 @@ BE_CreateDevice(int devindex) ...@@ -105,7 +93,7 @@ BE_CreateDevice(int devindex)
device->shape_driver.SetWindowShape = NULL; device->shape_driver.SetWindowShape = NULL;
device->shape_driver.ResizeWindowShape = NULL; device->shape_driver.ResizeWindowShape = NULL;
//#if SDL_VIDEO_OPENGL_WGL /* FIXME: Replace with BeOs's SDL OPENGL stuff */
device->GL_LoadLibrary = BE_GL_LoadLibrary; device->GL_LoadLibrary = BE_GL_LoadLibrary;
device->GL_GetProcAddress = BE_GL_GetProcAddress; device->GL_GetProcAddress = BE_GL_GetProcAddress;
device->GL_UnloadLibrary = BE_GL_UnloadLibrary; device->GL_UnloadLibrary = BE_GL_UnloadLibrary;
...@@ -115,7 +103,7 @@ BE_CreateDevice(int devindex) ...@@ -115,7 +103,7 @@ BE_CreateDevice(int devindex)
device->GL_GetSwapInterval = BE_GL_GetSwapInterval; device->GL_GetSwapInterval = BE_GL_GetSwapInterval;
device->GL_SwapWindow = BE_GL_SwapWindow; device->GL_SwapWindow = BE_GL_SwapWindow;
device->GL_DeleteContext = BE_GL_DeleteContext; device->GL_DeleteContext = BE_GL_DeleteContext;
//#endif
device->StartTextInput = BE_StartTextInput; device->StartTextInput = BE_StartTextInput;
device->StopTextInput = BE_StopTextInput; device->StopTextInput = BE_StopTextInput;
device->SetTextInputRect = BE_SetTextInputRect; device->SetTextInputRect = BE_SetTextInputRect;
...@@ -140,8 +128,6 @@ static void BE_DeleteDevice(SDL_VideoDevice * device) ...@@ -140,8 +128,6 @@ static void BE_DeleteDevice(SDL_VideoDevice * device)
SDL_free(device); SDL_free(device);
} }
/* FIXME: This is the 1.2 function at the moment. Read through it and
o understand what it does. */
int BE_VideoInit(_THIS) int BE_VideoInit(_THIS)
{ {
/* Initialize the Be Application for appserver interaction */ /* Initialize the Be Application for appserver interaction */
...@@ -162,9 +148,6 @@ int BE_VideoInit(_THIS) ...@@ -162,9 +148,6 @@ int BE_VideoInit(_THIS)
BE_GL_LoadLibrary(_this, NULL); BE_GL_LoadLibrary(_this, NULL);
#endif #endif
/* Fill in some window manager capabilities */
// _this->info.wm_available = 1;
/* We're done! */ /* We're done! */
return (0); return (0);
} }
...@@ -177,24 +160,8 @@ static int BE_Available(void) ...@@ -177,24 +160,8 @@ static int BE_Available(void)
void BE_VideoQuit(_THIS) void BE_VideoQuit(_THIS)
{ {
#if 0
SDL_Win->Quit();
SDL_Win = NULL;
#endif
#if 0
if (SDL_BlankCursor != NULL) {
BE_FreeWMCursor(_this, SDL_BlankCursor);
SDL_BlankCursor = NULL;
}
#endif
BE_QuitModes(_this); BE_QuitModes(_this);
#if SDL_VIDEO_OPENGL
// if (_this->gl_config.dll_handle != NULL)
// unload_add_on((image_id) _this->gl_config.dll_handle);
#endif
SDL_QuitBeApp(); SDL_QuitBeApp();
} }
......
...@@ -47,13 +47,17 @@ int _InitWindow(_THIS, SDL_Window *window) { ...@@ -47,13 +47,17 @@ int _InitWindow(_THIS, SDL_Window *window) {
); );
if(window->flags & SDL_WINDOW_FULLSCREEN) { if(window->flags & SDL_WINDOW_FULLSCREEN) {
/* TODO: Add support for this flag */
printf(__FILE__": %d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",__LINE__);
} }
if(window->flags & SDL_WINDOW_OPENGL) { if(window->flags & SDL_WINDOW_OPENGL) {
/* TODO: Add support for this flag */
} }
if(!(window->flags & SDL_WINDOW_RESIZABLE)) { if(!(window->flags & SDL_WINDOW_RESIZABLE)) {
flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE; flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE;
} }
if(window->flags & SDL_WINDOW_BORDERLESS) { if(window->flags & SDL_WINDOW_BORDERLESS) {
/* TODO: Add support for this flag */
} }
SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, flags); SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, flags);
...@@ -172,10 +176,12 @@ void BE_SetWindowFullscreen(_THIS, SDL_Window * window, ...@@ -172,10 +176,12 @@ void BE_SetWindowFullscreen(_THIS, SDL_Window * window,
int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) { int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) {
/* FIXME: Not BeOs/Haiku supported */ /* FIXME: Not BeOs/Haiku supported */
return -1;
} }
int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) { int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) {
/* FIXME: Not BeOs/Haiku supported */ /* FIXME: Not BeOs/Haiku supported */
return -1;
} }
...@@ -193,6 +199,7 @@ void BE_DestroyWindow(_THIS, SDL_Window * window) { ...@@ -193,6 +199,7 @@ void BE_DestroyWindow(_THIS, SDL_Window * window) {
SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info) { struct SDL_SysWMinfo *info) {
/* FIXME: What is the point of this? What information should be included? */ /* FIXME: What is the point of this? What information should be included? */
return SDL_FALSE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment