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/fx_win32_dib.cpp | |
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/fx_win32_dib.cpp')
-rw-r--r-- | core/fxge/win32/fx_win32_dib.cpp | 52 |
1 files changed, 27 insertions, 25 deletions
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; } |