Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Partially cleaned out code
Browse files Browse the repository at this point in the history
  • Loading branch information
antifinidictor committed Aug 22, 2011
1 parent 1621caa commit 5a7d45e
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 352 deletions.
15 changes: 2 additions & 13 deletions src/main/beos/SDL_BApp.h
Expand Up @@ -177,11 +177,6 @@ class SDL_BApp : public BApplication {
}
}

/* 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 */
Expand Down Expand Up @@ -225,7 +220,7 @@ class SDL_BApp : public BApplication {
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);
}

Expand Down Expand Up @@ -328,9 +323,6 @@ class SDL_BApp : public BApplication {
}
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) {
Expand All @@ -347,9 +339,6 @@ class SDL_BApp : public BApplication {
}
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) {
Expand Down Expand Up @@ -379,7 +368,7 @@ class SDL_BApp : public BApplication {


/* 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;
Expand Down
47 changes: 20 additions & 27 deletions src/video/bwindow/SDL_BWin.h
Expand Up @@ -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
};
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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; }
Expand All @@ -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; }
Expand Down Expand Up @@ -575,27 +569,12 @@ printf("Bounds = (%i,%i,%i,%i), Frame = (%0.f,%0.f,%0.f,%0.f)\n", _bounds.left,

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 */
Expand All @@ -615,19 +594,33 @@ 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;
BLocker *_buffer_locker;
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
18 changes: 4 additions & 14 deletions src/video/bwindow/SDL_bclipboard.cc
Expand Up @@ -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();
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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

}

Expand Down
1 change: 1 addition & 0 deletions src/video/bwindow/SDL_bevents.cc
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions src/video/bwindow/SDL_bframebuffer.cc
Expand Up @@ -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();
// }
bitmap = bwin->GetBitmap();
int32 windowPitch = bitmap->BytesPerRow();
int32 bufferPitch = bwin->GetRowBytes();
uint8 *windowpx;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 5a7d45e

Please sign in to comment.