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__':
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")]),
(OpaquePointer(Void), "pBits"),
])
+D3DLOCKED_RECT_ = Struct("D3DLOCKED_RECT", [
+ (INT, "Pitch"),
+ (LinearPointer(Void, "m_SizeToLock"), "pBits"),
+])
+
D3DBOX = Struct("D3DBOX", [
(UINT, "Left"),
(UINT, "Top"),
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')
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 ' }'