summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render/cpdf_renderstatus.cpp
diff options
context:
space:
mode:
authorNicolás Peña <npm@chromium.org>2017-03-23 14:31:11 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-03-23 14:43:07 +0000
commit4650ded3dccefca89b4ef4757bae49a21b4a786d (patch)
tree4bb47204c8864a568c29c6ffb3982499547ddc4c /core/fpdfapi/render/cpdf_renderstatus.cpp
parentcdba747a53082a7f36534dffa6a3ad01628e53c3 (diff)
downloadpdfium-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/render/cpdf_renderstatus.cpp')
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp50
1 files changed, 27 insertions, 23 deletions
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index a40a25c5cf..17576fc1f3 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -135,8 +135,9 @@ void DrawAxialShading(CFX_DIBitmap* pBitmap,
matrix.SetReverse(*pObject2Bitmap);
uint32_t total_results =
std::max(CountOutputs(funcs), pCS->CountComponents());
- std::vector<float> pResults(std::max(16U, total_results));
- FXSYS_memset(pResults.data(), 0, total_results * sizeof(float));
+ CFX_FixedBufGrow<float, 16> result_array(total_results);
+ float* pResults = result_array;
+ FXSYS_memset(pResults, 0, total_results * sizeof(float));
uint32_t rgb_array[SHADING_STEPS];
for (int i = 0; i < SHADING_STEPS; i++) {
float input = (t_max - t_min) * i / SHADING_STEPS + t_min;
@@ -144,14 +145,14 @@ void DrawAxialShading(CFX_DIBitmap* pBitmap,
for (const auto& func : funcs) {
if (func) {
int nresults = 0;
- if (func->Call(&input, 1, pResults.data() + offset, &nresults))
+ if (func->Call(&input, 1, pResults + offset, &nresults))
offset += nresults;
}
}
float R = 0.0f;
float G = 0.0f;
float B = 0.0f;
- pCS->GetRGB(pResults.data(), &R, &G, &B);
+ pCS->GetRGB(pResults, &R, &G, &B);
rgb_array[i] =
FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255),
FXSYS_round(G * 255), FXSYS_round(B * 255)));
@@ -217,8 +218,9 @@ void DrawRadialShading(CFX_DIBitmap* pBitmap,
}
uint32_t total_results =
std::max(CountOutputs(funcs), pCS->CountComponents());
- std::vector<float> pResults(std::max(16U, total_results));
- FXSYS_memset(pResults.data(), 0, total_results * sizeof(float));
+ CFX_FixedBufGrow<float, 16> result_array(total_results);
+ float* pResults = result_array;
+ FXSYS_memset(pResults, 0, total_results * sizeof(float));
uint32_t rgb_array[SHADING_STEPS];
for (int i = 0; i < SHADING_STEPS; i++) {
float input = (t_max - t_min) * i / SHADING_STEPS + t_min;
@@ -226,14 +228,14 @@ void DrawRadialShading(CFX_DIBitmap* pBitmap,
for (const auto& func : funcs) {
if (func) {
int nresults;
- if (func->Call(&input, 1, pResults.data() + offset, &nresults))
+ if (func->Call(&input, 1, pResults + offset, &nresults))
offset += nresults;
}
}
float R = 0.0f;
float G = 0.0f;
float B = 0.0f;
- pCS->GetRGB(pResults.data(), &R, &G, &B);
+ pCS->GetRGB(pResults, &R, &G, &B);
rgb_array[i] =
FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255),
FXSYS_round(G * 255), FXSYS_round(B * 255)));
@@ -341,8 +343,9 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap,
int pitch = pBitmap->GetPitch();
uint32_t total_results =
std::max(CountOutputs(funcs), pCS->CountComponents());
- std::vector<float> pResults(std::max(16U, total_results));
- FXSYS_memset(pResults.data(), 0, total_results * sizeof(float));
+ CFX_FixedBufGrow<float, 16> result_array(total_results);
+ float* pResults = result_array;
+ FXSYS_memset(pResults, 0, total_results * sizeof(float));
for (int row = 0; row < height; row++) {
uint32_t* dib_buf = (uint32_t*)(pBitmap->GetBuffer() + row * pitch);
for (int column = 0; column < width; column++) {
@@ -356,7 +359,7 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap,
for (const auto& func : funcs) {
if (func) {
int nresults;
- if (func->Call(input, 2, pResults.data() + offset, &nresults))
+ if (func->Call(input, 2, pResults + offset, &nresults))
offset += nresults;
}
}
@@ -364,7 +367,7 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap,
float R = 0.0f;
float G = 0.0f;
float B = 0.0f;
- pCS->GetRGB(pResults.data(), &R, &G, &B);
+ pCS->GetRGB(pResults, &R, &G, &B);
dib_buf[column] = FXARGB_TODIB(FXARGB_MAKE(
alpha, (int32_t)(R * 255), (int32_t)(G * 255), (int32_t)(B * 255)));
}
@@ -2039,13 +2042,13 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern,
CPDF_Array* pBackColor = pDict->GetArrayFor("Background");
if (pBackColor &&
pBackColor->GetCount() >= pColorSpace->CountComponents()) {
- std::vector<float> comps(std::max(16U, pColorSpace->CountComponents()));
+ CFX_FixedBufGrow<float, 16> comps(pColorSpace->CountComponents());
for (uint32_t i = 0; i < pColorSpace->CountComponents(); i++)
comps[i] = pBackColor->GetNumberAt(i);
float R = 0.0f;
float G = 0.0f;
float B = 0.0f;
- pColorSpace->GetRGB(comps.data(), &R, &G, &B);
+ pColorSpace->GetRGB(comps, &R, &G, &B);
background = ArgbEncode(255, (int32_t)(R * 255), (int32_t)(G * 255),
(int32_t)(B * 255));
}
@@ -2573,21 +2576,22 @@ std::unique_ptr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask(
float R, G, B;
uint32_t comps = 8;
- if (pCS->CountComponents() > comps)
+ if (pCS->CountComponents() > comps) {
comps = pCS->CountComponents();
-
- std::vector<float> pFloats(std::max(8U, comps));
+ }
+ CFX_FixedBufGrow<float, 8> float_array(comps);
+ float* pFloats = float_array;
FX_SAFE_UINT32 num_floats = comps;
num_floats *= sizeof(float);
- if (!num_floats.IsValid())
+ if (!num_floats.IsValid()) {
return nullptr;
-
- FXSYS_memset(pFloats.data(), 0, num_floats.ValueOrDie());
+ }
+ FXSYS_memset(pFloats, 0, num_floats.ValueOrDie());
size_t count = pBC->GetCount() > 8 ? 8 : pBC->GetCount();
for (size_t i = 0; i < count; i++) {
pFloats[i] = pBC->GetNumberAt(i);
}
- pCS->GetRGB(pFloats.data(), &R, &G, &B);
+ pCS->GetRGB(pFloats, &R, &G, &B);
back_color = 0xff000000 | ((int32_t)(R * 255) << 16) |
((int32_t)(G * 255) << 8) | (int32_t)(B * 255);
m_pContext->GetDocument()->GetPageData()->ReleaseColorSpace(pCSObj);
@@ -2619,11 +2623,11 @@ std::unique_ptr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask(
int src_pitch = bitmap.GetPitch();
std::vector<uint8_t> transfers(256);
if (pFunc) {
- std::vector<float> results(std::max(16U, pFunc->CountOutputs()));
+ CFX_FixedBufGrow<float, 16> results(pFunc->CountOutputs());
for (int i = 0; i < 256; i++) {
float input = (float)i / 255.0f;
int nresult;
- pFunc->Call(&input, 1, results.data(), &nresult);
+ pFunc->Call(&input, 1, results, &nresult);
transfers[i] = FXSYS_round(results[0] * 255);
}
} else {