Ziqing Hui : windowscodecs: Remove header and header_dxt10 in struct DdsDecoder.

Alexandre Julliard julliard at winehq.org
Mon Jul 13 16:08:50 CDT 2020


Module: wine
Branch: master
Commit: 43788707ce33235ae216407027c72ffdd275479b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=43788707ce33235ae216407027c72ffdd275479b

Author: Ziqing Hui <zhui at codeweavers.com>
Date:   Fri Jul 10 17:08:18 2020 +0800

windowscodecs: Remove header and header_dxt10 in struct DdsDecoder.

This make dds_info become the only dependence of implementation.

Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
Signed-off-by: Esme Povirk <esme at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/windowscodecs/ddsformat.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/dlls/windowscodecs/ddsformat.c b/dlls/windowscodecs/ddsformat.c
index 43fb87dfb1..7a28b82e3d 100644
--- a/dlls/windowscodecs/ddsformat.c
+++ b/dlls/windowscodecs/ddsformat.c
@@ -103,6 +103,7 @@ typedef struct dds_info {
     UINT mip_levels;
     UINT array_size;
     UINT frame_count;
+    UINT data_offset;
     DXGI_FORMAT format;
     WICDdsDimension dimension;
     WICDdsAlphaMode alpha_mode;
@@ -128,8 +129,6 @@ typedef struct DdsDecoder {
     BOOL initialized;
     IStream *stream;
     CRITICAL_SECTION lock;
-    DDS_HEADER header;
-    DDS_HEADER_DXT10 header_dxt10;
     dds_info info;
 } DdsDecoder;
 
@@ -226,10 +225,12 @@ static void get_dds_info(dds_info* info, DDS_HEADER *header, DDS_HEADER_DXT10 *h
         info->format = header_dxt10->dxgiFormat;
         info->dimension = get_dimension(NULL, header_dxt10);
         info->alpha_mode = header_dxt10->miscFlags2 & 0x00000008;
+        info->data_offset = sizeof(DWORD) + sizeof(*header) + sizeof(*header_dxt10);
     } else {
         info->format = get_format_from_fourcc(header->ddspf.fourCC);
         info->dimension = get_dimension(header, NULL);
         info->alpha_mode = get_alpha_mode_from_fourcc(header->ddspf.fourCC);
+        info->data_offset = sizeof(DWORD) + sizeof(*header);
     }
     info->pixel_format = (info->alpha_mode == WICDdsAlphaModePremultiplied) ?
                          &GUID_WICPixelFormat32bppPBGRA : &GUID_WICPixelFormat32bppBGRA;
@@ -614,6 +615,8 @@ static HRESULT WINAPI DdsDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
                                             WICDecodeOptions cacheOptions)
 {
     DdsDecoder *This = impl_from_IWICBitmapDecoder(iface);
+    DDS_HEADER_DXT10 header_dxt10;
+    DDS_HEADER header;
     HRESULT hr;
     LARGE_INTEGER seek;
     DWORD magic;
@@ -643,27 +646,27 @@ static HRESULT WINAPI DdsDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
         goto end;
     }
 
-    hr = IStream_Read(pIStream, &This->header, sizeof(This->header), &bytesread);
+    hr = IStream_Read(pIStream, &header, sizeof(header), &bytesread);
     if (FAILED(hr)) goto end;
-    if (bytesread != sizeof(This->header)) {
+    if (bytesread != sizeof(header)) {
         hr = WINCODEC_ERR_STREAMREAD;
         goto end;
     }
-    if (This->header.size != sizeof(This->header)) {
+    if (header.size != sizeof(header)) {
         hr = WINCODEC_ERR_BADHEADER;
         goto end;
     }
 
-    if (has_extended_header(&This->header)) {
-        hr = IStream_Read(pIStream, &This->header_dxt10, sizeof(This->header_dxt10), &bytesread);
+    if (has_extended_header(&header)) {
+        hr = IStream_Read(pIStream, &header_dxt10, sizeof(header_dxt10), &bytesread);
         if (FAILED(hr)) goto end;
-        if (bytesread != sizeof(This->header_dxt10)) {
+        if (bytesread != sizeof(header_dxt10)) {
             hr = WINCODEC_ERR_STREAMREAD;
             goto end;
         }
     }
 
-    get_dds_info(&This->info, &This->header, &This->header_dxt10);
+    get_dds_info(&This->info, &header, &header_dxt10);
 
     This->initialized = TRUE;
     This->stream = pIStream;
@@ -888,8 +891,7 @@ static HRESULT WINAPI DdsDecoder_Dds_GetFrame(IWICDdsDecoder *iface,
     }
 
     bytes_per_block = get_bytes_per_block(This->info.format);
-    seek.QuadPart = sizeof(DWORD) + sizeof(DDS_HEADER);
-    if (has_extended_header(&This->header)) seek.QuadPart += sizeof(DDS_HEADER_DXT10);
+    seek.QuadPart = This->info.data_offset;
 
     width = This->info.width;
     height = This->info.height;




More information about the wine-cvs mailing list