Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: core/fpdfapi/fpdf_page/fpdf_page_func.cpp

Issue 1828283002: support gradients and stroke+fill (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_page/pageint.h » ('j') | core/fpdfapi/fpdf_page/pageint.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/fpdf_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 PS.Execute(); 687 PS.Execute();
688 if (PS.GetStackSize() < m_nOutputs) { 688 if (PS.GetStackSize() < m_nOutputs) {
689 return FALSE; 689 return FALSE;
690 } 690 }
691 for (i = 0; i < m_nOutputs; i++) { 691 for (i = 0; i < m_nOutputs; i++) {
692 results[m_nOutputs - i - 1] = PS.Pop(); 692 results[m_nOutputs - i - 1] = PS.Pop();
693 } 693 }
694 return TRUE; 694 return TRUE;
695 } 695 }
696 696
697 class CPDF_ExpIntFunc : public CPDF_Function { 697 } // namespace
698 public:
699 CPDF_ExpIntFunc();
700 ~CPDF_ExpIntFunc() override;
701
702 // CPDF_Function
703 FX_BOOL v_Init(CPDF_Object* pObj) override;
704 FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override;
705
706 FX_FLOAT m_Exponent;
707 FX_FLOAT* m_pBeginValues;
708 FX_FLOAT* m_pEndValues;
709 int m_nOrigOutputs;
710 };
711 698
712 CPDF_ExpIntFunc::CPDF_ExpIntFunc() { 699 CPDF_ExpIntFunc::CPDF_ExpIntFunc() {
713 m_pBeginValues = NULL; 700 m_pBeginValues = NULL;
714 m_pEndValues = NULL; 701 m_pEndValues = NULL;
715 } 702 }
716 CPDF_ExpIntFunc::~CPDF_ExpIntFunc() { 703 CPDF_ExpIntFunc::~CPDF_ExpIntFunc() {
717 FX_Free(m_pBeginValues); 704 FX_Free(m_pBeginValues);
718 FX_Free(m_pEndValues); 705 FX_Free(m_pEndValues);
719 } 706 }
720 FX_BOOL CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj) { 707 FX_BOOL CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj) {
(...skipping 27 matching lines...) Expand all
748 for (int i = 0; i < m_nInputs; i++) 735 for (int i = 0; i < m_nInputs; i++)
749 for (int j = 0; j < m_nOrigOutputs; j++) { 736 for (int j = 0; j < m_nOrigOutputs; j++) {
750 results[i * m_nOrigOutputs + j] = 737 results[i * m_nOrigOutputs + j] =
751 m_pBeginValues[j] + 738 m_pBeginValues[j] +
752 (FX_FLOAT)FXSYS_pow(inputs[i], m_Exponent) * 739 (FX_FLOAT)FXSYS_pow(inputs[i], m_Exponent) *
753 (m_pEndValues[j] - m_pBeginValues[j]); 740 (m_pEndValues[j] - m_pBeginValues[j]);
754 } 741 }
755 return TRUE; 742 return TRUE;
756 } 743 }
757 744
758 class CPDF_StitchFunc : public CPDF_Function {
759 public:
760 CPDF_StitchFunc();
761 ~CPDF_StitchFunc() override;
762
763 // CPDF_Function
764 FX_BOOL v_Init(CPDF_Object* pObj) override;
765 FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override;
766
767 std::vector<CPDF_Function*> m_pSubFunctions;
768 FX_FLOAT* m_pBounds;
769 FX_FLOAT* m_pEncode;
770
771 static const int kRequiredNumInputs = 1;
772 };
773
774 CPDF_StitchFunc::CPDF_StitchFunc() { 745 CPDF_StitchFunc::CPDF_StitchFunc() {
775 m_pBounds = NULL; 746 m_pBounds = NULL;
776 m_pEncode = NULL; 747 m_pEncode = NULL;
777 } 748 }
778 CPDF_StitchFunc::~CPDF_StitchFunc() { 749 CPDF_StitchFunc::~CPDF_StitchFunc() {
779 for (auto& sub : m_pSubFunctions) { 750 for (auto& sub : m_pSubFunctions) {
780 delete sub; 751 delete sub;
781 } 752 }
782 FX_Free(m_pBounds); 753 FX_Free(m_pBounds);
783 FX_Free(m_pEncode); 754 FX_Free(m_pEncode);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 if (!m_pSubFunctions[i]) { 823 if (!m_pSubFunctions[i]) {
853 return FALSE; 824 return FALSE;
854 } 825 }
855 input = PDF_Interpolate(input, m_pBounds[i], m_pBounds[i + 1], 826 input = PDF_Interpolate(input, m_pBounds[i], m_pBounds[i + 1],
856 m_pEncode[i * 2], m_pEncode[i * 2 + 1]); 827 m_pEncode[i * 2], m_pEncode[i * 2 + 1]);
857 int nresults; 828 int nresults;
858 m_pSubFunctions[i]->Call(&input, kRequiredNumInputs, outputs, nresults); 829 m_pSubFunctions[i]->Call(&input, kRequiredNumInputs, outputs, nresults);
859 return TRUE; 830 return TRUE;
860 } 831 }
861 832
862 } // namespace
863
864 CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) { 833 CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) {
865 if (!pFuncObj) { 834 if (!pFuncObj) {
866 return NULL; 835 return NULL;
867 } 836 }
868 CPDF_Function* pFunc = NULL; 837 CPDF_Function* pFunc = NULL;
Tom Sepez 2016/03/24 18:07:07 nit: move to line 846?
caryclark 2016/03/25 20:47:55 Done.
869 int type; 838 int type;
870 if (CPDF_Stream* pStream = pFuncObj->AsStream()) { 839 if (CPDF_Stream* pStream = pFuncObj->AsStream()) {
871 type = pStream->GetDict()->GetIntegerBy("FunctionType"); 840 type = pStream->GetDict()->GetIntegerBy("FunctionType");
872 } else if (CPDF_Dictionary* pDict = pFuncObj->AsDictionary()) { 841 } else if (CPDF_Dictionary* pDict = pFuncObj->AsDictionary()) {
873 type = pDict->GetIntegerBy("FunctionType"); 842 type = pDict->GetIntegerBy("FunctionType");
874 } else { 843 } else {
875 return NULL; 844 return NULL;
876 } 845 }
877 if (type == 0) { 846 if (type == 0) {
878 pFunc = new CPDF_SampledFunc; 847 pFunc = new CPDF_SampledFunc;
879 } else if (type == 2) { 848 } else if (type == 2) {
880 pFunc = new CPDF_ExpIntFunc; 849 pFunc = new CPDF_ExpIntFunc;
881 } else if (type == 3) { 850 } else if (type == 3) {
882 pFunc = new CPDF_StitchFunc; 851 pFunc = new CPDF_StitchFunc;
883 } else if (type == 4) { 852 } else if (type == 4) {
884 pFunc = new CPDF_PSFunc; 853 pFunc = new CPDF_PSFunc;
885 } else { 854 } else {
886 return NULL; 855 return NULL;
887 } 856 }
888 if (!pFunc->Init(pFuncObj)) { 857 if (!pFunc->Init(pFuncObj)) {
889 delete pFunc; 858 delete pFunc;
890 return NULL; 859 return NULL;
891 } 860 }
861 pFunc->m_nType = type;
Tom Sepez 2016/03/24 18:07:07 Shouldn't the ctors of the various function sub-cl
caryclark 2016/03/25 20:47:55 Done.
892 return pFunc; 862 return pFunc;
893 } 863 }
894 CPDF_Function::CPDF_Function() { 864 CPDF_Function::CPDF_Function() {
895 m_pDomains = NULL; 865 m_pDomains = NULL;
896 m_pRanges = NULL; 866 m_pRanges = NULL;
897 } 867 }
898 CPDF_Function::~CPDF_Function() { 868 CPDF_Function::~CPDF_Function() {
899 FX_Free(m_pDomains); 869 FX_Free(m_pDomains);
900 FX_Free(m_pRanges); 870 FX_Free(m_pRanges);
901 } 871 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 for (int i = 0; i < m_nOutputs; i++) { 927 for (int i = 0; i < m_nOutputs; i++) {
958 if (results[i] < m_pRanges[i * 2]) { 928 if (results[i] < m_pRanges[i * 2]) {
959 results[i] = m_pRanges[i * 2]; 929 results[i] = m_pRanges[i * 2];
960 } else if (results[i] > m_pRanges[i * 2 + 1]) { 930 } else if (results[i] > m_pRanges[i * 2 + 1]) {
961 results[i] = m_pRanges[i * 2 + 1]; 931 results[i] = m_pRanges[i * 2 + 1];
962 } 932 }
963 } 933 }
964 } 934 }
965 return TRUE; 935 return TRUE;
966 } 936 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_page/pageint.h » ('j') | core/fpdfapi/fpdf_page/pageint.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698