From c84ea8eda5a53229cf1faaed7cb54013b9ea18c3 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 19 Apr 2018 20:55:44 +0000 Subject: Change SHADING_STEPS from a #define to a constant. Change-Id: I06eab59d7944309d6fe99b97956e8ffb11d64088 Reviewed-on: https://pdfium-review.googlesource.com/30991 Commit-Queue: dsinclair Reviewed-by: dsinclair --- core/fpdfapi/render/cpdf_renderstatus.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 74e4797b73..abccde52b4 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -65,10 +65,10 @@ #include "core/fxge/skia/fx_skia_device.h" #endif -#define SHADING_STEPS 256 - namespace { +constexpr int kShadingSteps = 256; + void ReleaseCachedType3(CPDF_Type3Font* pFont) { CPDF_Document* pDoc = pFont->GetDocument(); if (!pDoc) @@ -152,9 +152,9 @@ void DrawAxialShading(const RetainPtr& pBitmap, CFX_FixedBufGrow result_array(total_results); float* pResults = result_array; 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; + uint32_t rgb_array[kShadingSteps]; + for (int i = 0; i < kShadingSteps; i++) { + float input = (t_max - t_min) * i / kShadingSteps + t_min; int offset = 0; for (const auto& func : funcs) { if (func) { @@ -181,17 +181,17 @@ void DrawAxialShading(const RetainPtr& pBitmap, float scale = (((pos.x - start_x) * x_span) + ((pos.y - start_y) * y_span)) / axis_len_square; - int index = (int32_t)(scale * (SHADING_STEPS - 1)); + int index = (int32_t)(scale * (kShadingSteps - 1)); if (index < 0) { if (!bStartExtend) continue; index = 0; - } else if (index >= SHADING_STEPS) { + } else if (index >= kShadingSteps) { if (!bEndExtend) continue; - index = SHADING_STEPS - 1; + index = kShadingSteps - 1; } dib_buf[column] = rgb_array[index]; } @@ -238,9 +238,9 @@ void DrawRadialShading(const RetainPtr& pBitmap, CFX_FixedBufGrow result_array(total_results); float* pResults = result_array; 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; + uint32_t rgb_array[kShadingSteps]; + for (int i = 0; i < kShadingSteps; i++) { + float input = (t_max - t_min) * i / kShadingSteps + t_min; int offset = 0; for (const auto& func : funcs) { if (func) { @@ -316,18 +316,18 @@ void DrawRadialShading(const RetainPtr& pBitmap, continue; } } - int index = (int32_t)(s * (SHADING_STEPS - 1)); + int index = (int32_t)(s * (kShadingSteps - 1)); if (index < 0) { if (!bStartExtend) { continue; } index = 0; } - if (index >= SHADING_STEPS) { + if (index >= kShadingSteps) { if (!bEndExtend) { continue; } - index = SHADING_STEPS - 1; + index = kShadingSteps - 1; } dib_buf[column] = rgb_array[index]; } -- cgit v1.2.3