| 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 <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 uint32_t src_size = m_pStreamAcc->GetSize(); | 554 uint32_t src_size = m_pStreamAcc->GetSize(); |
| 555 const CPDF_Dictionary* pParams = m_pStreamAcc->GetImageParam(); | 555 const CPDF_Dictionary* pParams = m_pStreamAcc->GetImageParam(); |
| 556 if (decoder == "CCITTFaxDecode") { | 556 if (decoder == "CCITTFaxDecode") { |
| 557 m_pDecoder.reset(FPDFAPI_CreateFaxDecoder(src_data, src_size, m_Width, | 557 m_pDecoder.reset(FPDFAPI_CreateFaxDecoder(src_data, src_size, m_Width, |
| 558 m_Height, pParams)); | 558 m_Height, pParams)); |
| 559 } else if (decoder == "DCTDecode") { | 559 } else if (decoder == "DCTDecode") { |
| 560 m_pDecoder.reset(CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( | 560 m_pDecoder.reset(CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( |
| 561 src_data, src_size, m_Width, m_Height, m_nComponents, | 561 src_data, src_size, m_Width, m_Height, m_nComponents, |
| 562 pParams ? pParams->GetIntegerBy("ColorTransform", 1) : 1)); | 562 pParams ? pParams->GetIntegerBy("ColorTransform", 1) : 1)); |
| 563 if (!m_pDecoder) { | 563 if (!m_pDecoder) { |
| 564 FX_BOOL bTransform = FALSE; | 564 bool bTransform = false; |
| 565 int comps; | 565 int comps; |
| 566 int bpc; | 566 int bpc; |
| 567 CCodec_JpegModule* pJpegModule = CPDF_ModuleMgr::Get()->GetJpegModule(); | 567 CCodec_JpegModule* pJpegModule = CPDF_ModuleMgr::Get()->GetJpegModule(); |
| 568 if (pJpegModule->LoadInfo(src_data, src_size, m_Width, m_Height, comps, | 568 if (pJpegModule->LoadInfo(src_data, src_size, &m_Width, &m_Height, &comps, |
| 569 bpc, bTransform)) { | 569 &bpc, &bTransform)) { |
| 570 if (m_nComponents != static_cast<uint32_t>(comps)) { | 570 if (m_nComponents != static_cast<uint32_t>(comps)) { |
| 571 FX_Free(m_pCompData); | 571 FX_Free(m_pCompData); |
| 572 m_pCompData = nullptr; | 572 m_pCompData = nullptr; |
| 573 m_nComponents = static_cast<uint32_t>(comps); | 573 m_nComponents = static_cast<uint32_t>(comps); |
| 574 if (m_pColorSpace && | 574 if (m_pColorSpace && |
| 575 m_pColorSpace->CountComponents() != m_nComponents) | 575 m_pColorSpace->CountComponents() != m_nComponents) { |
| 576 return 0; | 576 return 0; |
| 577 } |
| 577 if (m_Family == PDFCS_LAB && m_nComponents != 3) | 578 if (m_Family == PDFCS_LAB && m_nComponents != 3) |
| 578 return 0; | 579 return 0; |
| 579 m_pCompData = GetDecodeAndMaskArray(m_bDefaultDecode, m_bColorKey); | 580 m_pCompData = GetDecodeAndMaskArray(m_bDefaultDecode, m_bColorKey); |
| 580 if (!m_pCompData) | 581 if (!m_pCompData) |
| 581 return 0; | 582 return 0; |
| 582 } | 583 } |
| 583 m_bpc = bpc; | 584 m_bpc = bpc; |
| 584 m_pDecoder.reset(CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( | 585 m_pDecoder.reset(CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( |
| 585 src_data, src_size, m_Width, m_Height, m_nComponents, bTransform)); | 586 src_data, src_size, m_Width, m_Height, m_nComponents, bTransform)); |
| 586 } | 587 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 606 ->GetBasicModule() | 607 ->GetBasicModule() |
| 607 ->CreateRunLengthDecoder(src_data, src_size, m_Width, | 608 ->CreateRunLengthDecoder(src_data, src_size, m_Width, |
| 608 m_Height, m_nComponents, | 609 m_Height, m_nComponents, |
| 609 m_bpc)); | 610 m_bpc)); |
| 610 } | 611 } |
| 611 if (!m_pDecoder) | 612 if (!m_pDecoder) |
| 612 return 0; | 613 return 0; |
| 613 | 614 |
| 614 FX_SAFE_UINT32 requested_pitch = | 615 FX_SAFE_UINT32 requested_pitch = |
| 615 CalculatePitch8(m_bpc, m_nComponents, m_Width); | 616 CalculatePitch8(m_bpc, m_nComponents, m_Width); |
| 616 if (!requested_pitch.IsValid()) { | 617 if (!requested_pitch.IsValid()) |
| 617 return 0; | 618 return 0; |
| 618 } | |
| 619 FX_SAFE_UINT32 provided_pitch = CalculatePitch8( | 619 FX_SAFE_UINT32 provided_pitch = CalculatePitch8( |
| 620 m_pDecoder->GetBPC(), m_pDecoder->CountComps(), m_pDecoder->GetWidth()); | 620 m_pDecoder->GetBPC(), m_pDecoder->CountComps(), m_pDecoder->GetWidth()); |
| 621 if (!provided_pitch.IsValid()) { | 621 if (!provided_pitch.IsValid()) |
| 622 return 0; | 622 return 0; |
| 623 } | 623 if (provided_pitch.ValueOrDie() < requested_pitch.ValueOrDie()) |
| 624 if (provided_pitch.ValueOrDie() < requested_pitch.ValueOrDie()) { | |
| 625 return 0; | 624 return 0; |
| 626 } | |
| 627 return 1; | 625 return 1; |
| 628 } | 626 } |
| 629 | 627 |
| 630 void CPDF_DIBSource::LoadJpxBitmap() { | 628 void CPDF_DIBSource::LoadJpxBitmap() { |
| 631 CCodec_JpxModule* pJpxModule = CPDF_ModuleMgr::Get()->GetJpxModule(); | 629 CCodec_JpxModule* pJpxModule = CPDF_ModuleMgr::Get()->GetJpxModule(); |
| 632 if (!pJpxModule) | 630 if (!pJpxModule) |
| 633 return; | 631 return; |
| 634 | 632 |
| 635 std::unique_ptr<JpxBitMapContext> context(new JpxBitMapContext(pJpxModule)); | 633 std::unique_ptr<JpxBitMapContext> context(new JpxBitMapContext(pJpxModule)); |
| 636 context->set_decoder(pJpxModule->CreateDecoder( | 634 context->set_decoder(pJpxModule->CreateDecoder( |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 IFX_Pause* pPause) { | 1569 IFX_Pause* pPause) { |
| 1572 return LoadHandle->Continue(pPause); | 1570 return LoadHandle->Continue(pPause); |
| 1573 } | 1571 } |
| 1574 | 1572 |
| 1575 CPDF_ImageLoader::~CPDF_ImageLoader() { | 1573 CPDF_ImageLoader::~CPDF_ImageLoader() { |
| 1576 if (!m_bCached) { | 1574 if (!m_bCached) { |
| 1577 delete m_pBitmap; | 1575 delete m_pBitmap; |
| 1578 delete m_pMask; | 1576 delete m_pMask; |
| 1579 } | 1577 } |
| 1580 } | 1578 } |
| OLD | NEW |