| 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()->GetDirectObjectBy( | 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_ByteString bsDecodeType = pFilters->GetString(); |
| 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 (size_t i = 0; i < pArray->GetCount(); i++) { | 420 for (size_t i = 0; i < pArray->GetCount(); i++) { |
| 421 CFX_ByteStringC bsDecodeType = pArray->GetConstStringAt(i); | 421 CFX_ByteString bsDecodeType = pArray->GetStringAt(i); |
| 422 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { | 422 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { |
| 423 m_Flags |= FXRENDER_IMAGE_LOSSY; | 423 m_Flags |= FXRENDER_IMAGE_LOSSY; |
| 424 break; | 424 break; |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 } | 429 } |
| 430 if (m_pRenderStatus->m_Options.m_Flags & RENDER_NOIMAGESMOOTH) { | 430 if (m_pRenderStatus->m_Options.m_Flags & RENDER_NOIMAGESMOOTH) { |
| 431 m_Flags |= FXDIB_NOSMOOTH; | 431 m_Flags |= FXDIB_NOSMOOTH; |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 int height, | 873 int height, |
| 874 int nComps, | 874 int nComps, |
| 875 int bpc, | 875 int bpc, |
| 876 const CPDF_Dictionary* pParams); | 876 const CPDF_Dictionary* pParams); |
| 877 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, | 877 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, |
| 878 FX_RECT* pClipRect, | 878 FX_RECT* pClipRect, |
| 879 const CFX_Matrix* pMatrix) { | 879 const CFX_Matrix* pMatrix) { |
| 880 if (!pSMaskDict) { | 880 if (!pSMaskDict) { |
| 881 return NULL; | 881 return NULL; |
| 882 } | 882 } |
| 883 int width = pClipRect->right - pClipRect->left; | |
| 884 int height = pClipRect->bottom - pClipRect->top; | |
| 885 FX_BOOL bLuminosity = FALSE; | |
| 886 bLuminosity = pSMaskDict->GetConstStringBy("S") != "Alpha"; | |
| 887 CPDF_Stream* pGroup = pSMaskDict->GetStreamBy("G"); | 883 CPDF_Stream* pGroup = pSMaskDict->GetStreamBy("G"); |
| 888 if (!pGroup) { | 884 if (!pGroup) { |
| 889 return NULL; | 885 return NULL; |
| 890 } | 886 } |
| 891 std::unique_ptr<CPDF_Function> pFunc; | 887 std::unique_ptr<CPDF_Function> pFunc; |
| 892 CPDF_Object* pFuncObj = pSMaskDict->GetDirectObjectBy("TR"); | 888 CPDF_Object* pFuncObj = pSMaskDict->GetDirectObjectBy("TR"); |
| 893 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) | 889 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) |
| 894 pFunc.reset(CPDF_Function::Load(pFuncObj)); | 890 pFunc.reset(CPDF_Function::Load(pFuncObj)); |
| 895 | 891 |
| 896 CFX_Matrix matrix = *pMatrix; | 892 CFX_Matrix matrix = *pMatrix; |
| 897 matrix.TranslateI(-pClipRect->left, -pClipRect->top); | 893 matrix.TranslateI(-pClipRect->left, -pClipRect->top); |
| 894 |
| 898 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(), | 895 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(), |
| 899 pGroup); | 896 pGroup); |
| 900 form.ParseContent(NULL, NULL, NULL, NULL); | 897 form.ParseContent(NULL, NULL, NULL, NULL); |
| 898 |
| 901 CFX_FxgeDevice bitmap_device; | 899 CFX_FxgeDevice bitmap_device; |
| 900 FX_BOOL bLuminosity = pSMaskDict->GetStringBy("S") != "Alpha"; |
| 901 int width = pClipRect->right - pClipRect->left; |
| 902 int height = pClipRect->bottom - pClipRect->top; |
| 902 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 903 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 903 if (!bitmap_device.Create(width, height, | 904 if (!bitmap_device.Create(width, height, |
| 904 bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) { | 905 bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) { |
| 905 return NULL; | 906 return NULL; |
| 906 } | 907 } |
| 907 #else | 908 #else |
| 908 if (!bitmap_device.Create(width, height, | 909 if (!bitmap_device.Create(width, height, |
| 909 bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask)) { | 910 bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask)) { |
| 910 return NULL; | 911 return NULL; |
| 911 } | 912 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 } else if (pFunc) { | 998 } else if (pFunc) { |
| 998 int size = dest_pitch * height; | 999 int size = dest_pitch * height; |
| 999 for (int i = 0; i < size; i++) { | 1000 for (int i = 0; i < size; i++) { |
| 1000 dest_buf[i] = transfers[src_buf[i]]; | 1001 dest_buf[i] = transfers[src_buf[i]]; |
| 1001 } | 1002 } |
| 1002 } else { | 1003 } else { |
| 1003 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1004 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
| 1004 } | 1005 } |
| 1005 return pMask.release(); | 1006 return pMask.release(); |
| 1006 } | 1007 } |
| OLD | NEW |