diff options
author | Jun Fang <jun_fang@foxitsoftware.com> | 2015-12-24 18:27:33 +0800 |
---|---|---|
committer | Jun Fang <jun_fang@foxitsoftware.com> | 2015-12-24 18:27:33 +0800 |
commit | c7b4357a70235063a725a467da8758b3491c373c (patch) | |
tree | c01d036e1c0e61eee89bf45c684816bef05cf410 | |
parent | c70bd39ec72921cc10b613ce9adcd8f07d7f3039 (diff) | |
download | pdfium-c7b4357a70235063a725a467da8758b3491c373c.tar.xz |
Merge to XFA: Fix failed JPX image rendering
BUG=pdfium:338
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1549043003 .
Review URL: https://codereview.chromium.org/1549083002 .
-rw-r--r-- | core/include/fxcodec/fx_codec.h | 3 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp | 5 | ||||
-rw-r--r-- | core/src/fxcodec/codec/codec_int.h | 3 | ||||
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_jpx_opj.cpp | 21 |
4 files changed, 16 insertions, 16 deletions
diff --git a/core/include/fxcodec/fx_codec.h b/core/include/fxcodec/fx_codec.h index e7aeaf939b..da9cd9260b 100644 --- a/core/include/fxcodec/fx_codec.h +++ b/core/include/fxcodec/fx_codec.h @@ -17,6 +17,7 @@ class CFX_DIBSource; class CJPX_Decoder; +class CPDF_ColorSpace; class CPDF_PrivateData; class CPDF_StreamAcc; class ICodec_BasicModule; @@ -259,7 +260,7 @@ class ICodec_JpxModule { virtual CJPX_Decoder* CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size, - bool use_colorspace) = 0; + CPDF_ColorSpace* cs) = 0; virtual void GetImageInfo(CJPX_Decoder* pDecoder, FX_DWORD* width, diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index 0306ff0227..6bb8033686 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -684,9 +684,8 @@ void CPDF_DIBSource::LoadJpxBitmap() { nonstd::unique_ptr<JpxBitMapContext> context( new JpxBitMapContext(pJpxModule)); - context->set_decoder(pJpxModule->CreateDecoder(m_pStreamAcc->GetData(), - m_pStreamAcc->GetSize(), - m_pColorSpace == nullptr)); + context->set_decoder(pJpxModule->CreateDecoder( + m_pStreamAcc->GetData(), m_pStreamAcc->GetSize(), m_pColorSpace)); if (!context->decoder()) return; diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h index 7d440d0b61..2950cfe2ae 100644 --- a/core/src/fxcodec/codec/codec_int.h +++ b/core/src/fxcodec/codec/codec_int.h @@ -18,6 +18,7 @@ class CFX_IccProfileCache; class CFX_IccTransformCache; +class CPDF_ColorSpace; class CCodec_BasicModule : public ICodec_BasicModule { public: @@ -332,7 +333,7 @@ class CCodec_JpxModule : public ICodec_JpxModule { // ICodec_JpxModule: CJPX_Decoder* CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size, - bool use_colorspace) override; + CPDF_ColorSpace* cs) override; void GetImageInfo(CJPX_Decoder* pDecoder, FX_DWORD* width, FX_DWORD* height, diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp index 21c1e441f0..d3276450c9 100644 --- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -9,6 +9,7 @@ #include <vector> #include "codec_int.h" +#include "core/include/fpdfapi/fpdf_resource.h" #include "core/include/fxcodec/fx_codec.h" #include "core/include/fxcrt/fx_safe_types.h" #include "third_party/lcms2-2.6/include/lcms2.h" @@ -660,7 +661,7 @@ void color_apply_conversion(opj_image_t* image) { } class CJPX_Decoder { public: - explicit CJPX_Decoder(bool use_colorspace); + explicit CJPX_Decoder(CPDF_ColorSpace* cs); ~CJPX_Decoder(); FX_BOOL Init(const unsigned char* src_data, FX_DWORD src_size); void GetInfo(FX_DWORD* width, FX_DWORD* height, FX_DWORD* components); @@ -674,15 +675,11 @@ class CJPX_Decoder { opj_image_t* image; opj_codec_t* l_codec; opj_stream_t* l_stream; - const bool m_UseColorSpace; + const CPDF_ColorSpace* const m_ColorSpace; }; -CJPX_Decoder::CJPX_Decoder(bool use_colorspace) - : image(nullptr), - l_codec(nullptr), - l_stream(nullptr), - m_UseColorSpace(use_colorspace) { -} +CJPX_Decoder::CJPX_Decoder(CPDF_ColorSpace* cs) + : image(nullptr), l_codec(nullptr), l_stream(nullptr), m_ColorSpace(cs) {} CJPX_Decoder::~CJPX_Decoder() { if (l_codec) { @@ -724,6 +721,8 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, FX_DWORD src_size) { if (!l_codec) { return FALSE; } + if (m_ColorSpace && m_ColorSpace->GetFamily() == PDFCS_INDEXED) + parameters.flags |= OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG; opj_set_info_handler(l_codec, fx_info_callback, 00); opj_set_warning_handler(l_codec, fx_warning_callback, 00); opj_set_error_handler(l_codec, fx_error_callback, 00); @@ -734,7 +733,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, FX_DWORD src_size) { image = NULL; return FALSE; } - image->pdfium_use_colorspace = m_UseColorSpace; + image->pdfium_use_colorspace = !!m_ColorSpace; if (!parameters.nb_tile_to_decode) { if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, parameters.DA_y0, @@ -865,8 +864,8 @@ CCodec_JpxModule::~CCodec_JpxModule() { CJPX_Decoder* CCodec_JpxModule::CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size, - bool use_colorspace) { - nonstd::unique_ptr<CJPX_Decoder> decoder(new CJPX_Decoder(use_colorspace)); + CPDF_ColorSpace* cs) { + nonstd::unique_ptr<CJPX_Decoder> decoder(new CJPX_Decoder(cs)); return decoder->Init(src_buf, src_size) ? decoder.release() : nullptr; } |