Module: wine Branch: master Commit: a215d326a59415745fd6ba31deb2f2a0a0920788 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a215d326a59415745fd6ba31de...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Tue Dec 15 17:51:36 2009 +0100
wined3d: Get rid of the "swapchain" parameter to surface_get_gl_buffer().
Casting the container to "IWineD3DSwapChainImpl *" is always safe when SFLAG_SWAPCHAIN is set on the surface. Most callers don't have a real need for the swapchain, and end up calling GetContainer() just to pass it to surface_get_gl_buffer().
---
dlls/wined3d/context.c | 2 +- dlls/wined3d/device.c | 14 ++++++------ dlls/wined3d/surface.c | 47 +++++++++++++++++++++++++-------------- dlls/wined3d/wined3d_private.h | 2 +- 4 files changed, 39 insertions(+), 26 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index f923a6f..2f27997 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -2061,7 +2061,7 @@ static void context_apply_draw_buffer(struct wined3d_context *context, BOOL blit if (!surface_is_offscreen(rt)) { ENTER_GL(); - glDrawBuffer(surface_get_gl_buffer(rt, (IWineD3DSwapChain *)((IWineD3DSurfaceImpl *)rt)->container)); + glDrawBuffer(surface_get_gl_buffer(rt)); checkGLcall("glDrawBuffers()"); LEAVE_GL(); } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index a55f3e6..8e97fb7 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5304,9 +5304,7 @@ static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface, { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; struct wined3d_context *context; - IWineD3DSwapChain *swapchain;
- swapchain = get_swapchain(surface); if (!surface_is_offscreen(surface)) { TRACE("Surface %p is onscreen\n", surface); @@ -5314,7 +5312,7 @@ static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface, context = context_acquire(This, surface, CTXUSAGE_RESOURCELOAD); ENTER_GL(); context_bind_fbo(context, GL_FRAMEBUFFER, NULL); - context_set_draw_buffer(context, surface_get_gl_buffer(surface, swapchain)); + context_set_draw_buffer(context, surface_get_gl_buffer(surface)); } else { @@ -5712,8 +5710,9 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
gl_info = context->gl_info;
- if (!surface_is_offscreen(src_surface)) { - GLenum buffer = surface_get_gl_buffer(src_surface, src_swapchain); + if (!surface_is_offscreen(src_surface)) + { + GLenum buffer = surface_get_gl_buffer(src_surface);
TRACE("Source surface %p is onscreen\n", src_surface); /* Make sure the drawable is up to date. In the offscreen case @@ -5750,8 +5749,9 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED LEAVE_GL();
/* Attach dst surface to dst fbo */ - if (!surface_is_offscreen(dst_surface)) { - GLenum buffer = surface_get_gl_buffer(dst_surface, dst_swapchain); + if (!surface_is_offscreen(dst_surface)) + { + GLenum buffer = surface_get_gl_buffer(dst_surface);
TRACE("Destination surface %p is onscreen\n", dst_surface); /* Make sure the drawable is up to date. In the offscreen case diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 1f8d8a7..f956927 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -661,20 +661,31 @@ void surface_set_compatible_renderbuffer(IWineD3DSurface *iface, unsigned int wi checkGLcall("set_compatible_renderbuffer"); }
-GLenum surface_get_gl_buffer(IWineD3DSurface *iface, IWineD3DSwapChain *swapchain) { +GLenum surface_get_gl_buffer(IWineD3DSurface *iface) +{ IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; - IWineD3DSwapChainImpl *swapchain_impl = (IWineD3DSwapChainImpl *)swapchain; + IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)This->container;
- TRACE("(%p) : swapchain %p\n", This, swapchain); + TRACE("iface %p.\n", iface);
- if (swapchain_impl->backBuffer && swapchain_impl->backBuffer[0] == iface) { - if(swapchain_impl->render_to_fbo) { + if (!(This->Flags & SFLAG_SWAPCHAIN)) + { + ERR("Surface %p is not on a swapchain.\n", iface); + return GL_NONE; + } + + if (swapchain->backBuffer && swapchain->backBuffer[0] == iface) + { + if (swapchain->render_to_fbo) + { TRACE("Returning GL_COLOR_ATTACHMENT0\n"); return GL_COLOR_ATTACHMENT0; } TRACE("Returning GL_BACK\n"); return GL_BACK; - } else if (swapchain_impl->frontBuffer == iface) { + } + else if (swapchain->frontBuffer == iface) + { TRACE("Returning GL_FRONT\n"); return GL_FRONT; } @@ -975,7 +986,7 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v else { /* Onscreen surfaces are always part of a swapchain */ - GLenum buffer = surface_get_gl_buffer((IWineD3DSurface *) This, (IWineD3DSwapChain *) This->container); + GLenum buffer = surface_get_gl_buffer((IWineD3DSurface *)This); TRACE("Locking %#x buffer\n", buffer); glReadBuffer(buffer); checkGLcall("glReadBuffer"); @@ -1198,7 +1209,7 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This, BOOL srgb) */ if (!surface_is_offscreen((IWineD3DSurface *)This)) { - GLenum buffer = surface_get_gl_buffer((IWineD3DSurface *)This, (IWineD3DSwapChain *)This->container); + GLenum buffer = surface_get_gl_buffer((IWineD3DSurface *)This); TRACE("Locking %#x buffer\n", buffer);
ENTER_GL(); @@ -1433,7 +1444,7 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, GLenum fm
if (!surface_is_offscreen((IWineD3DSurface *)This)) { - GLenum buffer = surface_get_gl_buffer((IWineD3DSurface *)This, (IWineD3DSwapChain *)This->container); + GLenum buffer = surface_get_gl_buffer((IWineD3DSurface *)This); TRACE("Unlocking %#x buffer.\n", buffer); context_set_draw_buffer(context, buffer); } @@ -3100,8 +3111,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_Flip(IWineD3DSurface *iface, IWineD3DS * with single pixel copy calls */ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface, - IWineD3DSwapChainImpl *swapchain, const WINED3DRECT *srect, const WINED3DRECT *drect, - BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter) + const WINED3DRECT *srect, const WINED3DRECT *drect, BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter) { IWineD3DDeviceImpl *myDevice = This->resource.device; float xrel, yrel; @@ -3121,9 +3131,10 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D TRACE("Reading from an offscreen target\n"); upsidedown = !upsidedown; glReadBuffer(myDevice->offscreenBuffer); - } else { - GLenum buffer = surface_get_gl_buffer(SrcSurface, (IWineD3DSwapChain *)swapchain); - glReadBuffer(buffer); + } + else + { + glReadBuffer(surface_get_gl_buffer(SrcSurface)); } checkGLcall("glReadBuffer");
@@ -3263,8 +3274,10 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine TRACE("Reading from an offscreen target\n"); upsidedown = !upsidedown; glReadBuffer(myDevice->offscreenBuffer); - } else { - glReadBuffer(surface_get_gl_buffer(SrcSurface, (IWineD3DSwapChain *)swapchain)); + } + else + { + glReadBuffer(surface_get_gl_buffer(SrcSurface)); }
/* TODO: Only back up the part that will be overwritten */ @@ -3697,7 +3710,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const } else if((!stretchx) || rect.x2 - rect.x1 > Src->currentDesc.Width || rect.y2 - rect.y1 > Src->currentDesc.Height) { TRACE("No stretching in x direction, using direct framebuffer -> texture copy\n"); - fb_copy_to_texture_direct(This, SrcSurface, srcSwapchain, &srect, &rect, upsideDown, Filter); + fb_copy_to_texture_direct(This, SrcSurface, &srect, &rect, upsideDown, Filter); } else { TRACE("Using hardware stretching to flip / stretch the texture\n"); fb_copy_to_texture_hwstretch(This, SrcSurface, srcSwapchain, &srect, &rect, upsideDown, Filter); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 1834c77..b74868d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2517,7 +2517,7 @@ void state_fog_fragpart(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) DECLSPEC_HIDDEN;
void surface_add_dirty_rect(IWineD3DSurface *iface, const RECT *dirty_rect) DECLSPEC_HIDDEN; -GLenum surface_get_gl_buffer(IWineD3DSurface *iface, IWineD3DSwapChain *swapchain) DECLSPEC_HIDDEN; +GLenum surface_get_gl_buffer(IWineD3DSurface *iface) DECLSPEC_HIDDEN; void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN; void surface_modify_ds_location(IWineD3DSurface *iface, DWORD location) DECLSPEC_HIDDEN; void surface_set_compatible_renderbuffer(IWineD3DSurface *iface,