|
@@ -32,6 +32,8 @@ |
|
|
extern "C" { |
|
|
#endif |
|
|
|
|
|
int32 BE_UpdateOnce(SDL_Window *window); |
|
|
|
|
|
static inline SDL_BWin *_ToBeWin(SDL_Window *window) { |
|
|
return ((SDL_BWin*)(window->driverdata)); |
|
|
} |
|
@@ -98,10 +100,15 @@ int BE_UpdateWindowFramebuffer(_THIS, SDL_Window * window, |
|
|
return 0; |
|
|
|
|
|
SDL_BWin *bwin = _ToBeWin(window); |
|
|
|
|
|
|
|
|
#ifdef DRAWTHREAD |
|
|
bwin->LockBuffer(); |
|
|
bwin->SetBufferDirty(true); |
|
|
bwin->UnlockBuffer(); |
|
|
#else |
|
|
bwin->SetBufferDirty(true); |
|
|
BE_UpdateOnce(window); |
|
|
#endif |
|
|
|
|
|
return 0; |
|
|
} |
|
@@ -148,9 +155,11 @@ int32 BE_DrawThread(void *data) { |
|
|
buffer */ |
|
|
for(y = 0; y < height; ++y) |
|
|
{ |
|
|
|
|
|
if(bwin->CanTrashWindowBuffer()) { |
|
|
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; |
|
@@ -183,6 +192,55 @@ void BE_DestroyWindowFramebuffer(_THIS, SDL_Window * window) { |
|
|
bwin->UnlockBuffer(); |
|
|
} |
|
|
|
|
|
|
|
|
int32 BE_UpdateOnce(SDL_Window *window) { |
|
|
SDL_BWin *bwin = _ToBeWin(window); |
|
|
BScreen bscreen; |
|
|
if(!bscreen.IsValid()) { |
|
|
return -1; |
|
|
} |
|
|
|
|
|
if(bwin->ConnectionEnabled() && bwin->Connected()) { |
|
|
bwin->LockBuffer(); |
|
|
int32 windowPitch = window->surface->pitch; |
|
|
int32 bufferPitch = bwin->GetRowBytes(); |
|
|
uint8 *windowpx; |
|
|
uint8 *bufferpx; |
|
|
|
|
|
int32 BPP = bwin->GetBytesPerPx(); |
|
|
uint8 *windowBaseAddress = (uint8*)window->surface->pixels; |
|
|
int32 windowSub = bwin->GetFbX() * BPP + |
|
|
bwin->GetFbY() * windowPitch; |
|
|
clipping_rect *clips = bwin->GetClips(); |
|
|
int32 numClips = bwin->GetNumClips(); |
|
|
int i, y; |
|
|
|
|
|
/* Blit each clipping rectangle */ |
|
|
bscreen.WaitForRetrace(); |
|
|
for(i = 0; i < numClips; ++i) { |
|
|
clipping_rect rc = clips[i]; |
|
|
/* Get addresses of the start of each clipping rectangle */ |
|
|
int32 width = clips[i].right - clips[i].left + 1; |
|
|
int32 height = clips[i].bottom - clips[i].top + 1; |
|
|
bufferpx = bwin->GetBufferPx() + |
|
|
clips[i].top * bufferPitch + clips[i].left * BPP; |
|
|
windowpx = windowBaseAddress + |
|
|
clips[i].top * windowPitch + clips[i].left * BPP - windowSub; |
|
|
|
|
|
/* Copy each row of pixels from the window buffer into the frame |
|
|
buffer */ |
|
|
for(y = 0; y < height; ++y) |
|
|
{ |
|
|
memcpy(bufferpx, windowpx, width * BPP); |
|
|
bufferpx += bufferPitch; |
|
|
windowpx += windowPitch; |
|
|
} |
|
|
} |
|
|
bwin->UnlockBuffer(); |
|
|
} |
|
|
return 0; |
|
|
} |
|
|
|
|
|
#ifdef __cplusplus |
|
|
} |
|
|
#endif |