From 02008a6f2e373ba4ff06deb8ca124ecd65b57227 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 8 Feb 2016 18:32:01 +0100 Subject: [PATCH] wined3d: Introduce wined3d_texture_update_overlay(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/ddraw/surface.c | 22 ++++++++----- dlls/wined3d/surface.c | 47 ---------------------------- dlls/wined3d/texture.c | 65 +++++++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d.spec | 2 +- include/wine/wined3d.h | 5 +-- 5 files changed, 84 insertions(+), 57 deletions(-) diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index e918f251290..9b7d76e6ee6 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -3691,22 +3691,30 @@ static HRESULT WINAPI ddraw_surface1_SetOverlayPosition(IDirectDrawSurface *ifac * DDERR_UNSUPPORTED, because we don't support overlays * *****************************************************************************/ -static HRESULT WINAPI ddraw_surface7_UpdateOverlay(IDirectDrawSurface7 *iface, RECT *SrcRect, - IDirectDrawSurface7 *DstSurface, RECT *DstRect, DWORD Flags, DDOVERLAYFX *FX) +static HRESULT WINAPI ddraw_surface7_UpdateOverlay(IDirectDrawSurface7 *iface, RECT *src_rect, + IDirectDrawSurface7 *dst_surface, RECT *dst_rect, DWORD flags, DDOVERLAYFX *fx) { struct ddraw_surface *src_impl = impl_from_IDirectDrawSurface7(iface); - struct ddraw_surface *dst_impl = unsafe_impl_from_IDirectDrawSurface7(DstSurface); + struct ddraw_surface *dst_impl = unsafe_impl_from_IDirectDrawSurface7(dst_surface); + struct wined3d_texture *dst_wined3d_texture = NULL; + unsigned int dst_sub_resource_idx = 0; HRESULT hr; TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n", - iface, wine_dbgstr_rect(SrcRect), DstSurface, wine_dbgstr_rect(DstRect), Flags, FX); + iface, wine_dbgstr_rect(src_rect), dst_surface, wine_dbgstr_rect(dst_rect), flags, fx); wined3d_mutex_lock(); - hr = wined3d_surface_update_overlay(src_impl->wined3d_surface, SrcRect, - dst_impl ? dst_impl->wined3d_surface : NULL, DstRect, Flags, (WINEDDOVERLAYFX *)FX); + if (dst_impl) + { + dst_wined3d_texture = dst_impl->wined3d_texture; + dst_sub_resource_idx = dst_impl->sub_resource_idx; + } + hr = wined3d_texture_update_overlay(src_impl->wined3d_texture, src_impl->sub_resource_idx, src_rect, + dst_wined3d_texture, dst_sub_resource_idx, dst_rect, flags, (WINEDDOVERLAYFX *)fx); wined3d_mutex_unlock(); - switch(hr) { + switch (hr) + { case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS; case WINEDDERR_NOTAOVERLAYSURFACE: return DDERR_NOTAOVERLAYSURFACE; case WINEDDERR_OVERLAYNOTVISIBLE: return DDERR_OVERLAYNOTVISIBLE; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index e36e353b58f..53f4d09a10f 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1923,53 +1923,6 @@ HRESULT CDECL wined3d_surface_update_overlay_z_order(struct wined3d_surface *sur return WINED3D_OK; } -HRESULT CDECL wined3d_surface_update_overlay(struct wined3d_surface *surface, const RECT *src_rect, - struct wined3d_surface *dst_surface, const RECT *dst_rect, DWORD flags, const WINEDDOVERLAYFX *fx) -{ - TRACE("surface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n", - surface, wine_dbgstr_rect(src_rect), dst_surface, wine_dbgstr_rect(dst_rect), flags, fx); - - if (!(surface->resource.usage & WINED3DUSAGE_OVERLAY)) - { - WARN("Not an overlay surface.\n"); - return WINEDDERR_NOTAOVERLAYSURFACE; - } - else if (!dst_surface) - { - WARN("Dest surface is NULL.\n"); - return WINED3DERR_INVALIDCALL; - } - - surface_get_rect(surface, src_rect, &surface->overlay_srcrect); - surface_get_rect(dst_surface, dst_rect, &surface->overlay_destrect); - - if (surface->overlay_dest && (surface->overlay_dest != dst_surface || flags & WINEDDOVER_HIDE)) - { - surface->overlay_dest = NULL; - list_remove(&surface->overlay_entry); - } - - if (flags & WINEDDOVER_SHOW) - { - if (surface->overlay_dest != dst_surface) - { - surface->overlay_dest = dst_surface; - list_add_tail(&dst_surface->overlays, &surface->overlay_entry); - } - } - else if (flags & WINEDDOVER_HIDE) - { - /* tests show that the rectangles are erased on hide */ - surface->overlay_srcrect.left = 0; surface->overlay_srcrect.top = 0; - surface->overlay_srcrect.right = 0; surface->overlay_srcrect.bottom = 0; - surface->overlay_destrect.left = 0; surface->overlay_destrect.top = 0; - surface->overlay_destrect.right = 0; surface->overlay_destrect.bottom = 0; - surface->overlay_dest = NULL; - } - - return WINED3D_OK; -} - HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info, void *mem, unsigned int pitch) { diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 54c5a528a99..0c48c91a5d2 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1402,6 +1402,71 @@ HRESULT CDECL wined3d_texture_set_overlay_position(struct wined3d_texture *textu return WINED3D_OK; } +HRESULT CDECL wined3d_texture_update_overlay(struct wined3d_texture *texture, unsigned int sub_resource_idx, + const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, + const RECT *dst_rect, DWORD flags, const WINEDDOVERLAYFX *fx) +{ + struct wined3d_resource *sub_resource, *dst_sub_resource; + struct wined3d_surface *surface, *dst_surface; + + TRACE("texture %p, sub_resource_idx %u, src_rect %s, dst_texture %p, " + "dst_sub_resource_idx %u, dst_rect %s, flags %#x, fx %p.\n", + texture, sub_resource_idx, wine_dbgstr_rect(src_rect), dst_texture, + dst_sub_resource_idx, wine_dbgstr_rect(dst_rect), flags, fx); + + if (!(texture->resource.usage & WINED3DUSAGE_OVERLAY) || texture->resource.type != WINED3D_RTYPE_TEXTURE_2D + || !(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx))) + { + WARN("Invalid sub-resource specified.\n"); + return WINEDDERR_NOTAOVERLAYSURFACE; + } + + if (!dst_texture || dst_texture->resource.type != WINED3D_RTYPE_TEXTURE_2D + || !(dst_sub_resource = wined3d_texture_get_sub_resource(dst_texture, dst_sub_resource_idx))) + { + WARN("Invalid destination sub-resource specified.\n"); + return WINED3DERR_INVALIDCALL; + } + + surface = surface_from_resource(sub_resource); + if (src_rect) + surface->overlay_srcrect = *src_rect; + else + SetRect(&surface->overlay_srcrect, 0, 0, surface->resource.width, surface->resource.height); + + dst_surface = surface_from_resource(dst_sub_resource); + if (dst_rect) + surface->overlay_destrect = *dst_rect; + else + SetRect(&surface->overlay_destrect, 0, 0, dst_surface->resource.width, dst_surface->resource.height); + + if (surface->overlay_dest && (surface->overlay_dest != dst_surface || flags & WINEDDOVER_HIDE)) + { + surface->overlay_dest = NULL; + list_remove(&surface->overlay_entry); + } + + if (flags & WINEDDOVER_SHOW) + { + if (surface->overlay_dest != dst_surface) + { + surface->overlay_dest = dst_surface; + list_add_tail(&dst_surface->overlays, &surface->overlay_entry); + } + } + else if (flags & WINEDDOVER_HIDE) + { + /* Tests show that the rectangles are erased on hide. */ + surface->overlay_srcrect.left = 0; surface->overlay_srcrect.top = 0; + surface->overlay_srcrect.right = 0; surface->overlay_srcrect.bottom = 0; + surface->overlay_destrect.left = 0; surface->overlay_destrect.top = 0; + surface->overlay_destrect.right = 0; surface->overlay_destrect.bottom = 0; + surface->overlay_dest = NULL; + } + + return WINED3D_OK; +} + HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct wined3d_resource_desc *desc, UINT level_count, DWORD flags, const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture) diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 4ec8336f00b..53eb97a4694 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -224,7 +224,6 @@ @ cdecl wined3d_surface_get_parent(ptr) @ cdecl wined3d_surface_get_pitch(ptr) -@ cdecl wined3d_surface_update_overlay(ptr ptr ptr ptr long ptr) @ cdecl wined3d_surface_update_overlay_z_order(ptr long ptr) @ cdecl wined3d_swapchain_create(ptr ptr ptr ptr ptr) @@ -265,6 +264,7 @@ @ cdecl wined3d_texture_set_lod(ptr long) @ cdecl wined3d_texture_set_overlay_position(ptr long long long) @ cdecl wined3d_texture_update_desc(ptr long long long long long ptr long) +@ cdecl wined3d_texture_update_overlay(ptr long ptr ptr long ptr long ptr) @ cdecl wined3d_vertex_declaration_create(ptr ptr long ptr ptr ptr) @ cdecl wined3d_vertex_declaration_create_from_fvf(ptr long ptr ptr ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index afe28beb570..40f3d49df2b 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2477,8 +2477,6 @@ ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock); void * __cdecl wined3d_surface_get_parent(const struct wined3d_surface *surface); DWORD __cdecl wined3d_surface_get_pitch(const struct wined3d_surface *surface); -HRESULT __cdecl wined3d_surface_update_overlay(struct wined3d_surface *surface, const RECT *src_rect, - struct wined3d_surface *dst_surface, const RECT *dst_rect, DWORD flags, const WINEDDOVERLAYFX *fx); HRESULT __cdecl wined3d_surface_update_overlay_z_order(struct wined3d_surface *surface, DWORD flags, struct wined3d_surface *ref); @@ -2545,6 +2543,9 @@ HRESULT __cdecl wined3d_texture_update_desc(struct wined3d_texture *texture, UINT width, UINT height, enum wined3d_format_id format_id, enum wined3d_multisample_type multisample_type, UINT multisample_quality, void *mem, UINT pitch); +HRESULT __cdecl wined3d_texture_update_overlay(struct wined3d_texture *texture, unsigned int sub_resource_idx, + const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, + const RECT *dst_rect, DWORD flags, const WINEDDOVERLAYFX *fx); HRESULT __cdecl wined3d_vertex_declaration_create(struct wined3d_device *device, const struct wined3d_vertex_element *elements, UINT element_count, void *parent,