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

Partially cleaned out code

parent 491df9d7
......@@ -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
there another way to do this? */
void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */
......@@ -225,7 +220,7 @@ private:
win = GetSDLWindow(winID);
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);
}
......@@ -328,9 +323,6 @@ private:
}
win = GetSDLWindow(winID);
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) {
......@@ -347,9 +339,6 @@ private:
}
win = GetSDLWindow(winID);
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) {
......@@ -379,7 +368,7 @@ private:
/* 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;
BGLView *_current_context;
......
......@@ -53,7 +53,7 @@ enum WinCommands {
BWIN_HIDE_WINDOW,
BWIN_MAXIMIZE_WINDOW,
BWIN_MINIMIZE_WINDOW,
BWIN_RESTORE_WINDOW, /* TODO: IMPLEMENT THIS! */
BWIN_RESTORE_WINDOW,
BWIN_SET_TITLE,
BWIN_FULLSCREEN
};
......@@ -185,9 +185,6 @@ class SDL_BWin:public BDirectWindow
_bits = (uint8*) info->bits;
_row_bytes = info->bytes_per_row;
_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;
_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,
virtual void FrameResized(float width, float height) {
/* Post a message to the BApp so that it can handle the window event */
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);
_PostWindowEvent(msg);
......@@ -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; }
int32 GetFbX() { return _bounds.left; }
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 Connected() { return _connected; }
clipping_rect *GetClips() { return _clips; }
int32 GetNumClips() { return _num_clips; }
uint8* GetBufferPx() { return _bits; }
int32 GetBytesPerPx() { return _bytes_per_px; }
// uint8* GetWindowFramebuffer() { return _window_buffer; }
bool CanTrashWindowBuffer() { return _trash_window_buffer; }
bool BufferExists() { return _buffer_created; }
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,
/* Setter methods */
void SetID(int32 id) { _id = id; }
void SetBufferExists(bool bufferExists) { _buffer_created = bufferExists; }
// void SetWindowFramebuffer(uint8* fb) { _window_buffer = fb; }
void LockBuffer() { _buffer_locker->Lock(); }
void UnlockBuffer() { _buffer_locker->Unlock(); }
void SetBufferDirty(bool bufferDirty) { _buffer_dirty = bufferDirty; }
......@@ -575,27 +569,12 @@ private:
void _SetFullScreen(BMessage *msg) {
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(
msg->FindBool("fullscreen", &fullscreen) != B_OK
) {
return;
}
if(fullscreen) {
printf("Setting fullscreen...\n");
} else {
printf("Unsetting fullscreen...\n");
}
#if 1
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 */
......@@ -615,7 +594,8 @@ rc2.left, rc2.top, rc2.right, rc2.bottom);
bool _connected,
_connection_disabled,
_buffer_created,
_buffer_dirty;
_buffer_dirty,
_trash_window_buffer;
uint8 *_bits;
uint32 _row_bytes;
clipping_rect _bounds;
......@@ -623,11 +603,24 @@ rc2.left, rc2.top, rc2.right, rc2.bottom);
clipping_rect *_clips;
int32 _num_clips;
int32 _bytes_per_px;
// uint8 *_window_buffer; /* A copy of the window buffer */
bool _trash_window_buffer;
thread_id _draw_thread_id;
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
......@@ -35,7 +35,6 @@ extern "C" {
#endif
int BE_SetClipboardText(_THIS, const char *text) {
#if 0
BMessage *clip = NULL;
if(be_clipboard->Lock()) {
be_clipboard->Clear();
......@@ -48,20 +47,17 @@ int BE_SetClipboardText(_THIS, const char *text) {
}
be_clipboard->Unlock();
}
#else
return -1;
#endif
}
char *BE_GetClipboardText(_THIS) {
#if 0
BMessage *clip = NULL;
const char *text;
ssize_t length;
if(be_clipboard->Lock()) {
if((clip = be_clipboard->Data())) {
/* 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 {
be_clipboard->Unlock();
return NULL;
......@@ -76,13 +72,9 @@ char *BE_GetClipboardText(_THIS) {
SDL_strlcpy(result, text, length);
return result;
#else
return NULL;
#endif;
}
SDL_bool BE_HasClipboardText(_THIS) {
#if 0
BMessage *clip = NULL;
const char *text;
ssize_t length;
......@@ -91,15 +83,13 @@ SDL_bool BE_HasClipboardText(_THIS) {
if(be_clipboard->Lock()) {
if((clip = be_clipboard->Data())) {
/* 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;
}
be_clipboard->Unlock();
}
return retval;
#else
return SDL_FALSE;
#endif
}
......
......@@ -26,6 +26,7 @@ extern "C" {
#endif
void BE_PumpEvents(_THIS) {
/* Since the event thread is its own thread, this isn't really necessary */
}
#ifdef __cplusplus
......
......@@ -126,9 +126,7 @@ int32 BE_DrawThread(void *data) {
if( bwin->Connected() && bwin->BufferExists() && bwin->BufferIsDirty() ) {
bwin->LockBuffer();
BBitmap *bitmap = NULL;
// while(!bitmap) {
bitmap = bwin->GetBitmap();
// }
int32 windowPitch = bitmap->BytesPerRow();
int32 bufferPitch = bwin->GetRowBytes();
uint8 *windowpx;
......@@ -163,14 +161,12 @@ int32 BE_DrawThread(void *data) {
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);
bufferpx += bufferPitch;
windowpx += windowPitch;
}
// printf("\t-\t");
}
// printf("\n");
bwin->SetBufferDirty(false);
escape:
bwin->UnlockBuffer();
......
This diff is collapsed.
......@@ -45,6 +45,7 @@ static inline SDL_BApp *_GetBeApp() {
/* Passing a NULL path means load pointers from the application */
int BE_GL_LoadLibrary(_THIS, const char *path)
{
/* FIXME: Is this working correctly? */
image_info info;
int32 cookie = 0;
while (get_next_image_info(0, &cookie, &info) == B_OK) {
......@@ -58,64 +59,6 @@ int BE_GL_LoadLibrary(_THIS, const char *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)
......@@ -161,28 +104,29 @@ SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window) {
void BE_GL_DeleteContext(_THIS, SDL_GLContext context) {
/* Currently, automatically unlocks the view */
printf(__FILE__": %d\n", __LINE__);
((SDL_BWin*)context)->RemoveGLView();
}
int BE_GL_SetSwapInterval(_THIS, int interval) {
printf(__FILE__": %d- swap interval set\n", __LINE__);
/* TODO: Implement this, if necessary? */
return 0;
}
int BE_GL_GetSwapInterval(_THIS) {
printf(__FILE__": %d- swap interval requested\n", __LINE__);
/* TODO: Implement this, if necessary? */
return 0;
}
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) {
SDL_Window *window = _this->windows;
while(window) {
......
......@@ -53,23 +53,11 @@ BE_CreateDevice(int devindex)
/* Initialize all variables that we clean on shutdown */
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 */
device->VideoInit = BE_VideoInit;
......@@ -105,7 +93,7 @@ BE_CreateDevice(int devindex)
device->shape_driver.SetWindowShape = 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_GetProcAddress = BE_GL_GetProcAddress;
device->GL_UnloadLibrary = BE_GL_UnloadLibrary;
......@@ -115,7 +103,7 @@ BE_CreateDevice(int devindex)
device->GL_GetSwapInterval = BE_GL_GetSwapInterval;
device->GL_SwapWindow = BE_GL_SwapWindow;
device->GL_DeleteContext = BE_GL_DeleteContext;
//#endif
device->StartTextInput = BE_StartTextInput;
device->StopTextInput = BE_StopTextInput;
device->SetTextInputRect = BE_SetTextInputRect;
......@@ -140,8 +128,6 @@ static void BE_DeleteDevice(SDL_VideoDevice * 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)
{
/* Initialize the Be Application for appserver interaction */
......@@ -162,9 +148,6 @@ int BE_VideoInit(_THIS)
BE_GL_LoadLibrary(_this, NULL);
#endif
/* Fill in some window manager capabilities */
// _this->info.wm_available = 1;
/* We're done! */
return (0);
}
......@@ -177,24 +160,8 @@ static int BE_Available(void)
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);
#if SDL_VIDEO_OPENGL
// if (_this->gl_config.dll_handle != NULL)
// unload_add_on((image_id) _this->gl_config.dll_handle);
#endif
SDL_QuitBeApp();
}
......
......@@ -47,13 +47,17 @@ int _InitWindow(_THIS, SDL_Window *window) {
);
if(window->flags & SDL_WINDOW_FULLSCREEN) {
/* TODO: Add support for this flag */
printf(__FILE__": %d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",__LINE__);
}
if(window->flags & SDL_WINDOW_OPENGL) {
/* TODO: Add support for this flag */
}
if(!(window->flags & SDL_WINDOW_RESIZABLE)) {
flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE;
}
if(window->flags & SDL_WINDOW_BORDERLESS) {
/* TODO: Add support for this flag */
}
SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, flags);
......@@ -172,10 +176,12 @@ void BE_SetWindowFullscreen(_THIS, SDL_Window * window,
int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) {
/* FIXME: Not BeOs/Haiku supported */
return -1;
}
int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) {
/* FIXME: Not BeOs/Haiku supported */
return -1;
}
......@@ -193,6 +199,7 @@ void BE_DestroyWindow(_THIS, SDL_Window * window) {
SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info) {
/* 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