Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenstateblock.c
Go to the documentation of this file.
00001 /* 00002 * IDirect3DStateBlock9 implementation 00003 * 00004 * Copyright 2002-2003 Raphael Junqueira 00005 * Copyright 2002-2003 Jason Edmeades 00006 * Copyright 2005 Oliver Stieber 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00021 */ 00022 00023 #include "config.h" 00024 #include "d3d9_private.h" 00025 00026 WINE_DEFAULT_DEBUG_CHANNEL(d3d9); 00027 00028 static inline IDirect3DStateBlock9Impl *impl_from_IDirect3DStateBlock9(IDirect3DStateBlock9 *iface) 00029 { 00030 return CONTAINING_RECORD(iface, IDirect3DStateBlock9Impl, IDirect3DStateBlock9_iface); 00031 } 00032 00033 static HRESULT WINAPI IDirect3DStateBlock9Impl_QueryInterface(IDirect3DStateBlock9 *iface, 00034 REFIID riid, void **ppobj) 00035 { 00036 IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface); 00037 00038 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj); 00039 00040 if (IsEqualGUID(riid, &IID_IUnknown) 00041 || IsEqualGUID(riid, &IID_IDirect3DStateBlock9)) { 00042 IDirect3DStateBlock9_AddRef(iface); 00043 *ppobj = This; 00044 return S_OK; 00045 } 00046 00047 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj); 00048 *ppobj = NULL; 00049 return E_NOINTERFACE; 00050 } 00051 00052 static ULONG WINAPI IDirect3DStateBlock9Impl_AddRef(IDirect3DStateBlock9 *iface) 00053 { 00054 IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface); 00055 ULONG ref = InterlockedIncrement(&This->ref); 00056 00057 TRACE("%p increasing refcount to %u.\n", iface, ref); 00058 00059 return ref; 00060 } 00061 00062 static ULONG WINAPI IDirect3DStateBlock9Impl_Release(IDirect3DStateBlock9 *iface) 00063 { 00064 IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface); 00065 ULONG ref = InterlockedDecrement(&This->ref); 00066 00067 TRACE("%p decreasing refcount to %u.\n", iface, ref); 00068 00069 if (ref == 0) { 00070 wined3d_mutex_lock(); 00071 wined3d_stateblock_decref(This->wined3d_stateblock); 00072 wined3d_mutex_unlock(); 00073 00074 IDirect3DDevice9Ex_Release(This->parentDevice); 00075 HeapFree(GetProcessHeap(), 0, This); 00076 } 00077 return ref; 00078 } 00079 00080 /* IDirect3DStateBlock9 Interface follow: */ 00081 static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(IDirect3DStateBlock9 *iface, 00082 IDirect3DDevice9 **device) 00083 { 00084 IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface); 00085 00086 TRACE("iface %p, device %p.\n", iface, device); 00087 00088 *device = (IDirect3DDevice9 *)This->parentDevice; 00089 IDirect3DDevice9_AddRef(*device); 00090 00091 TRACE("Returning device %p.\n", *device); 00092 00093 return D3D_OK; 00094 } 00095 00096 static HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(IDirect3DStateBlock9 *iface) 00097 { 00098 IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface); 00099 HRESULT hr; 00100 00101 TRACE("iface %p.\n", iface); 00102 00103 wined3d_mutex_lock(); 00104 hr = wined3d_stateblock_capture(This->wined3d_stateblock); 00105 wined3d_mutex_unlock(); 00106 00107 return hr; 00108 } 00109 00110 static HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(IDirect3DStateBlock9 *iface) 00111 { 00112 IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface); 00113 HRESULT hr; 00114 00115 TRACE("iface %p.\n", iface); 00116 00117 wined3d_mutex_lock(); 00118 hr = wined3d_stateblock_apply(This->wined3d_stateblock); 00119 wined3d_mutex_unlock(); 00120 00121 return hr; 00122 } 00123 00124 00125 static const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl = 00126 { 00127 /* IUnknown */ 00128 IDirect3DStateBlock9Impl_QueryInterface, 00129 IDirect3DStateBlock9Impl_AddRef, 00130 IDirect3DStateBlock9Impl_Release, 00131 /* IDirect3DStateBlock9 */ 00132 IDirect3DStateBlock9Impl_GetDevice, 00133 IDirect3DStateBlock9Impl_Capture, 00134 IDirect3DStateBlock9Impl_Apply 00135 }; 00136 00137 HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Impl *device, 00138 D3DSTATEBLOCKTYPE type, struct wined3d_stateblock *wined3d_stateblock) 00139 { 00140 HRESULT hr; 00141 00142 stateblock->IDirect3DStateBlock9_iface.lpVtbl = &Direct3DStateBlock9_Vtbl; 00143 stateblock->ref = 1; 00144 00145 if (wined3d_stateblock) 00146 { 00147 stateblock->wined3d_stateblock = wined3d_stateblock; 00148 } 00149 else 00150 { 00151 wined3d_mutex_lock(); 00152 hr = wined3d_stateblock_create(device->wined3d_device, 00153 (enum wined3d_stateblock_type)type, &stateblock->wined3d_stateblock); 00154 wined3d_mutex_unlock(); 00155 if (FAILED(hr)) 00156 { 00157 WARN("Failed to create wined3d stateblock, hr %#x.\n", hr); 00158 return hr; 00159 } 00160 } 00161 00162 stateblock->parentDevice = &device->IDirect3DDevice9Ex_iface; 00163 IDirect3DDevice9Ex_AddRef(stateblock->parentDevice); 00164 00165 return D3D_OK; 00166 } Generated on Fri May 25 2012 04:20:03 for ReactOS by
1.7.6.1
|