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 <utility> | 10 #include <utility> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" | 13 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" |
13 #include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h" | 14 #include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h" |
14 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" | 15 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" |
15 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h" | 16 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h" |
16 #include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h" | 17 #include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h" |
17 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 18 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
18 #include "core/fpdfapi/fpdf_page/pageint.h" | 19 #include "core/fpdfapi/fpdf_page/pageint.h" |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 m_pDIBSource = m_pClone.get(); | 436 m_pDIBSource = m_pClone.get(); |
436 } | 437 } |
437 m_Flags = 0; | 438 m_Flags = 0; |
438 if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) { | 439 if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) { |
439 m_Flags |= RENDER_FORCE_DOWNSAMPLE; | 440 m_Flags |= RENDER_FORCE_DOWNSAMPLE; |
440 } else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE) { | 441 } else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE) { |
441 m_Flags |= RENDER_FORCE_HALFTONE; | 442 m_Flags |= RENDER_FORCE_HALFTONE; |
442 } | 443 } |
443 if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) { | 444 if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) { |
444 CPDF_Object* pFilters = | 445 CPDF_Object* pFilters = |
445 m_pImageObject->m_pImage->GetStream()->GetDict()->GetDirectObjectBy( | 446 m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectBy( |
446 "Filter"); | 447 "Filter"); |
447 if (pFilters) { | 448 if (pFilters) { |
448 if (pFilters->IsName()) { | 449 if (pFilters->IsName()) { |
449 CFX_ByteString bsDecodeType = pFilters->GetString(); | 450 CFX_ByteString bsDecodeType = pFilters->GetString(); |
450 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { | 451 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { |
451 m_Flags |= FXRENDER_IMAGE_LOSSY; | 452 m_Flags |= FXRENDER_IMAGE_LOSSY; |
452 } | 453 } |
453 } else if (CPDF_Array* pArray = pFilters->AsArray()) { | 454 } else if (CPDF_Array* pArray = pFilters->AsArray()) { |
454 for (size_t i = 0; i < pArray->GetCount(); i++) { | 455 for (size_t i = 0; i < pArray->GetCount(); i++) { |
455 CFX_ByteString bsDecodeType = pArray->GetStringAt(i); | 456 CFX_ByteString bsDecodeType = pArray->GetStringAt(i); |
456 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { | 457 if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") { |
457 m_Flags |= FXRENDER_IMAGE_LOSSY; | 458 m_Flags |= FXRENDER_IMAGE_LOSSY; |
458 break; | 459 break; |
459 } | 460 } |
460 } | 461 } |
461 } | 462 } |
462 } | 463 } |
463 } | 464 } |
464 if (m_pRenderStatus->m_Options.m_Flags & RENDER_NOIMAGESMOOTH) { | 465 if (m_pRenderStatus->m_Options.m_Flags & RENDER_NOIMAGESMOOTH) { |
465 m_Flags |= FXDIB_NOSMOOTH; | 466 m_Flags |= FXDIB_NOSMOOTH; |
466 } else if (m_pImageObject->m_pImage->IsInterpol()) { | 467 } else if (m_pImageObject->GetImage()->IsInterpol()) { |
467 m_Flags |= FXDIB_INTERPOL; | 468 m_Flags |= FXDIB_INTERPOL; |
468 } | 469 } |
469 if (m_Loader.m_pMask) { | 470 if (m_Loader.m_pMask) { |
470 return DrawMaskedImage(); | 471 return DrawMaskedImage(); |
471 } | 472 } |
472 if (m_bPatternColor) { | 473 if (m_bPatternColor) { |
473 return DrawPatternImage(m_pObj2Device); | 474 return DrawPatternImage(m_pObj2Device); |
474 } | 475 } |
475 if (m_BitmapAlpha == 255 && pGeneralState && pGeneralState->m_FillOP && | 476 if (m_BitmapAlpha == 255 && pGeneralState && pGeneralState->m_FillOP && |
476 pGeneralState->m_OPMode == 0 && | 477 pGeneralState->m_OPMode == 0 && |
477 pGeneralState->m_BlendType == FXDIB_BLEND_NORMAL && | 478 pGeneralState->m_BlendType == FXDIB_BLEND_NORMAL && |
478 pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) { | 479 pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) { |
479 CPDF_Document* pDocument = nullptr; | 480 CPDF_Document* pDocument = nullptr; |
480 CPDF_Page* pPage = nullptr; | 481 CPDF_Page* pPage = nullptr; |
481 if (m_pRenderStatus->m_pContext->GetPageCache()) { | 482 if (m_pRenderStatus->m_pContext->GetPageCache()) { |
482 pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage(); | 483 pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage(); |
483 pDocument = pPage->m_pDocument; | 484 pDocument = pPage->m_pDocument; |
484 } else { | 485 } else { |
485 pDocument = m_pImageObject->m_pImage->GetDocument(); | 486 pDocument = m_pImageObject->GetImage()->GetDocument(); |
486 } | 487 } |
487 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; | 488 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; |
488 CPDF_Object* pCSObj = | 489 CPDF_Object* pCSObj = |
489 m_pImageObject->m_pImage->GetStream()->GetDict()->GetDirectObjectBy( | 490 m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectBy( |
490 "ColorSpace"); | 491 "ColorSpace"); |
491 CPDF_ColorSpace* pColorSpace = | 492 CPDF_ColorSpace* pColorSpace = |
492 pDocument->LoadColorSpace(pCSObj, pPageResources); | 493 pDocument->LoadColorSpace(pCSObj, pPageResources); |
493 if (pColorSpace) { | 494 if (pColorSpace) { |
494 int format = pColorSpace->GetFamily(); | 495 int format = pColorSpace->GetFamily(); |
495 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || | 496 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || |
496 format == PDFCS_DEVICEN) { | 497 format == PDFCS_DEVICEN) { |
497 m_BlendType = FXDIB_BLEND_DARKEN; | 498 m_BlendType = FXDIB_BLEND_DARKEN; |
498 } | 499 } |
499 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); | 500 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); |
500 } | 501 } |
501 } | 502 } |
502 return StartDIBSource(); | 503 return StartDIBSource(); |
503 } | 504 } |
504 | 505 |
505 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, | 506 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, |
506 const CPDF_PageObject* pObj, | 507 const CPDF_PageObject* pObj, |
507 const CFX_Matrix* pObj2Device, | 508 const CFX_Matrix* pObj2Device, |
508 FX_BOOL bStdCS, | 509 FX_BOOL bStdCS, |
509 int blendType) { | 510 int blendType) { |
510 m_pRenderStatus = pStatus; | 511 m_pRenderStatus = pStatus; |
511 m_bStdCS = bStdCS; | 512 m_bStdCS = bStdCS; |
512 m_pImageObject = pObj->AsImage(); | 513 m_pImageObject = pObj->AsImage(); |
513 m_BlendType = blendType; | 514 m_BlendType = blendType; |
514 m_pObj2Device = pObj2Device; | 515 m_pObj2Device = pObj2Device; |
515 CPDF_Dictionary* pOC = m_pImageObject->m_pImage->GetOC(); | 516 CPDF_Dictionary* pOC = m_pImageObject->GetImage()->GetOC(); |
516 if (pOC && m_pRenderStatus->m_Options.m_pOCContext && | 517 if (pOC && m_pRenderStatus->m_Options.m_pOCContext && |
517 !m_pRenderStatus->m_Options.m_pOCContext->CheckOCGVisible(pOC)) { | 518 !m_pRenderStatus->m_Options.m_pOCContext->CheckOCGVisible(pOC)) { |
518 return FALSE; | 519 return FALSE; |
519 } | 520 } |
520 m_ImageMatrix = m_pImageObject->m_Matrix; | 521 m_ImageMatrix = m_pImageObject->m_Matrix; |
521 m_ImageMatrix.Concat(*pObj2Device); | 522 m_ImageMatrix.Concat(*pObj2Device); |
522 if (StartLoadDIBSource()) { | 523 if (StartLoadDIBSource()) { |
523 return TRUE; | 524 return TRUE; |
524 } | 525 } |
525 return StartRenderDIBSource(); | 526 return StartRenderDIBSource(); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 } else if (pFunc) { | 1053 } else if (pFunc) { |
1053 int size = dest_pitch * height; | 1054 int size = dest_pitch * height; |
1054 for (int i = 0; i < size; i++) { | 1055 for (int i = 0; i < size; i++) { |
1055 dest_buf[i] = transfers[src_buf[i]]; | 1056 dest_buf[i] = transfers[src_buf[i]]; |
1056 } | 1057 } |
1057 } else { | 1058 } else { |
1058 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1059 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
1059 } | 1060 } |
1060 return pMask.release(); | 1061 return pMask.release(); |
1061 } | 1062 } |
OLD | NEW |