diff --git a/.gn b/.gn index 33179129c..874f695a8 100644 --- a/.gn +++ b/.gn @@ -35,6 +35,9 @@ default_args = { # PDFium does not include the temporal_rs library. v8_enable_temporal_support = false + # PDFium does not use ICU4X implementations for ECMA-402 features. + v8_enable_ecma402_icu4x = false + # PDFium has its own unsafe-buffers enforcement directories. clang_unsafe_buffers_paths = "//unsafe_buffers_paths.txt" diff --git a/DEPS b/DEPS index 2baa91ef5..1d0314ab3 100644 --- a/DEPS +++ b/DEPS @@ -102,7 +102,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling catapult # and whatever else without interference from each other. - 'catapult_revision': 'e1165abbf12a3d9ecf2d3151a404c930b5047894', + 'catapult_revision': 'c29dedc30c9ff1b0cc677e32a9a959ad5ed41bde', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling clang format # and whatever else without interference from each other. @@ -134,7 +134,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling fast_float # and whatever else without interference from each other. - 'fast_float_revision': 'b0ab987b3dfdde13fa1915f65ef2a5c068d9208c', + 'fast_float_revision': '42f254836ee416ffcf2f4e6576260003ac33d48c', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling fp16 # and whatever else without interference from each other. @@ -154,7 +154,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling gtest # and whatever else without interference from each other. - 'gtest_revision': '4fe3307fb2d9f86d19777c7eb0e4809e9694dde7', + 'gtest_revision': '0b656495436f57212be8700794a3d5fb14000c5f', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling HarfBuzz # and whatever else without interference from each other. @@ -166,7 +166,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling icu # and whatever else without interference from each other. - 'icu_revision': '5aa526207171ecadf31597f0980a7b7ad8872f33', + 'icu_revision': 'a0ea93436c528ca316a6e698e483e258839101a5', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling instrumented_lib # and whatever else without interference from each other. @@ -174,7 +174,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling jinja2 # and whatever else without interference from each other. - 'jinja2_revision': 'c3027d884967773057bf74b957e3fea87e5df4d7', + 'jinja2_revision': 'fde3c16799bd5937e4f15aedc9037c89f96236b9', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling jpeg_turbo # and whatever else without interference from each other. @@ -204,7 +204,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling llvm-libc # and whatever else without interference from each other. - 'llvm_libc_revision': '14e51fd2cd7ec21294f18a3a0b2fc5339afea271', + 'llvm_libc_revision': 'd8f2045008e230f3c5f50095d918c11f1997e477', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling markupsafe # and whatever else without interference from each other. @@ -244,7 +244,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling skia # and whatever else without interference from each other. - 'skia_revision': '0abfcf118530e0e46e7e466f6d028041af61581a', + 'skia_revision': '607de4b035dcf7fdbaafb66c6cc04f22009ff4d4', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling test_fonts # and whatever else without interference from each other. @@ -264,15 +264,15 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling tools_win_revision # and whatever else without interference from each other. - 'tools_win_revision': 'ae34cdd9867c5d2b185fadc9d4a9cc82bb741760', + 'tools_win_revision': 'd72db9e3040567a7589e00c0ad7ddf25c3b070bc', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling v8 # and whatever else without interference from each other. - 'v8_revision': '0d546234ecf0af2032e958300ef8aeb14bc716c9', + 'v8_revision': 'bb54fc4e853a1ef1640b160e5e854d0a3b514e29', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling zlib # and whatever else without interference from each other. - 'zlib_revision': '456ae730017b9b4bd3371927abc82627fd51feef', + 'zlib_revision': '9f9f52c60a14e8e772fb561029ae0a121fef7609', } # Only these hosts are allowed for dependencies in this DEPS file. @@ -1005,31 +1005,13 @@ hooks = [ }, # Configure remote exec cfg files { - # Use luci_auth if on windows and using chrome-untrusted project 'name': 'download_and_configure_reclient_cfgs', 'pattern': '.', - 'condition': 'download_remoteexec_cfg and host_os == "win"', + 'condition': 'download_remoteexec_cfg', 'action': ['python3', 'buildtools/reclient_cfgs/configure_reclient_cfgs.py', '--rbe_instance', Var('rbe_instance'), - '--reproxy_cfg_template', - 'reproxy.cfg.template', - '--rewrapper_cfg_project', - Var('rewrapper_cfg_project'), - '--use_luci_auth_credshelper', - '--quiet', - ], - }, { - 'name': 'download_and_configure_reclient_cfgs', - 'pattern': '.', - 'condition': 'download_remoteexec_cfg and not host_os == "win"', - 'action': ['python3', - 'buildtools/reclient_cfgs/configure_reclient_cfgs.py', - '--rbe_instance', - Var('rbe_instance'), - '--reproxy_cfg_template', - 'reproxy.cfg.template', '--rewrapper_cfg_project', Var('rewrapper_cfg_project'), '--quiet', @@ -1043,8 +1025,6 @@ hooks = [ 'buildtools/reclient_cfgs/configure_reclient_cfgs.py', '--rbe_instance', Var('rbe_instance'), - '--reproxy_cfg_template', - 'reproxy.cfg.template', '--rewrapper_cfg_project', Var('rewrapper_cfg_project'), '--skip_remoteexec_cfg_fetch', diff --git a/core/fpdfapi/edit/cpdf_image_redactor.cpp b/core/fpdfapi/edit/cpdf_image_redactor.cpp index 9c6f391a6..f0fb9ab22 100644 --- a/core/fpdfapi/edit/cpdf_image_redactor.cpp +++ b/core/fpdfapi/edit/cpdf_image_redactor.cpp @@ -758,10 +758,9 @@ std::optional Decode(CPDF_Document* doc, // CPDF_DIB reads both only when it loads the image's mask. const bool load_mask = inline_alpha || matte; auto dib = pdfium::MakeRetain(doc, std::move(stream)); - CPDF_DIB::LoadState state = - dib->StartLoadDIBBase(load_mask, resources, page_resources, - /*bStdCS=*/false, CPDF_ColorSpace::Family::kUnknown, - /*bLoadMask=*/load_mask, CFX_Size()); + CPDF_DIB::LoadState state = dib->StartLoadDIBBase( + load_mask, resources, page_resources, CPDF_ColorSpace::Family::kUnknown, + /*bLoadMask=*/load_mask, CFX_Size()); while (state == CPDF_DIB::LoadState::kContinue) { state = dib->ContinueLoadDIBBase(nullptr); } diff --git a/core/fpdfapi/page/cpdf_basedcs.cpp b/core/fpdfapi/page/cpdf_basedcs.cpp index 522b1ef8f..f67dbefaa 100644 --- a/core/fpdfapi/page/cpdf_basedcs.cpp +++ b/core/fpdfapi/page/cpdf_basedcs.cpp @@ -9,10 +9,3 @@ CPDF_BasedCS::CPDF_BasedCS(Family family) : CPDF_ColorSpace(family) {} CPDF_BasedCS::~CPDF_BasedCS() = default; - -void CPDF_BasedCS::EnableStdConversion(bool bEnabled) { - CPDF_ColorSpace::EnableStdConversion(bEnabled); - if (base_cs_) { - base_cs_->EnableStdConversion(bEnabled); - } -} diff --git a/core/fpdfapi/page/cpdf_basedcs.h b/core/fpdfapi/page/cpdf_basedcs.h index 55a16ad86..83746a189 100644 --- a/core/fpdfapi/page/cpdf_basedcs.h +++ b/core/fpdfapi/page/cpdf_basedcs.h @@ -18,8 +18,6 @@ class CPDF_BasedCS : public CPDF_ColorSpace { CONSTRUCT_VIA_MAKE_RETAIN; ~CPDF_BasedCS() override; - void EnableStdConversion(bool bEnabled) final; - protected: explicit CPDF_BasedCS(Family family); diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index d3c0e8d02..8411cf493 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -136,7 +136,7 @@ class CPDF_CalGray final : public CPDF_ColorSpace { int pixels, int image_width, int image_height, - bool bTransMask) const override; + bool is_transparency_mask) const override; private: static constexpr float kDefaultGamma = 1.0f; @@ -161,7 +161,7 @@ class CPDF_CalRGB final : public CPDF_ColorSpace { int pixels, int image_width, int image_height, - bool bTransMask) const override; + bool is_transparency_mask) const override; uint32_t v_Load(CPDF_Document* doc, const CPDF_Array* pArray, std::set* pVisited) override; @@ -195,7 +195,7 @@ class CPDF_LabCS final : public CPDF_ColorSpace { int pixels, int image_width, int image_height, - bool bTransMask) const override; + bool is_transparency_mask) const override; uint32_t v_Load(CPDF_Document* doc, const CPDF_Array* pArray, std::set* pVisited) override; @@ -224,7 +224,7 @@ class CPDF_ICCBasedCS final : public CPDF_BasedCS { int pixels, int image_width, int image_height, - bool bTransMask) const override; + bool is_transparency_mask) const override; bool IsNormal() const override; uint32_t v_Load(CPDF_Document* doc, const CPDF_Array* pArray, @@ -641,10 +641,9 @@ void CPDF_ColorSpace::TranslateImageLine(pdfium::span dest_span, int pixels, int image_width, int image_height, - bool bTransMask) const { - // Only applies to CMYK colorspaces. None of the colorspaces that use this - // generic base implementation are CMYK. - CHECK(!bTransMask); + bool is_transparency_mask) const { + // Transparency masks are only used with CMYK colorspaces, not base CS. + CHECK(!is_transparency_mask); uint8_t* dest_buf = dest_span.data(); const uint8_t* src_buf = src_span.data(); @@ -663,14 +662,6 @@ void CPDF_ColorSpace::TranslateImageLine(pdfium::span dest_span, }); } -void CPDF_ColorSpace::EnableStdConversion(bool bEnabled) { - if (bEnabled) { - std_conversion_++; - } else if (std_conversion_) { - std_conversion_--; - } -} - bool CPDF_ColorSpace::IsNormal() const { return GetFamily() == Family::kDeviceGray || GetFamily() == Family::kDeviceRGB || @@ -730,8 +721,9 @@ void CPDF_CalGray::TranslateImageLine(pdfium::span dest_span, int pixels, int image_width, int image_height, - bool bTransMask) const { - CHECK(!bTransMask); // Only applies to CMYK colorspaces. + bool is_transparency_mask) const { + // Transparency masks are only used with CMYK colorspaces, not CalGray. + CHECK(!is_transparency_mask); auto gray_span = src_span.first(static_cast(pixels)); auto rgb_span = fxcrt::reinterpret_span>(dest_span); @@ -813,8 +805,9 @@ void CPDF_CalRGB::TranslateImageLine(pdfium::span dest_span, int pixels, int image_width, int image_height, - bool bTransMask) const { - CHECK(!bTransMask); // Only applies to CMYK colorspaces. + bool is_transparency_mask) const { + // Transparency masks are only used with CMYK colorspaces, not CalRGB. + CHECK(!is_transparency_mask); fxcodec::ReverseRGB(dest_span, src_span, pixels); } @@ -904,8 +897,9 @@ void CPDF_LabCS::TranslateImageLine(pdfium::span dest_span, int pixels, int image_width, int image_height, - bool bTransMask) const { - CHECK(!bTransMask); // Only applies to CMYK colorspaces. + bool is_transparency_mask) const { + // Transparency masks are only used with CMYK colorspaces, not Lab. + CHECK(!is_transparency_mask); auto bgr_span = fxcrt::reinterpret_span>(dest_span); auto lab_span = @@ -996,8 +990,9 @@ void CPDF_ICCBasedCS::TranslateImageLine(pdfium::span dest_span, int pixels, int image_width, int image_height, - bool bTransMask) const { - CHECK(!bTransMask); // Only applies to CMYK colorspaces. + bool is_transparency_mask) const { + // Transparency masks are only used with CMYK colorspaces, not ICCBased. + CHECK(!is_transparency_mask); if (profile_->IsSRGB()) { fxcodec::ReverseRGB(dest_span, src_span, pixels); diff --git a/core/fpdfapi/page/cpdf_colorspace.h b/core/fpdfapi/page/cpdf_colorspace.h index fb01643f2..947f38088 100644 --- a/core/fpdfapi/page/cpdf_colorspace.h +++ b/core/fpdfapi/page/cpdf_colorspace.h @@ -126,8 +126,7 @@ class CPDF_ColorSpace : public Retainable, public Observable { int pixels, int image_width, int image_height, - bool bTransMask) const; - virtual void EnableStdConversion(bool bEnabled); + bool is_transparency_mask) const; virtual bool IsNormal() const; // Returns `this` as a CPDF_PatternCS* if `this` is a pattern. @@ -149,7 +148,6 @@ class CPDF_ColorSpace : public Retainable, public Observable { // components count. void SetComponentsForStockCS(uint32_t nComponents); - bool IsStdConversionEnabled() const { return std_conversion_ != 0; } bool HasSameArray(const CPDF_Object* pObj) const { return array_ == pObj; } private: @@ -160,7 +158,6 @@ class CPDF_ColorSpace : public Retainable, public Observable { ByteStringView bsFamilyName); const Family family_; - uint32_t std_conversion_ = 0; uint32_t components_ = 0; RetainPtr array_; }; diff --git a/core/fpdfapi/page/cpdf_colorspace_unittest.cpp b/core/fpdfapi/page/cpdf_colorspace_unittest.cpp index 63b81544b..fe298bf58 100644 --- a/core/fpdfapi/page/cpdf_colorspace_unittest.cpp +++ b/core/fpdfapi/page/cpdf_colorspace_unittest.cpp @@ -22,8 +22,8 @@ TEST(CPDFCalGrayTest, TranslateImageLine) { const uint8_t kSrc[12] = {255, 0, 0, 0, 255, 0, 0, 0, 255, 128, 128, 128}; uint8_t dst[12]; std::ranges::fill(dst, 0xbd); - // `bTransMask` only applies to CYMK colorspaces. - pCal->TranslateImageLine(dst, kSrc, 4, 4, 1, /*bTransMask=*/false); + // Transparency masks are only used with CMYK colorspaces, not CalGray. + pCal->TranslateImageLine(dst, kSrc, 4, 4, 1, /*is_transparency_mask=*/false); EXPECT_THAT(dst, ElementsAre(255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0)); } @@ -34,7 +34,7 @@ TEST(CPDFCalRGBTest, TranslateImageLine) { const uint8_t kSrc[12] = {255, 0, 0, 0, 255, 0, 0, 0, 255, 128, 128, 128}; uint8_t dst[12]; std::ranges::fill(dst, 0xbd); - // `bTransMask` only applies to CYMK colorspaces. - pCal->TranslateImageLine(dst, kSrc, 4, 4, 1, /*bTransMask=*/false); + // Transparency masks are only used with CMYK colorspaces, not CalRGB. + pCal->TranslateImageLine(dst, kSrc, 4, 4, 1, /*is_transparency_mask=*/false); EXPECT_THAT(dst, ElementsAre(0, 0, 255, 0, 255, 0, 255, 0, 0, 128, 128, 128)); } diff --git a/core/fpdfapi/page/cpdf_decodedimagestore.cpp b/core/fpdfapi/page/cpdf_decodedimagestore.cpp index d93affc5f..22416f408 100644 --- a/core/fpdfapi/page/cpdf_decodedimagestore.cpp +++ b/core/fpdfapi/page/cpdf_decodedimagestore.cpp @@ -46,16 +46,15 @@ struct CPDF_DecodedImageStore::Entry { const size_t bytes; }; -CPDF_DecodedImageStore::Key::Key(RetainPtr stream, - const CPDF_Document* document, - RetainPtr page_resources, - bool std_cs, - CPDF_ColorSpace::Family family, - bool load_mask) +CPDF_DecodedImageStore::Key::Key( + RetainPtr stream, + const CPDF_Document* document, + RetainPtr page_resources, + CPDF_ColorSpace::Family family, + bool load_mask) : stream_(std::move(stream)), page_resources_(std::move(page_resources)), document_(reinterpret_cast(document)), - std_cs_(std_cs), family_(family), load_mask_(load_mask) {} @@ -67,10 +66,9 @@ CPDF_DecodedImageStore::Key& CPDF_DecodedImageStore::Key::operator=( CPDF_DecodedImageStore::Key::~Key() = default; bool CPDF_DecodedImageStore::Key::operator<(const Key& that) const { - return std::tie(stream_, page_resources_, document_, std_cs_, family_, - load_mask_) < std::tie(that.stream_, that.page_resources_, - that.document_, that.std_cs_, - that.family_, that.load_mask_); + return std::tie(stream_, page_resources_, document_, family_, load_mask_) < + std::tie(that.stream_, that.page_resources_, that.document_, + that.family_, that.load_mask_); } CPDF_DecodedImageStore::Decoded::Decoded() = default; @@ -100,7 +98,6 @@ CPDF_DecodedImageStore* CPDF_DecodedImageStore::Get() { std::optional CPDF_DecodedImageStore::KeyFor( const CPDF_Image& image, const CPDF_Dictionary* page_resources, - bool std_cs, CPDF_ColorSpace::Family family, bool load_mask) { CPDF_DecodedImageStore* store = Get(); @@ -114,7 +111,7 @@ std::optional CPDF_DecodedImageStore::KeyFor( return std::nullopt; } return Key(std::move(stream), image.GetDocument(), - pdfium::WrapRetain(page_resources), std_cs, family, load_mask); + pdfium::WrapRetain(page_resources), family, load_mask); } CPDF_DecodedImageStore::CPDF_DecodedImageStore() = default; diff --git a/core/fpdfapi/page/cpdf_decodedimagestore.h b/core/fpdfapi/page/cpdf_decodedimagestore.h index a61f1b44c..469959ac7 100644 --- a/core/fpdfapi/page/cpdf_decodedimagestore.h +++ b/core/fpdfapi/page/cpdf_decodedimagestore.h @@ -38,7 +38,6 @@ class CPDF_DecodedImageStore { Key(RetainPtr stream, const CPDF_Document* document, RetainPtr page_resources, - bool std_cs, CPDF_ColorSpace::Family family, bool load_mask); Key(const Key& that); @@ -56,7 +55,6 @@ class CPDF_DecodedImageStore { RetainPtr page_resources_; // The document's address: only compared, never used. uintptr_t document_; - bool std_cs_; CPDF_ColorSpace::Family family_; bool load_mask_; }; @@ -80,7 +78,6 @@ class CPDF_DecodedImageStore { // keep such an image. static std::optional KeyFor(const CPDF_Image& image, const CPDF_Dictionary* page_resources, - bool std_cs, CPDF_ColorSpace::Family family, bool load_mask); diff --git a/core/fpdfapi/page/cpdf_devicecs.cpp b/core/fpdfapi/page/cpdf_devicecs.cpp index 822c52198..03a1bbaef 100644 --- a/core/fpdfapi/page/cpdf_devicecs.cpp +++ b/core/fpdfapi/page/cpdf_devicecs.cpp @@ -62,13 +62,6 @@ std::optional> CPDF_DeviceCS::GetRGB( case Family::kDeviceCMYK: { const auto& cmyk = fxcrt::reinterpret_span>(pBuf).front(); - if (IsStdConversionEnabled()) { - return FX_RGB_STRUCT{ - 1.0f - std::min(1.0f, cmyk.cyan + cmyk.key), - 1.0f - std::min(1.0f, cmyk.magenta + cmyk.key), - 1.0f - std::min(1.0f, cmyk.yellow + cmyk.key), - }; - } return AdobeCmykToStandardRgbF( NormalizeChannel(cmyk.cyan), NormalizeChannel(cmyk.magenta), NormalizeChannel(cmyk.yellow), NormalizeChannel(cmyk.key)); @@ -83,11 +76,12 @@ void CPDF_DeviceCS::TranslateImageLine(pdfium::span dest_span, int pixels, int image_width, int image_height, - bool bTransMask) const { + bool is_transparency_mask) const { auto rgb_out = fxcrt::reinterpret_span>(dest_span); switch (GetFamily()) { case Family::kDeviceGray: - CHECK(!bTransMask); // bTransMask only allowed for CMYK colorspaces. + // Transparency masks are only used with CMYK colorspaces, not DeviceGray. + CHECK(!is_transparency_mask); // Compiler can't conclude src/dest don't overlap, avoid interleaved // loads and stores by not using an auto& reference here. for (const auto pix : src_span.first(static_cast(pixels))) { @@ -98,13 +92,14 @@ void CPDF_DeviceCS::TranslateImageLine(pdfium::span dest_span, } break; case Family::kDeviceRGB: - CHECK(!bTransMask); // bTransMask only allowed for CMYK colorspaces. + // Transparency masks are only used with CMYK colorspaces, not DeviceRGB. + CHECK(!is_transparency_mask); fxcodec::ReverseRGB(dest_span, src_span, pixels); break; case Family::kDeviceCMYK: { auto cmyk_in = fxcrt::reinterpret_span>(src_span); - if (bTransMask) { + if (is_transparency_mask) { // Compiler can't conclude src/dest don't overlap, avoid interleaved // loads and stores by not using an auto& reference here. for (const auto cmyk : cmyk_in.first(static_cast(pixels))) { @@ -116,18 +111,6 @@ void CPDF_DeviceCS::TranslateImageLine(pdfium::span dest_span, } break; } - if (IsStdConversionEnabled()) { - // Compiler can't conclude src/dest don't overlap, avoid interleaved - // loads and stores by not using am auto& reference here, - for (const auto cmyk : cmyk_in.first(static_cast(pixels))) { - const uint8_t k = cmyk.key; - rgb_out.front().blue = 255 - std::min(255, cmyk.cyan + k); - rgb_out.front().green = 255 - std::min(255, cmyk.magenta + k); - rgb_out.front().red = 255 - std::min(255, cmyk.yellow + k); - rgb_out = rgb_out.subspan<1u>(); - } - break; - } for (const auto& cmyk : cmyk_in.first(static_cast(pixels))) { // TODO(tsepez): maybe this is a FX_BGR_STRUCT in reality? FX_RGB_STRUCT rgb = AdobeCmykToStandardRgb( diff --git a/core/fpdfapi/page/cpdf_devicecs.h b/core/fpdfapi/page/cpdf_devicecs.h index 5fff876a7..8fb476932 100644 --- a/core/fpdfapi/page/cpdf_devicecs.h +++ b/core/fpdfapi/page/cpdf_devicecs.h @@ -25,7 +25,7 @@ class CPDF_DeviceCS final : public CPDF_ColorSpace { int pixels, int image_width, int image_height, - bool bTransMask) const override; + bool is_transparency_mask) const override; uint32_t v_Load(CPDF_Document* doc, const CPDF_Array* pArray, std::set* pVisited) override; diff --git a/core/fpdfapi/page/cpdf_dib.cpp b/core/fpdfapi/page/cpdf_dib.cpp index 3c7e87466..d872ad66f 100644 --- a/core/fpdfapi/page/cpdf_dib.cpp +++ b/core/fpdfapi/page/cpdf_dib.cpp @@ -162,14 +162,6 @@ bool CPDF_DIB::Load() { return ContinueInternal(); } -bool CPDF_DIB::ContinueToLoadMask() { - if (color_space_ && std_cs_) { - color_space_->EnableStdConversion(true); - } - - return ContinueInternal(); -} - bool CPDF_DIB::ContinueInternal() { if (image_mask_) { SetMaskProperties(); @@ -213,11 +205,9 @@ CPDF_DIB::LoadState CPDF_DIB::StartLoadDIBBase( bool bHasMask, const CPDF_Dictionary* pFormResources, const CPDF_Dictionary* pPageResources, - bool bStdCS, CPDF_ColorSpace::Family GroupFamily, bool bLoadMask, const CFX_Size& max_size_required) { - std_cs_ = bStdCS; has_mask_ = bHasMask; group_family_ = GroupFamily; load_mask_ = bLoadMask; @@ -240,7 +230,7 @@ CPDF_DIB::LoadState CPDF_DIB::StartLoadDIBBase( return LoadState::kFail; } - if (!ContinueToLoadMask()) { + if (!ContinueInternal()) { return LoadState::kFail; } @@ -252,9 +242,6 @@ CPDF_DIB::LoadState CPDF_DIB::StartLoadDIBBase( DCHECK_EQ(iCreatedDecoder, LoadState::kSuccess); DCHECK_EQ(iLoadedMask, LoadState::kSuccess); - if (color_space_ && std_cs_) { - color_space_->EnableStdConversion(false); - } return LoadState::kSuccess; } @@ -326,13 +313,6 @@ CPDF_DIB::LoadState CPDF_DIB::ContinueLoadDIBBase(PauseIndicatorIface* pPause) { status_ = LoadState::kContinue; } } - if (iContinueStatus == LoadState::kContinue) { - return LoadState::kContinue; - } - - if (color_space_ && std_cs_) { - color_space_->EnableStdConversion(false); - } return iContinueStatus; } @@ -387,6 +367,11 @@ bool CPDF_DIB::LoadColorInfo(const CPDF_Dictionary* pFormResources, // decoded. components_ = color_space_->ComponentCount(); family_ = color_space_->GetFamily(); + if (family_ == CPDF_ColorSpace::Family::kPattern) { + // Per ISO 32000-1:2008, section 8.9.5.1, table 89, the ColorSpace entry of + // an image dictionary can be any type of color space except Pattern. + return false; + } if (family_ == CPDF_ColorSpace::Family::kICCBased && pCSObj->IsName()) { ByteString cs = pCSObj->GetString(); if (cs == "DeviceGray") { @@ -877,8 +862,7 @@ CPDF_DIB::LoadState CPDF_DIB::StartLoadMask() { } RetainPtr pMatte = mask->GetDict()->GetArrayFor("Matte"); - if (pMatte && color_space_ && family_ != CPDF_ColorSpace::Family::kPattern && - pMatte->size() == components_ && + if (pMatte && color_space_ && pMatte->size() == components_ && color_space_->ComponentCount() <= components_) { std::vector colors = ReadArrayElementsToVector(pMatte.Get(), components_); @@ -901,10 +885,6 @@ CPDF_DIB::LoadState CPDF_DIB::ContinueLoadMaskDIB(PauseIndicatorIface* pPause) { return LoadState::kContinue; } - if (color_space_ && std_cs_) { - color_space_->EnableStdConversion(false); - } - if (ret == LoadState::kFail) { mask_.Reset(); return LoadState::kFail; @@ -944,7 +924,7 @@ CPDF_DIB::LoadState CPDF_DIB::StartLoadMaskDIB( RetainPtr mask_stream) { mask_ = pdfium::MakeRetain(document_, std::move(mask_stream)); LoadState ret = - mask_->StartLoadDIBBase(false, nullptr, nullptr, true, + mask_->StartLoadDIBBase(false, nullptr, nullptr, CPDF_ColorSpace::Family::kUnknown, false, {0, 0}); if (ret == LoadState::kContinue) { if (status_ == LoadState::kFail) { @@ -959,7 +939,7 @@ CPDF_DIB::LoadState CPDF_DIB::StartLoadMaskDIB( } void CPDF_DIB::LoadPalette() { - if (!color_space_ || family_ == CPDF_ColorSpace::Family::kPattern) { + if (!color_space_) { return; } @@ -1108,7 +1088,7 @@ void CPDF_DIB::TranslateScanline24bpp( rgb.red = (1.0f - color_values[0]) * k; rgb.green = (1.0f - color_values[1]) * k; rgb.blue = (1.0f - color_values[2]) * k; - } else if (family_ != CPDF_ColorSpace::Family::kPattern) { + } else { rgb = color_space_->GetRGBOrZerosOnError(color_values); } const float R = std::clamp(rgb.red, 0.0f, 1.0f); diff --git a/core/fpdfapi/page/cpdf_dib.h b/core/fpdfapi/page/cpdf_dib.h index 39b47bcd9..bb33475d6 100644 --- a/core/fpdfapi/page/cpdf_dib.h +++ b/core/fpdfapi/page/cpdf_dib.h @@ -75,7 +75,6 @@ class CPDF_DIB final : public CFX_DIBBase { LoadState StartLoadDIBBase(bool bHasMask, const CPDF_Dictionary* pFormResources, const CPDF_Dictionary* pPageResources, - bool bStdCS, CPDF_ColorSpace::Family GroupFamily, bool bLoadMask, const CFX_Size& max_size_required); @@ -100,7 +99,6 @@ class CPDF_DIB final : public CFX_DIBBase { bool ContinueInternal(); LoadState StartLoadMask(); LoadState StartLoadMaskDIB(RetainPtr mask_stream); - bool ContinueToLoadMask(); LoadState ContinueLoadMaskDIB(PauseIndicatorIface* pPause); bool LoadColorInfo(const CPDF_Dictionary* pFormResources, const CPDF_Dictionary* pPageResources); @@ -154,7 +152,6 @@ class CPDF_DIB final : public CFX_DIBBase { bool do_bpc_check_ = true; bool color_key_ = false; bool has_mask_ = false; - bool std_cs_ = false; std::vector comp_data_; mutable DataVector line_buf_; mutable DataVector mask_buf_; diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp index 4aef6e7dc..74bbc1320 100644 --- a/core/fpdfapi/page/cpdf_image.cpp +++ b/core/fpdfapi/page/cpdf_image.cpp @@ -569,14 +569,13 @@ RetainPtr CPDF_Image::DetachMask() { bool CPDF_Image::StartLoadDIBBase(const CPDF_Dictionary* pFormResource, const CPDF_Dictionary* pPageResource, - bool bStdCS, CPDF_ColorSpace::Family GroupFamily, bool bLoadMask, const CFX_Size& max_size_required) { RetainPtr source = CreateNewDIB(); CPDF_DIB::LoadState ret = - source->StartLoadDIBBase(true, pFormResource, pPageResource, bStdCS, - GroupFamily, bLoadMask, max_size_required); + source->StartLoadDIBBase(true, pFormResource, pPageResource, GroupFamily, + bLoadMask, max_size_required); if (ret == CPDF_DIB::LoadState::kFail) { dibbase_.Reset(); return false; diff --git a/core/fpdfapi/page/cpdf_image.h b/core/fpdfapi/page/cpdf_image.h index a0ef86cfa..7e65562ac 100644 --- a/core/fpdfapi/page/cpdf_image.h +++ b/core/fpdfapi/page/cpdf_image.h @@ -92,7 +92,6 @@ class CPDF_Image final : public Retainable { // Returns whether to Continue() or not. bool StartLoadDIBBase(const CPDF_Dictionary* pFormResource, const CPDF_Dictionary* pPageResource, - bool bStdCS, CPDF_ColorSpace::Family GroupFamily, bool bLoadMask, const CFX_Size& max_size_required); diff --git a/core/fpdfapi/page/cpdf_imageloader.cpp b/core/fpdfapi/page/cpdf_imageloader.cpp index f49ed99f6..067c00a4d 100644 --- a/core/fpdfapi/page/cpdf_imageloader.cpp +++ b/core/fpdfapi/page/cpdf_imageloader.cpp @@ -24,7 +24,6 @@ bool CPDF_ImageLoader::Start(const CPDF_ImageObject* pImage, CPDF_PageImageCache* pPageImageCache, const CPDF_Dictionary* pFormResource, const CPDF_Dictionary* pPageResource, - bool bStdCS, CPDF_ColorSpace::Family eFamily, bool bLoadMask, const CFX_Size& max_size_required) { @@ -38,12 +37,11 @@ bool CPDF_ImageLoader::Start(const CPDF_ImageObject* pImage, bool should_continue; if (cache_) { should_continue = cache_->StartGetCachedBitmap( - image_object_->GetImage(), pFormResource, pPageResource, bStdCS, - eFamily, bLoadMask, max_size_required); + image_object_->GetImage(), pFormResource, pPageResource, eFamily, + bLoadMask, max_size_required); } else { should_continue = image_object_->GetImage()->StartLoadDIBBase( - pFormResource, pPageResource, bStdCS, eFamily, bLoadMask, - max_size_required); + pFormResource, pPageResource, eFamily, bLoadMask, max_size_required); } if (!should_continue) { Finish(); diff --git a/core/fpdfapi/page/cpdf_imageloader.h b/core/fpdfapi/page/cpdf_imageloader.h index 50eb0cefd..bd49c3a42 100644 --- a/core/fpdfapi/page/cpdf_imageloader.h +++ b/core/fpdfapi/page/cpdf_imageloader.h @@ -27,7 +27,6 @@ class CPDF_ImageLoader { CPDF_PageImageCache* pPageImageCache, const CPDF_Dictionary* pFormResource, const CPDF_Dictionary* pPageResource, - bool bStdCS, CPDF_ColorSpace::Family eFamily, bool bLoadMask, const CFX_Size& max_size_required); diff --git a/core/fpdfapi/page/cpdf_pageimagecache.cpp b/core/fpdfapi/page/cpdf_pageimagecache.cpp index 90c984398..ca97a1ad0 100644 --- a/core/fpdfapi/page/cpdf_pageimagecache.cpp +++ b/core/fpdfapi/page/cpdf_pageimagecache.cpp @@ -175,7 +175,6 @@ bool CPDF_PageImageCache::StartGetCachedBitmap( RetainPtr pImage, const CPDF_Dictionary* pFormResources, const CPDF_Dictionary* pPageResources, - bool bStdCS, CPDF_ColorSpace::Family eFamily, bool bLoadMask, const CFX_Size& max_size_required) { @@ -194,7 +193,7 @@ bool CPDF_PageImageCache::StartGetCachedBitmap( cur_image_cache_entry_ = std::make_unique(std::move(pImage)); } CPDF_DIB::LoadState ret = cur_image_cache_entry_->StartGetCachedBitmap( - this, pFormResources, pPageResources, bStdCS, eFamily, bLoadMask, + this, pFormResources, pPageResources, eFamily, bLoadMask, max_size_required); if (ret == CPDF_DIB::LoadState::kContinue) { return true; @@ -279,7 +278,6 @@ CPDF_DIB::LoadState CPDF_PageImageCache::Entry::StartGetCachedBitmap( CPDF_PageImageCache* pPageImageCache, const CPDF_Dictionary* pFormResources, const CPDF_Dictionary* pPageResources, - bool bStdCS, CPDF_ColorSpace::Family eFamily, bool bLoadMask, const CFX_Size& max_size_required) { @@ -291,8 +289,8 @@ CPDF_DIB::LoadState CPDF_PageImageCache::Entry::StartGetCachedBitmap( // EmbedPDF(decoded-image-store): consulted only where the cache would // decode; a stored decode leaves the entry as a new decode would. - store_key_ = CPDF_DecodedImageStore::KeyFor(*image_, pPageResources, bStdCS, - eFamily, bLoadMask); + store_key_ = CPDF_DecodedImageStore::KeyFor(*image_, pPageResources, eFamily, + bLoadMask); if (store_key_) { // The levels StartLoadDIBBase() would compute, from the same dictionary. RetainPtr dict = image_->GetStream()->GetDict(); @@ -320,7 +318,7 @@ CPDF_DIB::LoadState CPDF_PageImageCache::Entry::StartGetCachedBitmap( cur_bitmap_ = image_->CreateNewDIB(); CPDF_DIB::LoadState ret = cur_bitmap_.AsRaw()->StartLoadDIBBase( - true, pFormResources, pPageResources, bStdCS, eFamily, bLoadMask, + true, pFormResources, pPageResources, eFamily, bLoadMask, max_size_required); cached_set_max_size_required_ = (max_size_required.width != 0 && max_size_required.height != 0); diff --git a/core/fpdfapi/page/cpdf_pageimagecache.h b/core/fpdfapi/page/cpdf_pageimagecache.h index 44ded0bce..9da8a0fc8 100644 --- a/core/fpdfapi/page/cpdf_pageimagecache.h +++ b/core/fpdfapi/page/cpdf_pageimagecache.h @@ -43,7 +43,6 @@ class CPDF_PageImageCache { bool StartGetCachedBitmap(RetainPtr pImage, const CPDF_Dictionary* pFormResources, const CPDF_Dictionary* pPageResources, - bool bStdCS, CPDF_ColorSpace::Family eFamily, bool bLoadMask, const CFX_Size& max_size_required); @@ -71,7 +70,6 @@ class CPDF_PageImageCache { CPDF_PageImageCache* pPageImageCache, const CPDF_Dictionary* pFormResources, const CPDF_Dictionary* pPageResources, - bool bStdCS, CPDF_ColorSpace::Family eFamily, bool bLoadMask, const CFX_Size& max_size_required); diff --git a/core/fpdfapi/page/cpdf_pageimagecache_unittest.cpp b/core/fpdfapi/page/cpdf_pageimagecache_unittest.cpp index 860c93b39..f5be95de1 100644 --- a/core/fpdfapi/page/cpdf_pageimagecache_unittest.cpp +++ b/core/fpdfapi/page/cpdf_pageimagecache_unittest.cpp @@ -107,7 +107,7 @@ TEST_F(CPDFPageImageCacheTest, RenderBug1924) { // Render with small scale. bool should_continue = page_image_cache->StartGetCachedBitmap( - image->GetImage(), nullptr, page->GetMutablePageResources(), true, + image->GetImage(), nullptr, page->GetMutablePageResources(), CPDF_ColorSpace::Family::kICCBased, false, {50, 50}); while (should_continue) { should_continue = page_image_cache->Continue(nullptr); @@ -117,7 +117,7 @@ TEST_F(CPDFPageImageCacheTest, RenderBug1924) { // And render with large scale. should_continue = page_image_cache->StartGetCachedBitmap( - image->GetImage(), nullptr, page->GetMutablePageResources(), true, + image->GetImage(), nullptr, page->GetMutablePageResources(), CPDF_ColorSpace::Family::kICCBased, false, {100, 100}); while (should_continue) { should_continue = page_image_cache->Continue(nullptr); @@ -251,7 +251,7 @@ TEST_F(CPDFPageImageCacheTest, RenderReducedDctThenFullSize) { // Render with small scale: 400/50 -> 1/8, so a 50x50 bitmap. bool should_continue = page_image_cache->StartGetCachedBitmap( - image->GetImage(), nullptr, page->GetMutablePageResources(), true, + image->GetImage(), nullptr, page->GetMutablePageResources(), CPDF_ColorSpace::Family::kUnknown, false, {50, 50}); while (should_continue) { should_continue = page_image_cache->Continue(nullptr); @@ -264,7 +264,7 @@ TEST_F(CPDFPageImageCacheTest, RenderReducedDctThenFullSize) { // Render with large scale: 400/100 -> 1/4, so a 100x100 bitmap. The cached // 50x50 bitmap is too small, so this forces a higher-resolution re-decode. should_continue = page_image_cache->StartGetCachedBitmap( - image->GetImage(), nullptr, page->GetMutablePageResources(), true, + image->GetImage(), nullptr, page->GetMutablePageResources(), CPDF_ColorSpace::Family::kUnknown, false, {100, 100}); while (should_continue) { should_continue = page_image_cache->Continue(nullptr); @@ -312,7 +312,7 @@ TEST_F(CPDFPageImageCacheTest, RenderReducedDctWithSMask) { // Draw small so the 400x400 base is decoded at reduced resolution. bool should_continue = page_image_cache->StartGetCachedBitmap( - image->GetImage(), nullptr, page->GetMutablePageResources(), true, + image->GetImage(), nullptr, page->GetMutablePageResources(), CPDF_ColorSpace::Family::kUnknown, /*bLoadMask=*/true, {50, 50}); while (should_continue) { should_continue = page_image_cache->Continue(nullptr); @@ -370,7 +370,7 @@ TEST_F(CPDFPageImageCacheTest, NonMcuAlignedDctIsNotReduced) { // Draw small: an MCU-aligned image would be reduced here, but this one must // not be, so the decoded bitmap stays at the full 408x408. bool should_continue = page_image_cache->StartGetCachedBitmap( - image->GetImage(), nullptr, page->GetMutablePageResources(), true, + image->GetImage(), nullptr, page->GetMutablePageResources(), CPDF_ColorSpace::Family::kUnknown, false, {50, 50}); while (should_continue) { should_continue = page_image_cache->Continue(nullptr); diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index 5d1e4fa8f..aa291f04b 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -73,8 +73,7 @@ bool CPDF_ImageRenderer::StartLoadDIBBase() { if (!loader_->Start( image_object_, render_status_->GetContext()->GetPageCache(), render_status_->GetFormResource(), render_status_->GetPageResource(), - std_cs_, render_status_->GetGroupFamily(), - render_status_->GetLoadMask(), + render_status_->GetGroupFamily(), render_status_->GetLoadMask(), {render_status_->GetRenderDevice()->GetWidth(), render_status_->GetRenderDevice()->GetHeight()})) { return false; @@ -186,10 +185,8 @@ bool CPDF_ImageRenderer::StartRenderDIBBase() { } bool CPDF_ImageRenderer::Start(CPDF_ImageObject* pImageObject, - const CFX_Matrix& mtObj2Device, - bool bStdCS) { + const CFX_Matrix& mtObj2Device) { DCHECK(pImageObject); - std_cs_ = bStdCS; image_object_ = pImageObject; blend_type_ = BlendMode::kNormal; obj_to_device_ = mtObj2Device; @@ -209,14 +206,12 @@ bool CPDF_ImageRenderer::Start(CPDF_ImageObject* pImageObject, bool CPDF_ImageRenderer::Start(RetainPtr pDIBBase, FX_ARGB bitmap_argb, const CFX_Matrix& mtImage2Device, - const FXDIB_ResampleOptions& options, - bool bStdCS) { + const FXDIB_ResampleOptions& options) { dibbase_ = std::move(pDIBBase); fill_argb_ = bitmap_argb; alpha_ = 1.0f; image_matrix_ = mtImage2Device; resample_options_ = options; - std_cs_ = bStdCS; blend_type_ = BlendMode::kNormal; return StartDIBBase(); } @@ -281,12 +276,11 @@ RetainPtr CPDF_ImageRenderer::CalculateDrawImage( CPDF_RenderStatus mask_status(render_status_->GetContext(), mask_device.get()); mask_status.SetDropObjects(render_status_->GetDropObjects()); - mask_status.SetStdCS(true); mask_status.Initialize(nullptr, nullptr); CPDF_ImageRenderer mask_renderer(&mask_status); if (mask_renderer.Start(std::move(pDIBBase), 0xffffffff, mtNewMatrix, - resample_options_, true)) { + resample_options_)) { mask_renderer.Continue(nullptr); } if (loader_->MatteColor() != 0xffffffff) { @@ -349,7 +343,6 @@ bool CPDF_ImageRenderer::DrawPatternImage() { bitmap_device.get()); bitmap_status.SetOptions(GetRenderOptions()); bitmap_status.SetDropObjects(render_status_->GetDropObjects()); - bitmap_status.SetStdCS(true); bitmap_status.Initialize(nullptr, nullptr); CFX_Matrix pattern_matrix = obj_to_device_; @@ -404,10 +397,9 @@ bool CPDF_ImageRenderer::DrawMaskedImage() { CPDF_RenderStatus bitmap_status(render_status_->GetContext(), bitmap_device.get()); bitmap_status.SetDropObjects(render_status_->GetDropObjects()); - bitmap_status.SetStdCS(true); bitmap_status.Initialize(nullptr, nullptr); CPDF_ImageRenderer bitmap_renderer(&bitmap_status); - if (bitmap_renderer.Start(dibbase_, 0, new_matrix, resample_options_, true)) { + if (bitmap_renderer.Start(dibbase_, 0, new_matrix, resample_options_)) { bitmap_renderer.Continue(nullptr); } RetainPtr mask_bitmap = CalculateDrawImage( diff --git a/core/fpdfapi/render/cpdf_imagerenderer.h b/core/fpdfapi/render/cpdf_imagerenderer.h index 610f20f68..d3784aa9c 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.h +++ b/core/fpdfapi/render/cpdf_imagerenderer.h @@ -36,15 +36,12 @@ class CPDF_ImageRenderer { explicit CPDF_ImageRenderer(CPDF_RenderStatus* pStatus); ~CPDF_ImageRenderer(); - bool Start(CPDF_ImageObject* pImageObject, - const CFX_Matrix& mtObj2Device, - bool bStdCS); + bool Start(CPDF_ImageObject* pImageObject, const CFX_Matrix& mtObj2Device); bool Start(RetainPtr pDIBBase, FX_ARGB bitmap_argb, const CFX_Matrix& mtImage2Device, - const FXDIB_ResampleOptions& options, - bool bStdCS); + const FXDIB_ResampleOptions& options); bool Continue(PauseIndicatorIface* pPause); bool GetResult() const { return result_; } @@ -106,7 +103,6 @@ class CPDF_ImageRenderer { FX_ARGB fill_argb_ = 0; FXDIB_ResampleOptions resample_options_; bool pattern_color_ = false; - bool std_cs_ = false; bool result_ = true; }; diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index a5ef266a8..dd40df698 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -309,8 +309,7 @@ bool CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj, } image_renderer_ = std::make_unique(this); - if (!image_renderer_->Start(pObj->AsImage(), mtObj2Device, - /*bStdCS=*/false)) { + if (!image_renderer_->Start(pObj->AsImage(), mtObj2Device)) { if (!image_renderer_->GetResult()) { DrawObjWithBackground(pObj, mtObj2Device); } @@ -771,7 +770,6 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, CPDF_RenderStatus bitmap_render(context_, bitmap_device.get()); bitmap_render.SetOptions(options_); bitmap_render.SetStopObject(stop_obj_); - bitmap_render.SetStdCS(true); bitmap_render.SetDropObjects(drop_objects_); bitmap_render.SetFormResource(std::move(pFormResource)); bitmap_render.SetInGroup(transparency.IsGroup()); @@ -1107,7 +1105,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, CFX_Matrix image_matrix = pType3Char->matrix() * matrix; CPDF_ImageRenderer renderer(this); if (renderer.Start(pType3Char->GetBitmap(), fill_argb, image_matrix, - FXDIB_ResampleOptions(), false)) { + FXDIB_ResampleOptions())) { renderer.Continue(nullptr); } if (!renderer.GetResult()) { @@ -1350,7 +1348,7 @@ void CPDF_RenderStatus::ProcessPathPattern( bool CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj, const CFX_Matrix& mtObj2Device) { CPDF_ImageRenderer render(this); - if (render.Start(pImageObj, mtObj2Device, std_cs_)) { + if (render.Start(pImageObj, mtObj2Device)) { render.Continue(nullptr); } return render.GetResult(); @@ -1544,7 +1542,6 @@ RetainPtr CPDF_RenderStatus::LoadSMask( status.SetOptions(options); status.SetGroupFamily(nCSFamily); status.SetLoadMask(bLuminosity); - status.SetStdCS(true); status.SetFormResource(std::move(pFormResource)); status.SetDropObjects(drop_objects_); status.Initialize(nullptr, nullptr); diff --git a/core/fpdfapi/render/cpdf_renderstatus.h b/core/fpdfapi/render/cpdf_renderstatus.h index b002aa312..9050264fa 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.h +++ b/core/fpdfapi/render/cpdf_renderstatus.h @@ -59,7 +59,6 @@ class CPDF_RenderStatus { void SetFillColor(FX_ARGB color) { t3_fill_color_ = color; } void SetDropObjects(bool bDropObjects) { drop_objects_ = bDropObjects; } void SetLoadMask(bool bLoadMask) { load_mask_ = bLoadMask; } - void SetStdCS(bool bStdCS) { std_cs_ = bStdCS; } void SetGroupFamily(CPDF_ColorSpace::Family family) { group_family_ = family; } @@ -210,7 +209,6 @@ class CPDF_RenderStatus { bool print_ = false; #endif bool drop_objects_ = false; - bool std_cs_ = false; bool load_mask_ = false; bool in_group_ = false; CPDF_ColorSpace::Family group_family_ = CPDF_ColorSpace::Family::kUnknown; diff --git a/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp b/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp index 184f1f474..bc13fef9b 100644 --- a/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp +++ b/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp @@ -58,3 +58,12 @@ TEST_F(FPDFRenderPatternEmbedderTest, ZeroTilingPatternStep509964646) { ScopedFPDFBitmap bitmap = RenderLoadedPage(page.get()); ASSERT_TRUE(bitmap); } + +TEST_F(FPDFRenderPatternEmbedderTest, ImagePatternColorSpace) { + // Rendering an image with a Pattern color space should not crash. + ASSERT_TRUE(OpenDocument("image_pattern_colorspace.pdf")); + ScopedPage page = LoadScopedPage(0); + ASSERT_TRUE(page); + ScopedFPDFBitmap bitmap = RenderLoadedPage(page.get()); + ASSERT_TRUE(bitmap); +} diff --git a/docs/embedpdf/syncs/2026-11-04-2b52a82ab.md b/docs/embedpdf/syncs/2026-11-04-2b52a82ab.md new file mode 100644 index 000000000..fb7fd263b --- /dev/null +++ b/docs/embedpdf/syncs/2026-11-04-2b52a82ab.md @@ -0,0 +1,106 @@ +# Sync 2026-11-04: upstream 5f092b529..2b52a82ab (14 commits) + +## Summary + +Upstream from 2026-11-01 to 2026-11-02, merged into `27c505705`. + +Upstream removed the "standard" CMYK conversion for images (images with soft masks or non-normal +blend modes now convert CMYK like everything else), rejects Pattern color spaces for images (a +crash on malformed files), and rolled Skia, V8, ICU, zlib and test tools. No conflicts; our decoded +image store and image redactor drop the removed `bStdCS` argument. + +## Likely security fixes + +None. + +## Conflicts (0 files, 0 blocks) + +None. + +## Write audit (0 lines) + +None. + +## Upstream changes outside the conflicts + +- **No more "standard" CMYK conversion (`2b52a82ab`).** Images drawn with a soft mask or a + non-normal blend mode converted DeviceCMYK with `1 - min(1, C + K)`; they now use the same CMYK + conversion as everything else, which upstream says matches other renderers (its corpus test + `bug_557320961` changed). Such images render a little differently; engine render expectations + with CMYK images under soft masks or blend modes may move when the engine adopts this runtime. + The `bStdCS` / `std_cs_` plumbing is gone, so: + - our decoded image store (`cpdf_decodedimagestore.*`, decoded-image-store) no longer keys on + `std_cs`; the conversion no longer depends on it; + - `cpdf_pageimagecache.cpp` and the image redactor (`cpdf_image_redactor.cpp`) call the loaders + without it. +- **Pattern color spaces rejected for images (`bbb9926d4`):** ISO 32000-1 table 89 forbids them; an + 8 bpc image with one reached a `NOTREACHED()` in `CPDF_PatternCS::GetRGB()`, so a malformed file + could crash rendering. The image now fails to load instead. +- **Renames (`7e01bafbd`):** `bTransMask` to `is_transparency_mask`; nothing of ours used the name. +- Merged into files we change: `cpdf_colorspace`, `cpdf_dib`, `cpdf_image`, `cpdf_imageloader`, + `cpdf_pageimagecache`, `cpdf_renderstatus`, `fpdf_editimg.cpp`; all of upstream's hunks present. + +## Upstream appearance generator + +None. + +## Globals + +No new globals by the heuristic. `check-globals.py` on the darwin-arm64 release build: ok (263 shared +writable, 25 thread-local). + +## Build and patches + +- `DEPS` changed in 11 commits: Skia (`04d4d5c8a`, 139 commits), V8 (`9185ccc21`, not in our + builds), ICU (`f7878a86a`), zlib (`69856420f`), fast_float (`b75764a1d`), googletest + (`38ee50754`), llvm-libc (`55a435dce`), `tools/win` (`42ca51961`), Catapult and Jinja2, and the + reproxy config removed (`bc5a4257b`). Synced with `gclient sync --no-history --shallow`. +- All of `patches/embedpdf-runtime/` apply: every target's patches dry-run against clean sources, + and darwin-arm64 and wasm32 build. + +## API diff + +None. The darwin-arm64 exports match the public headers, as in S15. + +## Tests + +- [x] fork unit + embedder tests (darwin-arm64): 1320 unit tests pass. Embedder: 1784 tests, + 9 skipped, 12 failing: exactly S15's list, every one "Pixels do not match" against a Mac PNG + golden. Linux runs in the PR's CI. + The 12, as the baseline for the next sync: + - `EPDFMeasureEmbedderTest.CaptionAppearanceGolden` + - `FPDFEditEmbedderTest.SetTextRenderMode` + - `FPDFProgressiveRenderEmbedderTest.RenderAnnotWithPause` + - `FPDFProgressiveRenderEmbedderTest.RenderFormsWithPause` + - `FPDFProgressiveRenderEmbedderTest.RenderHighlightWithColorScheme` + - `FPDFProgressiveRenderEmbedderTest.RenderHighlightWithColorSchemeAndConvertFillToStroke` + - `FPDFProgressiveRenderEmbedderTest.RenderStampWithColorScheme` + - `FPDFProgressiveRenderEmbedderTest.RenderTextWithColorScheme` + - `FPDFProgressiveRenderEmbedderTest.RenderWithPause` + - `FPDFProgressiveRenderEmbedderTest.RenderWithoutPause` + - `FPDFViewEmbedderTest.RenderBug664284WithNoNativeText` + - `FPDFViewEmbedderTest.RenderHelloWorldWithFlags` +- [x] layer mode: exit 0; 213 layer-only failures, all expected; 185 crashes as in S15; 507 writers + (main now runs in-memory and linearized tests through layers, `e90678020` and #111). One warning: + `EPDFSlicedLoadEmbedderTest.SlicesKeepToTheirBudget` failed under load and passed alone, a timing + test, as in S11. (A Mac recording drops the Linux-only `TransFormWithClipAndSaveWithLocale`; its + line stays.) +- [x] tag check (`--base 2b52a82ab`): 1012 blocks, 0 untagged. +- [x] C API check: ok, 590 functions in 24 headers. +- [x] globals check: ok. +- [x] wasm build: builds locally. +- [ ] ThreadSanitizer soak: in the PR's CI. +- [ ] engine tests and engine-conformance with the local runtime: not run for this sync. +- changed expectations, each with its reason: + - Layer-mode writers: added `EPDFAnnotEmbedderTest.AcrobatCommentWrittenBackReadsTheSame` (1 + object), which came with #110 (`605f21fa1`) unrecorded; it writes a markup comment back, and + without it the release workflow's layer-mode gate fails. + - Layer-mode writer counts, informational: `EPDFPpoEmbedderTest.AddsToAFormAndRenamesAFontItUses` + 1 to 20, `RenamesAFontWithOtherWidths` 2 to 20, `RenamesTheFontOfAnAppearanceWithAComment` 2 to + 20, `SharesAFontDefinedTheSameWay` 1 to 19 (their destination is a `NewTestDocument()`, a layer + since `e90678020`, so the whole import counts); `RichTextSkipsDocumentSubsetWithoutCmap` 6 to 7, + `NumberFormatsRoundTripAndAbsentVersusEmpty` 1 to 4. + +## Ledger changes proposed + +None. diff --git a/fpdfsdk/fpdf_editimg.cpp b/fpdfsdk/fpdf_editimg.cpp index 8bc82c20a..797df8511 100644 --- a/fpdfsdk/fpdf_editimg.cpp +++ b/fpdfsdk/fpdf_editimg.cpp @@ -362,8 +362,7 @@ FPDFImageObj_GetRenderedBitmap(FPDF_DOCUMENT document, } // Do the actual rendering. - bool should_continue = - renderer.Start(image, image_render_matrix, /*bStdCS=*/false); + bool should_continue = renderer.Start(image, image_render_matrix); while (should_continue) { should_continue = renderer.Continue(/*pPause=*/nullptr); } @@ -530,7 +529,7 @@ FPDFImageObj_GetImageMetadata(FPDF_PAGEOBJECT image_object, RetainPtr pSource = pImg->CreateNewDIB(); CPDF_DIB::LoadState ret = pSource->StartLoadDIBBase( - false, nullptr, pPage->GetPageResources().Get(), false, + false, nullptr, pPage->GetPageResources().Get(), CPDF_ColorSpace::Family::kUnknown, false, {0, 0}); if (ret == CPDF_DIB::LoadState::kFail) { return true; diff --git a/fpdfsdk/fpdf_thumbnail.cpp b/fpdfsdk/fpdf_thumbnail.cpp index 18fe04909..97ec3e7c1 100644 --- a/fpdfsdk/fpdf_thumbnail.cpp +++ b/fpdfsdk/fpdf_thumbnail.cpp @@ -81,7 +81,7 @@ FPDFPage_GetThumbnailAsBitmap(FPDF_PAGE page) { auto dib_source = pdfium::MakeRetain(pdf_page->GetDocument(), std::move(thumb_stream)); const CPDF_DIB::LoadState start_status = dib_source->StartLoadDIBBase( - false, nullptr, pdf_page->GetPageResources().Get(), false, + false, nullptr, pdf_page->GetPageResources().Get(), CPDF_ColorSpace::Family::kUnknown, false, {0, 0}); if (start_status == CPDF_DIB::LoadState::kFail) { return nullptr; diff --git a/testing/embedpdf_layer_mode_writers.txt b/testing/embedpdf_layer_mode_writers.txt index d8fc78617..2a455f68c 100644 --- a/testing/embedpdf_layer_mode_writers.txt +++ b/testing/embedpdf_layer_mode_writers.txt @@ -49,6 +49,7 @@ EPDFActionEmbedderTest.NodeFilePathAndNamePayloadsFromSyntheticDicts 2 EPDFActionEmbedderTest.OpenActionDestinationForms 3 EPDFActionEmbedderTest.ResetFormThreeStates 1 EPDFActionEmbedderTest.SetNextChainsActions 3 +EPDFAnnotEmbedderTest.AcrobatCommentWrittenBackReadsTheSame 1 EPDFAnnotEmbedderTest.AnEmptyDashPatternIsASolidLine 15 EPDFAnnotEmbedderTest.AnnotFontMapStagesEveryNamedFont 16 EPDFAnnotEmbedderTest.ApplyPageRedactionsCountsRemovedAnnotations 6 @@ -149,7 +150,7 @@ EPDFAnnotEmbedderTest.RichTextPicksTheDocumentSubsetThatCoversTheText 16 EPDFAnnotEmbedderTest.RichTextPreviewAndPrintLastResortWaits 25 EPDFAnnotEmbedderTest.RichTextResolvesDocumentProgramWhenUnregistered 24 EPDFAnnotEmbedderTest.RichTextRtlRunCarriesActualTextAndExtracts 14 -EPDFAnnotEmbedderTest.RichTextSkipsDocumentSubsetWithoutCmap 6 +EPDFAnnotEmbedderTest.RichTextSkipsDocumentSubsetWithoutCmap 7 EPDFAnnotEmbedderTest.RichTextWriterFailureLeavesDocumentUntouched 18 EPDFAnnotEmbedderTest.RotatedCaretAppearanceCarriesTransform 3 EPDFAnnotEmbedderTest.SetDefaultAppearanceKeepsFontAtAutoSize 5 @@ -262,7 +263,7 @@ EPDFMeasureEmbedderTest.LayerReadsPromoteNothingAndPageWritesOnlyPage 5 EPDFMeasureEmbedderTest.LineAndShapeCaptionEntriesStaySeparate 5 EPDFMeasureEmbedderTest.LineAppearanceLeadersInlineGapAndStableBounds 7 EPDFMeasureEmbedderTest.MissingOrMalformedConversionNeverBecomesOne 4 -EPDFMeasureEmbedderTest.NumberFormatsRoundTripAndAbsentVersusEmpty 1 +EPDFMeasureEmbedderTest.NumberFormatsRoundTripAndAbsentVersusEmpty 4 EPDFMeasureEmbedderTest.RegisteredCaptionFontsStayOutOfCatalogAndEphemeralWrites 11 EPDFMeasureEmbedderTest.ShapeCaptionBoundsShrinkWhenMovedInward 6 EPDFMeasureEmbedderTest.ShapeCaptionCenterRoundTripsAndOnlyChangesVisualBounds 7 @@ -298,14 +299,14 @@ EPDFPieceInfoEmbedderTest.CatalogGranularClearPreservesOtherData 4 EPDFPieceInfoEmbedderTest.CatalogTypedValuesSaveReloadAndLayerRead 4 EPDFPieceInfoEmbedderTest.GranularClearPreservesOtherData 3 EPDFPieceInfoEmbedderTest.TypedValuesSaveReloadAndImport 3 -EPDFPpoEmbedderTest.AddsToAFormAndRenamesAFontItUses 1 +EPDFPpoEmbedderTest.AddsToAFormAndRenamesAFontItUses 20 EPDFPpoEmbedderTest.BringsOnlyWhatIsAboveThePagesWidgets 12 EPDFPpoEmbedderTest.BringsTheFieldsOfEveryPage 18 EPDFPpoEmbedderTest.CopiesOutOfALayerAsTheLayerReadsIt 14 EPDFPpoEmbedderTest.PointsCopiedParentsAtTheCopies 15 -EPDFPpoEmbedderTest.RenamesAFontWithOtherWidths 2 -EPDFPpoEmbedderTest.RenamesTheFontOfAnAppearanceWithAComment 2 -EPDFPpoEmbedderTest.SharesAFontDefinedTheSameWay 1 +EPDFPpoEmbedderTest.RenamesAFontWithOtherWidths 20 +EPDFPpoEmbedderTest.RenamesTheFontOfAnAppearanceWithAComment 20 +EPDFPpoEmbedderTest.SharesAFontDefinedTheSameWay 19 EPDFRedactEmbedderTest.DirectReplacementTextIsRemovedFromSiblingObjects 3 EPDFRedactEmbedderTest.InheritedPropertiesLeaveNoUnusedOriginalOnPage 5 EPDFRedactEmbedderTest.NestedFormsUseTheRenderersTransformOrder 7 diff --git a/testing/resources/image_pattern_colorspace.in b/testing/resources/image_pattern_colorspace.in new file mode 100644 index 000000000..8234b2a88 --- /dev/null +++ b/testing/resources/image_pattern_colorspace.in @@ -0,0 +1,51 @@ +{{header}} +{{object 1 0}} << + /Type /Catalog + /Pages 2 0 R +>> +endobj +{{object 2 0}} << + /Type /Pages + /Count 1 + /Kids [3 0 R] +>> +endobj +{{object 3 0}} << + /Type /Page + /Parent 2 0 R + /MediaBox [0 0 100 100] + /Contents 4 0 R + /Resources << + /XObject << + /Im0 5 0 R + >> + >> +>> +endobj +{{object 4 0}} << + {{streamlen}} +>> +stream +q +100 0 0 100 0 0 cm +/Im0 Do +Q +endstream +endobj +{{object 5 0}} << + /Type /XObject + /Subtype /Image + /Width 1 + /Height 1 + /BitsPerComponent 8 + /ColorSpace [/Pattern /DeviceRGB] + {{streamlen}} +>> +stream +abcd +endstream +endobj +{{xref}} +{{trailer}} +{{startxref}} +%%EOF diff --git a/testing/resources/image_pattern_colorspace.pdf b/testing/resources/image_pattern_colorspace.pdf new file mode 100644 index 000000000..3be90cccb Binary files /dev/null and b/testing/resources/image_pattern_colorspace.pdf differ diff --git a/testing/resources/pixel/bug_557320961_expected.pdf.0.png b/testing/resources/pixel/bug_557320961_expected.pdf.0.png index 397ef476c..8850e8975 100644 Binary files a/testing/resources/pixel/bug_557320961_expected.pdf.0.png and b/testing/resources/pixel/bug_557320961_expected.pdf.0.png differ