]> git.cworth.org Git - apitrace/commitdiff
Rudimentary surface lock rect retrace support.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 27 Apr 2012 17:15:11 +0000 (18:15 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 27 Apr 2012 17:15:11 +0000 (18:15 +0100)
retrace/d3dretrace.py
specs/d3d9.py
specs/d3d9types.py
wrappers/d3d9trace.py

index 29d81dcbd2bfab0c089a213e3ba6bcf47a15d347..c3bec0e7ba2eee31b8bbe07e43b1a873f5ae20ad 100644 (file)
@@ -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__':
index 2fd7755d8a972209454c4637115b22b68f0f15d1..d2b4d63edcc115b75832296e7bb82165552ec832 100644 (file)
@@ -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")]),
index bde6743f865a88f31989531ea3d91522ecbbce62..b588055ea0985f92e8c6b627704366f3e2358b03 100644 (file)
@@ -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"),
index ebf5489352f259721da9b3f5bfc8b0fd90da5160..300cfa2005a8795614d02b7ab2d7371fe577adfb 100644 (file)
@@ -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 '    }'