]> git.cworth.org Git - apitrace/blobdiff - wrappers/d3d9trace.py
Trace LockBox blobs.
[apitrace] / wrappers / d3d9trace.py
index 300cfa2005a8795614d02b7ab2d7371fe577adfb..ef5a14c6f436aacdab461f6622af0bbfc85eacbd 100644 (file)
@@ -38,63 +38,34 @@ class D3D9Tracer(DllTracer):
 
         DllTracer.serializeArgValue(self, function, arg)
 
-    bufferInterfaceNames = [
-        'IDirect3DVertexBuffer9',
-        'IDirect3DIndexBuffer9',
-    ]
-
     def declareWrapperInterfaceVariables(self, interface):
         DllTracer.declareWrapperInterfaceVariables(self, interface)
         
-        if interface.name in self.bufferInterfaceNames or \
-           interface.name == 'IDirect3DSurface9':
-            print '    UINT m_SizeToLock;'
+        if interface.getMethodByName('Lock') is not None or \
+           interface.getMethodByName('LockRect') is not None or \
+           interface.getMethodByName('LockBox') is not None:
+            print '    size_t _LockedSize;'
             print '    VOID *m_pbData;'
 
+
     def implementWrapperInterfaceMethodBody(self, interface, base, method):
-        if interface.name in self.bufferInterfaceNames and method.name == 'Unlock' or \
-           interface.name == 'IDirect3DSurface9' and method.name == 'UnlockRect':
+        if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'):
             print '    if (m_pbData) {'
-            self.emit_memcpy('(LPBYTE)m_pbData', '(LPBYTE)m_pbData', 'm_SizeToLock')
+            self.emit_memcpy('(LPBYTE)m_pbData', '(LPBYTE)m_pbData', '_LockedSize')
             print '    }'
 
         DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method)
 
-        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')
-            descArg = getDescMethod.args[0]
-            assert descArg.output
-            descType = getDescMethod.args[0].type.type
-
-            print '    if (_result == D3D_OK && !(Flags & D3DLOCK_READONLY)) {'
-            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 '        }'
+        if method.name in ('Lock', 'LockRect', 'LockedBox'):
+            print '    if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {'
+            print '        _LockedSize = _getLockSize(_this, %s);' % ', '.join(method.argNames()[:-1])
+            if method.name == 'Lock':
+                # FIXME: handle recursive locks
                 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;'
+            elif method.name == 'LockRect':
                 print '        m_pbData = pLockedRect->pBits;'
+            elif method.name == 'LockBox':
+                print '        m_pbData = pLockedBox->pBits;'
             else:
                 raise NotImplementedError
             print '    } else {'