Index: core/fpdfapi/fpdf_page/fpdf_page_func.cpp |
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/fpdfapi/fpdf_page/fpdf_page_func.cpp |
index b00ab73af1e6340a0844451705f4551354bb30a7..3e71d90a7d4876fe8e70889bbc8ed2b634b82faa 100644 |
--- a/core/fpdfapi/fpdf_page/fpdf_page_func.cpp |
+++ b/core/fpdfapi/fpdf_page/fpdf_page_func.cpp |
@@ -491,28 +491,38 @@ static uint32_t _GetBits32(const uint8_t* pData, int bitpos, int nbits) { |
} |
return result; |
} |
-typedef struct { |
- FX_FLOAT encode_max, encode_min; |
- int sizes; |
-} SampleEncodeInfo; |
-typedef struct { FX_FLOAT decode_max, decode_min; } SampleDecodeInfo; |
-class CPDF_SampledFunc : public CPDF_Function { |
+class CPDF_PSFunc : public CPDF_Function { |
public: |
- CPDF_SampledFunc(); |
- ~CPDF_SampledFunc() override; |
- |
// CPDF_Function |
+ CPDF_PSFunc() : CPDF_Function(Type::kType4PostScript) {} |
Tom Sepez
2016/04/11 16:41:49
nit: ctor should come before this comment, which i
caryclark
2016/04/11 20:41:51
Done.
|
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; |
- uint32_t m_nBitsPerSample; |
- uint32_t m_SampleMax; |
- CPDF_StreamAcc* m_pSampleStream; |
+ CPDF_PSEngine m_PS; |
Tom Sepez
2016/04/11 16:41:49
nit: can this be private or protected?
caryclark
2016/04/11 20:41:51
Done.
|
}; |
+FX_BOOL CPDF_PSFunc::v_Init(CPDF_Object* pObj) { |
+ CPDF_Stream* pStream = pObj->AsStream(); |
Tom Sepez
2016/04/11 16:41:49
nit: local not needed since it is only used once.
caryclark
2016/04/11 20:41:51
Done.
|
+ CPDF_StreamAcc acc; |
+ acc.LoadAllData(pStream, FALSE); |
+ return m_PS.Parse((const FX_CHAR*)acc.GetData(), acc.GetSize()); |
Tom Sepez
2016/04/11 16:41:49
nit: reinterpret_cast<const FX_CHAR*>
caryclark
2016/04/11 20:41:51
Done.
|
+} |
+FX_BOOL CPDF_PSFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { |
Tom Sepez
2016/04/11 16:41:49
nit: blank line here.
caryclark
2016/04/11 20:41:51
Done.
|
+ CPDF_PSEngine& PS = (CPDF_PSEngine&)m_PS; |
Tom Sepez
2016/04/11 16:41:49
nit: this isn't buying us anything over just using
caryclark
2016/04/11 20:41:51
v_Call is a const function; PS.Reset() for instanc
|
+ PS.Reset(); |
+ for (uint32_t i = 0; i < m_nInputs; i++) |
+ PS.Push(inputs[i]); |
+ PS.Execute(); |
+ if (PS.GetStackSize() < m_nOutputs) |
+ return FALSE; |
+ for (uint32_t i = 0; i < m_nOutputs; i++) |
+ results[m_nOutputs - i - 1] = PS.Pop(); |
+ return TRUE; |
+} |
+ |
+} // namespace |
dsinclair
2016/04/11 16:17:45
Hm, did this make the namespace section smaller? I
caryclark
2016/04/11 16:26:33
There were two namespace blocks. Now there is one.
|
+ |
CPDF_SampledFunc::CPDF_SampledFunc() : CPDF_Function(Type::kType0Sampled) { |
m_pSampleStream = NULL; |
m_pEncodeInfo = NULL; |
@@ -524,6 +534,7 @@ CPDF_SampledFunc::~CPDF_SampledFunc() { |
FX_Free(m_pEncodeInfo); |
FX_Free(m_pDecodeInfo); |
} |
+ |
FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { |
CPDF_Stream* pStream = pObj->AsStream(); |
if (!pStream) |
@@ -579,6 +590,7 @@ FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { |
} |
return TRUE; |
} |
+ |
FX_BOOL CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { |
int pos = 0; |
CFX_FixedBufGrow<FX_FLOAT, 16> encoded_input_buf(m_nInputs); |
@@ -650,37 +662,6 @@ FX_BOOL CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { |
return TRUE; |
} |
-class CPDF_PSFunc : public CPDF_Function { |
- public: |
- // CPDF_Function |
- CPDF_PSFunc() : CPDF_Function(Type::kType4PostScript) {} |
- FX_BOOL v_Init(CPDF_Object* pObj) override; |
- FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; |
- |
- CPDF_PSEngine m_PS; |
-}; |
- |
-FX_BOOL CPDF_PSFunc::v_Init(CPDF_Object* pObj) { |
- CPDF_Stream* pStream = pObj->AsStream(); |
- CPDF_StreamAcc acc; |
- acc.LoadAllData(pStream, FALSE); |
- return m_PS.Parse((const FX_CHAR*)acc.GetData(), acc.GetSize()); |
-} |
-FX_BOOL CPDF_PSFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { |
- CPDF_PSEngine& PS = (CPDF_PSEngine&)m_PS; |
- PS.Reset(); |
- for (uint32_t i = 0; i < m_nInputs; i++) |
- PS.Push(inputs[i]); |
- PS.Execute(); |
- if (PS.GetStackSize() < m_nOutputs) |
- return FALSE; |
- for (uint32_t i = 0; i < m_nOutputs; i++) |
- results[m_nOutputs - i - 1] = PS.Pop(); |
- return TRUE; |
-} |
- |
-} // namespace |
- |
CPDF_ExpIntFunc::CPDF_ExpIntFunc() |
: CPDF_Function(Type::kType2ExpotentialInterpolation) { |
m_pBeginValues = NULL; |