summaryrefslogtreecommitdiff
path: root/core/fxge/dib/fx_dib_convert.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2017-03-28 15:47:47 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-03-28 15:48:01 +0000
commit31b08d4cdaa17d7a03f35e087096a77036af98ec (patch)
tree40234b81f2972c857a33a86cb4b59868e56bb86b /core/fxge/dib/fx_dib_convert.cpp
parenta3e9bf66c3483db926602aa62b0bd1ff8d1357a1 (diff)
downloadpdfium-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/dib/fx_dib_convert.cpp')
-rw-r--r--core/fxge/dib/fx_dib_convert.cpp122
1 files changed, 61 insertions, 61 deletions
diff --git a/core/fxge/dib/fx_dib_convert.cpp b/core/fxge/dib/fx_dib_convert.cpp
index 624e1437e9..aad3f343e2 100644
--- a/core/fxge/dib/fx_dib_convert.cpp
+++ b/core/fxge/dib/fx_dib_convert.cpp
@@ -17,7 +17,7 @@ class CFX_Palette {
CFX_Palette();
~CFX_Palette();
- bool BuildPalette(const CFX_RetainPtr<CFX_DIBSource>& pBitmap);
+ bool BuildPalette(const CFX_DIBSource* pBitmap);
uint32_t* GetPalette() const { return m_pPalette; }
uint32_t* GetColorLut() const { return m_cLut; }
uint32_t* GetAmountLut() const { return m_aLut; }
@@ -101,7 +101,7 @@ CFX_Palette::~CFX_Palette() {
m_lut = 0;
}
-bool CFX_Palette::BuildPalette(const CFX_RetainPtr<CFX_DIBSource>& pBitmap) {
+bool CFX_Palette::BuildPalette(const CFX_DIBSource* pBitmap) {
if (!pBitmap) {
return false;
}
@@ -145,7 +145,7 @@ bool ConvertBuffer_1bppMask2Gray(uint8_t* dest_buf,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top) {
uint8_t set_gray, reset_gray;
@@ -169,7 +169,7 @@ bool ConvertBuffer_8bppMask2Gray(uint8_t* dest_buf,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top) {
for (int row = 0; row < height; row++) {
@@ -184,7 +184,7 @@ bool ConvertBuffer_1bppPlt2Gray(uint8_t* dest_buf,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top) {
uint32_t* src_plt = pSrcBitmap->GetPalette();
@@ -231,7 +231,7 @@ bool ConvertBuffer_8bppPlt2Gray(uint8_t* dest_buf,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top) {
uint32_t* src_plt = pSrcBitmap->GetPalette();
@@ -263,14 +263,13 @@ bool ConvertBuffer_8bppPlt2Gray(uint8_t* dest_buf,
return true;
}
-bool ConvertBuffer_RgbOrCmyk2Gray(
- uint8_t* dest_buf,
- int dest_pitch,
- int width,
- int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
- int src_left,
- int src_top) {
+bool ConvertBuffer_RgbOrCmyk2Gray(uint8_t* dest_buf,
+ int dest_pitch,
+ int width,
+ int height,
+ const CFX_DIBSource* pSrcBitmap,
+ int src_left,
+ int src_top) {
int Bpp = pSrcBitmap->GetBPP() / 8;
if (pSrcBitmap->IsCmykImage()) {
for (int row = 0; row < height; row++) {
@@ -305,7 +304,7 @@ void ConvertBuffer_IndexCopy(uint8_t* dest_buf,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top) {
if (pSrcBitmap->GetBPP() == 1) {
@@ -334,7 +333,7 @@ bool ConvertBuffer_Plt2PltRgb8(uint8_t* dest_buf,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top,
uint32_t* dst_plt) {
@@ -362,7 +361,7 @@ bool ConvertBuffer_Rgb2PltRgb8(uint8_t* dest_buf,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top,
uint32_t* dst_plt) {
@@ -425,7 +424,7 @@ bool ConvertBuffer_1bppMask2Rgb(FXDIB_Format dst_format,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top) {
int comps = (dst_format & 0xff) / 8;
@@ -456,7 +455,7 @@ bool ConvertBuffer_8bppMask2Rgb(FXDIB_Format dst_format,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top) {
int comps = (dst_format & 0xff) / 8;
@@ -480,7 +479,7 @@ bool ConvertBuffer_1bppPlt2Rgb(FXDIB_Format dst_format,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top) {
int comps = (dst_format & 0xff) / 8;
@@ -532,7 +531,7 @@ bool ConvertBuffer_8bppPlt2Rgb(FXDIB_Format dst_format,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top) {
int comps = (dst_format & 0xff) / 8;
@@ -573,14 +572,13 @@ bool ConvertBuffer_8bppPlt2Rgb(FXDIB_Format dst_format,
return true;
}
-bool ConvertBuffer_24bppRgb2Rgb24(
- uint8_t* dest_buf,
- int dest_pitch,
- int width,
- int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
- int src_left,
- int src_top) {
+bool ConvertBuffer_24bppRgb2Rgb24(uint8_t* dest_buf,
+ int dest_pitch,
+ int width,
+ int height,
+ const CFX_DIBSource* pSrcBitmap,
+ int src_left,
+ int src_top) {
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = dest_buf + row * dest_pitch;
const uint8_t* src_scan =
@@ -590,14 +588,13 @@ bool ConvertBuffer_24bppRgb2Rgb24(
return true;
}
-bool ConvertBuffer_32bppRgb2Rgb24(
- uint8_t* dest_buf,
- int dest_pitch,
- int width,
- int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
- int src_left,
- int src_top) {
+bool ConvertBuffer_32bppRgb2Rgb24(uint8_t* dest_buf,
+ int dest_pitch,
+ int width,
+ int height,
+ const CFX_DIBSource* pSrcBitmap,
+ int src_left,
+ int src_top) {
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = dest_buf + row * dest_pitch;
const uint8_t* src_scan =
@@ -616,7 +613,7 @@ bool ConvertBuffer_Rgb2Rgb32(uint8_t* dest_buf,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top) {
int comps = pSrcBitmap->GetBPP() / 8;
@@ -635,14 +632,13 @@ bool ConvertBuffer_Rgb2Rgb32(uint8_t* dest_buf,
return true;
}
-bool ConvertBuffer_32bppCmyk2Rgb32(
- uint8_t* dest_buf,
- int dest_pitch,
- int width,
- int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
- int src_left,
- int src_top) {
+bool ConvertBuffer_32bppCmyk2Rgb32(uint8_t* dest_buf,
+ int dest_pitch,
+ int width,
+ int height,
+ const CFX_DIBSource* pSrcBitmap,
+ int src_left,
+ int src_top) {
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = dest_buf + row * dest_pitch;
const uint8_t* src_scan =
@@ -662,7 +658,7 @@ bool ConvertBuffer(FXDIB_Format dest_format,
int dest_pitch,
int width,
int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
+ const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top,
std::unique_ptr<uint32_t, FxFreeDeleter>* p_pal) {
@@ -787,16 +783,16 @@ bool ConvertBuffer(FXDIB_Format dest_format,
}
}
-CFX_RetainPtr<CFX_DIBitmap> CFX_DIBSource::CloneConvert(
- FXDIB_Format dest_format) {
+std::unique_ptr<CFX_DIBitmap> CFX_DIBSource::CloneConvert(
+ FXDIB_Format dest_format) const {
if (dest_format == GetFormat())
return Clone(nullptr);
- auto pClone = pdfium::MakeRetain<CFX_DIBitmap>();
+ std::unique_ptr<CFX_DIBitmap> pClone = pdfium::MakeUnique<CFX_DIBitmap>();
if (!pClone->Create(m_Width, m_Height, dest_format))
return nullptr;
- CFX_RetainPtr<CFX_DIBitmap> pSrcAlpha;
+ CFX_MaybeOwned<CFX_DIBitmap> pSrcAlpha;
if (HasAlpha()) {
if (GetFormat() == FXDIB_Argb)
pSrcAlpha = CloneAlphaMask();
@@ -809,19 +805,19 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_DIBSource::CloneConvert(
bool ret = true;
if (dest_format & 0x0200) {
if (dest_format == FXDIB_Argb) {
- ret = pSrcAlpha ? pClone->LoadChannel(FXDIB_Alpha, pSrcAlpha, FXDIB_Alpha)
- : pClone->LoadChannel(FXDIB_Alpha, 0xff);
+ ret = pSrcAlpha
+ ? pClone->LoadChannel(FXDIB_Alpha, pSrcAlpha.Get(), FXDIB_Alpha)
+ : pClone->LoadChannel(FXDIB_Alpha, 0xff);
} else {
- ret = pClone->SetAlphaMask(pSrcAlpha);
+ ret = pClone->SetAlphaMask(pSrcAlpha.Get());
}
}
if (!ret)
return nullptr;
- CFX_RetainPtr<CFX_DIBSource> holder(this);
std::unique_ptr<uint32_t, FxFreeDeleter> pal_8bpp;
if (!ConvertBuffer(dest_format, pClone->GetBuffer(), pClone->GetPitch(),
- m_Width, m_Height, holder, 0, 0, &pal_8bpp)) {
+ m_Width, m_Height, this, 0, 0, &pal_8bpp)) {
return nullptr;
}
if (pal_8bpp)
@@ -857,7 +853,7 @@ bool CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) {
if (!dest_buf) {
return false;
}
- CFX_RetainPtr<CFX_DIBitmap> pAlphaMask;
+ CFX_DIBitmap* pAlphaMask = nullptr;
if (dest_format == FXDIB_Argb) {
FXSYS_memset(dest_buf, 0xff, dest_pitch * m_Height + 4);
if (m_pAlphaMask) {
@@ -872,7 +868,7 @@ bool CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) {
}
} else if (dest_format & 0x0200) {
if (src_format == FXDIB_Argb) {
- pAlphaMask = CloneAlphaMask();
+ pAlphaMask = CloneAlphaMask().release();
if (!pAlphaMask) {
FX_Free(dest_buf);
return false;
@@ -883,21 +879,25 @@ bool CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) {
FX_Free(dest_buf);
return false;
}
- pAlphaMask = std::move(m_pAlphaMask);
+ pAlphaMask = m_pAlphaMask;
+ m_pAlphaMask = nullptr;
} else {
pAlphaMask = m_pAlphaMask;
}
}
}
bool ret = false;
- CFX_RetainPtr<CFX_DIBSource> holder(this);
std::unique_ptr<uint32_t, FxFreeDeleter> pal_8bpp;
ret = ConvertBuffer(dest_format, dest_buf, dest_pitch, m_Width, m_Height,
- holder, 0, 0, &pal_8bpp);
+ this, 0, 0, &pal_8bpp);
if (!ret) {
+ if (pAlphaMask != m_pAlphaMask)
+ delete pAlphaMask;
FX_Free(dest_buf);
return false;
}
+ if (m_pAlphaMask && pAlphaMask != m_pAlphaMask)
+ delete m_pAlphaMask;
m_pAlphaMask = pAlphaMask;
m_pPalette = std::move(pal_8bpp);
if (!m_bExtBuf)