haiku-softpipe: Minor cleanup and color space fixes
authorAlexander von Gluck IV <kallisti5@unixzen.com>
Mon, 28 Oct 2013 17:56:43 +0000 (12:56 -0500)
committerAlexander von Gluck IV <kallisti5@unixzen.com>
Tue, 29 Oct 2013 20:27:43 +0000 (15:27 -0500)
* Use more consistant data sources
* Fix improper color space assignments
* Remove unnecessary comments and code
* Drop unnecessary round_up function (this was leftover
  from moving winsys code out of renderer)

Acked-by: Brian Paul <brianp@vmware.com>
src/gallium/targets/haiku-softpipe/GalliumContext.cpp
src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp

index ba76ddaee8916519635fa5ee6637234b5264dce8..ff420b9af269ee21341222ee14c07d386e3bce87 100644 (file)
@@ -73,10 +73,11 @@ hgl_fill_st_visual(gl_config* glVisual)
        // Determine color format
        if (glVisual->redBits == 8) {
                if (glVisual->alphaBits == 8)
-                       stVisual->color_format = PIPE_FORMAT_B8G8R8A8_UNORM;
+                       stVisual->color_format = PIPE_FORMAT_A8R8G8B8_UNORM;
                else
-                       stVisual->color_format = PIPE_FORMAT_B8G8R8X8_UNORM;
+                       stVisual->color_format = PIPE_FORMAT_X8R8G8B8_UNORM;
        } else {
+               // TODO: I think this should be RGB vs BGR
                stVisual->color_format = PIPE_FORMAT_B5G6R5_UNORM;
        }
 
@@ -91,11 +92,9 @@ hgl_fill_st_visual(gl_config* glVisual)
                        break;
                case 24:
                        if (glVisual->stencilBits == 0) {
-                               stVisual->depth_stencil_format = PIPE_FORMAT_Z24X8_UNORM;
-                               // or PIPE_FORMAT_X8Z24_UNORM?
+                               stVisual->depth_stencil_format = PIPE_FORMAT_X8Z24_UNORM;
                        } else {
-                               stVisual->depth_stencil_format = PIPE_FORMAT_Z24_UNORM_S8_UINT;
-                               // or PIPE_FORMAT_S8_UINT_Z24_UNORM?
+                               stVisual->depth_stencil_format = PIPE_FORMAT_S8_UINT_Z24_UNORM;
                        }
                        break;
                case 32:
@@ -126,13 +125,6 @@ hgl_fill_st_visual(gl_config* glVisual)
 }
 
 
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
-       return (n + multiple - 1) & ~(multiple - 1);
-}
-
-
 static int
 hook_stm_get_param(struct st_manager *smapi, enum st_manager_param param)
 {
@@ -253,10 +245,10 @@ GalliumContext::CreateContext(Bitmap *bitmap)
        const GLboolean stereoFlag      = false;
        const GLint depth                       = (fOptions & BGL_DEPTH) ? 24 : 0;
        const GLint stencil                     = (fOptions & BGL_STENCIL) ? 8 : 0;
-       const GLint accum                       = 0;            // (options & BGL_ACCUM) ? 16 : 0;
-       const GLint red                         = rgbFlag ? 8 : 0;
-       const GLint green                       = rgbFlag ? 8 : 0;
-       const GLint blue                        = rgbFlag ? 8 : 0;
+       const GLint accum                       = (fOptions & BGL_ACCUM) ? 16 : 0;
+       const GLint red                         = rgbFlag ? 8 : 5;
+       const GLint green                       = rgbFlag ? 8 : 5;
+       const GLint blue                        = rgbFlag ? 8 : 5;
        const GLint alpha                       = alphaFlag ? 8 : 0;
 
        TRACE("rgb      :\t%d\n", (bool)rgbFlag);
@@ -521,3 +513,4 @@ GalliumContext::SwapBuffers(context_id contextID)
 
        return B_OK;
 }
+/* vim: set tabstop=4: */
index ced22566a09b18762d98b53cc470a419fa7a7da6..fa71dd764e044ab108574387945f6ed597966cb9 100644 (file)
@@ -116,9 +116,7 @@ SoftwareRenderer::LockGL()
        BAutolock lock(fInfoLocker);
        if (fDirectModeEnabled && fInfo != NULL) {
                fNewWidth = fInfo->window_bounds.right - fInfo->window_bounds.left;
-                       // + 1;
                fNewHeight = fInfo->window_bounds.bottom - fInfo->window_bounds.top;
-                       // + 1;
        }
 
        if (fBitmap && cs == fColorSpace && fNewWidth == fWidth
@@ -179,8 +177,10 @@ SoftwareRenderer::SwapBuffers(bool vsync)
                ERROR("%s: Bitmap size doesn't match size!\n", __func__);
                return;
        }
-       uint8 bytesPerPixel = fInfo->bits_per_pixel / 8;
+
        uint32 bytesPerRow = fBitmap->BytesPerRow();
+       uint8 bytesPerPixel = bytesPerRow / fBitmap->Bounds().IntegerWidth();
+
        for (uint32 i = 0; i < fInfo->clip_list_count; i++) {
                clipping_rect *clip = &fInfo->clip_list[i];
                int32 height = clip->bottom - clip->top + 1;