From: José Fonseca Date: Fri, 27 Apr 2012 17:15:11 +0000 (+0100) Subject: Rudimentary surface lock rect retrace support. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=0c878369c4e89d774e07d778a3f5eb7458c358f8;p=apitrace Rudimentary surface lock rect retrace support. --- diff --git a/retrace/d3dretrace.py b/retrace/d3dretrace.py index 29d81dc..c3bec0e 100644 --- a/retrace/d3dretrace.py +++ b/retrace/d3dretrace.py @@ -60,17 +60,34 @@ class D3DRetracer(Retracer): print r' retrace::warning(call) << "failed\n";' print r' }' - if interface.name in self.bufferInterfaceNames and method.name == 'Lock': + if interface.name in self.bufferInterfaceNames and method.name == 'Lock' or \ + interface.name == 'IDirect3DSurface9' and method.name == 'LockRect': getDescMethod = interface.getMethodByName('GetDesc') descArg = getDescMethod.args[0] assert descArg.output descType = getDescMethod.args[0].type.type - print ' if (!SizeToLock) {' - print ' %s Desc;' % descType - print ' _this->GetDesc(&Desc);' - print ' SizeToLock = Desc.Size;' - print ' }' + if interface.name in self.bufferInterfaceNames: + print ' if (!SizeToLock) {' + print ' %s Desc;' % descType + print ' _this->GetDesc(&Desc);' + print ' SizeToLock = Desc.Size;' + print ' }' + elif interface.name == 'IDirect3DSurface9': + print ' UINT Width;' + print ' UINT Height;' + print ' if (pRect) {' + print ' Width = pRect->right - pRect->left;' + print ' Height = pRect->bottom - pRect->top;' + print ' } else {' + print ' %s Desc;' % descType + print ' _this->GetDesc(&Desc);' + print ' Width = Desc.Width;' + print ' Height = Desc.Height;' + print ' }' + print ' UINT m_SizeToLock = Height * pLockedRect->Pitch;' + # TODO: take in consideration the width and pixels and blocks + print ' (void)Width;' if __name__ == '__main__': diff --git a/specs/d3d9.py b/specs/d3d9.py index 2fd7755..d2b4d63 100644 --- a/specs/d3d9.py +++ b/specs/d3d9.py @@ -361,7 +361,7 @@ IDirect3DIndexBuffer9.methods += [ IDirect3DSurface9.methods += [ Method(HRESULT, "GetContainer", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppContainer")], sideeffects=False), Method(HRESULT, "GetDesc", [Out(Pointer(D3DSURFACE_DESC), "pDesc")], sideeffects=False), - Method(HRESULT, "LockRect", [Out(Pointer(D3DLOCKED_RECT), "pLockedRect"), (ConstPointer(RECT), "pRect"), (D3DLOCK, "Flags")]), + Method(HRESULT, "LockRect", [Out(Pointer(D3DLOCKED_RECT_), "pLockedRect"), (ConstPointer(RECT), "pRect"), (D3DLOCK, "Flags")]), Method(HRESULT, "UnlockRect", []), Method(HRESULT, "GetDC", [Out(Pointer(HDC), "phdc")]), Method(HRESULT, "ReleaseDC", [(HDC, "hdc")]), diff --git a/specs/d3d9types.py b/specs/d3d9types.py index bde6743..b588055 100644 --- a/specs/d3d9types.py +++ b/specs/d3d9types.py @@ -929,6 +929,11 @@ D3DLOCKED_RECT = Struct("D3DLOCKED_RECT", [ (OpaquePointer(Void), "pBits"), ]) +D3DLOCKED_RECT_ = Struct("D3DLOCKED_RECT", [ + (INT, "Pitch"), + (LinearPointer(Void, "m_SizeToLock"), "pBits"), +]) + D3DBOX = Struct("D3DBOX", [ (UINT, "Left"), (UINT, "Top"), diff --git a/wrappers/d3d9trace.py b/wrappers/d3d9trace.py index ebf5489..300cfa2 100644 --- a/wrappers/d3d9trace.py +++ b/wrappers/d3d9trace.py @@ -46,19 +46,22 @@ class D3D9Tracer(DllTracer): def declareWrapperInterfaceVariables(self, interface): DllTracer.declareWrapperInterfaceVariables(self, interface) - if interface.name in self.bufferInterfaceNames: + if interface.name in self.bufferInterfaceNames or \ + interface.name == 'IDirect3DSurface9': print ' UINT m_SizeToLock;' print ' VOID *m_pbData;' def implementWrapperInterfaceMethodBody(self, interface, base, method): - if interface.name in self.bufferInterfaceNames and method.name == 'Unlock': + if interface.name in self.bufferInterfaceNames and method.name == 'Unlock' or \ + interface.name == 'IDirect3DSurface9' and method.name == 'UnlockRect': print ' if (m_pbData) {' self.emit_memcpy('(LPBYTE)m_pbData', '(LPBYTE)m_pbData', 'm_SizeToLock') print ' }' DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method) - if interface.name in self.bufferInterfaceNames and method.name == 'Lock': + if interface.name in self.bufferInterfaceNames and method.name == 'Lock' or \ + interface.name == 'IDirect3DSurface9' and method.name == 'LockRect': # FIXME: handle recursive locks getDescMethod = interface.getMethodByName('GetDesc') @@ -67,14 +70,33 @@ class D3D9Tracer(DllTracer): descType = getDescMethod.args[0].type.type print ' if (_result == D3D_OK && !(Flags & D3DLOCK_READONLY)) {' - print ' if (SizeToLock) {' - print ' m_SizeToLock = SizeToLock;' - print ' } else {' - print ' %s Desc;' % descType - print ' m_pInstance->GetDesc(&Desc);' - print ' m_SizeToLock = Desc.Size;' - print ' }' - print ' m_pbData = *ppbData;' + if interface.name in self.bufferInterfaceNames: + print ' if (SizeToLock) {' + print ' m_SizeToLock = SizeToLock;' + print ' } else {' + print ' %s Desc;' % descType + print ' m_pInstance->GetDesc(&Desc);' + print ' m_SizeToLock = Desc.Size;' + print ' }' + print ' m_pbData = *ppbData;' + elif interface.name == 'IDirect3DSurface9': + print ' UINT Width;' + print ' UINT Height;' + print ' if (pRect) {' + print ' Width = pRect->right - pRect->left;' + print ' Height = pRect->bottom - pRect->top;' + print ' } else {' + print ' %s Desc;' % descType + print ' m_pInstance->GetDesc(&Desc);' + print ' Width = Desc.Width;' + print ' Height = Desc.Height;' + print ' }' + print ' m_SizeToLock = Height * pLockedRect->Pitch;' + # TODO: take in consideration the width and pixels and blocks + print ' (void)Width;' + print ' m_pbData = pLockedRect->pBits;' + else: + raise NotImplementedError print ' } else {' print ' m_pbData = NULL;' print ' }'