Henri Verbeet : wined3d: Add WINED3DFMT_P8_UINT support to wined3d_format_convert_from_float().
Alexandre Julliard
julliard at winehq.org
Wed Aug 3 12:48:09 CDT 2011
Module: wine
Branch: master
Commit: 111e8fe77cc85162cde2eaf35edd290739482920
URL: http://source.winehq.org/git/wine.git/?a=commit;h=111e8fe77cc85162cde2eaf35edd290739482920
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Tue Aug 2 21:42:15 2011 +0200
wined3d: Add WINED3DFMT_P8_UINT support to wined3d_format_convert_from_float().
---
dlls/wined3d/surface.c | 2 +-
dlls/wined3d/utils.c | 37 ++++++++++++++++++++++++++++++++++++-
dlls/wined3d/wined3d_private.h | 2 +-
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 02bf4c4..d9060ff 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -7355,7 +7355,7 @@ static HRESULT cpu_blit_color_fill(struct wined3d_device *device, struct wined3d
memset(&BltFx, 0, sizeof(BltFx));
BltFx.dwSize = sizeof(BltFx);
- BltFx.u5.dwFillColor = wined3d_format_convert_from_float(dst_surface->resource.format, color);
+ BltFx.u5.dwFillColor = wined3d_format_convert_from_float(dst_surface, color);
return wined3d_surface_blt(dst_surface, dst_rect, NULL, NULL,
WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_POINT);
}
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 177f071..68e6d75 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -2622,7 +2622,7 @@ BOOL getDepthStencilBits(const struct wined3d_format *format, BYTE *depthSize, B
/* Note: It's the caller's responsibility to ensure values can be expressed
* in the requested format. UNORM formats for example can only express values
* in the range 0.0f -> 1.0f. */
-DWORD wined3d_format_convert_from_float(const struct wined3d_format *format, const WINED3DCOLORVALUE *color)
+DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface, const WINED3DCOLORVALUE *color)
{
static const struct
{
@@ -2653,6 +2653,7 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_format *format, con
{WINED3DFMT_B10G10R10A2_UNORM, 1023.0f, 1023.0f, 1023.0f, 3.0f, 20, 10, 0, 30},
{WINED3DFMT_R10G10B10A2_UNORM, 1023.0f, 1023.0f, 1023.0f, 3.0f, 0, 10, 20, 30},
};
+ const struct wined3d_format *format = surface->resource.format;
unsigned int i;
TRACE("Converting color {%.8e %.8e %.8e %.8e} to format %s.\n",
@@ -2674,6 +2675,40 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_format *format, con
return ret;
}
+ if (format->id == WINED3DFMT_P8_UINT)
+ {
+ PALETTEENTRY *e;
+ BYTE r, g, b, a;
+
+ if (!surface->palette)
+ {
+ WARN("Surface doesn't have a palette, returning 0.\n");
+ return 0;
+ }
+
+ r = (BYTE)((color->r * 255.0f) + 0.5f);
+ g = (BYTE)((color->g * 255.0f) + 0.5f);
+ b = (BYTE)((color->b * 255.0f) + 0.5f);
+ a = (BYTE)((color->a * 255.0f) + 0.5f);
+
+ e = &surface->palette->palents[a];
+ if (e->peRed == r && e->peGreen == g && e->peBlue == b)
+ return a;
+
+ WARN("Alpha didn't match index, searching full palette.\n");
+
+ for (i = 0; i < 256; ++i)
+ {
+ e = &surface->palette->palents[i];
+ if (e->peRed == r && e->peGreen == g && e->peBlue == b)
+ return i;
+ }
+
+ FIXME("Unable to convert color to palette index.\n");
+
+ return 0;
+ }
+
FIXME("Conversion for format %s not implemented.\n", debug_d3dformat(format->id));
return 0;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 17e8b41..e7cc3eb 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2805,7 +2805,7 @@ const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl
enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
UINT wined3d_format_calculate_size(const struct wined3d_format *format,
UINT alignment, UINT width, UINT height) DECLSPEC_HIDDEN;
-DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
+DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface,
const WINED3DCOLORVALUE *color) DECLSPEC_HIDDEN;
static inline BOOL use_vs(const struct wined3d_state *state)
More information about the wine-cvs
mailing list