diff options
author | dsinclair <dsinclair@chromium.org> | 2017-03-28 15:47:47 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-28 15:48:01 +0000 |
commit | 31b08d4cdaa17d7a03f35e087096a77036af98ec (patch) | |
tree | 40234b81f2972c857a33a86cb4b59868e56bb86b /core/fxge/win32 | |
parent | a3e9bf66c3483db926602aa62b0bd1ff8d1357a1 (diff) | |
download | pdfium-31b08d4cdaa17d7a03f35e087096a77036af98ec.tar.xz |
Revert "Refcount all CFX_DIBSources (and subclasses) all the time."
This reverts commit 0004f29bf6ee3c6060a272c79f14993e92e053c7.
Reason for revert: Breaks build with skia_paths enabled (which will break the chrome roll).
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:1858:38: error: no member named 'get' in 'CFX_RetainPtr<CFX_DIBitmap>'
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:1861:42: error: no member named 'get' in 'CFX_RetainPtr<CFX_DIBitmap>'
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2987:15: error: no viable overloaded '='
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2991:18: error: no viable overloaded '='
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2999:17: error: no viable overloaded '='
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:3001:43: error: no member named 'GetObject' in 'CFX_RetainPtr<CFX_DIBitmap>'
Original change's description:
> Refcount all CFX_DIBSources (and subclasses) all the time.
>
> There are currently several ownership models for these objects,
> including ad-hoc logic for sharing and deletion, and the
> now-redundant CFX_DIBitmapRef externally-counted handle to the DIBs.
>
> Replace them all with the internal refcount scheme.
>
> Change-Id: I2db399dfc19219eda384f94cc989353b78ce2872
> Reviewed-on: https://pdfium-review.googlesource.com/3166
> Reviewed-by: dsinclair <dsinclair@chromium.org>
> Commit-Queue: dsinclair <dsinclair@chromium.org>
>
TBR=thestig@chromium.org,tsepez@chromium.org,dsinclair@chromium.org,pdfium-reviews@googlegroups.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I678b1fbc5e666cf7a19372ebaff3270fb115ba5e
Reviewed-on: https://pdfium-review.googlesource.com/3243
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxge/win32')
-rw-r--r-- | core/fxge/win32/cfx_psrenderer.cpp | 21 | ||||
-rw-r--r-- | core/fxge/win32/cfx_psrenderer.h | 6 | ||||
-rw-r--r-- | core/fxge/win32/cfx_windowsdib.h | 24 | ||||
-rw-r--r-- | core/fxge/win32/dwrite_int.h | 3 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 165 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_dib.cpp | 52 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_dwrite.cpp | 27 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_gdipext.cpp | 41 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_print.cpp | 69 | ||||
-rw-r--r-- | core/fxge/win32/win32_int.h | 39 |
10 files changed, 213 insertions, 234 deletions
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index 5350c383b4..391af83630 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -338,7 +338,7 @@ static void PSCompressData(int PSLevel, } } -bool CFX_PSRenderer::SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, +bool CFX_PSRenderer::SetDIBits(const CFX_DIBSource* pSource, uint32_t color, int left, int top) { @@ -349,7 +349,7 @@ bool CFX_PSRenderer::SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, return DrawDIBits(pSource, color, &matrix, 0); } -bool CFX_PSRenderer::StretchDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, +bool CFX_PSRenderer::StretchDIBits(const CFX_DIBSource* pSource, uint32_t color, int dest_left, int dest_top, @@ -362,7 +362,7 @@ bool CFX_PSRenderer::StretchDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, return DrawDIBits(pSource, color, &matrix, flags); } -bool CFX_PSRenderer::DrawDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, +bool CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource, uint32_t color, const CFX_Matrix* pMatrix, uint32_t flags) { @@ -419,25 +419,25 @@ bool CFX_PSRenderer::DrawDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, output_buf.release(); } else { CFX_DIBExtractor source_extractor(pSource); - CFX_RetainPtr<CFX_DIBSource> pConverted = source_extractor.GetBitmap(); - if (!pConverted) + CFX_MaybeOwned<CFX_DIBSource> pConverted(source_extractor.GetBitmap()); + if (!pConverted.Get()) return false; switch (pSource->GetFormat()) { case FXDIB_1bppRgb: case FXDIB_Rgb32: - pConverted = pConverted->CloneConvert(FXDIB_Rgb); + pConverted = pConverted->CloneConvert(FXDIB_Rgb).release(); break; case FXDIB_8bppRgb: if (pSource->GetPalette()) { - pConverted = pConverted->CloneConvert(FXDIB_Rgb); + pConverted = pConverted->CloneConvert(FXDIB_Rgb).release(); } break; case FXDIB_1bppCmyk: - pConverted = pConverted->CloneConvert(FXDIB_Cmyk); + pConverted = pConverted->CloneConvert(FXDIB_Cmyk).release(); break; case FXDIB_8bppCmyk: if (pSource->GetPalette()) { - pConverted = pConverted->CloneConvert(FXDIB_Cmyk); + pConverted = pConverted->CloneConvert(FXDIB_Cmyk).release(); } break; default: @@ -452,7 +452,8 @@ bool CFX_PSRenderer::DrawDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, FX_STRSIZE output_size = 0; const char* filter = nullptr; if ((m_PSLevel == 2 || flags & FXRENDER_IMAGE_LOSSY) && - CCodec_JpegModule::JpegEncode(pConverted, &output_buf, &output_size)) { + CCodec_JpegModule::JpegEncode(pConverted.Get(), &output_buf, + &output_size)) { filter = "/DCTDecode filter "; } if (!filter) { diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h index 5768d0770f..133d7b9d72 100644 --- a/core/fxge/win32/cfx_psrenderer.h +++ b/core/fxge/win32/cfx_psrenderer.h @@ -51,18 +51,18 @@ class CFX_PSRenderer { uint32_t fill_color, uint32_t stroke_color, int fill_mode); - bool SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, + bool SetDIBits(const CFX_DIBSource* pBitmap, uint32_t color, int dest_left, int dest_top); - bool StretchDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, + bool StretchDIBits(const CFX_DIBSource* pBitmap, uint32_t color, int dest_left, int dest_top, int dest_width, int dest_height, uint32_t flags); - bool DrawDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, + bool DrawDIBits(const CFX_DIBSource* pBitmap, uint32_t color, const CFX_Matrix* pMatrix, uint32_t flags); diff --git a/core/fxge/win32/cfx_windowsdib.h b/core/fxge/win32/cfx_windowsdib.h index e59e9d60a4..0bfab3fee1 100644 --- a/core/fxge/win32/cfx_windowsdib.h +++ b/core/fxge/win32/cfx_windowsdib.h @@ -10,9 +10,6 @@ #ifndef _WINDOWS_ #include <windows.h> #endif - -#include "core/fxge/fx_dib.h" - #define WINDIB_OPEN_MEMORY 0x1 #define WINDIB_OPEN_PATHNAME 0x2 @@ -28,20 +25,15 @@ typedef struct WINDIB_Open_Args_ { class CFX_WindowsDIB : public CFX_DIBitmap { public: - template <typename T, typename... Args> - friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); - + CFX_WindowsDIB(HDC hDC, int width, int height); ~CFX_WindowsDIB() override; - static CFX_ByteString GetBitmapInfo( - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap); - static HBITMAP GetDDBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, - HDC hDC); - - static CFX_RetainPtr<CFX_DIBitmap> LoadFromBuf(BITMAPINFO* pbmi, void* pData); - static CFX_RetainPtr<CFX_DIBitmap> LoadFromFile(const wchar_t* filename); - static CFX_RetainPtr<CFX_DIBitmap> LoadFromFile(const char* filename); - static CFX_RetainPtr<CFX_DIBitmap> LoadDIBitmap(WINDIB_Open_Args_ args); + static CFX_ByteString GetBitmapInfo(const CFX_DIBitmap* pBitmap); + static CFX_DIBitmap* LoadFromBuf(BITMAPINFO* pbmi, void* pData); + static HBITMAP GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC); + static CFX_DIBitmap* LoadFromFile(const wchar_t* filename); + static CFX_DIBitmap* LoadFromFile(const char* filename); + static CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args); HDC GetDC() const { return m_hMemDC; } HBITMAP GetWindowsBitmap() const { return m_hBitmap; } @@ -50,8 +42,6 @@ class CFX_WindowsDIB : public CFX_DIBitmap { void SetToDevice(HDC hDC, int left, int top); protected: - CFX_WindowsDIB(HDC hDC, int width, int height); - HDC m_hMemDC; HBITMAP m_hBitmap; HBITMAP m_hOldBitmap; diff --git a/core/fxge/win32/dwrite_int.h b/core/fxge/win32/dwrite_int.h index 8e8908a7a1..105c34998c 100644 --- a/core/fxge/win32/dwrite_int.h +++ b/core/fxge/win32/dwrite_int.h @@ -39,8 +39,7 @@ class CDWriteExt { void* DwCreateFontFaceFromStream(uint8_t* pData, uint32_t size, int simulation_style); - bool DwCreateRenderingTarget(const CFX_RetainPtr<CFX_DIBitmap>& pSrc, - void** renderTarget); + bool DwCreateRenderingTarget(CFX_DIBitmap* pSrc, void** renderTarget); void DwDeleteRenderingTarget(void* renderTarget); bool DwRendingString(void* renderTarget, CFX_ClipRgn* pClipRgn, diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 140a5b07d5..b2ee4549ea 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -782,13 +782,12 @@ void CGdiDeviceDriver::RestoreState(bool bKeepSaved) { SaveDC(m_hDC); } -bool CGdiDeviceDriver::GDI_SetDIBits( - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap1, - const FX_RECT* pSrcRect, - int left, - int top) { +bool CGdiDeviceDriver::GDI_SetDIBits(CFX_DIBitmap* pBitmap1, + const FX_RECT* pSrcRect, + int left, + int top) { if (m_DeviceClass == FXDC_PRINTER) { - CFX_RetainPtr<CFX_DIBitmap> pBitmap = pBitmap1->FlipImage(false, true); + std::unique_ptr<CFX_DIBitmap> pBitmap = pBitmap1->FlipImage(false, true); if (!pBitmap) return false; @@ -797,7 +796,7 @@ bool CGdiDeviceDriver::GDI_SetDIBits( int width = pSrcRect->Width(), height = pSrcRect->Height(); LPBYTE pBuffer = pBitmap->GetBuffer(); - CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); + CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap.get()); ((BITMAPINFOHEADER*)info.c_str())->biHeight *= -1; FX_RECT dst_rect(0, 0, width, height); dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); @@ -807,15 +806,15 @@ bool CGdiDeviceDriver::GDI_SetDIBits( dst_height, pBuffer, (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS, SRCCOPY); } else { - CFX_RetainPtr<CFX_DIBitmap> pBitmap = pBitmap1; + CFX_MaybeOwned<CFX_DIBitmap> pBitmap(pBitmap1); if (pBitmap->IsCmykImage()) { - pBitmap = pBitmap->CloneConvert(FXDIB_Rgb); + pBitmap = pBitmap->CloneConvert(FXDIB_Rgb).release(); if (!pBitmap) return false; } int width = pSrcRect->Width(), height = pSrcRect->Height(); LPBYTE pBuffer = pBitmap->GetBuffer(); - CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); + CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap.Get()); ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, pBitmap->GetHeight() - pSrcRect->bottom, 0, pBitmap->GetHeight(), pBuffer, @@ -824,14 +823,13 @@ bool CGdiDeviceDriver::GDI_SetDIBits( return true; } -bool CGdiDeviceDriver::GDI_StretchDIBits( - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap1, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - uint32_t flags) { - CFX_RetainPtr<CFX_DIBitmap> pBitmap = pBitmap1; +bool CGdiDeviceDriver::GDI_StretchDIBits(CFX_DIBitmap* pBitmap1, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + uint32_t flags) { + CFX_DIBitmap* pBitmap = pBitmap1; if (!pBitmap || dest_width == 0 || dest_height == 0) return false; @@ -846,14 +844,14 @@ bool CGdiDeviceDriver::GDI_StretchDIBits( } else { SetStretchBltMode(m_hDC, COLORONCOLOR); } - CFX_RetainPtr<CFX_DIBitmap> pToStrechBitmap = pBitmap; + CFX_MaybeOwned<CFX_DIBitmap> pToStrechBitmap(pBitmap); if (m_DeviceClass == FXDC_PRINTER && ((int64_t)pBitmap->GetWidth() * pBitmap->GetHeight() > (int64_t)abs(dest_width) * abs(dest_height))) { pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); } CFX_ByteString toStrechBitmapInfo = - CFX_WindowsDIB::GetBitmapInfo(pToStrechBitmap); + CFX_WindowsDIB::GetBitmapInfo(pToStrechBitmap.Get()); ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeight(), pToStrechBitmap->GetBuffer(), @@ -862,15 +860,14 @@ bool CGdiDeviceDriver::GDI_StretchDIBits( return true; } -bool CGdiDeviceDriver::GDI_StretchBitMask( - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap1, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - uint32_t bitmap_color, - uint32_t flags) { - CFX_RetainPtr<CFX_DIBitmap> pBitmap = pBitmap1; +bool CGdiDeviceDriver::GDI_StretchBitMask(CFX_DIBitmap* pBitmap1, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + uint32_t bitmap_color, + uint32_t flags) { + CFX_DIBitmap* pBitmap = pBitmap1; if (!pBitmap || dest_width == 0 || dest_height == 0) return false; @@ -1168,9 +1165,7 @@ CGdiDisplayDriver::CGdiDisplayDriver(HDC hDC) CGdiDisplayDriver::~CGdiDisplayDriver() {} -bool CGdiDisplayDriver::GetDIBits(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, - int left, - int top) { +bool CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) { bool ret = false; int width = pBitmap->GetWidth(); int height = pBitmap->GetHeight(); @@ -1190,12 +1185,12 @@ bool CGdiDisplayDriver::GetDIBits(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi, DIB_RGB_COLORS) == height; } else { - auto bitmap = pdfium::MakeRetain<CFX_DIBitmap>(); - if (bitmap->Create(width, height, FXDIB_Rgb)) { + CFX_DIBitmap bitmap; + if (bitmap.Create(width, height, FXDIB_Rgb)) { bmi.bmiHeader.biBitCount = 24; - ::GetDIBits(hDCMemory, hbmp, 0, height, bitmap->GetBuffer(), &bmi, + ::GetDIBits(hDCMemory, hbmp, 0, height, bitmap.GetBuffer(), &bmi, DIB_RGB_COLORS); - ret = pBitmap->TransferBitmap(0, 0, width, height, bitmap, 0, 0); + ret = pBitmap->TransferBitmap(0, 0, width, height, &bitmap, 0, 0); } else { ret = false; } @@ -1208,7 +1203,7 @@ bool CGdiDisplayDriver::GetDIBits(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, return ret; } -bool CGdiDisplayDriver::SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, +bool CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, uint32_t color, const FX_RECT* pSrcRect, int left, @@ -1219,16 +1214,17 @@ bool CGdiDisplayDriver::SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, int width = pSource->GetWidth(), height = pSource->GetHeight(); int alpha = FXARGB_A(color); if (pSource->GetBPP() != 1 || alpha != 255) { - auto background = pdfium::MakeRetain<CFX_DIBitmap>(); - if (!background->Create(width, height, FXDIB_Rgb32) || - !GetDIBits(background, left, top) || - !background->CompositeMask(0, 0, width, height, pSource, color, 0, 0, - FXDIB_BLEND_NORMAL, nullptr, false, 0, - nullptr)) { + CFX_DIBitmap background; + if (!background.Create(width, height, FXDIB_Rgb32) || + !GetDIBits(&background, left, top) || + !background.CompositeMask(0, 0, width, height, pSource, color, 0, 0, + FXDIB_BLEND_NORMAL, nullptr, false, 0, + nullptr)) { return false; } FX_RECT src_rect(0, 0, width, height); - return SetDIBits(background, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL); + return SetDIBits(&background, 0, &src_rect, left, top, + FXDIB_BLEND_NORMAL); } FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->Height()); @@ -1238,33 +1234,32 @@ bool CGdiDisplayDriver::SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, } int width = pSrcRect->Width(), height = pSrcRect->Height(); if (pSource->HasAlpha()) { - auto bitmap = pdfium::MakeRetain<CFX_DIBitmap>(); - if (!bitmap->Create(width, height, FXDIB_Rgb) || - !GetDIBits(bitmap, left, top) || - !bitmap->CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, - pSrcRect->top, FXDIB_BLEND_NORMAL, nullptr, - false, nullptr)) { + CFX_DIBitmap bitmap; + if (!bitmap.Create(width, height, FXDIB_Rgb) || + !GetDIBits(&bitmap, left, top) || + !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, + pSrcRect->top, FXDIB_BLEND_NORMAL, nullptr, + false, nullptr)) { return false; } FX_RECT src_rect(0, 0, width, height); - return SetDIBits(bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL); + return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL); } CFX_DIBExtractor temp(pSource); - CFX_RetainPtr<CFX_DIBitmap> pBitmap = temp.GetBitmap(); + CFX_DIBitmap* pBitmap = temp.GetBitmap(); if (!pBitmap) return false; return GDI_SetDIBits(pBitmap, pSrcRect, left, top); } -bool CGdiDisplayDriver::UseFoxitStretchEngine( - const CFX_RetainPtr<CFX_DIBSource>& pSource, - uint32_t color, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - const FX_RECT* pClipRect, - int render_flags) { +bool CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, + uint32_t color, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + const FX_RECT* pClipRect, + int render_flags) { FX_RECT bitmap_clip = *pClipRect; if (dest_width < 0) dest_left += dest_width; @@ -1273,26 +1268,25 @@ bool CGdiDisplayDriver::UseFoxitStretchEngine( dest_top += dest_height; bitmap_clip.Offset(-dest_left, -dest_top); - CFX_RetainPtr<CFX_DIBitmap> pStretched = - pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip); + std::unique_ptr<CFX_DIBitmap> pStretched( + pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip)); if (!pStretched) return true; FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight()); - return SetDIBits(pStretched, color, &src_rect, pClipRect->left, + return SetDIBits(pStretched.get(), color, &src_rect, pClipRect->left, pClipRect->top, FXDIB_BLEND_NORMAL); } -bool CGdiDisplayDriver::StretchDIBits( - const CFX_RetainPtr<CFX_DIBSource>& pSource, - uint32_t color, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - const FX_RECT* pClipRect, - uint32_t flags, - int blend_type) { +bool CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, + uint32_t color, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + const FX_RECT* pClipRect, + uint32_t flags, + int blend_type) { ASSERT(pSource && pClipRect); if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 10000 || dest_height < -10000) { @@ -1309,23 +1303,24 @@ bool CGdiDisplayDriver::StretchDIBits( clip_rect.Intersect(*pClipRect); clip_rect.Offset(-image_rect.left, -image_rect.top); int clip_width = clip_rect.Width(), clip_height = clip_rect.Height(); - CFX_RetainPtr<CFX_DIBitmap> pStretched( + std::unique_ptr<CFX_DIBitmap> pStretched( pSource->StretchTo(dest_width, dest_height, flags, &clip_rect)); if (!pStretched) return true; - auto background = pdfium::MakeRetain<CFX_DIBitmap>(); - if (!background->Create(clip_width, clip_height, FXDIB_Rgb32) || - !GetDIBits(background, image_rect.left + clip_rect.left, + CFX_DIBitmap background; + if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) || + !GetDIBits(&background, image_rect.left + clip_rect.left, image_rect.top + clip_rect.top) || - !background->CompositeMask(0, 0, clip_width, clip_height, pStretched, - color, 0, 0, FXDIB_BLEND_NORMAL, nullptr, - false, 0, nullptr)) { + !background.CompositeMask( + 0, 0, clip_width, clip_height, pStretched.get(), color, 0, 0, + FXDIB_BLEND_NORMAL, nullptr, false, 0, nullptr)) { return false; } FX_RECT src_rect(0, 0, clip_width, clip_height); - return SetDIBits(background, 0, &src_rect, image_rect.left + clip_rect.left, + return SetDIBits(&background, 0, &src_rect, + image_rect.left + clip_rect.left, image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL); } if (pSource->HasAlpha()) { @@ -1333,7 +1328,7 @@ bool CGdiDisplayDriver::StretchDIBits( (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); if (pPlatform->m_GdiplusExt.IsAvailable() && !pSource->IsCmykImage()) { CFX_DIBExtractor temp(pSource); - CFX_RetainPtr<CFX_DIBitmap> pBitmap = temp.GetBitmap(); + CFX_DIBitmap* pBitmap = temp.GetBitmap(); if (!pBitmap) return false; return pPlatform->m_GdiplusExt.StretchDIBits( @@ -1344,14 +1339,14 @@ bool CGdiDisplayDriver::StretchDIBits( dest_width, dest_height, pClipRect, flags); } CFX_DIBExtractor temp(pSource); - CFX_RetainPtr<CFX_DIBitmap> pBitmap = temp.GetBitmap(); + CFX_DIBitmap* pBitmap = temp.GetBitmap(); if (!pBitmap) return false; return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_height, flags); } -bool CGdiDisplayDriver::StartDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, +bool CGdiDisplayDriver::StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, diff --git a/core/fxge/win32/fx_win32_dib.cpp b/core/fxge/win32/fx_win32_dib.cpp index 9815457bbd..9b85b57317 100644 --- a/core/fxge/win32/fx_win32_dib.cpp +++ b/core/fxge/win32/fx_win32_dib.cpp @@ -11,8 +11,7 @@ #include "core/fxge/win32/cfx_windowsdib.h" #include "core/fxge/win32/win32_int.h" -CFX_ByteString CFX_WindowsDIB::GetBitmapInfo( - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap) { +CFX_ByteString CFX_WindowsDIB::GetBitmapInfo(const CFX_DIBitmap* pBitmap) { CFX_ByteString result; int len = sizeof(BITMAPINFOHEADER); if (pBitmap->GetBPP() == 1 || pBitmap->GetBPP() == 8) { @@ -52,9 +51,9 @@ CFX_ByteString CFX_WindowsDIB::GetBitmapInfo( return result; } -CFX_RetainPtr<CFX_DIBitmap> _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, - LPVOID pData, - bool bAlpha) { +CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, + LPVOID pData, + bool bAlpha) { int width = pbmi->bmiHeader.biWidth; int height = pbmi->bmiHeader.biHeight; BOOL bBottomUp = true; @@ -63,13 +62,15 @@ CFX_RetainPtr<CFX_DIBitmap> _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, bBottomUp = false; } int pitch = (width * pbmi->bmiHeader.biBitCount + 31) / 32 * 4; - auto pBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); + CFX_DIBitmap* pBitmap = new CFX_DIBitmap; FXDIB_Format format = bAlpha ? (FXDIB_Format)(pbmi->bmiHeader.biBitCount + 0x200) : (FXDIB_Format)pbmi->bmiHeader.biBitCount; - if (!pBitmap->Create(width, height, format)) + bool ret = pBitmap->Create(width, height, format); + if (!ret) { + delete pBitmap; return nullptr; - + } FXSYS_memcpy(pBitmap->GetBuffer(), pData, pitch * height); if (bBottomUp) { uint8_t* temp_buf = FX_Alloc(uint8_t, pitch); @@ -97,13 +98,11 @@ CFX_RetainPtr<CFX_DIBitmap> _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, return pBitmap; } -CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, - LPVOID pData) { +CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) { return _FX_WindowsDIB_LoadFromBuf(pbmi, pData, false); } -HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, - HDC hDC) { +HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) { CFX_ByteString info = GetBitmapInfo(pBitmap); return CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT, pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), @@ -117,8 +116,7 @@ void GetBitmapSize(HBITMAP hBitmap, int& w, int& h) { h = bmp.bmHeight; } -CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromFile( - const wchar_t* filename) { +CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const wchar_t* filename) { CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); if (pPlatform->m_GdiplusExt.IsAvailable()) { @@ -133,29 +131,30 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromFile( return nullptr; } HDC hDC = CreateCompatibleDC(nullptr); - int width; - int height; + int width, height; GetBitmapSize(hBitmap, width, height); - auto pDIBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); + CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { + delete pDIBitmap; DeleteDC(hDC); return nullptr; } CFX_ByteString info = GetBitmapInfo(pDIBitmap); int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); + if (!ret) { + delete pDIBitmap; + pDIBitmap = nullptr; + } DeleteDC(hDC); - if (!ret) - return nullptr; return pDIBitmap; } -CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadFromFile(const char* filename) { +CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const char* filename) { return LoadFromFile(CFX_WideString::FromLocal(filename).c_str()); } -CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadDIBitmap( - WINDIB_Open_Args_ args) { +CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) { CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); if (pPlatform->m_GdiplusExt.IsAvailable()) { @@ -172,17 +171,20 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_WindowsDIB::LoadDIBitmap( HDC hDC = CreateCompatibleDC(nullptr); int width, height; GetBitmapSize(hBitmap, width, height); - auto pDIBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); + CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { + delete pDIBitmap; DeleteDC(hDC); return nullptr; } CFX_ByteString info = GetBitmapInfo(pDIBitmap); int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); + if (!ret) { + delete pDIBitmap; + pDIBitmap = nullptr; + } DeleteDC(hDC); - if (!ret) - return nullptr; return pDIBitmap; } diff --git a/core/fxge/win32/fx_win32_dwrite.cpp b/core/fxge/win32/fx_win32_dwrite.cpp index 91fb465af4..e088e832bc 100644 --- a/core/fxge/win32/fx_win32_dwrite.cpp +++ b/core/fxge/win32/fx_win32_dwrite.cpp @@ -103,7 +103,7 @@ class CDwFontContext { class CDwGdiTextRenderer { public: - CDwGdiTextRenderer(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, + CDwGdiTextRenderer(CFX_DIBitmap* pBitmap, IDWriteBitmapRenderTarget* bitmapRenderTarget, IDWriteRenderingParams* renderingParams); ~CDwGdiTextRenderer(); @@ -118,7 +118,7 @@ class CDwGdiTextRenderer { const COLORREF& textColor); private: - CFX_RetainPtr<CFX_DIBitmap> pBitmap_; + CFX_DIBitmap* pBitmap_; IDWriteBitmapRenderTarget* pRenderTarget_; IDWriteRenderingParams* pRenderingParams_; }; @@ -180,9 +180,8 @@ failed: return nullptr; } -bool CDWriteExt::DwCreateRenderingTarget( - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, - void** renderTarget) { +bool CDWriteExt::DwCreateRenderingTarget(CFX_DIBitmap* pBitmap, + void** renderTarget) { if (pBitmap->GetFormat() > FXDIB_Argb) { return false; } @@ -396,7 +395,7 @@ HRESULT CDwFontContext::Initialize() { } CDwGdiTextRenderer::CDwGdiTextRenderer( - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, + CFX_DIBitmap* pBitmap, IDWriteBitmapRenderTarget* bitmapRenderTarget, IDWriteRenderingParams* renderingParams) : pBitmap_(pBitmap), @@ -427,13 +426,13 @@ STDMETHODIMP CDwGdiTextRenderer::DrawGlyphRun( HBITMAP hBitmap = (HBITMAP)::GetCurrentObject(hDC, OBJ_BITMAP); BITMAP bitmap; GetObject(hBitmap, sizeof bitmap, &bitmap); - auto dib = pdfium::MakeRetain<CFX_DIBitmap>(); - dib->Create(bitmap.bmWidth, bitmap.bmHeight, - bitmap.bmBitsPixel == 24 ? FXDIB_Rgb : FXDIB_Rgb32, - (uint8_t*)bitmap.bmBits); - dib->CompositeBitmap(text_bbox.left, text_bbox.top, text_bbox.Width(), - text_bbox.Height(), pBitmap_, text_bbox.left, - text_bbox.top, FXDIB_BLEND_NORMAL, nullptr); + CFX_DIBitmap dib; + dib.Create(bitmap.bmWidth, bitmap.bmHeight, + bitmap.bmBitsPixel == 24 ? FXDIB_Rgb : FXDIB_Rgb32, + (uint8_t*)bitmap.bmBits); + dib.CompositeBitmap(text_bbox.left, text_bbox.top, text_bbox.Width(), + text_bbox.Height(), pBitmap_, text_bbox.left, + text_bbox.top, FXDIB_BLEND_NORMAL, nullptr); hr = pRenderTarget_->DrawGlyphRun(baselineOriginX, baselineOriginY, measuringMode, glyphRun, pRenderingParams_, textColor); @@ -441,7 +440,7 @@ STDMETHODIMP CDwGdiTextRenderer::DrawGlyphRun( return hr; } pBitmap_->CompositeBitmap(text_bbox.left, text_bbox.top, text_bbox.Width(), - text_bbox.Height(), dib, text_bbox.left, + text_bbox.Height(), &dib, text_bbox.left, text_bbox.top, FXDIB_BLEND_NORMAL, pClipRgn); return hr; } diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index 41f9ba55ad..8a7f55e0cb 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -461,10 +461,10 @@ static GpBrush* _GdipCreateBrush(DWORD argb) { return solidBrush; } -static CFX_RetainPtr<CFX_DIBitmap> StretchMonoToGray( +static std::unique_ptr<CFX_DIBitmap> StretchMonoToGray( int dest_width, int dest_height, - const CFX_RetainPtr<CFX_DIBitmap>& pSource, + const CFX_DIBitmap* pSource, FX_RECT* pClipRect) { bool bFlipX = dest_width < 0; if (bFlipX) @@ -477,7 +477,7 @@ static CFX_RetainPtr<CFX_DIBitmap> StretchMonoToGray( int result_width = pClipRect->Width(); int result_height = pClipRect->Height(); int result_pitch = (result_width + 3) / 4 * 4; - auto pStretched = pdfium::MakeRetain<CFX_DIBitmap>(); + auto pStretched = pdfium::MakeUnique<CFX_DIBitmap>(); if (!pStretched->Create(result_width, result_height, FXDIB_8bppRgb)) return nullptr; @@ -518,7 +518,7 @@ static CFX_RetainPtr<CFX_DIBitmap> StretchMonoToGray( static void OutputImageMask(GpGraphics* pGraphics, BOOL bMonoDevice, - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, + const CFX_DIBitmap* pBitmap, int dest_left, int dest_top, int dest_width, @@ -562,7 +562,7 @@ static void OutputImageMask(GpGraphics* pGraphics, return; } image_clip.Offset(-image_rect.left, -image_rect.top); - CFX_RetainPtr<CFX_DIBitmap> pStretched; + std::unique_ptr<CFX_DIBitmap> pStretched; if (src_width * src_height > 10000) { pStretched = StretchMonoToGray(dest_width, dest_height, pBitmap, &image_clip); @@ -602,7 +602,7 @@ static void OutputImageMask(GpGraphics* pGraphics, CallFunc(GdipDisposeImage)(bitmap); } static void OutputImage(GpGraphics* pGraphics, - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, + const CFX_DIBitmap* pBitmap, const FX_RECT* pSrcRect, int dest_left, int dest_top, @@ -613,11 +613,11 @@ static void OutputImage(GpGraphics* pGraphics, ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; if (pBitmap->GetBPP() == 1 && (pSrcRect->left % 8)) { FX_RECT new_rect(0, 0, src_width, src_height); - CFX_RetainPtr<CFX_DIBitmap> pCloned = pBitmap->Clone(pSrcRect); + std::unique_ptr<CFX_DIBitmap> pCloned = pBitmap->Clone(pSrcRect); if (!pCloned) return; - OutputImage(pGraphics, pCloned, &new_rect, dest_left, dest_top, dest_width, - dest_height); + OutputImage(pGraphics, pCloned.get(), &new_rect, dest_left, dest_top, + dest_width, dest_height); return; } int src_pitch = pBitmap->GetPitch(); @@ -730,8 +730,7 @@ void CGdiplusExt::DeleteMemFont(LPVOID pCollection) { ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; CallFunc(GdipDeletePrivateFontCollection)((GpFontCollection**)&pCollection); } -bool CGdiplusExt::GdipCreateBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, - void** bitmap) { +bool CGdiplusExt::GdipCreateBitmap(CFX_DIBitmap* pBitmap, void** bitmap) { CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; PixelFormat format; @@ -913,7 +912,7 @@ void CGdiplusExt::GdipDeleteGraphics(void* graphics) { } bool CGdiplusExt::StretchBitMask(HDC hDC, BOOL bMonoDevice, - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, + const CFX_DIBitmap* pBitmap, int dest_left, int dest_top, int dest_width, @@ -939,7 +938,7 @@ bool CGdiplusExt::StretchBitMask(HDC hDC, return true; } bool CGdiplusExt::StretchDIBits(HDC hDC, - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, + const CFX_DIBitmap* pBitmap, int dest_left, int dest_top, int dest_width, @@ -1493,16 +1492,14 @@ static void FreeDIBitmap(PREVIEW3_DIBITMAP* pInfo) { FX_Free(pInfo); } -// TODO(tsepez): Really? Really? Move to header. -CFX_RetainPtr<CFX_DIBitmap> _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, - LPVOID pData, - bool bAlpha); - -CFX_RetainPtr<CFX_DIBitmap> CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) { +CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, + LPVOID pData, + bool bAlpha); +CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) { PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args); - if (!pInfo) + if (!pInfo) { return nullptr; - + } int height = abs(pInfo->pbmi->bmiHeader.biHeight); int width = pInfo->pbmi->bmiHeader.biWidth; int dest_pitch = (width * pInfo->pbmi->bmiHeader.biBitCount + 31) / 32 * 4; @@ -1515,7 +1512,7 @@ CFX_RetainPtr<CFX_DIBitmap> CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) { dest_pitch); } } - CFX_RetainPtr<CFX_DIBitmap> pDIBitmap = _FX_WindowsDIB_LoadFromBuf( + CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf( pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32); FX_Free(pData); FreeDIBitmap(pInfo); diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index 6d96243655..061896f09b 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -67,7 +67,7 @@ int CGdiPrinterDriver::GetDeviceCaps(int caps_id) const { return CGdiDeviceDriver::GetDeviceCaps(caps_id); } -bool CGdiPrinterDriver::SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, +bool CGdiPrinterDriver::SetDIBits(const CFX_DIBSource* pSource, uint32_t color, const FX_RECT* pSrcRect, int left, @@ -87,30 +87,29 @@ bool CGdiPrinterDriver::SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, return false; CFX_DIBExtractor temp(pSource); - CFX_RetainPtr<CFX_DIBitmap> pBitmap = temp.GetBitmap(); + CFX_DIBitmap* pBitmap = temp.GetBitmap(); if (!pBitmap) return false; return GDI_SetDIBits(pBitmap, pSrcRect, left, top); } -bool CGdiPrinterDriver::StretchDIBits( - const CFX_RetainPtr<CFX_DIBSource>& pSource, - uint32_t color, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - const FX_RECT* pClipRect, - uint32_t flags, - int blend_type) { +bool CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource, + uint32_t color, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + const FX_RECT* pClipRect, + uint32_t flags, + int blend_type) { if (pSource->IsAlphaMask()) { int alpha = FXARGB_A(color); if (pSource->GetBPP() != 1 || alpha != 255) return false; if (dest_width < 0 || dest_height < 0) { - CFX_RetainPtr<CFX_DIBitmap> pFlipped = + std::unique_ptr<CFX_DIBitmap> pFlipped = pSource->FlipImage(dest_width < 0, dest_height < 0); if (!pFlipped) return false; @@ -120,12 +119,13 @@ bool CGdiPrinterDriver::StretchDIBits( if (dest_height < 0) dest_top += dest_height; - return GDI_StretchBitMask(pFlipped, dest_left, dest_top, abs(dest_width), - abs(dest_height), color, flags); + return GDI_StretchBitMask(pFlipped.get(), dest_left, dest_top, + abs(dest_width), abs(dest_height), color, + flags); } CFX_DIBExtractor temp(pSource); - CFX_RetainPtr<CFX_DIBitmap> pBitmap = temp.GetBitmap(); + CFX_DIBitmap* pBitmap = temp.GetBitmap(); if (!pBitmap) return false; return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width, @@ -136,7 +136,7 @@ bool CGdiPrinterDriver::StretchDIBits( return false; if (dest_width < 0 || dest_height < 0) { - CFX_RetainPtr<CFX_DIBitmap> pFlipped = + std::unique_ptr<CFX_DIBitmap> pFlipped = pSource->FlipImage(dest_width < 0, dest_height < 0); if (!pFlipped) return false; @@ -146,19 +146,19 @@ bool CGdiPrinterDriver::StretchDIBits( if (dest_height < 0) dest_top += dest_height; - return GDI_StretchDIBits(pFlipped, dest_left, dest_top, abs(dest_width), - abs(dest_height), flags); + return GDI_StretchDIBits(pFlipped.get(), dest_left, dest_top, + abs(dest_width), abs(dest_height), flags); } CFX_DIBExtractor temp(pSource); - CFX_RetainPtr<CFX_DIBitmap> pBitmap = temp.GetBitmap(); + CFX_DIBitmap* pBitmap = temp.GetBitmap(); if (!pBitmap) return false; return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_height, flags); } -bool CGdiPrinterDriver::StartDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, +bool CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, @@ -185,12 +185,12 @@ bool CGdiPrinterDriver::StartDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, if (FXSYS_fabs(pMatrix->a) >= 0.5f || FXSYS_fabs(pMatrix->d) >= 0.5f) return false; - CFX_RetainPtr<CFX_DIBitmap> pTransformed = + std::unique_ptr<CFX_DIBitmap> pTransformed = pSource->SwapXY(pMatrix->c > 0, pMatrix->b < 0); if (!pTransformed) return false; - return StretchDIBits(pTransformed, color, full_rect.left, full_rect.top, + return StretchDIBits(pTransformed.get(), color, full_rect.left, full_rect.top, full_rect.Width(), full_rect.Height(), nullptr, 0, blend_type); } @@ -436,7 +436,7 @@ bool CPSPrinterDriver::GetClipBox(FX_RECT* pRect) { return true; } -bool CPSPrinterDriver::SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, +bool CPSPrinterDriver::SetDIBits(const CFX_DIBSource* pBitmap, uint32_t color, const FX_RECT* pSrcRect, int left, @@ -447,23 +447,22 @@ bool CPSPrinterDriver::SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, return m_PSRenderer.SetDIBits(pBitmap, color, left, top); } -bool CPSPrinterDriver::StretchDIBits( - const CFX_RetainPtr<CFX_DIBSource>& pBitmap, - uint32_t color, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - const FX_RECT* pClipRect, - uint32_t flags, - int blend_type) { +bool CPSPrinterDriver::StretchDIBits(const CFX_DIBSource* pBitmap, + uint32_t color, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + const FX_RECT* pClipRect, + uint32_t flags, + int blend_type) { if (blend_type != FXDIB_BLEND_NORMAL) return false; return m_PSRenderer.StretchDIBits(pBitmap, color, dest_left, dest_top, dest_width, dest_height, flags); } -bool CPSPrinterDriver::StartDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, +bool CPSPrinterDriver::StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h index 35521d0096..54ea3716e1 100644 --- a/core/fxge/win32/win32_int.h +++ b/core/fxge/win32/win32_int.h @@ -34,7 +34,7 @@ class CGdiplusExt { bool IsAvailable() { return !!m_hModule; } bool StretchBitMask(HDC hDC, BOOL bMonoDevice, - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, + const CFX_DIBitmap* pBitmap, int dest_left, int dest_top, int dest_width, @@ -43,7 +43,7 @@ class CGdiplusExt { const FX_RECT* pClipRect, int flags); bool StretchDIBits(HDC hDC, - const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, + const CFX_DIBitmap* pBitmap, int dest_left, int dest_top, int dest_width, @@ -96,8 +96,7 @@ class CGdiplusExt { float font_size, int fontstyle); void GdipDeleteFont(void* pFont); - bool GdipCreateBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, - void** bitmap); + bool GdipCreateBitmap(CFX_DIBitmap* pBitmap, void** bitmap); void GdipDisposeImage(void* bitmap); void GdipGetFontSize(void* pFont, float* size); void* GdiAddFontMemResourceEx(void* pFontdata, @@ -105,7 +104,7 @@ class CGdiplusExt { void* pdv, uint32_t* num_face); bool GdiRemoveFontMemResourceEx(void* handle); - CFX_RetainPtr<CFX_DIBitmap> LoadDIBitmap(WINDIB_Open_Args_ args); + CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args); FARPROC m_Functions[100]; FuncType_GdiAddFontMemResourceEx m_pGdiAddFontMemResourceEx; @@ -159,17 +158,17 @@ class CGdiDeviceDriver : public IFX_RenderDeviceDriver { void DrawLine(float x1, float y1, float x2, float y2); - bool GDI_SetDIBits(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, + bool GDI_SetDIBits(CFX_DIBitmap* pBitmap, const FX_RECT* pSrcRect, int left, int top); - bool GDI_StretchDIBits(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, + bool GDI_StretchDIBits(CFX_DIBitmap* pBitmap, int dest_left, int dest_top, int dest_width, int dest_height, uint32_t flags); - bool GDI_StretchBitMask(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, + bool GDI_StretchBitMask(CFX_DIBitmap* pBitmap, int dest_left, int dest_top, int dest_width, @@ -192,16 +191,14 @@ class CGdiDisplayDriver : public CGdiDeviceDriver { ~CGdiDisplayDriver() override; protected: - bool GetDIBits(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap, - int left, - int top) override; - bool SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, + bool GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) override; + bool SetDIBits(const CFX_DIBSource* pBitmap, uint32_t color, const FX_RECT* pSrcRect, int left, int top, int blend_type) override; - bool StretchDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, + bool StretchDIBits(const CFX_DIBSource* pBitmap, uint32_t color, int dest_left, int dest_top, @@ -210,14 +207,14 @@ class CGdiDisplayDriver : public CGdiDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int blend_type) override; - bool StartDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, + bool StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, uint32_t render_flags, void*& handle, int blend_type) override; - bool UseFoxitStretchEngine(const CFX_RetainPtr<CFX_DIBSource>& pSource, + bool UseFoxitStretchEngine(const CFX_DIBSource* pSource, uint32_t color, int dest_left, int dest_top, @@ -234,13 +231,13 @@ class CGdiPrinterDriver : public CGdiDeviceDriver { protected: int GetDeviceCaps(int caps_id) const override; - bool SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, + bool SetDIBits(const CFX_DIBSource* pBitmap, uint32_t color, const FX_RECT* pSrcRect, int left, int top, int blend_type) override; - bool StretchDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, + bool StretchDIBits(const CFX_DIBSource* pBitmap, uint32_t color, int dest_left, int dest_top, @@ -249,7 +246,7 @@ class CGdiPrinterDriver : public CGdiDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int blend_type) override; - bool StartDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, + bool StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, @@ -293,13 +290,13 @@ class CPSPrinterDriver : public IFX_RenderDeviceDriver { int fill_mode, int blend_type) override; bool GetClipBox(FX_RECT* pRect) override; - bool SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, + bool SetDIBits(const CFX_DIBSource* pBitmap, uint32_t color, const FX_RECT* pSrcRect, int left, int top, int blend_type) override; - bool StretchDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, + bool StretchDIBits(const CFX_DIBSource* pBitmap, uint32_t color, int dest_left, int dest_top, @@ -308,7 +305,7 @@ class CPSPrinterDriver : public IFX_RenderDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int blend_type) override; - bool StartDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, + bool StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, |