+#if DIRECT3D_VERSION >= 0x0900
+
+static inline size_t
+_lockSize(IDirect3DSurface9 *pSurface, const D3DLOCKED_RECT *pLockedRect, const RECT *pRect) {
+ D3DSURFACE_DESC Desc;
+ pSurface->GetDesc(&Desc);
+
+ UINT Width;
+ UINT Height;
+ if (pRect) {
+ Width = pRect->right - pRect->left;
+ Height = pRect->bottom - pRect->top;
+ } else {
+ Width = Desc.Width;
+ Height = Desc.Height;
+ }
+
+ return _formatSize(Desc.Format, Width, Height, pLockedRect->Pitch);
+}
+
+
+#endif /* DIRECT3D_VERSION >= 0x0900 */
+
+