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 "core/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/fpdfapi/fpdf_render/render_int.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 FXDIB_Format format; | 983 FXDIB_Format format; |
984 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || defined _SKIA_SUPPORT_ | 984 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || defined _SKIA_SUPPORT_ |
985 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask; | 985 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask; |
986 #else | 986 #else |
987 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask; | 987 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask; |
988 #endif | 988 #endif |
989 if (!bitmap_device.Create(width, height, format, nullptr)) | 989 if (!bitmap_device.Create(width, height, format, nullptr)) |
990 return nullptr; | 990 return nullptr; |
991 | 991 |
992 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); | 992 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); |
993 CPDF_Object* pCSObj = nullptr; | 993 int color_space_family = 0; |
994 CPDF_ColorSpace* pCS = nullptr; | |
995 if (bLuminosity) { | 994 if (bLuminosity) { |
996 CPDF_Array* pBC = pSMaskDict->GetArrayFor("BC"); | 995 CPDF_Array* pBC = pSMaskDict->GetArrayFor("BC"); |
997 FX_ARGB back_color = 0xff000000; | 996 FX_ARGB back_color = 0xff000000; |
998 if (pBC) { | 997 if (pBC) { |
| 998 CPDF_Object* pCSObj = nullptr; |
999 CPDF_Dictionary* pDict = pGroup->GetDict(); | 999 CPDF_Dictionary* pDict = pGroup->GetDict(); |
1000 if (pDict && pDict->GetDictFor("Group")) | 1000 if (pDict && pDict->GetDictFor("Group")) { |
1001 pCSObj = pDict->GetDictFor("Group")->GetDirectObjectFor("CS"); | 1001 pCSObj = pDict->GetDictFor("Group")->GetDirectObjectFor("CS"); |
1002 else | 1002 } |
1003 pCSObj = nullptr; | 1003 const CPDF_ColorSpace* pCS = |
1004 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); | 1004 m_pContext->GetDocument()->LoadColorSpace(pCSObj); |
1005 if (pCS) { | 1005 if (pCS) { |
| 1006 // Store Color Space Family to use in CPDF_RenderStatus::Initialize. |
| 1007 color_space_family = pCS->GetFamily(); |
| 1008 |
1006 FX_FLOAT R, G, B; | 1009 FX_FLOAT R, G, B; |
1007 uint32_t comps = 8; | 1010 uint32_t comps = 8; |
1008 if (pCS->CountComponents() > comps) { | 1011 if (pCS->CountComponents() > comps) { |
1009 comps = pCS->CountComponents(); | 1012 comps = pCS->CountComponents(); |
1010 } | 1013 } |
1011 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); | 1014 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); |
1012 FX_FLOAT* pFloats = float_array; | 1015 FX_FLOAT* pFloats = float_array; |
1013 FX_SAFE_UINT32 num_floats = comps; | 1016 FX_SAFE_UINT32 num_floats = comps; |
1014 num_floats *= sizeof(FX_FLOAT); | 1017 num_floats *= sizeof(FX_FLOAT); |
1015 if (!num_floats.IsValid()) { | 1018 if (!num_floats.IsValid()) { |
(...skipping 16 matching lines...) Expand all Loading... |
1032 } | 1035 } |
1033 CPDF_Dictionary* pFormResource = nullptr; | 1036 CPDF_Dictionary* pFormResource = nullptr; |
1034 if (form.m_pFormDict) { | 1037 if (form.m_pFormDict) { |
1035 pFormResource = form.m_pFormDict->GetDictFor("Resources"); | 1038 pFormResource = form.m_pFormDict->GetDictFor("Resources"); |
1036 } | 1039 } |
1037 CPDF_RenderOptions options; | 1040 CPDF_RenderOptions options; |
1038 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; | 1041 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; |
1039 CPDF_RenderStatus status; | 1042 CPDF_RenderStatus status; |
1040 status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, nullptr, | 1043 status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, nullptr, |
1041 nullptr, &options, 0, m_bDropObjects, pFormResource, TRUE, | 1044 nullptr, &options, 0, m_bDropObjects, pFormResource, TRUE, |
1042 nullptr, 0, pCS ? pCS->GetFamily() : 0, bLuminosity); | 1045 nullptr, 0, color_space_family, bLuminosity); |
1043 status.RenderObjectList(&form, &matrix); | 1046 status.RenderObjectList(&form, &matrix); |
1044 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap); | 1047 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap); |
1045 if (!pMask->Create(width, height, FXDIB_8bppMask)) | 1048 if (!pMask->Create(width, height, FXDIB_8bppMask)) |
1046 return nullptr; | 1049 return nullptr; |
1047 | 1050 |
1048 uint8_t* dest_buf = pMask->GetBuffer(); | 1051 uint8_t* dest_buf = pMask->GetBuffer(); |
1049 int dest_pitch = pMask->GetPitch(); | 1052 int dest_pitch = pMask->GetPitch(); |
1050 uint8_t* src_buf = bitmap.GetBuffer(); | 1053 uint8_t* src_buf = bitmap.GetBuffer(); |
1051 int src_pitch = bitmap.GetPitch(); | 1054 int src_pitch = bitmap.GetPitch(); |
1052 std::vector<uint8_t> transfers(256); | 1055 std::vector<uint8_t> transfers(256); |
(...skipping 23 matching lines...) Expand all Loading... |
1076 } else if (pFunc) { | 1079 } else if (pFunc) { |
1077 int size = dest_pitch * height; | 1080 int size = dest_pitch * height; |
1078 for (int i = 0; i < size; i++) { | 1081 for (int i = 0; i < size; i++) { |
1079 dest_buf[i] = transfers[src_buf[i]]; | 1082 dest_buf[i] = transfers[src_buf[i]]; |
1080 } | 1083 } |
1081 } else { | 1084 } else { |
1082 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1085 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
1083 } | 1086 } |
1084 return pMask.release(); | 1087 return pMask.release(); |
1085 } | 1088 } |
OLD | NEW |