Author: jackburton Date: 2011-01-01 17:37:21 +0100 (Sat, 01 Jan 2011) New Revision: 40051 Changeset: http://dev.haiku-os.org/changeset/40051 Modified: haiku/trunk/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.cpp haiku/trunk/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.h Log: Extract the code to copy the bacbuffer to the direct window. When in nondirect mode, SwapBuffers() wasn't respecting the vsync parameter. Modified: haiku/trunk/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.cpp =================================================================== --- haiku/trunk/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.cpp 2011-01-01 16:09:11 UTC (rev 40050) +++ haiku/trunk/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.cpp 2011-01-01 16:37:21 UTC (rev 40051) @@ -430,38 +430,9 @@ GLView()->DrawBitmap(fBitmap, B_ORIGIN); GLView()->UnlockLooper(); } - return; - } + } else + _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; - } - } - if (VSync) { BScreen screen(GLView()->Window()); screen.WaitForRetrace(); @@ -475,7 +446,6 @@ CALLED(); if (fBitmap && (!fDirectModeEnabled || (fInfo == NULL))) GLView()->DrawBitmap(fBitmap, updateRect, updateRect); - } @@ -880,3 +850,36 @@ _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; + } + } +} Modified: haiku/trunk/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.h =================================================================== --- haiku/trunk/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.h 2011-01-01 16:09:11 UTC (rev 40050) +++ haiku/trunk/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.h 2011-01-01 16:37:21 UTC (rev 40051) @@ -92,6 +92,7 @@ static void _DeleteBackBuffer(struct gl_renderbuffer* rb); void _AllocateBitmap(); + void _CopyToDirect(); BBitmap* fBitmap; bool fDirectModeEnabled;