=?UTF-8?Q?Stefan=20D=C3=B6singer=20?=: wined3d: Move surface_convert_color_to_float to utils.c.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Apr 7 10:11:28 CDT 2015
Module: wine
Branch: master
Commit: fa0a9232e05fd2e9d66bc3face95df85c5819f44
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fa0a9232e05fd2e9d66bc3face95df85c5819f44
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Mon Apr 6 00:28:53 2015 +0200
wined3d: Move surface_convert_color_to_float to utils.c.
---
dlls/wined3d/surface.c | 60 +++---------------------------------------
dlls/wined3d/utils.c | 51 +++++++++++++++++++++++++++++++++++
dlls/wined3d/wined3d_private.h | 2 ++
3 files changed, 56 insertions(+), 57 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index d27339b..e3601a2 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1013,62 +1013,6 @@ static BOOL fbo_blit_supported(const struct wined3d_gl_info *gl_info, enum wined
return TRUE;
}
-static BOOL surface_convert_color_to_float(const struct wined3d_surface *surface,
- DWORD color, struct wined3d_color *float_color)
-{
- const struct wined3d_format *format = surface->resource.format;
- const struct wined3d_palette *palette;
-
- switch (format->id)
- {
- case WINED3DFMT_P8_UINT:
- palette = surface->container->swapchain ? surface->container->swapchain->palette : NULL;
-
- if (palette)
- {
- float_color->r = palette->colors[color].rgbRed / 255.0f;
- float_color->g = palette->colors[color].rgbGreen / 255.0f;
- float_color->b = palette->colors[color].rgbBlue / 255.0f;
- }
- else
- {
- float_color->r = 0.0f;
- float_color->g = 0.0f;
- float_color->b = 0.0f;
- }
- float_color->a = color / 255.0f;
- break;
-
- case WINED3DFMT_B5G6R5_UNORM:
- float_color->r = ((color >> 11) & 0x1f) / 31.0f;
- float_color->g = ((color >> 5) & 0x3f) / 63.0f;
- float_color->b = (color & 0x1f) / 31.0f;
- float_color->a = 1.0f;
- break;
-
- case WINED3DFMT_B8G8R8_UNORM:
- case WINED3DFMT_B8G8R8X8_UNORM:
- float_color->r = D3DCOLOR_R(color);
- float_color->g = D3DCOLOR_G(color);
- float_color->b = D3DCOLOR_B(color);
- float_color->a = 1.0f;
- break;
-
- case WINED3DFMT_B8G8R8A8_UNORM:
- float_color->r = D3DCOLOR_R(color);
- float_color->g = D3DCOLOR_G(color);
- float_color->b = D3DCOLOR_B(color);
- float_color->a = D3DCOLOR_A(color);
- break;
-
- default:
- ERR("Unhandled conversion from %s to floating point.\n", debug_d3dformat(format->id));
- return FALSE;
- }
-
- return TRUE;
-}
-
static BOOL surface_convert_depth_to_float(const struct wined3d_surface *surface, DWORD depth, float *float_depth)
{
const struct wined3d_format *format = surface->resource.format;
@@ -5333,10 +5277,12 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC
if (flags & WINEDDBLT_COLORFILL)
{
struct wined3d_color color;
+ const struct wined3d_palette *palette = dst_swapchain ? dst_swapchain->palette : NULL;
TRACE("Color fill.\n");
- if (!surface_convert_color_to_float(dst_surface, fx->u5.dwFillColor, &color))
+ if (!wined3d_format_convert_color_to_float(dst_surface->resource.format,
+ palette, fx->u5.dwFillColor, &color))
goto fallback;
if (SUCCEEDED(surface_color_fill(dst_surface, &dst_rect, &color)))
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 1cb928e..f3c84ac 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3511,6 +3511,57 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface, c
return 0;
}
+BOOL wined3d_format_convert_color_to_float(const struct wined3d_format *format,
+ const struct wined3d_palette *palette, DWORD color, struct wined3d_color *float_color)
+{
+ switch (format->id)
+ {
+ case WINED3DFMT_P8_UINT:
+ if (palette)
+ {
+ float_color->r = palette->colors[color].rgbRed / 255.0f;
+ float_color->g = palette->colors[color].rgbGreen / 255.0f;
+ float_color->b = palette->colors[color].rgbBlue / 255.0f;
+ }
+ else
+ {
+ float_color->r = 0.0f;
+ float_color->g = 0.0f;
+ float_color->b = 0.0f;
+ }
+ float_color->a = color / 255.0f;
+ break;
+
+ case WINED3DFMT_B5G6R5_UNORM:
+ float_color->r = ((color >> 11) & 0x1f) / 31.0f;
+ float_color->g = ((color >> 5) & 0x3f) / 63.0f;
+ float_color->b = (color & 0x1f) / 31.0f;
+ float_color->a = 1.0f;
+ break;
+
+ case WINED3DFMT_B8G8R8_UNORM:
+ case WINED3DFMT_B8G8R8X8_UNORM:
+ float_color->r = D3DCOLOR_R(color);
+ float_color->g = D3DCOLOR_G(color);
+ float_color->b = D3DCOLOR_B(color);
+ float_color->a = 1.0f;
+ break;
+
+ case WINED3DFMT_B8G8R8A8_UNORM:
+ float_color->r = D3DCOLOR_R(color);
+ float_color->g = D3DCOLOR_G(color);
+ float_color->b = D3DCOLOR_B(color);
+ float_color->a = D3DCOLOR_A(color);
+ break;
+
+ default:
+ ERR("Unhandled conversion from %s to floating point.\n", debug_d3dformat(format->id));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/* DirectDraw stuff */
enum wined3d_format_id pixelformat_for_depth(DWORD depth)
{
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index e401b8a..5d736dd 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3167,6 +3167,8 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format,
UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN;
DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface,
const struct wined3d_color *color) DECLSPEC_HIDDEN;
+BOOL wined3d_format_convert_color_to_float(const struct wined3d_format *format,
+ const struct wined3d_palette *palette, DWORD color, struct wined3d_color *float_color) DECLSPEC_HIDDEN;
const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion(
const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list