[PATCH 6/8] wined3d: Rename surface_calculate_size() to wined3d_format_calculate_size().

Henri Verbeet hverbeet at codeweavers.com
Sun Aug 15 16:21:47 CDT 2010


---
 dlls/wined3d/surface.c         |   27 +--------------------------
 dlls/wined3d/surface_base.c    |    2 +-
 dlls/wined3d/utils.c           |   24 ++++++++++++++++++++++++
 dlls/wined3d/wined3d_private.h |    4 ++--
 4 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index eff5a5e..9ea65ae 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -92,31 +92,6 @@ static void surface_cleanup(IWineD3DSurfaceImpl *This)
     resource_cleanup((IWineD3DResource *)This);
 }
 
-UINT surface_calculate_size(const struct wined3d_format_desc *format_desc, UINT alignment, UINT width, UINT height)
-{
-    UINT size;
-
-    if (format_desc->format == WINED3DFMT_UNKNOWN)
-    {
-        size = 0;
-    }
-    else if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
-    {
-        UINT row_block_count = (width + format_desc->block_width - 1) / format_desc->block_width;
-        UINT row_count = (height + format_desc->block_height - 1) / format_desc->block_height;
-        size = row_count * row_block_count * format_desc->block_byte_count;
-    }
-    else
-    {
-        /* The pitch is a multiple of 4 bytes. */
-        size = height * (((width * format_desc->byte_count) + alignment - 1) & ~(alignment - 1));
-    }
-
-    if (format_desc->heightscale != 0.0f) size *= format_desc->heightscale;
-
-    return size;
-}
-
 struct blt_info
 {
     GLenum binding;
@@ -356,7 +331,7 @@ HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type,
 
     /* FIXME: Check that the format is supported by the device. */
 
-    resource_size = surface_calculate_size(format_desc, alignment, width, height);
+    resource_size = wined3d_format_calculate_size(format_desc, alignment, width, height);
 
     /* Look at the implementation and set the correct Vtable. */
     switch (surface_type)
diff --git a/dlls/wined3d/surface_base.c b/dlls/wined3d/surface_base.c
index e9e1ff7..6c12155 100644
--- a/dlls/wined3d/surface_base.c
+++ b/dlls/wined3d/surface_base.c
@@ -511,7 +511,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3D
 
     TRACE("(%p) : Setting texture format to (%d,%s)\n", This, format, debug_d3dformat(format));
 
-    This->resource.size = surface_calculate_size(format_desc, This->resource.device->surface_alignment,
+    This->resource.size = wined3d_format_calculate_size(format_desc, This->resource.device->surface_alignment,
             This->pow2Width, This->pow2Height);
 
     This->Flags |= (WINED3DFMT_D16_LOCKABLE == format) ? SFLAG_LOCKABLE : 0;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index a4ea624..8396513 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -1550,6 +1550,30 @@ const struct wined3d_format_desc *getFormatDescEntry(WINED3DFORMAT fmt, const st
     return &gl_info->gl_formats[idx];
 }
 
+UINT wined3d_format_calculate_size(const struct wined3d_format_desc *format, UINT alignment, UINT width, UINT height)
+{
+    UINT size;
+
+    if (format->format == WINED3DFMT_UNKNOWN)
+    {
+        size = 0;
+    }
+    else if (format->Flags & WINED3DFMT_FLAG_COMPRESSED)
+    {
+        UINT row_block_count = (width + format->block_width - 1) / format->block_width;
+        UINT row_count = (height + format->block_height - 1) / format->block_height;
+        size = row_count * (((row_block_count * format->block_byte_count) + alignment - 1) & ~(alignment - 1));
+    }
+    else
+    {
+        size = height * (((width * format->byte_count) + alignment - 1) & ~(alignment - 1));
+    }
+
+    if (format->heightscale != 0.0f) size *= format->heightscale;
+
+    return size;
+}
+
 /*****************************************************************************
  * Trace formatting of useful values
  */
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 330d92b..e21685e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2068,8 +2068,6 @@ extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl DECLSPEC_HIDDEN;
 extern const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl DECLSPEC_HIDDEN;
 
 void surface_add_dirty_rect(IWineD3DSurfaceImpl *surface, const RECT *dirty_rect) DECLSPEC_HIDDEN;
-UINT surface_calculate_size(const struct wined3d_format_desc *format_desc,
-        UINT alignment, UINT width, UINT height) DECLSPEC_HIDDEN;
 void surface_gdi_cleanup(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN;
 GLenum surface_get_gl_buffer(IWineD3DSurfaceImpl *surface) DECLSPEC_HIDDEN;
 HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type, UINT alignment,
@@ -2980,6 +2978,8 @@ struct wined3d_format_desc
 
 const struct wined3d_format_desc *getFormatDescEntry(WINED3DFORMAT fmt,
         const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
+UINT wined3d_format_calculate_size(const struct wined3d_format_desc *format,
+        UINT alignment, UINT width, UINT height) DECLSPEC_HIDDEN;
 
 static inline BOOL use_vs(IWineD3DStateBlockImpl *stateblock)
 {
-- 
1.7.1




More information about the wine-patches mailing list