From: Daniel Ansorregui Subject: [PATCH 4/6] wined3d: Expose wined3d_color <--> d3dcolor conversion functions Message-Id: <20181015191720.1981-4-mailszeros@gmail.com> Date: Mon, 15 Oct 2018 20:17:18 +0100 In-Reply-To: <20181015191720.1981-1-mailszeros@gmail.com> References: <20181015191720.1981-1-mailszeros@gmail.com> * This is to allow conversion calls to be used in d3d9 Signed-off-by: Daniel Ansorregui --- dlls/wined3d/wined3d_private.h | 13 ------------- include/wine/wined3d.h | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index afa711f033..dbcf17e26c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1428,19 +1428,6 @@ extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDD #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f) -#define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff) -#define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff) -#define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff) -#define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff) - -static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_color, DWORD d3d_color) -{ - wined3d_color->r = D3DCOLOR_B_R(d3d_color) / 255.0f; - wined3d_color->g = D3DCOLOR_B_G(d3d_color) / 255.0f; - wined3d_color->b = D3DCOLOR_B_B(d3d_color) / 255.0f; - wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f; -} - #define HIGHEST_TRANSFORMSTATE WINED3D_TS_WORLD_MATRIX(255) /* Highest value in wined3d_transform_state. */ void wined3d_check_gl_call(const struct wined3d_gl_info *gl_info, diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 286df47c77..3441fee16a 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2793,4 +2793,27 @@ static inline void wined3d_box_set(struct wined3d_box *box, unsigned int left, u box->back = back; } +#define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff) +#define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff) +#define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff) +#define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff) + +static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_color, DWORD d3d_color) +{ + wined3d_color->r = D3DCOLOR_B_R(d3d_color) / 255.0f; + wined3d_color->g = D3DCOLOR_B_G(d3d_color) / 255.0f; + wined3d_color->b = D3DCOLOR_B_B(d3d_color) / 255.0f; + wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f; +} + +static inline DWORD d3dcolor_from_wined3d_color(struct wined3d_color wined3d_color) +{ + DWORD d3d_color; + d3d_color = ((DWORD)(wined3d_color.a * 255.0f + 0.5f) & 0xff) << 24; + d3d_color += ((DWORD)(wined3d_color.r * 255.0f + 0.5f) & 0xff) << 16; + d3d_color += ((DWORD)(wined3d_color.g * 255.0f + 0.5f) & 0xff) << 8; + d3d_color += ((DWORD)(wined3d_color.b * 255.0f + 0.5f) & 0xff) << 0; + return d3d_color; +} + #endif /* __WINE_WINED3D_H */ -- 2.17.1