OLD | NEW |
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 "render_int.h" | 7 #include "render_int.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 if (!pGroup) { | 876 if (!pGroup) { |
877 return NULL; | 877 return NULL; |
878 } | 878 } |
879 std::unique_ptr<CPDF_Function> pFunc; | 879 std::unique_ptr<CPDF_Function> pFunc; |
880 CPDF_Object* pFuncObj = pSMaskDict->GetElementValue("TR"); | 880 CPDF_Object* pFuncObj = pSMaskDict->GetElementValue("TR"); |
881 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) | 881 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) |
882 pFunc.reset(CPDF_Function::Load(pFuncObj)); | 882 pFunc.reset(CPDF_Function::Load(pFuncObj)); |
883 | 883 |
884 CFX_Matrix matrix = *pMatrix; | 884 CFX_Matrix matrix = *pMatrix; |
885 matrix.TranslateI(-pClipRect->left, -pClipRect->top); | 885 matrix.TranslateI(-pClipRect->left, -pClipRect->top); |
886 CPDF_Form form(m_pContext->m_pDocument, m_pContext->m_pPageResources, pGroup); | 886 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(), |
| 887 pGroup); |
887 form.ParseContent(NULL, NULL, NULL, NULL); | 888 form.ParseContent(NULL, NULL, NULL, NULL); |
888 CFX_FxgeDevice bitmap_device; | 889 CFX_FxgeDevice bitmap_device; |
889 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 890 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
890 if (!bitmap_device.Create(width, height, | 891 if (!bitmap_device.Create(width, height, |
891 bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) { | 892 bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) { |
892 return NULL; | 893 return NULL; |
893 } | 894 } |
894 #else | 895 #else |
895 if (!bitmap_device.Create(width, height, | 896 if (!bitmap_device.Create(width, height, |
896 bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask)) { | 897 bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask)) { |
897 return NULL; | 898 return NULL; |
898 } | 899 } |
899 #endif | 900 #endif |
900 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); | 901 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); |
901 CPDF_Object* pCSObj = NULL; | 902 CPDF_Object* pCSObj = NULL; |
902 CPDF_ColorSpace* pCS = NULL; | 903 CPDF_ColorSpace* pCS = NULL; |
903 if (bLuminosity) { | 904 if (bLuminosity) { |
904 CPDF_Array* pBC = pSMaskDict->GetArray("BC"); | 905 CPDF_Array* pBC = pSMaskDict->GetArray("BC"); |
905 FX_ARGB back_color = 0xff000000; | 906 FX_ARGB back_color = 0xff000000; |
906 if (pBC) { | 907 if (pBC) { |
907 CPDF_Dictionary* pDict = pGroup->GetDict(); | 908 CPDF_Dictionary* pDict = pGroup->GetDict(); |
908 if (pDict && pDict->GetDict("Group")) | 909 if (pDict && pDict->GetDict("Group")) |
909 pCSObj = pDict->GetDict("Group")->GetElementValue("CS"); | 910 pCSObj = pDict->GetDict("Group")->GetElementValue("CS"); |
910 else | 911 else |
911 pCSObj = NULL; | 912 pCSObj = NULL; |
912 pCS = m_pContext->m_pDocument->LoadColorSpace(pCSObj); | 913 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); |
913 if (pCS) { | 914 if (pCS) { |
914 FX_FLOAT R, G, B; | 915 FX_FLOAT R, G, B; |
915 FX_DWORD comps = 8; | 916 FX_DWORD comps = 8; |
916 if (pCS->CountComponents() > static_cast<int32_t>(comps)) { | 917 if (pCS->CountComponents() > static_cast<int32_t>(comps)) { |
917 comps = (FX_DWORD)pCS->CountComponents(); | 918 comps = (FX_DWORD)pCS->CountComponents(); |
918 } | 919 } |
919 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); | 920 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); |
920 FX_FLOAT* pFloats = float_array; | 921 FX_FLOAT* pFloats = float_array; |
921 FX_SAFE_DWORD num_floats = comps; | 922 FX_SAFE_DWORD num_floats = comps; |
922 num_floats *= sizeof(FX_FLOAT); | 923 num_floats *= sizeof(FX_FLOAT); |
923 if (!num_floats.IsValid()) { | 924 if (!num_floats.IsValid()) { |
924 return NULL; | 925 return NULL; |
925 } | 926 } |
926 FXSYS_memset(pFloats, 0, num_floats.ValueOrDie()); | 927 FXSYS_memset(pFloats, 0, num_floats.ValueOrDie()); |
927 int count = pBC->GetCount() > 8 ? 8 : pBC->GetCount(); | 928 int count = pBC->GetCount() > 8 ? 8 : pBC->GetCount(); |
928 for (int i = 0; i < count; i++) { | 929 for (int i = 0; i < count; i++) { |
929 pFloats[i] = pBC->GetNumber(i); | 930 pFloats[i] = pBC->GetNumber(i); |
930 } | 931 } |
931 pCS->GetRGB(pFloats, R, G, B); | 932 pCS->GetRGB(pFloats, R, G, B); |
932 back_color = 0xff000000 | ((int32_t)(R * 255) << 16) | | 933 back_color = 0xff000000 | ((int32_t)(R * 255) << 16) | |
933 ((int32_t)(G * 255) << 8) | (int32_t)(B * 255); | 934 ((int32_t)(G * 255) << 8) | (int32_t)(B * 255); |
934 m_pContext->m_pDocument->GetPageData()->ReleaseColorSpace(pCSObj); | 935 m_pContext->GetDocument()->GetPageData()->ReleaseColorSpace(pCSObj); |
935 } | 936 } |
936 } | 937 } |
937 bitmap.Clear(back_color); | 938 bitmap.Clear(back_color); |
938 } else { | 939 } else { |
939 bitmap.Clear(0); | 940 bitmap.Clear(0); |
940 } | 941 } |
941 CPDF_Dictionary* pFormResource = NULL; | 942 CPDF_Dictionary* pFormResource = NULL; |
942 if (form.m_pFormDict) { | 943 if (form.m_pFormDict) { |
943 pFormResource = form.m_pFormDict->GetDict("Resources"); | 944 pFormResource = form.m_pFormDict->GetDict("Resources"); |
944 } | 945 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 } else if (pFunc) { | 985 } else if (pFunc) { |
985 int size = dest_pitch * height; | 986 int size = dest_pitch * height; |
986 for (int i = 0; i < size; i++) { | 987 for (int i = 0; i < size; i++) { |
987 dest_buf[i] = transfers[src_buf[i]]; | 988 dest_buf[i] = transfers[src_buf[i]]; |
988 } | 989 } |
989 } else { | 990 } else { |
990 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 991 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
991 } | 992 } |
992 return pMask.release(); | 993 return pMask.release(); |
993 } | 994 } |
OLD | NEW |