From 903625ee2921a0d0f5755f03ab65d47e01864a5a Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 1 Jan 2011 16:37:21 +0000 Subject: [PATCH] Extract the code to copy the bacbuffer to the direct window. When in nondirect mode, SwapBuffers() wasn't respecting the vsync parameter. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40051 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../MesaSoftwareRenderer.cpp | 67 ++++++++++--------- .../MesaSoftwareRenderer.h | 1 + 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.cpp b/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.cpp index db1592088d..a0028320af 100644 --- a/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.cpp +++ b/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.cpp @@ -430,37 +430,8 @@ MesaSoftwareRenderer::SwapBuffers(bool VSync) GLView()->DrawBitmap(fBitmap, B_ORIGIN); GLView()->UnlockLooper(); } - return; - } - - BAutolock lock(fInfoLocker); - - // check the bitmap size still matches the size - if (fInfo->window_bounds.bottom - fInfo->window_bounds.top - != fBitmap->Bounds().IntegerHeight() - || fInfo->window_bounds.right - fInfo->window_bounds.left - != fBitmap->Bounds().IntegerWidth()) - return; - uint8 bytesPerPixel = fInfo->bits_per_pixel / 8; - uint32 bytesPerRow = fBitmap->BytesPerRow(); - for (uint32 i = 0; i < fInfo->clip_list_count; i++) { - clipping_rect *clip = &fInfo->clip_list[i]; - int32 height = clip->bottom - clip->top + 1; - int32 bytesWidth - = (clip->right - clip->left + 1) * bytesPerPixel; - uint8 *p = (uint8 *)fInfo->bits + clip->top - * fInfo->bytes_per_row + clip->left * bytesPerPixel; - uint8 *b = (uint8 *)fBitmap->Bits() - + (clip->top - fInfo->window_bounds.top) * bytesPerRow - + (clip->left - fInfo->window_bounds.left) - * bytesPerPixel; - - for (int y = 0; y < height; y++) { - memcpy(p, b, bytesWidth); - p += fInfo->bytes_per_row; - b += bytesPerRow; - } - } + } else + _CopyToDirect(); if (VSync) { BScreen screen(GLView()->Window()); @@ -475,7 +446,6 @@ MesaSoftwareRenderer::Draw(BRect updateRect) CALLED(); if (fBitmap && (!fDirectModeEnabled || (fInfo == NULL))) GLView()->DrawBitmap(fBitmap, updateRect, updateRect); - } @@ -880,3 +850,36 @@ MesaSoftwareRenderer::_DeleteBackBuffer(struct gl_renderbuffer* rb) _mesa_free(rb); } + +void +MesaSoftwareRenderer::_CopyToDirect() +{ + BAutolock lock(fInfoLocker); + + // check the bitmap size still matches the size + if (fInfo->window_bounds.bottom - fInfo->window_bounds.top + != fBitmap->Bounds().IntegerHeight() + || fInfo->window_bounds.right - fInfo->window_bounds.left + != fBitmap->Bounds().IntegerWidth()) + return; + uint8 bytesPerPixel = fInfo->bits_per_pixel / 8; + uint32 bytesPerRow = fBitmap->BytesPerRow(); + for (uint32 i = 0; i < fInfo->clip_list_count; i++) { + clipping_rect *clip = &fInfo->clip_list[i]; + int32 height = clip->bottom - clip->top + 1; + int32 bytesWidth + = (clip->right - clip->left + 1) * bytesPerPixel; + uint8 *p = (uint8 *)fInfo->bits + clip->top + * fInfo->bytes_per_row + clip->left * bytesPerPixel; + uint8 *b = (uint8 *)fBitmap->Bits() + + (clip->top - fInfo->window_bounds.top) * bytesPerRow + + (clip->left - fInfo->window_bounds.left) + * bytesPerPixel; + + for (int y = 0; y < height; y++) { + memcpy(p, b, bytesWidth); + p += fInfo->bytes_per_row; + b += bytesPerRow; + } + } +} diff --git a/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.h b/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.h index e5c7a30177..f61ceeaa2a 100644 --- a/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.h +++ b/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.h @@ -92,6 +92,7 @@ private: static void _DeleteBackBuffer(struct gl_renderbuffer* rb); void _AllocateBitmap(); + void _CopyToDirect(); BBitmap* fBitmap; bool fDirectModeEnabled;