From 2c71b853345b07ccc4ae476a212ed32040ce7314 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 24 Jul 2009 10:44:15 +0200 Subject: [PATCH] wined3d: Explicitly pass the context to get_drawable_size(). --- dlls/wined3d/device.c | 40 ++++++++++++++++++---------------- dlls/wined3d/state.c | 4 ++-- dlls/wined3d/swapchain.c | 11 +++++----- dlls/wined3d/wined3d_private.h | 10 ++++----- 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 6edb39e7a09..aa16d9e7be5 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4888,6 +4888,7 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfa UINT drawable_width, drawable_height; IWineD3DSurfaceImpl *depth_stencil = (IWineD3DSurfaceImpl *) This->stencilBufferTarget; IWineD3DSwapChainImpl *swapchain = NULL; + struct WineD3DContext *context; /* When we're clearing parts of the drawable, make sure that the target surface is well up to date in the * drawable. After the clear we'll mark the drawable up to date, so we have to make sure that this is true @@ -4923,9 +4924,9 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfa } } - ActivateContext(This, (IWineD3DSurface *)target, CTXUSAGE_CLEAR); + context = ActivateContext(This, (IWineD3DSurface *)target, CTXUSAGE_CLEAR); - target->get_drawable_size(target, &drawable_width, &drawable_height); + target->get_drawable_size(context, &drawable_width, &drawable_height); ENTER_GL(); @@ -7695,28 +7696,29 @@ void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) { } } -void get_drawable_size_pbuffer(IWineD3DSurfaceImpl *This, UINT *width, UINT *height) { - IWineD3DDeviceImpl *dev = This->resource.wineD3DDevice; - /* The drawable size of a pbuffer render target is the current pbuffer size - */ - *width = dev->pbufferWidth; - *height = dev->pbufferHeight; +void get_drawable_size_pbuffer(struct WineD3DContext *context, UINT *width, UINT *height) +{ + IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->current_rt)->resource.wineD3DDevice; + /* The drawable size of a pbuffer render target is the current pbuffer size. */ + *width = device->pbufferWidth; + *height = device->pbufferHeight; } -void get_drawable_size_fbo(IWineD3DSurfaceImpl *This, UINT *width, UINT *height) { - /* The drawable size of a fbo target is the opengl texture size, which is the power of two size - */ - *width = This->pow2Width; - *height = This->pow2Height; +void get_drawable_size_fbo(struct WineD3DContext *context, UINT *width, UINT *height) +{ + IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)context->current_rt; + /* The drawable size of a fbo target is the opengl texture size, which is the power of two size. */ + *width = surface->pow2Width; + *height = surface->pow2Height; } -void get_drawable_size_backbuffer(IWineD3DSurfaceImpl *This, UINT *width, UINT *height) { - IWineD3DDeviceImpl *dev = This->resource.wineD3DDevice; +void get_drawable_size_backbuffer(struct WineD3DContext *context, UINT *width, UINT *height) +{ + IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)context->surface; /* The drawable size of a backbuffer / aux buffer offscreen target is the size of the * current context's drawable, which is the size of the back buffer of the swapchain * the active context belongs to. The back buffer of the swapchain is stored as the - * surface the context belongs to. - */ - *width = ((IWineD3DSurfaceImpl *) dev->activeContext->surface)->currentDesc.Width; - *height = ((IWineD3DSurfaceImpl *) dev->activeContext->surface)->currentDesc.Height; + * surface the context belongs to. */ + *width = surface->currentDesc.Width; + *height = surface->currentDesc.Height; } diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index e4de1cf761f..44c0c064b81 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -4532,7 +4532,7 @@ static void viewport_miscpart(DWORD state, IWineD3DStateBlockImpl *stateblock, W stateblock->viewport.Width, stateblock->viewport.Height); } else { target = (IWineD3DSurfaceImpl *) stateblock->wineD3DDevice->render_targets[0]; - target->get_drawable_size(target, &width, &height); + target->get_drawable_size(context, &width, &height); glViewport(stateblock->viewport.X, (height - (stateblock->viewport.Y + stateblock->viewport.Height)), @@ -4674,7 +4674,7 @@ static void scissorrect(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D UINT width; IWineD3DSurfaceImpl *target = (IWineD3DSurfaceImpl *) stateblock->wineD3DDevice->render_targets[0]; - target->get_drawable_size(target, &width, &height); + target->get_drawable_size(context, &width, &height); /* Warning: glScissor uses window coordinates, not viewport coordinates, so our viewport correction does not apply * Warning2: Even in windowed mode the coords are relative to the window, not the screen */ diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 683640aa4cf..0994c6d8a69 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -402,10 +402,11 @@ WineD3DContext *IWineD3DSwapChainImpl_CreateContextForThread(IWineD3DSwapChain * return ctx; } -void get_drawable_size_swapchain(IWineD3DSurfaceImpl *This, UINT *width, UINT *height) { +void get_drawable_size_swapchain(struct WineD3DContext *context, UINT *width, UINT *height) +{ + IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)context->surface; /* The drawable size of an onscreen drawable is the surface size. - * (Actually: The window size, but the surface is created in window size) - */ - *width = This->currentDesc.Width; - *height = This->currentDesc.Height; + * (Actually: The window size, but the surface is created in window size) */ + *width = surface->currentDesc.Width; + *height = surface->currentDesc.Height; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index be2811b1abf..545c33c66da 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1957,7 +1957,7 @@ struct IWineD3DSurfaceImpl UINT pow2Height; /* A method to retrieve the drawable size. Not in the Vtable to make it changeable */ - void (*get_drawable_size)(IWineD3DSurfaceImpl *This, UINT *width, UINT *height); + void (*get_drawable_size)(struct WineD3DContext *context, UINT *width, UINT *height); /* Oversized texture */ RECT glRect; @@ -2051,10 +2051,10 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DL void WINAPI IWineD3DBaseSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL srgb); const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface); -void get_drawable_size_swapchain(IWineD3DSurfaceImpl *This, UINT *width, UINT *height); -void get_drawable_size_backbuffer(IWineD3DSurfaceImpl *This, UINT *width, UINT *height); -void get_drawable_size_pbuffer(IWineD3DSurfaceImpl *This, UINT *width, UINT *height); -void get_drawable_size_fbo(IWineD3DSurfaceImpl *This, UINT *width, UINT *height); +void get_drawable_size_swapchain(struct WineD3DContext *context, UINT *width, UINT *height); +void get_drawable_size_backbuffer(struct WineD3DContext *context, UINT *width, UINT *height); +void get_drawable_size_pbuffer(struct WineD3DContext *context, UINT *width, UINT *height); +void get_drawable_size_fbo(struct WineD3DContext *context, UINT *width, UINT *height); void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back);