From 06bbdef296b483e6f666156b198319019d3c6373 Mon Sep 17 00:00:00 2001 From: wileyrya Date: Fri, 26 May 2017 15:20:23 -0500 Subject: Add public API for setting the blend mode on a page object. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG=pdfium:720 R=npm@chromium.org Change-Id: I2a43b34da6946265ca06502b9ff19ad352fd18cb Reviewed-on: https://pdfium-review.googlesource.com/5953 Commit-Queue: Nicolás Peña Reviewed-by: Nicolás Peña --- core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'core/fpdfapi/edit') diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index e9ea064810..2cf10bd7cb 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -225,8 +225,12 @@ void CPDF_PageContentGenerator::ProcessGraphics(CFX_ByteTextBuf* buf, GraphicsData graphD; graphD.fillAlpha = pPageObj->m_GeneralState.GetFillAlpha(); graphD.strokeAlpha = pPageObj->m_GeneralState.GetStrokeAlpha(); - if (graphD.fillAlpha == 1.0f && graphD.strokeAlpha == 1.0f) + int blend_type = pPageObj->m_GeneralState.GetBlendType(); + if (graphD.fillAlpha == 1.0f && graphD.strokeAlpha == 1.0f && + (blend_type == FXDIB_BLEND_UNSUPPORTED || + blend_type == FXDIB_BLEND_NORMAL)) { return; + } CFX_ByteString name; auto it = m_pPage->m_GraphicsMap.find(graphD); @@ -234,8 +238,17 @@ void CPDF_PageContentGenerator::ProcessGraphics(CFX_ByteTextBuf* buf, name = it->second; } else { auto gsDict = pdfium::MakeUnique(); - gsDict->SetNewFor("ca", graphD.fillAlpha); - gsDict->SetNewFor("CA", graphD.strokeAlpha); + if (graphD.fillAlpha != 1.0f) + gsDict->SetNewFor("ca", graphD.fillAlpha); + + if (graphD.strokeAlpha != 1.0f) + gsDict->SetNewFor("CA", graphD.strokeAlpha); + + if (blend_type != FXDIB_BLEND_UNSUPPORTED && + blend_type != FXDIB_BLEND_NORMAL) { + gsDict->SetNewFor("BM", + pPageObj->m_GeneralState.GetBlendMode()); + } CPDF_Object* pDict = m_pDocument->AddIndirectObject(std::move(gsDict)); uint32_t dwObjNum = pDict->GetObjNum(); name = RealizeResource(dwObjNum, "ExtGState"); -- cgit v1.2.3