diff options
author | Nicolás Peña <npm@chromium.org> | 2017-03-23 14:31:11 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-23 14:43:07 +0000 |
commit | 4650ded3dccefca89b4ef4757bae49a21b4a786d (patch) | |
tree | 4bb47204c8864a568c29c6ffb3982499547ddc4c /core/fpdfapi/page | |
parent | cdba747a53082a7f36534dffa6a3ad01628e53c3 (diff) | |
download | pdfium-4650ded3dccefca89b4ef4757bae49a21b4a786d.tar.xz |
Revert "Remove CFX_FixedBufGrow"
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 <tsepez@chromium.org>
> Commit-Queue: dsinclair <dsinclair@chromium.org>
>
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 <npm@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r-- | core/fpdfapi/page/cpdf_colorspace.cpp | 35 | ||||
-rw-r--r-- | core/fpdfapi/page/fpdf_page_func.cpp | 8 |
2 files changed, 22 insertions, 21 deletions
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 <limits> #include <memory> #include <utility> -#include <vector> #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<float> src(std::max(16U, m_nComponents)); + CFX_FixedBufGrow<float, 16> 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<float>(*src_buf++) / divisor; - - float R; - float G; - float B; - GetRGB(src.data(), &R, &G, &B); + GetRGB(src, &R, &G, &B); *dest_buf++ = static_cast<int32_t>(B * 255); *dest_buf++ = static_cast<int32_t>(G * 255); *dest_buf++ = static_cast<int32_t>(R * 255); @@ -1101,15 +1100,15 @@ bool CPDF_IndexedCS::GetRGB(float* pBuf, float* R, float* G, float* B) const { return false; } } - - std::vector<float> comps(std::max(16, m_nBaseComponents)); + CFX_FixedBufGrow<float, 16> 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<float> results(std::max(16, nComps)); + CFX_FixedBufGrow<float, 16> 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<float> results(std::max(16U, m_pFunc->CountOutputs())); + CFX_FixedBufGrow<float, 16> 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<float> results(std::max(16U, m_pFunc->CountOutputs())); + CFX_FixedBufGrow<float, 16> 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<float> encoded_input(std::max(16U, m_nInputs)); - std::vector<uint32_t> index(std::max(32U, m_nInputs * 2)); - uint32_t* blocksize = index.data() + m_nInputs; + CFX_FixedBufGrow<float, 16> encoded_input_buf(m_nInputs); + float* encoded_input = encoded_input_buf; + CFX_FixedBufGrow<uint32_t, 32> 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; |