From 833619b4441915c7c55085d44b3221eaef0d9800 Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 7 Dec 2016 09:21:17 -0800 Subject: Refcount all the IFX_ stream classes all the time. We can remove a lot of "bOwnsStream" logic in the process. Always pass these by const reference, in case the called method wants to hang on to the stream (one exception is where we stick a raw pointer into a void* slot in a context from another layer). Review-Url: https://codereview.chromium.org/2451493002 --- xfa/fxfa/app/xfa_ffwidget.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'xfa/fxfa/app/xfa_ffwidget.cpp') diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index dfe418b76b..99333ba1dd 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -1054,7 +1054,7 @@ CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, FXCODEC_IMAGE_TYPE type = XFA_GetImageType(wsContentType); CFX_ByteString bsContent; uint8_t* pImageBuffer = nullptr; - IFX_SeekableReadStream* pImageFileRead = nullptr; + CFX_RetainPtr pImageFileRead; if (wsImage.GetLength() > 0) { XFA_ATTRIBUTEENUM iEncoding = (XFA_ATTRIBUTEENUM)pImage->GetTransferEncoding(); @@ -1092,7 +1092,6 @@ CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, CFX_DIBitmap* pBitmap = XFA_LoadImageFromBuffer(pImageFileRead, type, iImageXDpi, iImageYDpi); FX_Free(pImageBuffer); - pImageFileRead->Release(); return pBitmap; } static FXDIB_Format XFA_GetDIBFormat(FXCODEC_IMAGE_TYPE type, @@ -1115,18 +1114,20 @@ static FXDIB_Format XFA_GetDIBFormat(FXCODEC_IMAGE_TYPE type, } return dibFormat; } -CFX_DIBitmap* XFA_LoadImageFromBuffer(IFX_SeekableReadStream* pImageFileRead, - FXCODEC_IMAGE_TYPE type, - int32_t& iImageXDpi, - int32_t& iImageYDpi) { + +CFX_DIBitmap* XFA_LoadImageFromBuffer( + const CFX_RetainPtr& pImageFileRead, + FXCODEC_IMAGE_TYPE type, + int32_t& iImageXDpi, + int32_t& iImageYDpi) { CFX_GEModule* pGeModule = CFX_GEModule::Get(); - if (!pGeModule) { + if (!pGeModule) return nullptr; - } + CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule(); - if (!pCodecMgr) { + if (!pCodecMgr) return nullptr; - } + CFX_DIBAttribute dibAttr; CFX_DIBitmap* pBitmap = nullptr; CCodec_ProgressiveDecoder* pProgressiveDecoder = -- cgit v1.2.3