diff options
Diffstat (limited to 'core/fpdfapi/render/cpdf_renderstatus.cpp')
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index f9261570fe..708d7076c1 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -48,7 +48,6 @@ #include "core/fpdfapi/render/cpdf_type3cache.h" #include "core/fpdfdoc/cpdf_occontext.h" #include "core/fxcrt/autorestorer.h" -#include "core/fxcrt/cfx_fixedbufgrow.h" #include "core/fxcrt/fx_fallthrough.h" #include "core/fxcrt/fx_safe_types.h" #include "core/fxcrt/maybe_owned.h" @@ -151,9 +150,7 @@ void DrawAxialShading(const RetainPtr<CFX_DIBitmap>& pBitmap, float y_span = end_y - start_y; float axis_len_square = (x_span * x_span) + (y_span * y_span); - CFX_FixedBufGrow<float, 16> result_array(total_results); - float* pResults = result_array; - memset(pResults, 0, total_results * sizeof(float)); + std::vector<float> results(total_results); uint32_t rgb_array[kShadingSteps]; for (int i = 0; i < kShadingSteps; i++) { float input = (t_max - t_min) * i / kShadingSteps + t_min; @@ -161,14 +158,14 @@ void DrawAxialShading(const RetainPtr<CFX_DIBitmap>& pBitmap, for (const auto& func : funcs) { if (func) { int nresults = 0; - if (func->Call(&input, 1, pResults + offset, &nresults)) + if (func->Call(&input, 1, results.data() + offset, &nresults)) offset += nresults; } } float R = 0.0f; float G = 0.0f; float B = 0.0f; - pCS->GetRGB(pResults, &R, &G, &B); + pCS->GetRGB(results.data(), &R, &G, &B); rgb_array[i] = FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), FXSYS_round(G * 255), FXSYS_round(B * 255))); @@ -237,9 +234,7 @@ void DrawRadialShading(const RetainPtr<CFX_DIBitmap>& pBitmap, bEndExtend = !!pArray->GetIntegerAt(1); } - CFX_FixedBufGrow<float, 16> result_array(total_results); - float* pResults = result_array; - memset(pResults, 0, total_results * sizeof(float)); + std::vector<float> results(total_results); uint32_t rgb_array[kShadingSteps]; for (int i = 0; i < kShadingSteps; i++) { float input = (t_max - t_min) * i / kShadingSteps + t_min; @@ -247,14 +242,14 @@ void DrawRadialShading(const RetainPtr<CFX_DIBitmap>& pBitmap, for (const auto& func : funcs) { if (func) { int nresults; - if (func->Call(&input, 1, pResults + offset, &nresults)) + if (func->Call(&input, 1, results.data() + offset, &nresults)) offset += nresults; } } float R = 0.0f; float G = 0.0f; float B = 0.0f; - pCS->GetRGB(pResults, &R, &G, &B); + pCS->GetRGB(results.data(), &R, &G, &B); rgb_array[i] = FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), FXSYS_round(G * 255), FXSYS_round(B * 255))); @@ -366,9 +361,7 @@ void DrawFuncShading(const RetainPtr<CFX_DIBitmap>& pBitmap, int height = pBitmap->GetHeight(); int pitch = pBitmap->GetPitch(); - CFX_FixedBufGrow<float, 16> result_array(total_results); - float* pResults = result_array; - memset(pResults, 0, total_results * sizeof(float)); + std::vector<float> results(total_results); for (int row = 0; row < height; row++) { uint32_t* dib_buf = (uint32_t*)(pBitmap->GetBuffer() + row * pitch); for (int column = 0; column < width; column++) { @@ -382,7 +375,7 @@ void DrawFuncShading(const RetainPtr<CFX_DIBitmap>& pBitmap, for (const auto& func : funcs) { if (func) { int nresults; - if (func->Call(input, 2, pResults + offset, &nresults)) + if (func->Call(input, 2, results.data() + offset, &nresults)) offset += nresults; } } @@ -390,7 +383,7 @@ void DrawFuncShading(const RetainPtr<CFX_DIBitmap>& pBitmap, float R = 0.0f; float G = 0.0f; float B = 0.0f; - pCS->GetRGB(pResults, &R, &G, &B); + pCS->GetRGB(results.data(), &R, &G, &B); dib_buf[column] = FXARGB_TODIB(FXARGB_MAKE( alpha, (int32_t)(R * 255), (int32_t)(G * 255), (int32_t)(B * 255))); } @@ -2054,13 +2047,14 @@ void CPDF_RenderStatus::DrawShading(const CPDF_ShadingPattern* pPattern, CPDF_Array* pBackColor = pDict->GetArrayFor("Background"); if (pBackColor && pBackColor->GetCount() >= pColorSpace->CountComponents()) { - CFX_FixedBufGrow<float, 16> comps(pColorSpace->CountComponents()); + std::vector<float> comps; + comps.reserve(pColorSpace->CountComponents()); for (uint32_t i = 0; i < pColorSpace->CountComponents(); i++) - comps[i] = pBackColor->GetNumberAt(i); + comps.push_back(pBackColor->GetNumberAt(i)); float R = 0.0f; float G = 0.0f; float B = 0.0f; - pColorSpace->GetRGB(comps, &R, &G, &B); + pColorSpace->GetRGB(comps.data(), &R, &G, &B); background = ArgbEncode(255, (int32_t)(R * 255), (int32_t)(G * 255), (int32_t)(B * 255)); } @@ -2584,23 +2578,13 @@ RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask( color_space_family = pCS->GetFamily(); float R, G, B; - uint32_t comps = 8; - if (pCS->CountComponents() > comps) { - comps = pCS->CountComponents(); - } - 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()) { - return nullptr; - } - memset(pFloats, 0, num_floats.ValueOrDie()); - size_t count = pBC->GetCount() > 8 ? 8 : pBC->GetCount(); + uint32_t comps = std::max(8u, pCS->CountComponents()); + std::vector<float> floats(comps); + size_t count = std::min<size_t>(8, pBC->GetCount()); for (size_t i = 0; i < count; i++) { - pFloats[i] = pBC->GetNumberAt(i); + floats[i] = pBC->GetNumberAt(i); } - pCS->GetRGB(pFloats, &R, &G, &B); + pCS->GetRGB(floats.data(), &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); @@ -2633,11 +2617,11 @@ RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask( int src_pitch = bitmap.GetPitch(); std::vector<uint8_t> transfers(256); if (pFunc) { - CFX_FixedBufGrow<float, 16> results(pFunc->CountOutputs()); + std::vector<float> results(pFunc->CountOutputs()); for (int i = 0; i < 256; i++) { float input = (float)i / 255.0f; int nresult; - pFunc->Call(&input, 1, results, &nresult); + pFunc->Call(&input, 1, results.data(), &nresult); transfers[i] = FXSYS_round(results[0] * 255); } } else { |