Fix incorrect current transformation matrix when saving PDFs CPDF_PageContentGenerator has been incorrectly writing out the inverse of the current transformation matrix when saving PDFs, instead of the CTM. The reason this worked for many test cases is because they tested PDFs where the inverted CTM is equal to the CTM. With new test cases where the inverted CTM is not equal to the CTM, making this correction makes them render correctly. Bug: pdfium:2132 Change-Id: Idb0a7951d68dfdfaa30f9a41479b6941c341b4aa Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117053 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Thomas Sepez <tsepez@google.com>
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index 60a6ea9..c2f83dc 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -183,7 +183,7 @@ buf << "q\n"; const CFX_Matrix& ctm = m_pObjHolder->GetLastCTM(); if (!ctm.IsIdentity()) { - WriteMatrix(buf, ctm.GetInverse()) << " cm\n"; + WriteMatrix(buf, ctm) << " cm\n"; } ProcessDefaultGraphics(&buf);
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp index 39c205c..22ce975 100644 --- a/fpdfsdk/fpdf_edit_embeddertest.cpp +++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -5267,24 +5267,7 @@ UnloadPage(page); - // TODO(crbug.com/pdfium/2132): This should use HelloWorldChecksum(). - const char* const kWrongChecksum = []() { - if (CFX_DefaultRenderDevice::UseSkiaRenderer()) { -#if BUILDFLAG(IS_WIN) - return "0b5370959c7731c846a35066f0463aee"; -#elif BUILDFLAG(IS_MAC) - return "8715c645f7dccfb23e25a32da32ef6af"; -#else - return "b4a1a4a73668c5dd4b769db86334943b"; -#endif - } -#if BUILDFLAG(IS_MAC) - return "6cb1bfe4f8bef5547eab41cdfad79d59"; -#else - return "0e6dd5f1332bb4c4b0cd3aa6a0b89943"; -#endif - }(); - VerifySavedDocument(kExpectedWidth, kExpectedHeight, kWrongChecksum); + VerifySavedDocument(kExpectedWidth, kExpectedHeight, HelloWorldChecksum()); } class FPDFEditMoveEmbedderTest : public EmbedderTest {
diff --git a/fpdfsdk/fpdf_editpath_embeddertest.cpp b/fpdfsdk/fpdf_editpath_embeddertest.cpp index 91103aa..9a9fe63 100644 --- a/fpdfsdk/fpdf_editpath_embeddertest.cpp +++ b/fpdfsdk/fpdf_editpath_embeddertest.cpp
@@ -186,12 +186,5 @@ UnloadPage(page); - // TODO(crbug.com/pdfium/2132): This should use RectanglesChecksum(). - const char* const kWrongChecksum = []() { - if (CFX_DefaultRenderDevice::UseSkiaRenderer()) { - return "f7c69f8d0bb92541d48dbbbba003396d"; - } - return "37a215071985bd88079fedb56b001685"; - }(); - VerifySavedDocument(kExpectedWidth, kExpectedHeight, kWrongChecksum); + VerifySavedDocument(kExpectedWidth, kExpectedHeight, RectanglesChecksum()); }