Henri Verbeet : wined3d: Introduce wined3d_colour_srgb_from_linear().
Alexandre Julliard
julliard at winehq.org
Mon Aug 19 15:35:12 CDT 2019
Module: wine
Branch: master
Commit: f193979a185be943dd2f5a966803c09a1c4e67b0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=f193979a185be943dd2f5a966803c09a1c4e67b0
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Mon Aug 19 16:42:28 2019 +0430
wined3d: Introduce wined3d_colour_srgb_from_linear().
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wined3d/device.c | 22 ++++------------------
dlls/wined3d/wined3d_private.h | 26 +++++++++++++++++++++++---
2 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 81a6d3a..7f1a98f 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -291,7 +291,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
struct wined3d_context_gl *context_gl;
struct wined3d_texture *target = NULL;
UINT drawable_width, drawable_height;
- struct wined3d_color corrected_color;
+ struct wined3d_color colour_srgb;
struct wined3d_context *context;
GLbitfield clear_mask = 0;
BOOL render_offscreen;
@@ -430,25 +430,11 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
if (!gl_info->supported[ARB_FRAMEBUFFER_SRGB] && needs_srgb_write(context, state, fb))
{
if (rt_count > 1)
- WARN("Clearing multiple sRGB render targets with no GL_ARB_framebuffer_sRGB "
+ WARN("Clearing multiple sRGB render targets without GL_ARB_framebuffer_sRGB "
"support, this might cause graphical issues.\n");
- corrected_color.r = color->r < wined3d_srgb_const1[0]
- ? color->r * wined3d_srgb_const0[3]
- : pow(color->r, wined3d_srgb_const0[0]) * wined3d_srgb_const0[1]
- - wined3d_srgb_const0[2];
- corrected_color.r = min(max(corrected_color.r, 0.0f), 1.0f);
- corrected_color.g = color->g < wined3d_srgb_const1[0]
- ? color->g * wined3d_srgb_const0[3]
- : pow(color->g, wined3d_srgb_const0[0]) * wined3d_srgb_const0[1]
- - wined3d_srgb_const0[2];
- corrected_color.g = min(max(corrected_color.g, 0.0f), 1.0f);
- corrected_color.b = color->b < wined3d_srgb_const1[0]
- ? color->b * wined3d_srgb_const0[3]
- : pow(color->b, wined3d_srgb_const0[0]) * wined3d_srgb_const0[1]
- - wined3d_srgb_const0[2];
- corrected_color.b = min(max(corrected_color.b, 0.0f), 1.0f);
- color = &corrected_color;
+ wined3d_colour_srgb_from_linear(&colour_srgb, color);
+ color = &colour_srgb;
}
gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 71e4d71..68250f0 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1482,6 +1482,29 @@ static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_col
wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f;
}
+extern const float wined3d_srgb_const0[] DECLSPEC_HIDDEN;
+extern const float wined3d_srgb_const1[] DECLSPEC_HIDDEN;
+
+static inline float wined3d_srgb_from_linear(float colour)
+{
+ if (colour < 0.0f)
+ return 0.0f;
+ if (colour < wined3d_srgb_const1[0])
+ return colour * wined3d_srgb_const0[3];
+ if (colour < 1.0f)
+ return wined3d_srgb_const0[1] * powf(colour, wined3d_srgb_const0[0]) - wined3d_srgb_const0[2];
+ return 1.0f;
+}
+
+static inline void wined3d_colour_srgb_from_linear(struct wined3d_color *colour_srgb,
+ const struct wined3d_color *colour)
+{
+ colour_srgb->r = wined3d_srgb_from_linear(colour->r);
+ colour_srgb->g = wined3d_srgb_from_linear(colour->g);
+ colour_srgb->b = wined3d_srgb_from_linear(colour->b);
+ colour_srgb->a = colour->a;
+}
+
#define WINED3D_HIGHEST_TRANSFORM_STATE WINED3D_TS_WORLD_MATRIX(255) /* Highest value in wined3d_transform_state. */
void wined3d_check_gl_call(const struct wined3d_gl_info *gl_info,
@@ -2978,9 +3001,6 @@ const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *frag
void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc) DECLSPEC_HIDDEN;
void wined3d_ftoa(float value, char *s) DECLSPEC_HIDDEN;
-extern const float wined3d_srgb_const0[] DECLSPEC_HIDDEN;
-extern const float wined3d_srgb_const1[] DECLSPEC_HIDDEN;
-
enum wined3d_ffp_vs_fog_mode
{
WINED3D_FFP_VS_FOG_OFF = 0,
More information about the wine-cvs
mailing list