summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_colorspace.cpp35
-rw-r--r--core/fpdfapi/page/fpdf_page_func.cpp8
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;