From 55d1d0191ea8316df32858d8cc62fb7c620e8613 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 21 Mar 2017 16:24:57 -0400 Subject: Remove CFX_FixedBufGrow This Cl replaces the CFX_FixedBufGrow class with std::vector. Change-Id: I85c85b7a8de4794840b561e09841bb464cfa9dfe Reviewed-on: https://pdfium-review.googlesource.com/3138 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- core/fpdfapi/page/cpdf_colorspace.cpp | 35 ++++++++++++++++++----------------- core/fpdfapi/page/fpdf_page_func.cpp | 8 +++----- 2 files changed, 21 insertions(+), 22 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index 3244319cc2..428ab0e7f7 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "core/fpdfapi/cpdf_modulemgr.h" #include "core/fpdfapi/page/cpdf_docpagedata.h" @@ -540,16 +541,16 @@ void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf, int image_width, int image_height, bool bTransMask) const { - CFX_FixedBufGrow srcbuf(m_nComponents); - float* src = srcbuf; - float R; - float G; - float B; + std::vector src(std::max(16U, m_nComponents)); const int divisor = m_Family != PDFCS_INDEXED ? 255 : 1; for (int i = 0; i < pixels; i++) { for (uint32_t j = 0; j < m_nComponents; j++) src[j] = static_cast(*src_buf++) / divisor; - GetRGB(src, &R, &G, &B); + + float R; + float G; + float B; + GetRGB(src.data(), &R, &G, &B); *dest_buf++ = static_cast(B * 255); *dest_buf++ = static_cast(G * 255); *dest_buf++ = static_cast(R * 255); @@ -1100,15 +1101,15 @@ bool CPDF_IndexedCS::GetRGB(float* pBuf, float* R, float* G, float* B) const { return false; } } - CFX_FixedBufGrow Comps(m_nBaseComponents); - float* comps = Comps; + + std::vector comps(std::max(16, m_nBaseComponents)); const uint8_t* pTable = m_Table.raw_str(); for (int i = 0; i < m_nBaseComponents; i++) { comps[i] = m_pCompMinMax[i * 2] + m_pCompMinMax[i * 2 + 1] * pTable[index * m_nBaseComponents + i] / 255; } - return m_pBaseCS->GetRGB(comps, R, G, B); + return m_pBaseCS->GetRGB(comps.data(), R, G, B); } CPDF_ColorSpace* CPDF_IndexedCS::GetBaseCS() const { @@ -1221,20 +1222,20 @@ bool CPDF_SeparationCS::GetRGB(float* pBuf, return false; int nComps = m_pAltCS->CountComponents(); - CFX_FixedBufGrow results(nComps); + std::vector results(std::max(16, nComps)); for (int i = 0; i < nComps; i++) results[i] = *pBuf; - return m_pAltCS->GetRGB(results, R, G, B); + return m_pAltCS->GetRGB(results.data(), R, G, B); } - CFX_FixedBufGrow results(m_pFunc->CountOutputs()); + std::vector results(std::max(16U, m_pFunc->CountOutputs())); int nresults = 0; - m_pFunc->Call(pBuf, 1, results, &nresults); + m_pFunc->Call(pBuf, 1, results.data(), &nresults); if (nresults == 0) return false; if (m_pAltCS) - return m_pAltCS->GetRGB(results, R, G, B); + return m_pAltCS->GetRGB(results.data(), R, G, B); R = 0; G = 0; @@ -1284,13 +1285,13 @@ bool CPDF_DeviceNCS::GetRGB(float* pBuf, float* R, float* G, float* B) const { if (!m_pFunc) return false; - CFX_FixedBufGrow results(m_pFunc->CountOutputs()); + std::vector results(std::max(16U, m_pFunc->CountOutputs())); int nresults = 0; - m_pFunc->Call(pBuf, m_nComponents, results, &nresults); + m_pFunc->Call(pBuf, m_nComponents, results.data(), &nresults); if (nresults == 0) return false; - return m_pAltCS->GetRGB(results, R, G, B); + return m_pAltCS->GetRGB(results.data(), R, G, B); } void CPDF_DeviceNCS::EnableStdConversion(bool bEnabled) { diff --git a/core/fpdfapi/page/fpdf_page_func.cpp b/core/fpdfapi/page/fpdf_page_func.cpp index 30f3b895d4..b12b2863fe 100644 --- a/core/fpdfapi/page/fpdf_page_func.cpp +++ b/core/fpdfapi/page/fpdf_page_func.cpp @@ -529,11 +529,9 @@ bool CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { bool CPDF_SampledFunc::v_Call(float* inputs, float* results) const { int pos = 0; - CFX_FixedBufGrow encoded_input_buf(m_nInputs); - float* encoded_input = encoded_input_buf; - CFX_FixedBufGrow int_buf(m_nInputs * 2); - uint32_t* index = int_buf; - uint32_t* blocksize = index + m_nInputs; + std::vector encoded_input(std::max(16U, m_nInputs)); + std::vector index(std::max(32U, m_nInputs * 2)); + uint32_t* blocksize = index.data() + m_nInputs; for (uint32_t i = 0; i < m_nInputs; i++) { if (i == 0) blocksize[i] = 1; -- cgit v1.2.3