~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/d3d8/swapchain.c

Version: ~ [ wine-1.5.31 ] ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * IDirect3DSwapChain8 implementation
  3  *
  4  * Copyright 2005 Oliver Stieber
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include "config.h"
 22 #include "d3d8_private.h"
 23 
 24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
 25 
 26 static inline struct d3d8_swapchain *impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface)
 27 {
 28     return CONTAINING_RECORD(iface, struct d3d8_swapchain, IDirect3DSwapChain8_iface);
 29 }
 30 
 31 static HRESULT WINAPI d3d8_swapchain_QueryInterface(IDirect3DSwapChain8 *iface, REFIID riid, void **out)
 32 {
 33     TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
 34 
 35     if (IsEqualGUID(riid, &IID_IDirect3DSwapChain8)
 36             || IsEqualGUID(riid, &IID_IUnknown))
 37     {
 38         IUnknown_AddRef(iface);
 39         *out = iface;
 40         return S_OK;
 41     }
 42 
 43     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
 44 
 45     *out = NULL;
 46     return E_NOINTERFACE;
 47 }
 48 
 49 static ULONG WINAPI d3d8_swapchain_AddRef(IDirect3DSwapChain8 *iface)
 50 {
 51     struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
 52     ULONG ref = InterlockedIncrement(&swapchain->refcount);
 53 
 54     TRACE("%p increasing refcount to %u.\n", iface, ref);
 55 
 56     if (ref == 1)
 57     {
 58         if (swapchain->parent_device)
 59             IDirect3DDevice8_AddRef(swapchain->parent_device);
 60         wined3d_mutex_lock();
 61         wined3d_swapchain_incref(swapchain->wined3d_swapchain);
 62         wined3d_mutex_unlock();
 63     }
 64 
 65     return ref;
 66 }
 67 
 68 static ULONG WINAPI d3d8_swapchain_Release(IDirect3DSwapChain8 *iface)
 69 {
 70     struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
 71     ULONG ref = InterlockedDecrement(&swapchain->refcount);
 72 
 73     TRACE("%p decreasing refcount to %u.\n", iface, ref);
 74 
 75     if (!ref)
 76     {
 77         IDirect3DDevice8 *parent_device = swapchain->parent_device;
 78 
 79         wined3d_mutex_lock();
 80         wined3d_swapchain_decref(swapchain->wined3d_swapchain);
 81         wined3d_mutex_unlock();
 82 
 83         if (parent_device)
 84             IDirect3DDevice8_Release(parent_device);
 85     }
 86     return ref;
 87 }
 88 
 89 static HRESULT WINAPI d3d8_swapchain_Present(IDirect3DSwapChain8 *iface,
 90         const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override,
 91         const RGNDATA *dirty_region)
 92 {
 93     struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
 94     HRESULT hr;
 95 
 96     TRACE("iface %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p.\n",
 97             iface, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect), dst_window_override, dirty_region);
 98 
 99     wined3d_mutex_lock();
100     hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, src_rect,
101             dst_rect, dst_window_override, dirty_region, 0);
102     wined3d_mutex_unlock();
103 
104     return hr;
105 }
106 
107 static HRESULT WINAPI d3d8_swapchain_GetBackBuffer(IDirect3DSwapChain8 *iface,
108         UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface8 **backbuffer)
109 {
110     struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
111     struct wined3d_surface *wined3d_surface = NULL;
112     struct d3d8_surface *surface_impl;
113     HRESULT hr;
114 
115     TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
116             iface, backbuffer_idx, backbuffer_type, backbuffer);
117 
118     wined3d_mutex_lock();
119     hr = wined3d_swapchain_get_back_buffer(swapchain->wined3d_swapchain,
120             backbuffer_idx, (enum wined3d_backbuffer_type)backbuffer_type, &wined3d_surface);
121     if (SUCCEEDED(hr) && wined3d_surface)
122     {
123         surface_impl = wined3d_surface_get_parent(wined3d_surface);
124         *backbuffer = &surface_impl->IDirect3DSurface8_iface;
125         IDirect3DSurface8_AddRef(*backbuffer);
126         wined3d_surface_decref(wined3d_surface);
127     }
128     wined3d_mutex_unlock();
129 
130     return hr;
131 }
132 
133 static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl =
134 {
135     d3d8_swapchain_QueryInterface,
136     d3d8_swapchain_AddRef,
137     d3d8_swapchain_Release,
138     d3d8_swapchain_Present,
139     d3d8_swapchain_GetBackBuffer
140 };
141 
142 static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released(void *parent)
143 {
144     HeapFree(GetProcessHeap(), 0, parent);
145 }
146 
147 static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops =
148 {
149     d3d8_swapchain_wined3d_object_released,
150 };
151 
152 static HRESULT swapchain_init(struct d3d8_swapchain *swapchain, struct d3d8_device *device,
153         struct wined3d_swapchain_desc *desc)
154 {
155     HRESULT hr;
156 
157     swapchain->refcount = 1;
158     swapchain->IDirect3DSwapChain8_iface.lpVtbl = &d3d8_swapchain_vtbl;
159 
160     wined3d_mutex_lock();
161     hr = wined3d_swapchain_create(device->wined3d_device, desc,
162             WINED3D_SURFACE_TYPE_OPENGL, swapchain, &d3d8_swapchain_wined3d_parent_ops,
163             &swapchain->wined3d_swapchain);
164     wined3d_mutex_unlock();
165 
166     if (FAILED(hr))
167     {
168         WARN("Failed to create wined3d swapchain, hr %#x.\n", hr);
169         return hr;
170     }
171 
172     swapchain->parent_device = &device->IDirect3DDevice8_iface;
173     IDirect3DDevice8_AddRef(swapchain->parent_device);
174 
175     return D3D_OK;
176 }
177 
178 HRESULT d3d8_swapchain_create(struct d3d8_device *device, struct wined3d_swapchain_desc *desc,
179         struct d3d8_swapchain **swapchain)
180 {
181     struct d3d8_swapchain *object;
182     HRESULT hr;
183 
184     if (!(object = HeapAlloc(GetProcessHeap(),  HEAP_ZERO_MEMORY, sizeof(*object))))
185     {
186         ERR("Failed to allocate swapchain memory.\n");
187         return E_OUTOFMEMORY;
188     }
189 
190     if (FAILED(hr = swapchain_init(object, device, desc)))
191     {
192         WARN("Failed to initialize swapchain, hr %#x.\n", hr);
193         HeapFree(GetProcessHeap(), 0, object);
194         return hr;
195     }
196 
197     TRACE("Created swapchain %p.\n", object);
198     *swapchain = object;
199 
200     return D3D_OK;
201 }
202 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.