Use DataVector<T> in core/fxge/.
Easier to write than std::vector<T, FxAllocAllocator<T>>.
Change-Id: I8fb629f72c15b8190fd5eed6add93b134e676d13
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/96613
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/apple/fx_apple_impl.cpp b/core/fxge/apple/fx_apple_impl.cpp
index 67b464a..668d025 100644
--- a/core/fxge/apple/fx_apple_impl.cpp
+++ b/core/fxge/apple/fx_apple_impl.cpp
@@ -4,10 +4,12 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include <stdint.h>
+
#include <memory>
#include <vector>
-#include "core/fxcrt/fx_memory_wrappers.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxge/apple/fx_apple_platform.h"
#include "core/fxge/cfx_cliprgn.h"
@@ -57,8 +59,7 @@
if (!pFont->GetPlatformFont())
return false;
}
- std::vector<uint16_t, FxAllocAllocator<uint16_t>> glyph_indices(
- pCharPos.size());
+ DataVector<uint16_t> glyph_indices(pCharPos.size());
std::vector<CGPoint> glyph_positions(pCharPos.size());
for (size_t i = 0; i < pCharPos.size(); i++) {
glyph_indices[i] =
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index 6e4fc0f..abfcf68 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -6,13 +6,15 @@
#include "core/fxge/cfx_font.h"
+#include <stdint.h>
+
#include <algorithm>
#include <limits>
#include <memory>
#include <utility>
-#include <vector>
#include "build/build_config.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/unowned_ptr.h"
@@ -439,8 +441,7 @@
uint64_t object_tag) {
m_bVertical = force_vertical;
m_ObjectTag = object_tag;
- m_FontDataAllocation = std::vector<uint8_t, FxAllocAllocator<uint8_t>>(
- src_span.begin(), src_span.end());
+ m_FontDataAllocation = DataVector<uint8_t>(src_span.begin(), src_span.end());
m_Face = CFX_GEModule::Get()->GetFontMgr()->NewFixedFace(
nullptr, m_FontDataAllocation, 0);
m_bEmbedded = true;
diff --git a/core/fxge/cfx_font.h b/core/fxge/cfx_font.h
index 3d87961..9ec8748 100644
--- a/core/fxge/cfx_font.h
+++ b/core/fxge/cfx_font.h
@@ -7,11 +7,13 @@
#ifndef CORE_FXGE_CFX_FONT_H_
#define CORE_FXGE_CFX_FONT_H_
+#include <stdint.h>
+
#include <memory>
-#include <vector>
#include "build/build_config.h"
#include "core/fxcrt/bytestring.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_codepage_forward.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_memory_wrappers.h"
@@ -164,7 +166,7 @@
mutable RetainPtr<CFX_GlyphCache> m_GlyphCache;
std::unique_ptr<CFX_SubstFont> m_pSubstFont;
std::unique_ptr<uint8_t, FxFreeDeleter> m_pGsubData;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_FontDataAllocation;
+ DataVector<uint8_t> m_FontDataAllocation;
pdfium::span<uint8_t> m_FontData;
FontType m_FontType = FontType::kUnknown;
uint64_t m_ObjectTag = 0;
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index 118b194..dfd367e 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -6,12 +6,14 @@
#include "core/fxge/cfx_fontmapper.h"
+#include <stdint.h>
+
#include <algorithm>
#include <memory>
#include <utility>
-#include <vector>
#include "build/build_config.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_memory.h"
@@ -428,7 +430,7 @@
if (!size)
return ByteString();
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> buffer(size);
+ DataVector<uint8_t> buffer(size);
size_t bytes_read = m_pFontInfo->GetFontData(font_handle, kTableNAME, buffer);
return bytes_read == size ? GetNameFromTT(buffer, 6) : ByteString();
}
diff --git a/core/fxge/dib/cfx_bitmapcomposer.h b/core/fxge/dib/cfx_bitmapcomposer.h
index c25850d..24cb57e 100644
--- a/core/fxge/dib/cfx_bitmapcomposer.h
+++ b/core/fxge/dib/cfx_bitmapcomposer.h
@@ -7,9 +7,9 @@
#ifndef CORE_FXGE_DIB_CFX_BITMAPCOMPOSER_H_
#define CORE_FXGE_DIB_CFX_BITMAPCOMPOSER_H_
-#include <vector>
+#include <stdint.h>
-#include "core/fxcrt/fx_memory_wrappers.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
#include "core/fxge/dib/cfx_scanlinecompositor.h"
@@ -73,10 +73,10 @@
bool m_bFlipY;
bool m_bRgbByteOrder = false;
BlendMode m_BlendMode = BlendMode::kNormal;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_pScanlineV;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_pClipScanV;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_pAddClipScan;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_pScanlineAlphaV;
+ DataVector<uint8_t> m_pScanlineV;
+ DataVector<uint8_t> m_pClipScanV;
+ DataVector<uint8_t> m_pAddClipScan;
+ DataVector<uint8_t> m_pScanlineAlphaV;
};
#endif // CORE_FXGE_DIB_CFX_BITMAPCOMPOSER_H_
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index a315567..e882d07 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -6,12 +6,14 @@
#include "core/fxge/dib/cfx_dibbase.h"
+#include <stdint.h>
#include <string.h>
#include <algorithm>
#include <utility>
#include <vector>
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_safe_types.h"
@@ -1035,7 +1037,7 @@
}
RetainPtr<const CFX_DIBBase> holder(this);
- std::vector<uint32_t, FxAllocAllocator<uint32_t>> pal_8bpp;
+ DataVector<uint32_t> pal_8bpp;
if (!ConvertBuffer(dest_format, pClone->GetBuffer(), pClone->GetPitch(),
m_Width, m_Height, holder, 0, 0, &pal_8bpp)) {
return nullptr;
@@ -1177,16 +1179,15 @@
}
// static
-bool CFX_DIBBase::ConvertBuffer(
- FXDIB_Format dest_format,
- uint8_t* dest_buf,
- int dest_pitch,
- int width,
- int height,
- const RetainPtr<const CFX_DIBBase>& pSrcBitmap,
- int src_left,
- int src_top,
- std::vector<uint32_t, FxAllocAllocator<uint32_t>>* pal) {
+bool CFX_DIBBase::ConvertBuffer(FXDIB_Format dest_format,
+ uint8_t* dest_buf,
+ int dest_pitch,
+ int width,
+ int height,
+ const RetainPtr<const CFX_DIBBase>& pSrcBitmap,
+ int src_left,
+ int src_top,
+ DataVector<uint32_t>* pal) {
FXDIB_Format src_format = pSrcBitmap->GetFormat();
const int bpp = GetBppFromFormat(src_format);
switch (dest_format) {
diff --git a/core/fxge/dib/cfx_dibbase.h b/core/fxge/dib/cfx_dibbase.h
index aebdb03..5ad1774 100644
--- a/core/fxge/dib/cfx_dibbase.h
+++ b/core/fxge/dib/cfx_dibbase.h
@@ -7,9 +7,9 @@
#ifndef CORE_FXGE_DIB_CFX_DIBBASE_H_
#define CORE_FXGE_DIB_CFX_DIBBASE_H_
-#include <vector>
+#include <stdint.h>
-#include "core/fxcrt/fx_memory_wrappers.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxge/dib/fx_dib.h"
#include "third_party/base/span.h"
@@ -102,16 +102,15 @@
protected:
CFX_DIBBase();
- static bool ConvertBuffer(
- FXDIB_Format dest_format,
- uint8_t* dest_buf,
- int dest_pitch,
- int width,
- int height,
- const RetainPtr<const CFX_DIBBase>& pSrcBitmap,
- int src_left,
- int src_top,
- std::vector<uint32_t, FxAllocAllocator<uint32_t>>* pal);
+ static bool ConvertBuffer(FXDIB_Format dest_format,
+ uint8_t* dest_buf,
+ int dest_pitch,
+ int width,
+ int height,
+ const RetainPtr<const CFX_DIBBase>& pSrcBitmap,
+ int src_left,
+ int src_top,
+ DataVector<uint32_t>* pal);
RetainPtr<CFX_DIBitmap> ClipToInternal(const FX_RECT* pClip) const;
void BuildPalette();
@@ -123,7 +122,7 @@
int m_Height = 0;
uint32_t m_Pitch = 0;
RetainPtr<CFX_DIBitmap> m_pAlphaMask;
- std::vector<uint32_t, FxAllocAllocator<uint32_t>> m_palette;
+ DataVector<uint32_t> m_palette;
};
#endif // CORE_FXGE_DIB_CFX_DIBBASE_H_
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index 2141fba..bb24ab8 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -6,14 +6,15 @@
#include "core/fxge/dib/cfx_dibitmap.h"
+#include <stdint.h>
#include <string.h>
#include <limits>
#include <memory>
#include <utility>
-#include <vector>
#include "build/build_config.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxge/calculate_pitch.h"
@@ -246,7 +247,7 @@
uint8_t* dest_buf =
m_pBuffer.Get() + dest_top * m_Pitch + offset.ValueOrDie();
- std::vector<uint32_t, FxAllocAllocator<uint32_t>> d_plt;
+ DataVector<uint32_t> d_plt;
return ConvertBuffer(dest_format, dest_buf, m_Pitch, width, height,
pSrcBitmap, src_left, src_top, &d_plt);
}
@@ -1105,7 +1106,7 @@
}
bool ret = false;
RetainPtr<CFX_DIBBase> holder(this);
- std::vector<uint32_t, FxAllocAllocator<uint32_t>> pal_8bpp;
+ DataVector<uint32_t> pal_8bpp;
ret = ConvertBuffer(dest_format, dest_buf.get(), dest_pitch, m_Width,
m_Height, holder, 0, 0, &pal_8bpp);
if (!ret)
diff --git a/core/fxge/dib/cstretchengine.h b/core/fxge/dib/cstretchengine.h
index 544ccbf..fd7977f 100644
--- a/core/fxge/dib/cstretchengine.h
+++ b/core/fxge/dib/cstretchengine.h
@@ -7,10 +7,10 @@
#ifndef CORE_FXGE_DIB_CSTRETCHENGINE_H_
#define CORE_FXGE_DIB_CSTRETCHENGINE_H_
-#include <vector>
+#include <stdint.h>
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_coordinates.h"
-#include "core/fxcrt/fx_memory_wrappers.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
@@ -98,7 +98,7 @@
int m_DestMin = 0;
size_t m_ItemSizeBytes = 0;
size_t m_WeightTablesSizeBytes = 0;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_WeightTables;
+ DataVector<uint8_t> m_WeightTables;
};
CStretchEngine(ScanlineComposerIface* pDestBitmap,
@@ -145,10 +145,10 @@
const int m_DestWidth;
const int m_DestHeight;
const FX_RECT m_DestClip;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_DestScanline;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_DestMaskScanline;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_InterBuf;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_ExtraAlphaBuf;
+ DataVector<uint8_t> m_DestScanline;
+ DataVector<uint8_t> m_DestMaskScanline;
+ DataVector<uint8_t> m_InterBuf;
+ DataVector<uint8_t> m_ExtraAlphaBuf;
FX_RECT m_SrcClip;
int m_InterPitch;
int m_ExtraMaskPitch;
diff --git a/core/fxge/win32/cps_printer_driver.cpp b/core/fxge/win32/cps_printer_driver.cpp
index 52dff32..ee9381e 100644
--- a/core/fxge/win32/cps_printer_driver.cpp
+++ b/core/fxge/win32/cps_printer_driver.cpp
@@ -9,8 +9,8 @@
#include <stdint.h>
#include <sstream>
-#include <vector>
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxge/cfx_fillrenderoptions.h"
@@ -69,7 +69,7 @@
if (::GetClipRgn(m_hDC, hRgn) == 1) {
DWORD dwCount = ::GetRegionData(hRgn, 0, nullptr);
if (dwCount) {
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> buffer(dwCount);
+ DataVector<uint8_t> buffer(dwCount);
RGNDATA* pData = reinterpret_cast<RGNDATA*>(buffer.data());
if (::GetRegionData(hRgn, dwCount, pData)) {
CFX_Path path;