winsys: Correct Haiku winsys display target code
* Instead of assuming the displaytarget is the same stride / colorspace as the destination, lets actually check the source bitmap. * Fixes random stride issues in rendering Acked-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
b8f89fc5cb
commit
439dd0e20a
|
@ -77,10 +77,22 @@ void
|
||||||
copy_bitmap_bits(const Bitmap* bitmap, void* data, int32 length)
|
copy_bitmap_bits(const Bitmap* bitmap, void* data, int32 length)
|
||||||
{
|
{
|
||||||
BBitmap *bb = (BBitmap*)bitmap;
|
BBitmap *bb = (BBitmap*)bitmap;
|
||||||
if (bb) {
|
|
||||||
color_space cs = bb->ColorSpace();
|
// We assume the data is 1:1 the format of the bitmap
|
||||||
bb->ImportBits(data, length, bb->BytesPerRow(), 0, cs);
|
if (bb)
|
||||||
}
|
bb->ImportBits(data, length, bb->BytesPerRow(), 0, bb->ColorSpace());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
import_bitmap_bits(const Bitmap* bitmap, void* data, int32 length,
|
||||||
|
unsigned srcStride, color_space srcColorSpace)
|
||||||
|
{
|
||||||
|
BBitmap *bb = (BBitmap*)bitmap;
|
||||||
|
|
||||||
|
// Import image and adjust image format from source to dest
|
||||||
|
if (bb)
|
||||||
|
bb->ImportBits(data, length, srcStride, 0, srcColorSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,14 +40,17 @@ extern "C" {
|
||||||
|
|
||||||
|
|
||||||
Bitmap* create_bitmap(int32 width, int32 height, color_space colorSpace);
|
Bitmap* create_bitmap(int32 width, int32 height, color_space colorSpace);
|
||||||
|
void delete_bitmap(Bitmap* bitmap);
|
||||||
|
|
||||||
void copy_bitmap_bits(const Bitmap* bitmap, void* data, int32 length);
|
void copy_bitmap_bits(const Bitmap* bitmap, void* data, int32 length);
|
||||||
|
void import_bitmap_bits(const Bitmap* bitmap, void* data, int32 length,
|
||||||
|
unsigned srcStride, color_space srcColorSpace);
|
||||||
|
|
||||||
void get_bitmap_size(const Bitmap* bitmap, int32* width, int32* height);
|
void get_bitmap_size(const Bitmap* bitmap, int32* width, int32* height);
|
||||||
color_space get_bitmap_color_space(const Bitmap* bitmap);
|
color_space get_bitmap_color_space(const Bitmap* bitmap);
|
||||||
int32 get_bitmap_bytes_per_row(const Bitmap* bitmap);
|
int32 get_bitmap_bytes_per_row(const Bitmap* bitmap);
|
||||||
int32 get_bitmap_bits_length(const Bitmap* bitmap);
|
int32 get_bitmap_bits_length(const Bitmap* bitmap);
|
||||||
|
|
||||||
void delete_bitmap(Bitmap* bitmap);
|
|
||||||
void dump_bitmap(const Bitmap* bitmap);
|
void dump_bitmap(const Bitmap* bitmap);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include "util/u_memory.h"
|
#include "util/u_memory.h"
|
||||||
|
|
||||||
#include "hgl_sw_winsys.h"
|
#include "hgl_sw_winsys.h"
|
||||||
#include "bitmap_wrapper.h"
|
|
||||||
|
|
||||||
|
|
||||||
// Cast
|
// Cast
|
||||||
|
@ -60,6 +59,19 @@ hgl_winsys_is_displaytarget_format_supported(struct sw_winsys* winsys,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static color_space
|
||||||
|
hgl_winsys_convert_cs(enum pipe_format format)
|
||||||
|
{
|
||||||
|
// TODO: B_RGB24, B_RGB16, B_RGB15?
|
||||||
|
switch(format) {
|
||||||
|
case PIPE_FORMAT_B5G6R5_UNORM:
|
||||||
|
return B_CMAP8;
|
||||||
|
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||||
|
case PIPE_FORMAT_X8R8G8B8_UNORM:
|
||||||
|
default:
|
||||||
|
return B_RGB32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static struct sw_displaytarget*
|
static struct sw_displaytarget*
|
||||||
hgl_winsys_displaytarget_create(struct sw_winsys* winsys,
|
hgl_winsys_displaytarget_create(struct sw_winsys* winsys,
|
||||||
|
@ -70,6 +82,7 @@ hgl_winsys_displaytarget_create(struct sw_winsys* winsys,
|
||||||
= CALLOC_STRUCT(haiku_displaytarget);
|
= CALLOC_STRUCT(haiku_displaytarget);
|
||||||
assert(haikuDisplayTarget);
|
assert(haikuDisplayTarget);
|
||||||
|
|
||||||
|
haikuDisplayTarget->colorSpace = hgl_winsys_convert_cs(format);
|
||||||
haikuDisplayTarget->format = format;
|
haikuDisplayTarget->format = format;
|
||||||
haikuDisplayTarget->width = width;
|
haikuDisplayTarget->width = width;
|
||||||
haikuDisplayTarget->height = height;
|
haikuDisplayTarget->height = height;
|
||||||
|
@ -156,8 +169,9 @@ hgl_winsys_displaytarget_display(struct sw_winsys* winsys,
|
||||||
struct haiku_displaytarget* haikuDisplayTarget
|
struct haiku_displaytarget* haikuDisplayTarget
|
||||||
= hgl_sw_displaytarget(displayTarget);
|
= hgl_sw_displaytarget(displayTarget);
|
||||||
|
|
||||||
copy_bitmap_bits(bitmap, haikuDisplayTarget->data,
|
import_bitmap_bits(bitmap, haikuDisplayTarget->data,
|
||||||
haikuDisplayTarget->size);
|
haikuDisplayTarget->size, haikuDisplayTarget->stride,
|
||||||
|
haikuDisplayTarget->colorSpace);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,14 @@
|
||||||
#include "state_tracker/st_api.h"
|
#include "state_tracker/st_api.h"
|
||||||
#include "state_tracker/sw_winsys.h"
|
#include "state_tracker/sw_winsys.h"
|
||||||
|
|
||||||
|
#include "bitmap_wrapper.h"
|
||||||
|
|
||||||
|
|
||||||
struct haiku_displaytarget
|
struct haiku_displaytarget
|
||||||
{
|
{
|
||||||
enum pipe_format format;
|
enum pipe_format format;
|
||||||
|
color_space colorSpace;
|
||||||
|
|
||||||
unsigned width;
|
unsigned width;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
unsigned stride;
|
unsigned stride;
|
||||||
|
|
Loading…
Reference in New Issue