| 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 <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 m_pDIBSource = m_pClone; | 401 m_pDIBSource = m_pClone; |
| 402 } | 402 } |
| 403 m_Flags = 0; | 403 m_Flags = 0; |
| 404 if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) { | 404 if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) { |
| 405 m_Flags |= RENDER_FORCE_DOWNSAMPLE; | 405 m_Flags |= RENDER_FORCE_DOWNSAMPLE; |
| 406 } else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE) { | 406 } else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE) { |
| 407 m_Flags |= RENDER_FORCE_HALFTONE; | 407 m_Flags |= RENDER_FORCE_HALFTONE; |
| 408 } | 408 } |
| 409 if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) { | 409 if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) { |
| 410 CPDF_Object* pFilters = | 410 CPDF_Object* pFilters = |
| 411 m_pImageObject->m_pImage->GetStream()->GetDict()->GetElementValue( | 411 m_pImageObject->m_pImage->GetStream()->GetDict()->GetDirectObjectBy( |
| 412 "Filter"); | 412 "Filter"); |
| 413 if (pFilters) { | 413 if (pFilters) { |
| 414 if (pFilters->IsName()) { | 414 if (pFilters->IsName()) { |
| 415 CFX_ByteStringC bsDecodeType = pFilters->GetConstString(); | 415 CFX_ByteStringC bsDecodeType = pFilters->GetConstString(); |
| 416 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { | 416 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { |
| 417 m_Flags |= FXRENDER_IMAGE_LOSSY; | 417 m_Flags |= FXRENDER_IMAGE_LOSSY; |
| 418 } | 418 } |
| 419 } else if (CPDF_Array* pArray = pFilters->AsArray()) { | 419 } else if (CPDF_Array* pArray = pFilters->AsArray()) { |
| 420 for (uint32_t i = 0; i < pArray->GetCount(); i++) { | 420 for (uint32_t i = 0; i < pArray->GetCount(); i++) { |
| 421 CFX_ByteStringC bsDecodeType = pArray->GetConstStringAt(i); | 421 CFX_ByteStringC bsDecodeType = pArray->GetConstStringAt(i); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 445 CPDF_Document* pDocument = NULL; | 445 CPDF_Document* pDocument = NULL; |
| 446 CPDF_Page* pPage = NULL; | 446 CPDF_Page* pPage = NULL; |
| 447 if (m_pRenderStatus->m_pContext->GetPageCache()) { | 447 if (m_pRenderStatus->m_pContext->GetPageCache()) { |
| 448 pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage(); | 448 pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage(); |
| 449 pDocument = pPage->m_pDocument; | 449 pDocument = pPage->m_pDocument; |
| 450 } else { | 450 } else { |
| 451 pDocument = m_pImageObject->m_pImage->GetDocument(); | 451 pDocument = m_pImageObject->m_pImage->GetDocument(); |
| 452 } | 452 } |
| 453 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL; | 453 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL; |
| 454 CPDF_Object* pCSObj = | 454 CPDF_Object* pCSObj = |
| 455 m_pImageObject->m_pImage->GetStream()->GetDict()->GetElementValue( | 455 m_pImageObject->m_pImage->GetStream()->GetDict()->GetDirectObjectBy( |
| 456 "ColorSpace"); | 456 "ColorSpace"); |
| 457 CPDF_ColorSpace* pColorSpace = | 457 CPDF_ColorSpace* pColorSpace = |
| 458 pDocument->LoadColorSpace(pCSObj, pPageResources); | 458 pDocument->LoadColorSpace(pCSObj, pPageResources); |
| 459 if (pColorSpace) { | 459 if (pColorSpace) { |
| 460 int format = pColorSpace->GetFamily(); | 460 int format = pColorSpace->GetFamily(); |
| 461 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || | 461 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || |
| 462 format == PDFCS_DEVICEN) { | 462 format == PDFCS_DEVICEN) { |
| 463 m_BlendType = FXDIB_BLEND_DARKEN; | 463 m_BlendType = FXDIB_BLEND_DARKEN; |
| 464 } | 464 } |
| 465 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); | 465 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 } | 882 } |
| 883 int width = pClipRect->right - pClipRect->left; | 883 int width = pClipRect->right - pClipRect->left; |
| 884 int height = pClipRect->bottom - pClipRect->top; | 884 int height = pClipRect->bottom - pClipRect->top; |
| 885 FX_BOOL bLuminosity = FALSE; | 885 FX_BOOL bLuminosity = FALSE; |
| 886 bLuminosity = pSMaskDict->GetConstStringBy("S") != "Alpha"; | 886 bLuminosity = pSMaskDict->GetConstStringBy("S") != "Alpha"; |
| 887 CPDF_Stream* pGroup = pSMaskDict->GetStreamBy("G"); | 887 CPDF_Stream* pGroup = pSMaskDict->GetStreamBy("G"); |
| 888 if (!pGroup) { | 888 if (!pGroup) { |
| 889 return NULL; | 889 return NULL; |
| 890 } | 890 } |
| 891 std::unique_ptr<CPDF_Function> pFunc; | 891 std::unique_ptr<CPDF_Function> pFunc; |
| 892 CPDF_Object* pFuncObj = pSMaskDict->GetElementValue("TR"); | 892 CPDF_Object* pFuncObj = pSMaskDict->GetDirectObjectBy("TR"); |
| 893 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) | 893 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) |
| 894 pFunc.reset(CPDF_Function::Load(pFuncObj)); | 894 pFunc.reset(CPDF_Function::Load(pFuncObj)); |
| 895 | 895 |
| 896 CFX_Matrix matrix = *pMatrix; | 896 CFX_Matrix matrix = *pMatrix; |
| 897 matrix.TranslateI(-pClipRect->left, -pClipRect->top); | 897 matrix.TranslateI(-pClipRect->left, -pClipRect->top); |
| 898 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(), | 898 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(), |
| 899 pGroup); | 899 pGroup); |
| 900 form.ParseContent(NULL, NULL, NULL, NULL); | 900 form.ParseContent(NULL, NULL, NULL, NULL); |
| 901 CFX_FxgeDevice bitmap_device; | 901 CFX_FxgeDevice bitmap_device; |
| 902 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 902 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 903 if (!bitmap_device.Create(width, height, | 903 if (!bitmap_device.Create(width, height, |
| 904 bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) { | 904 bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) { |
| 905 return NULL; | 905 return NULL; |
| 906 } | 906 } |
| 907 #else | 907 #else |
| 908 if (!bitmap_device.Create(width, height, | 908 if (!bitmap_device.Create(width, height, |
| 909 bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask)) { | 909 bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask)) { |
| 910 return NULL; | 910 return NULL; |
| 911 } | 911 } |
| 912 #endif | 912 #endif |
| 913 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); | 913 CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); |
| 914 CPDF_Object* pCSObj = NULL; | 914 CPDF_Object* pCSObj = NULL; |
| 915 CPDF_ColorSpace* pCS = NULL; | 915 CPDF_ColorSpace* pCS = NULL; |
| 916 if (bLuminosity) { | 916 if (bLuminosity) { |
| 917 CPDF_Array* pBC = pSMaskDict->GetArrayBy("BC"); | 917 CPDF_Array* pBC = pSMaskDict->GetArrayBy("BC"); |
| 918 FX_ARGB back_color = 0xff000000; | 918 FX_ARGB back_color = 0xff000000; |
| 919 if (pBC) { | 919 if (pBC) { |
| 920 CPDF_Dictionary* pDict = pGroup->GetDict(); | 920 CPDF_Dictionary* pDict = pGroup->GetDict(); |
| 921 if (pDict && pDict->GetDictBy("Group")) | 921 if (pDict && pDict->GetDictBy("Group")) |
| 922 pCSObj = pDict->GetDictBy("Group")->GetElementValue("CS"); | 922 pCSObj = pDict->GetDictBy("Group")->GetDirectObjectBy("CS"); |
| 923 else | 923 else |
| 924 pCSObj = NULL; | 924 pCSObj = NULL; |
| 925 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); | 925 pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); |
| 926 if (pCS) { | 926 if (pCS) { |
| 927 FX_FLOAT R, G, B; | 927 FX_FLOAT R, G, B; |
| 928 uint32_t comps = 8; | 928 uint32_t comps = 8; |
| 929 if (pCS->CountComponents() > comps) { | 929 if (pCS->CountComponents() > comps) { |
| 930 comps = pCS->CountComponents(); | 930 comps = pCS->CountComponents(); |
| 931 } | 931 } |
| 932 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); | 932 CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 } else if (pFunc) { | 997 } else if (pFunc) { |
| 998 int size = dest_pitch * height; | 998 int size = dest_pitch * height; |
| 999 for (int i = 0; i < size; i++) { | 999 for (int i = 0; i < size; i++) { |
| 1000 dest_buf[i] = transfers[src_buf[i]]; | 1000 dest_buf[i] = transfers[src_buf[i]]; |
| 1001 } | 1001 } |
| 1002 } else { | 1002 } else { |
| 1003 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1003 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
| 1004 } | 1004 } |
| 1005 return pMask.release(); | 1005 return pMask.release(); |
| 1006 } | 1006 } |
| OLD | NEW |