[PATCH 6/6] wined3d: Add support for partial updates of compressed surfaces to IWineD3DDeviceImpl_UpdateSurface().

Henri Verbeet hverbeet at codeweavers.com
Thu Mar 25 16:51:26 CDT 2010


---
 dlls/wined3d/device.c |   46 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 922b20a..897681d 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5262,21 +5262,45 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
     ENTER_GL();
 
     /* TODO: Cube and volume support */
-    if(rowoffset != 0){
-        /* not a whole row so we have to do it a line at a time */
-        int j;
+    if (rowoffset) /* Not a whole row so we have to do it a line at a time. */
+    {
+        if (dst_format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
+        {
+            const unsigned char *data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface));
+            UINT row_length = (srcWidth / src_format_desc->block_width) * src_format_desc->block_byte_count;
+            UINT row_count = srcHeight /  src_format_desc->block_height;
+            UINT src_pitch = IWineD3DSurface_GetPitch(pSourceSurface);
+            UINT y = destTop;
+            UINT row;
 
-        /* hopefully using pointer addition will be quicker than using a point + j * rowoffset */
-        const unsigned char* data =((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset;
+            data += (pSourceRect->top / src_format_desc->block_height) * src_pitch;
+            data += (pSourceRect->left / src_format_desc->block_width) * src_format_desc->block_byte_count;
 
-        for (j = destTop; j < (srcHeight + destTop); ++j)
-        {
-            glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, destLeft, j,
-                    srcWidth, 1, dst_format_desc->glFormat, dst_format_desc->glType,data);
-            data += rowoffset;
+            for (row = 0; row < row_count; ++row)
+            {
+                GL_EXTCALL(glCompressedTexSubImage2DARB(dst_impl->texture_target, dst_impl->texture_level,
+                            destLeft, y, srcWidth, src_format_desc->block_height,
+                            dst_format_desc->glInternal, row_length, data));
+                y += src_format_desc->block_height;
+                data += src_pitch;
+            }
+            checkGLcall("glCompressedTexSubImage2DARB");
         }
+        else
+        {
+            const unsigned char *data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset;
+            unsigned int j;
 
-    } else { /* Full width, so just write out the whole texture */
+            for (j = destTop; j < (srcHeight + destTop); ++j)
+            {
+                glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, destLeft, j,
+                        srcWidth, 1, dst_format_desc->glFormat, dst_format_desc->glType,data);
+                data += rowoffset;
+            }
+        }
+    }
+    else /* Full width, so just write out the whole texture. */
+    {
         const unsigned char* data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset;
 
         if (dst_format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
-- 
1.6.4.4




More information about the wine-patches mailing list