From 4650ded3dccefca89b4ef4757bae49a21b4a786d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Pe=C3=B1a?= Date: Thu, 23 Mar 2017 14:31:11 +0000 Subject: Revert "Remove CFX_FixedBufGrow" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 55d1d0191ea8316df32858d8cc62fb7c620e8613. Reason for revert: Slowing down corpus tests by a lot on Mac/Win Original change's description: > 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 > TBR=tsepez@chromium.org,dsinclair@chromium.org,pdfium-reviews@googlegroups.com # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: Iaee27570f140b2033b5d8fb8f3077fc839558d64 Reviewed-on: https://pdfium-review.googlesource.com/3158 Reviewed-by: Nicolás Peña Commit-Queue: Nicolás Peña --- core/fpdfapi/page/cpdf_colorspace.cpp | 35 +++++++++++++++++------------------ core/fpdfapi/page/fpdf_page_func.cpp | 8 +++++--- 2 files changed, 22 insertions(+), 21 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index 428ab0e7f7..3244319cc2 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include "core/fpdfapi/cpdf_modulemgr.h" #include "core/fpdfapi/page/cpdf_docpagedata.h" @@ -541,16 +540,16 @@ void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf, int image_width, int image_height, bool bTransMask) const { - std::vector src(std::max(16U, m_nComponents)); + CFX_FixedBufGrow srcbuf(m_nComponents); + float* src = srcbuf; + float R; + float G; + float B; 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; - - float R; - float G; - float B; - GetRGB(src.data(), &R, &G, &B); + GetRGB(src, &R, &G, &B); *dest_buf++ = static_cast(B * 255); *dest_buf++ = static_cast(G * 255); *dest_buf++ = static_cast(R * 255); @@ -1101,15 +1100,15 @@ bool CPDF_IndexedCS::GetRGB(float* pBuf, float* R, float* G, float* B) const { return false; } } - - std::vector comps(std::max(16, m_nBaseComponents)); + CFX_FixedBufGrow Comps(m_nBaseComponents); + float* comps = Comps; 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.data(), R, G, B); + return m_pBaseCS->GetRGB(comps, R, G, B); } CPDF_ColorSpace* CPDF_IndexedCS::GetBaseCS() const { @@ -1222,20 +1221,20 @@ bool CPDF_SeparationCS::GetRGB(float* pBuf, return false; int nComps = m_pAltCS->CountComponents(); - std::vector results(std::max(16, nComps)); + CFX_FixedBufGrow results(nComps); for (int i = 0; i < nComps; i++) results[i] = *pBuf; - return m_pAltCS->GetRGB(results.data(), R, G, B); + return m_pAltCS->GetRGB(results, R, G, B); } - std::vector results(std::max(16U, m_pFunc->CountOutputs())); + CFX_FixedBufGrow results(m_pFunc->CountOutputs()); int nresults = 0; - m_pFunc->Call(pBuf, 1, results.data(), &nresults); + m_pFunc->Call(pBuf, 1, results, &nresults); if (nresults == 0) return false; if (m_pAltCS) - return m_pAltCS->GetRGB(results.data(), R, G, B); + return m_pAltCS->GetRGB(results, R, G, B); R = 0; G = 0; @@ -1285,13 +1284,13 @@ bool CPDF_DeviceNCS::GetRGB(float* pBuf, float* R, float* G, float* B) const { if (!m_pFunc) return false; - std::vector results(std::max(16U, m_pFunc->CountOutputs())); + CFX_FixedBufGrow results(m_pFunc->CountOutputs()); int nresults = 0; - m_pFunc->Call(pBuf, m_nComponents, results.data(), &nresults); + m_pFunc->Call(pBuf, m_nComponents, results, &nresults); if (nresults == 0) return false; - return m_pAltCS->GetRGB(results.data(), R, G, B); + return m_pAltCS->GetRGB(results, 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 b12b2863fe..30f3b895d4 100644 --- a/core/fpdfapi/page/fpdf_page_func.cpp +++ b/core/fpdfapi/page/fpdf_page_func.cpp @@ -529,9 +529,11 @@ bool CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { bool CPDF_SampledFunc::v_Call(float* inputs, float* results) const { int pos = 0; - 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; + 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; for (uint32_t i = 0; i < m_nInputs; i++) { if (i == 0) blocksize[i] = 1; -- cgit v1.2.3