summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2018-06-13 20:41:27 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-13 20:41:27 +0000
commitfb73bcdb998550bd537fb5e735dc71198e80c4d5 (patch)
tree0d9d2faeb903c196661e7d52c2075c6a030ed3ce /core
parent07d52a916ddc6d7e04845598376e033f2a04faba (diff)
downloadpdfium-fb73bcdb998550bd537fb5e735dc71198e80c4d5.tar.xz
Remove CFX_FixedBufGrow from cpdf_colorspace.cpp
Bug: pdfium:177 Change-Id: I92e71fd0f2445736680e1cf9e7cc41bda8e6505e Reviewed-on: https://pdfium-review.googlesource.com/35114 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/page/cpdf_colorspace.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp
index 31c485fe03..cf1f25063f 100644
--- a/core/fpdfapi/page/cpdf_colorspace.cpp
+++ b/core/fpdfapi/page/cpdf_colorspace.cpp
@@ -31,7 +31,6 @@
#include "core/fpdfdoc/cpdf_action.h"
#include "core/fxcodec/codec/ccodec_iccmodule.h"
#include "core/fxcodec/fx_codec.h"
-#include "core/fxcrt/cfx_fixedbufgrow.h"
#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/maybe_owned.h"
#include "third_party/base/stl_util.h"
@@ -574,8 +573,7 @@ void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf,
int image_width,
int image_height,
bool bTransMask) const {
- CFX_FixedBufGrow<float, 16> srcbuf(m_nComponents);
- float* src = srcbuf;
+ std::vector<float> src(m_nComponents);
float R;
float G;
float B;
@@ -583,7 +581,7 @@ void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf,
for (int i = 0; i < pixels; i++) {
for (uint32_t j = 0; j < m_nComponents; j++)
src[j] = static_cast<float>(*src_buf++) / divisor;
- GetRGB(src, &R, &G, &B);
+ GetRGB(src.data(), &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);
@@ -1153,15 +1151,15 @@ bool CPDF_IndexedCS::GetRGB(const float* pBuf,
return false;
}
}
- CFX_FixedBufGrow<float, 16> Comps(m_nBaseComponents);
- float* comps = Comps;
+ std::vector<float> comps(m_nBaseComponents);
const uint8_t* pTable = m_Table.raw_str();
- for (uint32_t i = 0; i < m_nBaseComponents; i++) {
+ for (uint32_t 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);
+ ASSERT(m_nBaseComponents == m_pBaseCS->CountComponents());
+ return m_pBaseCS->GetRGB(comps.data(), R, G, B);
}
void CPDF_IndexedCS::EnableStdConversion(bool bEnabled) {
@@ -1226,19 +1224,20 @@ bool CPDF_SeparationCS::GetRGB(const float* pBuf,
return false;
int nComps = m_pAltCS->CountComponents();
- CFX_FixedBufGrow<float, 16> results(nComps);
+ std::vector<float> results(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<float, 16> results(m_pFunc->CountOutputs());
+ // Using at least 16 elements due to the call m_pAltCS->GetRGB() below.
+ std::vector<float> results(std::max(m_pFunc->CountOutputs(), 16u));
int nresults = 0;
- if (!m_pFunc->Call(pBuf, 1, results, &nresults) || nresults == 0)
+ if (!m_pFunc->Call(pBuf, 1, results.data(), &nresults) || 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;
@@ -1298,14 +1297,15 @@ bool CPDF_DeviceNCS::GetRGB(const float* pBuf,
if (!m_pFunc)
return false;
- CFX_FixedBufGrow<float, 16> results(m_pFunc->CountOutputs());
+ // Using at least 16 elements due to the call m_pAltCS->GetRGB() below.
+ std::vector<float> results(std::max(m_pFunc->CountOutputs(), 16u));
int nresults = 0;
- if (!m_pFunc->Call(pBuf, CountComponents(), results, &nresults) ||
+ if (!m_pFunc->Call(pBuf, CountComponents(), results.data(), &nresults) ||
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) {