| 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 m_pImageObject->m_pImage->GetStream()->GetDict()->GetElementValue( | 399 m_pImageObject->m_pImage->GetStream()->GetDict()->GetElementValue( |
| 400 "Filter"); | 400 "Filter"); |
| 401 if (pFilters) { | 401 if (pFilters) { |
| 402 if (pFilters->IsName()) { | 402 if (pFilters->IsName()) { |
| 403 CFX_ByteStringC bsDecodeType = pFilters->GetConstString(); | 403 CFX_ByteStringC bsDecodeType = pFilters->GetConstString(); |
| 404 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { | 404 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { |
| 405 m_Flags |= FXRENDER_IMAGE_LOSSY; | 405 m_Flags |= FXRENDER_IMAGE_LOSSY; |
| 406 } | 406 } |
| 407 } else if (CPDF_Array* pArray = pFilters->AsArray()) { | 407 } else if (CPDF_Array* pArray = pFilters->AsArray()) { |
| 408 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { | 408 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { |
| 409 CFX_ByteStringC bsDecodeType = pArray->GetConstString(i); | 409 CFX_ByteStringC bsDecodeType = pArray->GetConstStringAt(i); |
| 410 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { | 410 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { |
| 411 m_Flags |= FXRENDER_IMAGE_LOSSY; | 411 m_Flags |= FXRENDER_IMAGE_LOSSY; |
| 412 break; | 412 break; |
| 413 } | 413 } |
| 414 } | 414 } |
| 415 } | 415 } |
| 416 } | 416 } |
| 417 } | 417 } |
| 418 if (m_pRenderStatus->m_Options.m_Flags & RENDER_NOIMAGESMOOTH) { | 418 if (m_pRenderStatus->m_Options.m_Flags & RENDER_NOIMAGESMOOTH) { |
| 419 m_Flags |= FXDIB_NOSMOOTH; | 419 m_Flags |= FXDIB_NOSMOOTH; |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 const CPDF_Dictionary* pParams); | 864 const CPDF_Dictionary* pParams); |
| 865 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, | 865 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, |
| 866 FX_RECT* pClipRect, | 866 FX_RECT* pClipRect, |
| 867 const CFX_Matrix* pMatrix) { | 867 const CFX_Matrix* pMatrix) { |
| 868 if (!pSMaskDict) { | 868 if (!pSMaskDict) { |
| 869 return NULL; | 869 return NULL; |
| 870 } | 870 } |
| 871 int width = pClipRect->right - pClipRect->left; | 871 int width = pClipRect->right - pClipRect->left; |
| 872 int height = pClipRect->bottom - pClipRect->top; | 872 int height = pClipRect->bottom - pClipRect->top; |
| 873 FX_BOOL bLuminosity = FALSE; | 873 FX_BOOL bLuminosity = FALSE; |
| 874 bLuminosity = pSMaskDict->GetConstString("S") != "Alpha"; | 874 bLuminosity = pSMaskDict->GetConstStringBy("S") != "Alpha"; |
| 875 CPDF_Stream* pGroup = pSMaskDict->GetStream("G"); | 875 CPDF_Stream* pGroup = pSMaskDict->GetStreamBy("G"); |
| 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->GetDocument(), m_pContext->GetPageResources(), | 886 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(), |
| 887 pGroup); | 887 pGroup); |
| 888 form.ParseContent(NULL, NULL, NULL, NULL); | 888 form.ParseContent(NULL, NULL, NULL, NULL); |
| 889 CFX_FxgeDevice bitmap_device; | 889 CFX_FxgeDevice bitmap_device; |
| 890 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 890 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 891 if (!bitmap_device.Create(width, height, | 891 if (!bitmap_device.Create(width, height, |
| 892 bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) { | 892 bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) { |
| 893 return NULL; | 893 return NULL; |
| 894 } | 894 } |
| 895 #else | 895 #else |
| 896 if (!bitmap_device.Create(width, height, | 896 if (!bitmap_device.Create(width, height, |
| 897 bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask)) { | 897 bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask)) { |
| 898 return NULL; | 898 return NULL; |
| 899 } | 899 } |
| 900 #endif | 900 #endif |
| 901 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); | 901 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); |
| 902 CPDF_Object* pCSObj = NULL; | 902 CPDF_Object* pCSObj = NULL; |
| 903 CPDF_ColorSpace* pCS = NULL; | 903 CPDF_ColorSpace* pCS = NULL; |
| 904 if (bLuminosity) { | 904 if (bLuminosity) { |
| 905 CPDF_Array* pBC = pSMaskDict->GetArray("BC"); | 905 CPDF_Array* pBC = pSMaskDict->GetArrayBy("BC"); |
| 906 FX_ARGB back_color = 0xff000000; | 906 FX_ARGB back_color = 0xff000000; |
| 907 if (pBC) { | 907 if (pBC) { |
| 908 CPDF_Dictionary* pDict = pGroup->GetDict(); | 908 CPDF_Dictionary* pDict = pGroup->GetDict(); |
| 909 if (pDict && pDict->GetDict("Group")) | 909 if (pDict && pDict->GetDictBy("Group")) |
| 910 pCSObj = pDict->GetDict("Group")->GetElementValue("CS"); | 910 pCSObj = pDict->GetDictBy("Group")->GetElementValue("CS"); |
| 911 else | 911 else |
| 912 pCSObj = NULL; | 912 pCSObj = NULL; |
| 913 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); | 913 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); |
| 914 if (pCS) { | 914 if (pCS) { |
| 915 FX_FLOAT R, G, B; | 915 FX_FLOAT R, G, B; |
| 916 FX_DWORD comps = 8; | 916 FX_DWORD comps = 8; |
| 917 if (pCS->CountComponents() > static_cast<int32_t>(comps)) { | 917 if (pCS->CountComponents() > static_cast<int32_t>(comps)) { |
| 918 comps = (FX_DWORD)pCS->CountComponents(); | 918 comps = (FX_DWORD)pCS->CountComponents(); |
| 919 } | 919 } |
| 920 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); | 920 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); |
| 921 FX_FLOAT* pFloats = float_array; | 921 FX_FLOAT* pFloats = float_array; |
| 922 FX_SAFE_DWORD num_floats = comps; | 922 FX_SAFE_DWORD num_floats = comps; |
| 923 num_floats *= sizeof(FX_FLOAT); | 923 num_floats *= sizeof(FX_FLOAT); |
| 924 if (!num_floats.IsValid()) { | 924 if (!num_floats.IsValid()) { |
| 925 return NULL; | 925 return NULL; |
| 926 } | 926 } |
| 927 FXSYS_memset(pFloats, 0, num_floats.ValueOrDie()); | 927 FXSYS_memset(pFloats, 0, num_floats.ValueOrDie()); |
| 928 int count = pBC->GetCount() > 8 ? 8 : pBC->GetCount(); | 928 int count = pBC->GetCount() > 8 ? 8 : pBC->GetCount(); |
| 929 for (int i = 0; i < count; i++) { | 929 for (int i = 0; i < count; i++) { |
| 930 pFloats[i] = pBC->GetNumber(i); | 930 pFloats[i] = pBC->GetNumberAt(i); |
| 931 } | 931 } |
| 932 pCS->GetRGB(pFloats, R, G, B); | 932 pCS->GetRGB(pFloats, R, G, B); |
| 933 back_color = 0xff000000 | ((int32_t)(R * 255) << 16) | | 933 back_color = 0xff000000 | ((int32_t)(R * 255) << 16) | |
| 934 ((int32_t)(G * 255) << 8) | (int32_t)(B * 255); | 934 ((int32_t)(G * 255) << 8) | (int32_t)(B * 255); |
| 935 m_pContext->GetDocument()->GetPageData()->ReleaseColorSpace(pCSObj); | 935 m_pContext->GetDocument()->GetPageData()->ReleaseColorSpace(pCSObj); |
| 936 } | 936 } |
| 937 } | 937 } |
| 938 bitmap.Clear(back_color); | 938 bitmap.Clear(back_color); |
| 939 } else { | 939 } else { |
| 940 bitmap.Clear(0); | 940 bitmap.Clear(0); |
| 941 } | 941 } |
| 942 CPDF_Dictionary* pFormResource = NULL; | 942 CPDF_Dictionary* pFormResource = NULL; |
| 943 if (form.m_pFormDict) { | 943 if (form.m_pFormDict) { |
| 944 pFormResource = form.m_pFormDict->GetDict("Resources"); | 944 pFormResource = form.m_pFormDict->GetDictBy("Resources"); |
| 945 } | 945 } |
| 946 CPDF_RenderOptions options; | 946 CPDF_RenderOptions options; |
| 947 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; | 947 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; |
| 948 CPDF_RenderStatus status; | 948 CPDF_RenderStatus status; |
| 949 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, NULL, NULL, | 949 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, NULL, NULL, |
| 950 &options, 0, m_bDropObjects, pFormResource, TRUE, NULL, 0, | 950 &options, 0, m_bDropObjects, pFormResource, TRUE, NULL, 0, |
| 951 pCS ? pCS->GetFamily() : 0, bLuminosity); | 951 pCS ? pCS->GetFamily() : 0, bLuminosity); |
| 952 status.RenderObjectList(&form, &matrix); | 952 status.RenderObjectList(&form, &matrix); |
| 953 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap); | 953 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap); |
| 954 if (!pMask->Create(width, height, FXDIB_8bppMask)) | 954 if (!pMask->Create(width, height, FXDIB_8bppMask)) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 985 } else if (pFunc) { | 985 } else if (pFunc) { |
| 986 int size = dest_pitch * height; | 986 int size = dest_pitch * height; |
| 987 for (int i = 0; i < size; i++) { | 987 for (int i = 0; i < size; i++) { |
| 988 dest_buf[i] = transfers[src_buf[i]]; | 988 dest_buf[i] = transfers[src_buf[i]]; |
| 989 } | 989 } |
| 990 } else { | 990 } else { |
| 991 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 991 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
| 992 } | 992 } |
| 993 return pMask.release(); | 993 return pMask.release(); |
| 994 } | 994 } |
| OLD | NEW |