Ziqing Hui : windowscodecs: In struct DdsFrameDecode, add a new member "pixel_data" and rename member "data" to "block_data".
Module: wine Branch: master Commit: 1b4318b14c7f7b9394babafa84dbb917c0bbcc50 URL: https://source.winehq.org/git/wine.git/?a=commit;h=1b4318b14c7f7b9394babafa8... Author: Ziqing Hui <zhui(a)codeweavers.com> Date: Mon Aug 24 12:10:18 2020 +0800 windowscodecs: In struct DdsFrameDecode, add a new member "pixel_data" and rename member "data" to "block_data". Signed-off-by: Ziqing Hui <zhui(a)codeweavers.com> Signed-off-by: Esme Povirk <esme(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/windowscodecs/ddsformat.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/dlls/windowscodecs/ddsformat.c b/dlls/windowscodecs/ddsformat.c index c179a38935..ccd83ace55 100644 --- a/dlls/windowscodecs/ddsformat.c +++ b/dlls/windowscodecs/ddsformat.c @@ -149,7 +149,8 @@ typedef struct DdsFrameDecode { IWICBitmapFrameDecode IWICBitmapFrameDecode_iface; IWICDdsFrameDecode IWICDdsFrameDecode_iface; LONG ref; - BYTE *data; + BYTE *block_data; + BYTE *pixel_data; CRITICAL_SECTION lock; dds_frame_info info; } DdsFrameDecode; @@ -535,7 +536,8 @@ static ULONG WINAPI DdsFrameDecode_Release(IWICBitmapFrameDecode *iface) TRACE("(%p) refcount=%u\n", iface, ref); if (ref == 0) { - HeapFree(GetProcessHeap(), 0, This->data); + HeapFree(GetProcessHeap(), 0, This->pixel_data); + HeapFree(GetProcessHeap(), 0, This->block_data); HeapFree(GetProcessHeap(), 0, This); } @@ -593,6 +595,7 @@ static HRESULT WINAPI DdsFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, DdsFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface); UINT bpp, frame_stride, frame_size; INT x, y, width, height; + HRESULT hr = S_OK; TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); @@ -619,7 +622,20 @@ static HRESULT WINAPI DdsFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, if (cbStride < width * bpp / 8) return E_INVALIDARG; if (cbBufferSize < cbStride * height) return WINCODEC_ERR_INSUFFICIENTBUFFER; - return S_OK; + EnterCriticalSection(&This->lock); + + if (!This->pixel_data) { + This->pixel_data = HeapAlloc(GetProcessHeap(), 0, frame_size); + if (!This->pixel_data) { + hr = E_OUTOFMEMORY; + goto end; + } + } + +end: + LeaveCriticalSection(&This->lock); + + return hr; } static HRESULT WINAPI DdsFrameDecode_GetMetadataQueryReader(IWICBitmapFrameDecode *iface, @@ -731,7 +747,7 @@ static HRESULT WINAPI DdsFrameDecode_Dds_CopyBlocks(IWICDdsFrameDecode *iface, if (!boundsInBlocks) { if (stride < frame_stride) return E_INVALIDARG; if (bufferSize < frame_size) return E_INVALIDARG; - memcpy(buffer, This->data, frame_size); + memcpy(buffer, This->block_data, frame_size); return S_OK; } @@ -747,7 +763,7 @@ static HRESULT WINAPI DdsFrameDecode_Dds_CopyBlocks(IWICDdsFrameDecode *iface, if (stride < width * bytes_per_block) return E_INVALIDARG; if (bufferSize < stride * height) return E_INVALIDARG; - data = This->data + (x + y * This->info.width_in_blocks) * bytes_per_block; + data = This->block_data + (x + y * This->info.width_in_blocks) * bytes_per_block; dst_buffer = buffer; for (i = 0; i < height; i++) { @@ -1143,10 +1159,11 @@ static HRESULT WINAPI DdsDecoder_Dds_GetFrame(IWICDdsDecoder *iface, frame_decode->info.height_in_blocks = frame_height_in_blocks; frame_decode->info.pixel_format = This->info.pixel_format; frame_decode->info.pixel_format_bpp = get_pixel_format_bpp(This->info.pixel_format); - frame_decode->data = HeapAlloc(GetProcessHeap(), 0, frame_size); + frame_decode->block_data = HeapAlloc(GetProcessHeap(), 0, frame_size); + frame_decode->pixel_data = NULL; hr = IStream_Seek(This->stream, seek, SEEK_SET, NULL); if (hr != S_OK) goto end; - hr = IStream_Read(This->stream, frame_decode->data, frame_size, &bytesread); + hr = IStream_Read(This->stream, frame_decode->block_data, frame_size, &bytesread); if (hr != S_OK || bytesread != frame_size) { hr = WINCODEC_ERR_STREAMREAD; goto end;
participants (1)
-
Alexandre Julliard