[PATCH 3/5] wined3d: Merge swapchain_base.c into swapchain.c.
Henri Verbeet
hverbeet at codeweavers.com
Thu Apr 7 11:45:59 CDT 2011
---
dlls/wined3d/Makefile.in | 1 -
dlls/wined3d/swapchain.c | 192 ++++++++++++++++++++++++++++++++++++++-
dlls/wined3d/swapchain_base.c | 197 ----------------------------------------
dlls/wined3d/wined3d_private.h | 22 -----
4 files changed, 187 insertions(+), 225 deletions(-)
delete mode 100644 dlls/wined3d/swapchain_base.c
diff --git a/dlls/wined3d/Makefile.in b/dlls/wined3d/Makefile.in
index e3015af..562d0f2 100644
--- a/dlls/wined3d/Makefile.in
+++ b/dlls/wined3d/Makefile.in
@@ -26,7 +26,6 @@ C_SRCS = \
surface_base.c \
surface_gdi.c \
swapchain.c \
- swapchain_base.c \
texture.c \
utils.c \
vertexdeclaration.c \
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index feb0471..1c875bf 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -22,14 +22,196 @@
#include "config.h"
#include "wined3d_private.h"
+WINE_DEFAULT_DEBUG_CHANNEL(d3d);
+WINE_DECLARE_DEBUG_CHANNEL(fps);
-/*TODO: some of the additional parameters may be required to
- set the gamma ramp (for some weird reason microsoft have left swap gammaramp in device
- but it operates on a swapchain, it may be a good idea to move it to IWineD3DSwapChain for IWineD3D)*/
+static HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+ if (IsEqualGUID(riid, &IID_IWineD3DSwapChain)
+ || IsEqualGUID(riid, &IID_IWineD3DBase)
+ || IsEqualGUID(riid, &IID_IUnknown))
+ {
+ IUnknown_AddRef(iface);
+ *object = iface;
+ return S_OK;
+ }
-WINE_DEFAULT_DEBUG_CHANNEL(d3d);
-WINE_DECLARE_DEBUG_CHANNEL(fps);
+ WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
+
+ *object = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface)
+{
+ IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
+ ULONG refcount = InterlockedIncrement(&swapchain->ref);
+
+ TRACE("%p increasing refcount to %u.\n", swapchain, refcount);
+
+ return refcount;
+}
+
+/* Do not call while under the GL lock. */
+static ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface)
+{
+ IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
+ ULONG refcount = InterlockedDecrement(&swapchain->ref);
+
+ TRACE("%p decreasing refcount to %u.\n", swapchain, refcount);
+
+ if (!refcount)
+ IWineD3DSwapChain_Destroy(iface);
+
+ return refcount;
+}
+
+static void * WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ((IWineD3DSwapChainImpl *)iface)->parent;
+}
+
+static HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface,
+ IWineD3DSurface *dst_surface)
+{
+ IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
+ POINT offset = {0, 0};
+
+ TRACE("iface %p, dst_surface %p.\n", iface, dst_surface);
+
+ if (swapchain->presentParms.Windowed)
+ MapWindowPoints(swapchain->win_handle, NULL, &offset, 1);
+
+ IWineD3DSurface_BltFast(dst_surface, offset.x, offset.y,
+ (IWineD3DSurface *)swapchain->front_buffer, NULL, 0);
+
+ return WINED3D_OK;
+}
+
+static HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface,
+ UINT back_buffer_idx, WINED3DBACKBUFFER_TYPE type, IWineD3DSurface **back_buffer)
+{
+ IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
+
+ TRACE("iface %p, back_buffer_idx %u, type %#x, back_buffer %p.\n",
+ iface, back_buffer_idx, type, back_buffer);
+
+ /* Return invalid if there is no backbuffer array, otherwise it will
+ * crash when ddraw is used (there swapchain->back_buffers is always
+ * NULL). We need this because this function is called from
+ * stateblock_init_default_state() to get the default scissorrect
+ * dimensions. */
+ if (!swapchain->back_buffers || back_buffer_idx >= swapchain->presentParms.BackBufferCount)
+ {
+ WARN("Invalid back buffer index.\n");
+ /* Native d3d9 doesn't set NULL here, just as wine's d3d9. But set it
+ * here in wined3d to avoid problems in other libs. */
+ *back_buffer = NULL;
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ *back_buffer = (IWineD3DSurface *)swapchain->back_buffers[back_buffer_idx];
+ if (*back_buffer) IWineD3DSurface_AddRef(*back_buffer);
+
+ TRACE("Returning back buffer %p.\n", *back_buffer);
+
+ return WINED3D_OK;
+}
+
+static HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface,
+ WINED3DRASTER_STATUS *raster_status)
+{
+ static BOOL warned;
+ /* No OpenGL equivalent */
+ if (!warned)
+ {
+ FIXME("iface %p, raster_status %p stub!\n", iface, raster_status);
+ warned = TRUE;
+ }
+
+ /* Obtaining the raster status is a widely implemented but optional
+ * feature. When this method returns OK Starcraft 2 expects the
+ * raster_status->InVBlank value to actually change over time. To prevent
+ * Starcraft 2 from running in an infinite loop at startup this method
+ * returns INVALIDCALL. */
+ return WINED3DERR_INVALIDCALL;
+}
+
+static HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE *mode)
+{
+ IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
+ HRESULT hr;
+
+ TRACE("iface %p, mode %p.\n", iface, mode);
+
+ hr = wined3d_get_adapter_display_mode(swapchain->device->wined3d, swapchain->device->adapter->ordinal, mode);
+
+ TRACE("Returning w %u, h %u, refresh rate %u, format %s.\n",
+ mode->Width, mode->Height, mode->RefreshRate, debug_d3dformat(mode->Format));
+
+ return hr;
+}
+
+static HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice **device)
+{
+ IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
+
+ TRACE("iface %p, device %p.\n", iface, device);
+
+ *device = (IWineD3DDevice *)swapchain->device;
+ IWineD3DDevice_AddRef(*device);
+
+ return WINED3D_OK;
+}
+
+static HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface,
+ WINED3DPRESENT_PARAMETERS *present_parameters)
+{
+ IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
+
+ TRACE("iface %p, present_parameters %p.\n", iface, present_parameters);
+
+ *present_parameters = swapchain->presentParms;
+
+ return WINED3D_OK;
+}
+
+static HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface,
+ DWORD flags, const WINED3DGAMMARAMP *ramp)
+{
+ IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
+ HDC dc;
+
+ TRACE("iface %p, flags %#x, ramp %p.\n", iface, flags, ramp);
+
+ if (flags)
+ FIXME("Ignoring flags %#x.\n", flags);
+
+ dc = GetDC(swapchain->device_window);
+ SetDeviceGammaRamp(dc, (void *)ramp);
+ ReleaseDC(swapchain->device_window, dc);
+
+ return WINED3D_OK;
+}
+
+static HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface,
+ WINED3DGAMMARAMP *ramp)
+{
+ IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
+ HDC dc;
+
+ TRACE("iface %p, ramp %p.\n", iface, ramp);
+
+ dc = GetDC(swapchain->device_window);
+ GetDeviceGammaRamp(dc, ramp);
+ ReleaseDC(swapchain->device_window, dc);
+
+ return WINED3D_OK;
+}
/* Do not call while under the GL lock. */
static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface)
diff --git a/dlls/wined3d/swapchain_base.c b/dlls/wined3d/swapchain_base.c
deleted file mode 100644
index 79d1187..0000000
--- a/dlls/wined3d/swapchain_base.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- *IDirect3DSwapChain9 implementation
- *
- *Copyright 2002-2003 Jason Edmeades
- *Copyright 2002-2003 Raphael Junqueira
- *Copyright 2005 Oliver Stieber
- *Copyright 2007-2008 Stefan Dösinger for CodeWeavers
- *
- *This library is free software; you can redistribute it and/or
- *modify it under the terms of the GNU Lesser General Public
- *License as published by the Free Software Foundation; either
- *version 2.1 of the License, or (at your option) any later version.
- *
- *This library is distributed in the hope that it will be useful,
- *but WITHOUT ANY WARRANTY; without even the implied warranty of
- *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- *Lesser General Public License for more details.
- *
- *You should have received a copy of the GNU Lesser General Public
- *License along with this library; if not, write to the Free Software
- *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "config.h"
-#include "wined3d_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(d3d);
-
-/* IDirect3DSwapChain IUnknown parts follow: */
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, REFIID riid, void **object)
-{
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
-
- if (IsEqualGUID(riid, &IID_IWineD3DSwapChain)
- || IsEqualGUID(riid, &IID_IWineD3DBase)
- || IsEqualGUID(riid, &IID_IUnknown))
- {
- IUnknown_AddRef(iface);
- *object = iface;
- return S_OK;
- }
-
- WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
-
- *object = NULL;
- return E_NOINTERFACE;
-}
-
-ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface) {
- IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
- DWORD refCount = InterlockedIncrement(&This->ref);
- TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
- return refCount;
-}
-
-/* Do not call while under the GL lock. */
-ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface)
-{
- IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
- DWORD refCount;
- refCount = InterlockedDecrement(&This->ref);
- TRACE("(%p) : ReleaseRef to %d\n", This, refCount);
-
- if (!refCount) IWineD3DSwapChain_Destroy(iface);
-
- return refCount;
-}
-
-void * WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface)
-{
- TRACE("iface %p.\n", iface);
-
- return ((IWineD3DSwapChainImpl *)iface)->parent;
-}
-
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface, IWineD3DSurface *dst_surface)
-{
- IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
- POINT start;
-
- TRACE("iface %p, dst_surface %p.\n", iface, dst_surface);
-
- start.x = 0;
- start.y = 0;
-
- if (This->presentParms.Windowed) {
- MapWindowPoints(This->win_handle, NULL, &start, 1);
- }
-
- IWineD3DSurface_BltFast(dst_surface, start.x, start.y, (IWineD3DSurface *)This->front_buffer, NULL, 0);
- return WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface,
- UINT back_buffer_idx, WINED3DBACKBUFFER_TYPE type, IWineD3DSurface **back_buffer)
-{
- IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
-
- TRACE("iface %p, back_buffer_idx %u, type %#x, back_buffer %p.\n",
- iface, back_buffer_idx, type, back_buffer);
-
- /* Return invalid if there is no backbuffer array, otherwise it will
- * crash when ddraw is used (there swapchain->back_buffers is always
- * NULL). We need this because this function is called from
- * stateblock_init_default_state() to get the default scissorrect
- * dimensions. */
- if (!swapchain->back_buffers || back_buffer_idx >= swapchain->presentParms.BackBufferCount)
- {
- WARN("Invalid back buffer index.\n");
- /* Native d3d9 doesn't set NULL here, just as wine's d3d9. But set it
- * here in wined3d to avoid problems in other libs. */
- *back_buffer = NULL;
- return WINED3DERR_INVALIDCALL;
- }
-
- *back_buffer = (IWineD3DSurface *)swapchain->back_buffers[back_buffer_idx];
- if (*back_buffer) IWineD3DSurface_AddRef(*back_buffer);
-
- TRACE("Returning back buffer %p.\n", *back_buffer);
-
- return WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, WINED3DRASTER_STATUS *pRasterStatus) {
- static BOOL warned;
- /* No OpenGL equivalent */
- if (!warned)
- {
- FIXME("iface %p, raster_status %p stub!\n", iface, pRasterStatus);
- warned = TRUE;
- }
- /* Obtaining the raster status is a widely implemented but optional feature.
- * When this method returns OK then the application Starcraft 2 expects that
- * the pRasterStatus->InVBlank value differs over time. To prevent Starcraft 2
- * from running in an infinite loop at startup this method returns INVALIDCALL.
- */
- return WINED3DERR_INVALIDCALL;
-}
-
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE*pMode) {
- IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
- HRESULT hr;
-
- TRACE("(%p)->(%p): Calling GetAdapterDisplayMode\n", This, pMode);
- hr = wined3d_get_adapter_display_mode(This->device->wined3d, This->device->adapter->ordinal, pMode);
-
- TRACE("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate,
- pMode->Format, debug_d3dformat(pMode->Format));
- return hr;
-}
-
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice **device)
-{
- IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
-
- *device = (IWineD3DDevice *)This->device;
- IWineD3DDevice_AddRef(*device);
-
- TRACE("(%p) : returning %p\n", This, *device);
- return WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface, WINED3DPRESENT_PARAMETERS *pPresentationParameters) {
- IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
- TRACE("(%p)\n", This);
-
- *pPresentationParameters = This->presentParms;
-
- return WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface,
- DWORD flags, const WINED3DGAMMARAMP *pRamp)
-{
- IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
- HDC hDC;
-
- TRACE("iface %p, flags %#x, ramp %p.\n", iface, flags, pRamp);
-
- hDC = GetDC(This->device_window);
- SetDeviceGammaRamp(hDC, (LPVOID)pRamp);
- ReleaseDC(This->device_window, hDC);
- return WINED3D_OK;
-
-}
-
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface, WINED3DGAMMARAMP *pRamp){
-
- IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
- HDC hDC;
- TRACE("(%p) : pRamp@%p\n", This, pRamp);
- hDC = GetDC(This->device_window);
- GetDeviceGammaRamp(hDC, pRamp);
- ReleaseDC(This->device_window, hDC);
- return WINED3D_OK;
-
-}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index cb56ce4..37344b8 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2554,28 +2554,6 @@ struct IWineD3DSwapChainImpl
void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface,
- REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
-ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
-ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
-void * WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface,
- IWineD3DSurface *dst_surface) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer,
- WINED3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface,
- WINED3DRASTER_STATUS *pRasterStatus) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface,
- WINED3DDISPLAYMODE *pMode) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDevice(IWineD3DSwapChain *iface,
- IWineD3DDevice **device) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface,
- WINED3DPRESENT_PARAMETERS *pPresentationParameters) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface,
- DWORD flags, const WINED3DGAMMARAMP *pRamp) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface,
- WINED3DGAMMARAMP *pRamp) DECLSPEC_HIDDEN;
-
struct wined3d_context *swapchain_get_context(struct IWineD3DSwapChainImpl *swapchain) DECLSPEC_HIDDEN;
HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface_type,
IWineD3DDeviceImpl *device, WINED3DPRESENT_PARAMETERS *present_parameters, void *parent) DECLSPEC_HIDDEN;
--
1.7.3.4
More information about the wine-patches
mailing list