summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/oned
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-27 13:51:46 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-28 14:14:50 +0000
commit0004f29bf6ee3c6060a272c79f14993e92e053c7 (patch)
treeb82385e4853a157e10148af8d95ebb6bae4fb4c7 /xfa/fxbarcode/oned
parent369fe1f7f9f3a424ee3cf8f992c3128db27fa479 (diff)
downloadpdfium-0004f29bf6ee3c6060a272c79f14993e92e053c7.tar.xz
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>
Diffstat (limited to 'xfa/fxbarcode/oned')
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimWriter.cpp35
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimWriter.h6
-rw-r--r--xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp16
-rw-r--r--xfa/fxbarcode/oned/BC_OnedEAN13Writer.h2
-rw-r--r--xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp17
-rw-r--r--xfa/fxbarcode/oned/BC_OnedEAN8Writer.h2
-rw-r--r--xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp17
-rw-r--r--xfa/fxbarcode/oned/BC_OnedUPCAWriter.h2
8 files changed, 47 insertions, 50 deletions
diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
index 02ae58dc84..16eba2df10 100644
--- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -224,13 +224,14 @@ void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device,
m_fontColor, FXTEXT_CLEARTYPE);
}
-void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap,
- const CFX_ByteString str,
- float geWidth,
- FXTEXT_CHARPOS* pCharPos,
- float locX,
- float locY,
- int32_t barWidth) {
+void CBC_OneDimWriter::ShowBitmapChars(
+ const CFX_RetainPtr<CFX_DIBitmap>& pOutBitmap,
+ const CFX_ByteString str,
+ float geWidth,
+ FXTEXT_CHARPOS* pCharPos,
+ float locX,
+ float locY,
+ int32_t barWidth) {
int32_t iFontSize = (int32_t)fabs(m_fFontSize);
int32_t iTextHeight = iFontSize + 1;
CFX_FxgeDevice ge;
@@ -248,7 +249,7 @@ void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap,
}
void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents,
- CFX_DIBitmap* pOutBitmap,
+ const CFX_RetainPtr<CFX_DIBitmap>& pOutBitmap,
CFX_RenderDevice* device,
const CFX_Matrix* matrix,
int32_t barWidth,
@@ -316,9 +317,10 @@ void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents,
FX_Free(pCharPos);
}
-void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
- const CFX_WideStringC& contents,
- int32_t& e) {
+void CBC_OneDimWriter::RenderBitmapResult(
+ CFX_RetainPtr<CFX_DIBitmap>& pOutBitmap,
+ const CFX_WideStringC& contents,
+ int32_t& e) {
if (!m_output)
if (e != BCExceptionNO)
return;
@@ -337,20 +339,17 @@ void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
}
}
int32_t i = 0;
- for (; i < contents.GetLength(); i++)
- if (contents.GetAt(i) != ' ') {
+ for (; i < contents.GetLength(); i++) {
+ if (contents.GetAt(i) != ' ')
break;
- }
+ }
if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) {
ShowChars(contents, pOutBitmap, nullptr, nullptr, m_barWidth, m_multiple,
e);
if (e != BCExceptionNO)
return;
}
- std::unique_ptr<CFX_DIBitmap> pStretchBitmap =
- pOutBitmap->StretchTo(m_Width, m_Height);
- delete pOutBitmap;
- pOutBitmap = pStretchBitmap.release();
+ pOutBitmap = pOutBitmap->StretchTo(m_Width, m_Height);
}
void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device,
diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.h b/xfa/fxbarcode/oned/BC_OneDimWriter.h
index b2447cffb7..4892889ddb 100644
--- a/xfa/fxbarcode/oned/BC_OneDimWriter.h
+++ b/xfa/fxbarcode/oned/BC_OneDimWriter.h
@@ -42,7 +42,7 @@ class CBC_OneDimWriter : public CBC_Writer {
int32_t codeLength,
bool isDevice,
int32_t& e);
- virtual void RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
+ virtual void RenderBitmapResult(CFX_RetainPtr<CFX_DIBitmap>& pOutBitmap,
const CFX_WideStringC& contents,
int32_t& e);
virtual void RenderDeviceResult(CFX_RenderDevice* device,
@@ -68,13 +68,13 @@ class CBC_OneDimWriter : public CBC_Writer {
int32_t fontSize,
float& charsLen);
virtual void ShowChars(const CFX_WideStringC& contents,
- CFX_DIBitmap* pOutBitmap,
+ const CFX_RetainPtr<CFX_DIBitmap>& pOutBitmap,
CFX_RenderDevice* device,
const CFX_Matrix* matrix,
int32_t barWidth,
int32_t multiple,
int32_t& e);
- virtual void ShowBitmapChars(CFX_DIBitmap* pOutBitmap,
+ virtual void ShowBitmapChars(const CFX_RetainPtr<CFX_DIBitmap>& pOutBitmap,
const CFX_ByteString str,
float geWidth,
FXTEXT_CHARPOS* pCharPos,
diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index 555b58643d..dcea777089 100644
--- a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -167,13 +167,14 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents,
return result;
}
-void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
- CFX_DIBitmap* pOutBitmap,
- CFX_RenderDevice* device,
- const CFX_Matrix* matrix,
- int32_t barWidth,
- int32_t multiple,
- int32_t& e) {
+void CBC_OnedEAN13Writer::ShowChars(
+ const CFX_WideStringC& contents,
+ const CFX_RetainPtr<CFX_DIBitmap>& pOutBitmap,
+ CFX_RenderDevice* device,
+ const CFX_Matrix* matrix,
+ int32_t barWidth,
+ int32_t multiple,
+ int32_t& e) {
if (!device && !pOutBitmap) {
e = BCExceptionIllegalArgument;
return;
@@ -278,7 +279,6 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
CalcTextInfo(tempStr, pCharPos, m_pFont, (float)strWidth, iFontSize, blank);
if (pOutBitmap) {
- delete ge.GetBitmap();
ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
ge.DrawNormalText(iLen, pCharPos, m_pFont, static_cast<float>(iFontSize),
diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.h b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.h
index 5775f89046..8336259568 100644
--- a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.h
+++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.h
@@ -46,7 +46,7 @@ class CBC_OnedEAN13Writer : public CBC_OneDimWriter {
protected:
void ShowChars(const CFX_WideStringC& contents,
- CFX_DIBitmap* pOutBitmap,
+ const CFX_RetainPtr<CFX_DIBitmap>& pOutBitmap,
CFX_RenderDevice* device,
const CFX_Matrix* matrix,
int32_t barWidth,
diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp
index 5f571c2a30..a7fa30c811 100644
--- a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp
@@ -165,13 +165,14 @@ uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents,
return result;
}
-void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
- CFX_DIBitmap* pOutBitmap,
- CFX_RenderDevice* device,
- const CFX_Matrix* matrix,
- int32_t barWidth,
- int32_t multiple,
- int32_t& e) {
+void CBC_OnedEAN8Writer::ShowChars(
+ const CFX_WideStringC& contents,
+ const CFX_RetainPtr<CFX_DIBitmap>& pOutBitmap,
+ CFX_RenderDevice* device,
+ const CFX_Matrix* matrix,
+ int32_t barWidth,
+ int32_t multiple,
+ int32_t& e) {
if (!device && !pOutBitmap) {
e = BCExceptionIllegalArgument;
return;
@@ -217,7 +218,6 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (float)iFontSize);
CFX_FxgeDevice ge;
if (pOutBitmap) {
- delete ge.GetBitmap();
ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
ge.DrawNormalText(iLen, pCharPos, m_pFont, static_cast<float>(iFontSize),
@@ -237,7 +237,6 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
CalcTextInfo(tempStr, pCharPos + 4, m_pFont, (float)strWidth, iFontSize,
blank);
if (pOutBitmap) {
- delete ge.GetBitmap();
ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
ge.DrawNormalText(iLen, pCharPos + 4, m_pFont,
diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.h b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.h
index 844fc33afa..b9921babc3 100644
--- a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.h
+++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.h
@@ -50,7 +50,7 @@ class CBC_OnedEAN8Writer : public CBC_OneDimWriter {
protected:
void ShowChars(const CFX_WideStringC& contents,
- CFX_DIBitmap* pOutBitmap,
+ const CFX_RetainPtr<CFX_DIBitmap>& pOutBitmap,
CFX_RenderDevice* device,
const CFX_Matrix* matrix,
int32_t barWidth,
diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index cefae97d8d..540e852d5d 100644
--- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -117,13 +117,14 @@ uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents,
return nullptr;
}
-void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
- CFX_DIBitmap* pOutBitmap,
- CFX_RenderDevice* device,
- const CFX_Matrix* matrix,
- int32_t barWidth,
- int32_t multiple,
- int32_t& e) {
+void CBC_OnedUPCAWriter::ShowChars(
+ const CFX_WideStringC& contents,
+ const CFX_RetainPtr<CFX_DIBitmap>& pOutBitmap,
+ CFX_RenderDevice* device,
+ const CFX_Matrix* matrix,
+ int32_t barWidth,
+ int32_t multiple,
+ int32_t& e) {
if (!device && !pOutBitmap) {
e = BCExceptionIllegalArgument;
return;
@@ -235,7 +236,6 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank);
if (pOutBitmap) {
- delete ge.GetBitmap();
ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
ge.DrawNormalText(iLen, pCharPos, m_pFont, static_cast<float>(iFontSize),
@@ -255,7 +255,6 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
iLen = tempStr.GetLength();
CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank);
if (pOutBitmap) {
- delete ge.GetBitmap();
ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
ge.DrawNormalText(iLen, pCharPos + 11, m_pFont,
diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h
index 6b786ce3b8..6c0929a051 100644
--- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h
+++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h
@@ -52,7 +52,7 @@ class CBC_OnedUPCAWriter : public CBC_OneDimWriter {
protected:
void ShowChars(const CFX_WideStringC& contents,
- CFX_DIBitmap* pOutBitmap,
+ const CFX_RetainPtr<CFX_DIBitmap>& pOutBitmap,
CFX_RenderDevice* device,
const CFX_Matrix* matrix,
int32_t barWidth,