summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_func.cpp58
-rw-r--r--core/fpdfapi/fpdf_page/pageint.h56
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp5
3 files changed, 72 insertions, 47 deletions
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/fpdfapi/fpdf_page/fpdf_page_func.cpp
index 96aad6d87f..08eafad6ac 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_func.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_func.cpp
@@ -520,11 +520,12 @@ class CPDF_SampledFunc : public CPDF_Function {
CPDF_StreamAcc* m_pSampleStream;
};
-CPDF_SampledFunc::CPDF_SampledFunc() {
+CPDF_SampledFunc::CPDF_SampledFunc() : CPDF_Function(Type::kType0Sampled) {
m_pSampleStream = NULL;
m_pEncodeInfo = NULL;
m_pDecodeInfo = NULL;
}
+
CPDF_SampledFunc::~CPDF_SampledFunc() {
delete m_pSampleStream;
FX_Free(m_pEncodeInfo);
@@ -665,6 +666,7 @@ FX_BOOL CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const {
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;
@@ -694,25 +696,14 @@ FX_BOOL CPDF_PSFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const {
return TRUE;
}
-class CPDF_ExpIntFunc : public CPDF_Function {
- public:
- CPDF_ExpIntFunc();
- ~CPDF_ExpIntFunc() override;
-
- // CPDF_Function
- FX_BOOL v_Init(CPDF_Object* pObj) override;
- FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override;
-
- FX_FLOAT m_Exponent;
- FX_FLOAT* m_pBeginValues;
- FX_FLOAT* m_pEndValues;
- int m_nOrigOutputs;
-};
+} // namespace
-CPDF_ExpIntFunc::CPDF_ExpIntFunc() {
+CPDF_ExpIntFunc::CPDF_ExpIntFunc()
+ : CPDF_Function(Type::kType2ExpotentialInterpolation) {
m_pBeginValues = NULL;
m_pEndValues = NULL;
}
+
CPDF_ExpIntFunc::~CPDF_ExpIntFunc() {
FX_Free(m_pBeginValues);
FX_Free(m_pEndValues);
@@ -755,26 +746,11 @@ FX_BOOL CPDF_ExpIntFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const {
return TRUE;
}
-class CPDF_StitchFunc : public CPDF_Function {
- public:
- CPDF_StitchFunc();
- ~CPDF_StitchFunc() override;
-
- // CPDF_Function
- FX_BOOL v_Init(CPDF_Object* pObj) override;
- FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override;
-
- std::vector<CPDF_Function*> m_pSubFunctions;
- FX_FLOAT* m_pBounds;
- FX_FLOAT* m_pEncode;
-
- static const int kRequiredNumInputs = 1;
-};
-
-CPDF_StitchFunc::CPDF_StitchFunc() {
+CPDF_StitchFunc::CPDF_StitchFunc() : CPDF_Function(Type::kType3Stitching) {
m_pBounds = NULL;
m_pEncode = NULL;
}
+
CPDF_StitchFunc::~CPDF_StitchFunc() {
for (auto& sub : m_pSubFunctions) {
delete sub;
@@ -859,13 +835,10 @@ FX_BOOL CPDF_StitchFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* outputs) const {
return TRUE;
}
-} // namespace
-
CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) {
if (!pFuncObj) {
return NULL;
}
- CPDF_Function* pFunc = NULL;
int type;
if (CPDF_Stream* pStream = pFuncObj->AsStream()) {
type = pStream->GetDict()->GetIntegerBy("FunctionType");
@@ -874,14 +847,15 @@ CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) {
} else {
return NULL;
}
+ CPDF_Function* pFunc = NULL;
if (type == 0) {
- pFunc = new CPDF_SampledFunc;
+ pFunc = new CPDF_SampledFunc();
} else if (type == 2) {
- pFunc = new CPDF_ExpIntFunc;
+ pFunc = new CPDF_ExpIntFunc();
} else if (type == 3) {
- pFunc = new CPDF_StitchFunc;
+ pFunc = new CPDF_StitchFunc();
} else if (type == 4) {
- pFunc = new CPDF_PSFunc;
+ pFunc = new CPDF_PSFunc();
} else {
return NULL;
}
@@ -891,10 +865,12 @@ CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) {
}
return pFunc;
}
-CPDF_Function::CPDF_Function() {
+
+CPDF_Function::CPDF_Function(Type type) : m_Type(type) {
m_pDomains = NULL;
m_pRanges = NULL;
}
+
CPDF_Function::~CPDF_Function() {
FX_Free(m_pDomains);
FX_Free(m_pRanges);
diff --git a/core/fpdfapi/fpdf_page/pageint.h b/core/fpdfapi/fpdf_page/pageint.h
index d254477dc3..297b1e2e77 100644
--- a/core/fpdfapi/fpdf_page/pageint.h
+++ b/core/fpdfapi/fpdf_page/pageint.h
@@ -377,24 +377,68 @@ class CPDF_DocPageData {
class CPDF_Function {
public:
+ enum class Type {
+ kType0Sampled,
+ kType2ExpotentialInterpolation,
+ kType3Stitching,
+ kType4PostScript,
+ };
+
static CPDF_Function* Load(CPDF_Object* pFuncObj);
virtual ~CPDF_Function();
FX_BOOL Call(FX_FLOAT* inputs,
int ninputs,
FX_FLOAT* results,
int& nresults) const;
- int CountInputs() { return m_nInputs; }
- int CountOutputs() { return m_nOutputs; }
+ int CountInputs() const { return m_nInputs; }
+ int CountOutputs() const { return m_nOutputs; }
+ FX_FLOAT GetDomain(int i) const { return m_pDomains[i]; }
+ Type GetType() const { return m_Type; }
protected:
- CPDF_Function();
- int m_nInputs, m_nOutputs;
- FX_FLOAT* m_pDomains;
- FX_FLOAT* m_pRanges;
+ CPDF_Function(Type type);
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;
+
+ int m_nInputs;
+ int m_nOutputs;
+ FX_FLOAT* m_pDomains;
+ FX_FLOAT* m_pRanges;
+ Type m_Type;
+};
+
+class CPDF_ExpIntFunc : public CPDF_Function {
+ public:
+ CPDF_ExpIntFunc();
+ ~CPDF_ExpIntFunc() override;
+
+ // CPDF_Function
+ FX_BOOL v_Init(CPDF_Object* pObj) override;
+ FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override;
+
+ int m_nOrigOutputs;
+ FX_FLOAT m_Exponent;
+ FX_FLOAT* m_pBeginValues;
+ FX_FLOAT* m_pEndValues;
+};
+
+class CPDF_StitchFunc : public CPDF_Function {
+ public:
+ CPDF_StitchFunc();
+ ~CPDF_StitchFunc() override;
+
+ // CPDF_Function
+ FX_BOOL v_Init(CPDF_Object* pObj) override;
+ FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override;
+
+ std::vector<CPDF_Function*> m_pSubFunctions;
+ FX_FLOAT* m_pBounds;
+ FX_FLOAT* m_pEncode;
+
+ static const int kRequiredNumInputs = 1;
};
+
class CPDF_IccProfile {
public:
CPDF_IccProfile(const uint8_t* pData, FX_DWORD dwSize);
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index d4dd8ec211..94f38c5186 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -859,6 +859,11 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern,
rect.Transform(pMatrix);
clip_rect.Intersect(rect.GetOutterRect());
}
+ if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SHADING &&
+ m_pDevice->GetDeviceDriver()->DrawShading(pPattern, pMatrix, alpha,
+ bAlphaMode)) {
+ return;
+ }
CPDF_DeviceBuffer buffer;
buffer.Initialize(m_pContext, m_pDevice, &clip_rect, m_pCurObj, 150);
CFX_Matrix FinalMatrix = *pMatrix;