From 9b1a0ee2a8f24411609a2f7554119597950dbd04 Mon Sep 17 00:00:00 2001 From: thestig Date: Thu, 19 May 2016 15:47:01 -0700 Subject: Fix Undefined-shift in CPDF_SampledFunc::v_Init(). Also fix a divide by zero in CPDF_SampledFunc. Do some cleanups too. BUG=596530,613032 Review-Url: https://codereview.chromium.org/1990843004 --- core/fpdfapi/fpdf_page/pageint.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'core/fpdfapi/fpdf_page/pageint.h') diff --git a/core/fpdfapi/fpdf_page/pageint.h b/core/fpdfapi/fpdf_page/pageint.h index d1364d0dd1..8d507a181d 100644 --- a/core/fpdfapi/fpdf_page/pageint.h +++ b/core/fpdfapi/fpdf_page/pageint.h @@ -367,13 +367,16 @@ class CPDF_DocPageData { class CPDF_Function { public: enum class Type { - kType0Sampled, - kType2ExpotentialInterpolation, - kType3Stitching, - kType4PostScript, + kTypeInvalid = -1, + kType0Sampled = 0, + kType2ExpotentialInterpolation = 2, + kType3Stitching = 3, + kType4PostScript = 4, }; static CPDF_Function* Load(CPDF_Object* pFuncObj); + static Type IntegerToFunctionType(int iType); + virtual ~CPDF_Function(); FX_BOOL Call(FX_FLOAT* inputs, uint32_t ninputs, @@ -381,12 +384,10 @@ class CPDF_Function { int& nresults) const; uint32_t CountInputs() const { return m_nInputs; } uint32_t CountOutputs() const { return m_nOutputs; } - FX_FLOAT GetDomain(int i) const { return m_pDomains[i]; } - FX_FLOAT GetRange(int i) const { return m_pRanges[i]; } - Type GetType() const { return m_Type; } protected: - CPDF_Function(Type type); + CPDF_Function(); + FX_BOOL Init(CPDF_Object* pObj); virtual FX_BOOL v_Init(CPDF_Object* pObj) = 0; virtual FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const = 0; @@ -395,7 +396,6 @@ class CPDF_Function { uint32_t m_nOutputs; FX_FLOAT* m_pDomains; FX_FLOAT* m_pRanges; - Type m_Type; }; class CPDF_ExpIntFunc : public CPDF_Function { @@ -433,11 +433,12 @@ class CPDF_SampledFunc : public CPDF_Function { FX_BOOL v_Init(CPDF_Object* pObj) override; FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; - SampleEncodeInfo* m_pEncodeInfo; - SampleDecodeInfo* m_pDecodeInfo; + private: + std::vector m_pEncodeInfo; + std::vector m_pDecodeInfo; uint32_t m_nBitsPerSample; uint32_t m_SampleMax; - CPDF_StreamAcc* m_pSampleStream; + std::unique_ptr m_pSampleStream; }; class CPDF_StitchFunc : public CPDF_Function { @@ -449,7 +450,7 @@ class CPDF_StitchFunc : public CPDF_Function { FX_BOOL v_Init(CPDF_Object* pObj) override; FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; - std::vector m_pSubFunctions; + std::vector> m_pSubFunctions; FX_FLOAT* m_pBounds; FX_FLOAT* m_pEncode; -- cgit v1.2.3