Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp

Issue 1310603006: Cleanup dead code in CPDF_DIBSource::LoadJpxBitmap() and friends. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: no pass by ref, use override, use unique_ptr, remove dead param Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "../../../../third_party/base/nonstd_unique_ptr.h" 7 #include "../../../../third_party/base/nonstd_unique_ptr.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fpdfapi/fpdf_pageobj.h" 9 #include "../../../include/fpdfapi/fpdf_pageobj.h"
10 #include "../../../include/fpdfapi/fpdf_render.h" 10 #include "../../../include/fpdfapi/fpdf_render.h"
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 context->set_context(pJpxModule->CreateDecoder(m_pStreamAcc->GetData(), 701 context->set_context(pJpxModule->CreateDecoder(m_pStreamAcc->GetData(),
702 m_pStreamAcc->GetSize(), 702 m_pStreamAcc->GetSize(),
703 m_pColorSpace != nullptr)); 703 m_pColorSpace != nullptr));
704 if (!context->context()) 704 if (!context->context())
705 return; 705 return;
706 706
707 FX_DWORD width = 0; 707 FX_DWORD width = 0;
708 FX_DWORD height = 0; 708 FX_DWORD height = 0;
709 FX_DWORD codestream_nComps = 0; 709 FX_DWORD codestream_nComps = 0;
710 FX_DWORD image_nComps = 0; 710 FX_DWORD image_nComps = 0;
711 pJpxModule->GetImageInfo(context->context(), width, height, codestream_nComps, 711 pJpxModule->GetImageInfo(context->context(), &width, &height,
712 image_nComps); 712 &codestream_nComps, &image_nComps);
713 if ((int)width < m_Width || (int)height < m_Height) 713 if ((int)width < m_Width || (int)height < m_Height)
714 return; 714 return;
715 715
716 int output_nComps; 716 int output_nComps;
717 FX_BOOL bTranslateColor;
718 FX_BOOL bSwapRGB = FALSE; 717 FX_BOOL bSwapRGB = FALSE;
719 if (m_pColorSpace) { 718 if (m_pColorSpace) {
720 if (codestream_nComps != (FX_DWORD)m_pColorSpace->CountComponents()) 719 if (codestream_nComps != (FX_DWORD)m_pColorSpace->CountComponents())
721 return; 720 return;
722 output_nComps = codestream_nComps; 721 output_nComps = codestream_nComps;
723 bTranslateColor = FALSE;
724 if (m_pColorSpace == CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB)) { 722 if (m_pColorSpace == CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB)) {
725 bSwapRGB = TRUE; 723 bSwapRGB = TRUE;
726 m_pColorSpace = nullptr; 724 m_pColorSpace = nullptr;
727 } 725 }
728 } else { 726 } else {
729 bTranslateColor = TRUE;
730 if (image_nComps) { 727 if (image_nComps) {
731 output_nComps = image_nComps; 728 output_nComps = image_nComps;
732 } else { 729 } else {
733 output_nComps = codestream_nComps; 730 output_nComps = codestream_nComps;
734 } 731 }
735 if (output_nComps == 3) { 732 if (output_nComps == 3) {
736 bSwapRGB = TRUE; 733 bSwapRGB = TRUE;
737 } else if (output_nComps == 4) { 734 } else if (output_nComps == 4) {
738 m_pColorSpace = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); 735 m_pColorSpace = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK);
739 bTranslateColor = FALSE;
740 } 736 }
741 m_nComponents = output_nComps; 737 m_nComponents = output_nComps;
742 } 738 }
743 FXDIB_Format format; 739 FXDIB_Format format;
744 if (output_nComps == 1) { 740 if (output_nComps == 1) {
745 format = FXDIB_8bppRgb; 741 format = FXDIB_8bppRgb;
746 } else if (output_nComps <= 3) { 742 } else if (output_nComps <= 3) {
747 format = FXDIB_Rgb; 743 format = FXDIB_Rgb;
748 } else if (output_nComps == 4) { 744 } else if (output_nComps == 4) {
749 format = FXDIB_Rgb32; 745 format = FXDIB_Rgb32;
750 } else { 746 } else {
751 width = (width * output_nComps + 2) / 3; 747 width = (width * output_nComps + 2) / 3;
752 format = FXDIB_Rgb; 748 format = FXDIB_Rgb;
753 } 749 }
754 m_pCachedBitmap.reset(new CFX_DIBitmap); 750 m_pCachedBitmap.reset(new CFX_DIBitmap);
755 if (!m_pCachedBitmap->Create(width, height, format)) { 751 if (!m_pCachedBitmap->Create(width, height, format)) {
756 m_pCachedBitmap.reset(); 752 m_pCachedBitmap.reset();
757 return; 753 return;
758 } 754 }
759 m_pCachedBitmap->Clear(0xFFFFFFFF); 755 m_pCachedBitmap->Clear(0xFFFFFFFF);
760 context->set_output_offsets(FX_Alloc(uint8_t, output_nComps)); 756 context->set_output_offsets(FX_Alloc(uint8_t, output_nComps));
761 for (int i = 0; i < output_nComps; ++i) 757 for (int i = 0; i < output_nComps; ++i)
762 context->output_offsets()[i] = i; 758 context->output_offsets()[i] = i;
763 if (bSwapRGB) { 759 if (bSwapRGB) {
764 context->output_offsets()[0] = 2; 760 context->output_offsets()[0] = 2;
765 context->output_offsets()[2] = 0; 761 context->output_offsets()[2] = 0;
766 } 762 }
767 if (!pJpxModule->Decode(context->context(), m_pCachedBitmap->GetBuffer(), 763 if (!pJpxModule->Decode(context->context(), m_pCachedBitmap->GetBuffer(),
768 m_pCachedBitmap->GetPitch(), bTranslateColor, 764 m_pCachedBitmap->GetPitch(),
769 context->output_offsets())) { 765 context->output_offsets())) {
770 m_pCachedBitmap.reset(); 766 m_pCachedBitmap.reset();
771 return; 767 return;
772 } 768 }
773 if (m_pColorSpace && m_pColorSpace->GetFamily() == PDFCS_INDEXED && 769 if (m_pColorSpace && m_pColorSpace->GetFamily() == PDFCS_INDEXED &&
774 m_bpc < 8) { 770 m_bpc < 8) {
775 int scale = 8 - m_bpc; 771 int scale = 8 - m_bpc;
776 for (FX_DWORD row = 0; row < height; ++row) { 772 for (FX_DWORD row = 0; row < height; ++row) {
777 uint8_t* scanline = (uint8_t*)m_pCachedBitmap->GetScanline(row); 773 uint8_t* scanline = (uint8_t*)m_pCachedBitmap->GetScanline(row);
778 for (FX_DWORD col = 0; col < width; ++col) { 774 for (FX_DWORD col = 0; col < width; ++col) {
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 } 1669 }
1674 FX_BOOL CPDF_ImageLoader::Continue(void* LoadHandle, IFX_Pause* pPause) { 1670 FX_BOOL CPDF_ImageLoader::Continue(void* LoadHandle, IFX_Pause* pPause) {
1675 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); 1671 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause);
1676 } 1672 }
1677 CPDF_ImageLoader::~CPDF_ImageLoader() { 1673 CPDF_ImageLoader::~CPDF_ImageLoader() {
1678 if (!m_bCached) { 1674 if (!m_bCached) {
1679 delete m_pBitmap; 1675 delete m_pBitmap;
1680 delete m_pMask; 1676 delete m_pMask;
1681 } 1677 }
1682 } 1678 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698