Get rid of dead CYMK output code in CPSPrinterDriver and CFX_PSRenderer.
CPSPrinterDriver is never initialized with the CYMK output bit set to
true. Thus there is a bit of unused code here.
Change-Id: Id91b514a8e99ff38fd39425e77b24cc850800398
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/75290
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
diff --git a/core/fxge/cfx_windowsrenderdevice.cpp b/core/fxge/cfx_windowsrenderdevice.cpp
index 88ec4a9..3f40c7a 100644
--- a/core/fxge/cfx_windowsrenderdevice.cpp
+++ b/core/fxge/cfx_windowsrenderdevice.cpp
@@ -447,7 +447,7 @@
if (g_pdfium_print_mode == WindowsPrintMode::kModeTextOnly)
return std::make_unique<CTextOnlyPrinterDriver>(hDC);
- return std::make_unique<CPSPrinterDriver>(hDC, g_pdfium_print_mode, false,
+ return std::make_unique<CPSPrinterDriver>(hDC, g_pdfium_print_mode,
pEncoderIface);
}
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index a27e8bc..b2553f6 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -46,15 +46,13 @@
void CFX_PSRenderer::Init(const RetainPtr<IFX_RetainableWriteStream>& pStream,
int pslevel,
int width,
- int height,
- bool bCmykOutput) {
+ int height) {
m_PSLevel = pslevel;
m_pStream = pStream;
m_ClipBox.left = 0;
m_ClipBox.top = 0;
m_ClipBox.right = width;
m_ClipBox.bottom = height;
- m_bCmykOutput = bCmykOutput;
}
bool CFX_PSRenderer::StartRendering() {
@@ -446,24 +444,15 @@
}
void CFX_PSRenderer::SetColor(uint32_t color) {
- bool bCMYK = false;
- if (bCMYK != m_bCmykOutput || !m_bColorSet || m_LastColor != color) {
- std::ostringstream buf;
- if (bCMYK) {
- buf << FXSYS_GetCValue(color) / 255.0 << " "
- << FXSYS_GetMValue(color) / 255.0 << " "
- << FXSYS_GetYValue(color) / 255.0 << " "
- << FXSYS_GetKValue(color) / 255.0 << " k\n";
- } else {
- buf << FXARGB_R(color) / 255.0 << " " << FXARGB_G(color) / 255.0 << " "
- << FXARGB_B(color) / 255.0 << " rg\n";
- }
- if (bCMYK == m_bCmykOutput) {
- m_bColorSet = true;
- m_LastColor = color;
- }
- WriteToStream(&buf);
- }
+ if (m_bColorSet && m_LastColor == color)
+ return;
+
+ std::ostringstream buf;
+ buf << FXARGB_R(color) / 255.0 << " " << FXARGB_G(color) / 255.0 << " "
+ << FXARGB_B(color) / 255.0 << " rg\n";
+ m_bColorSet = true;
+ m_LastColor = color;
+ WriteToStream(&buf);
}
void CFX_PSRenderer::FindPSFontGlyph(CFX_GlyphCache* pGlyphCache,
diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h
index 86a1767..8ecd1bf 100644
--- a/core/fxge/win32/cfx_psrenderer.h
+++ b/core/fxge/win32/cfx_psrenderer.h
@@ -57,8 +57,7 @@
void Init(const RetainPtr<IFX_RetainableWriteStream>& stream,
int pslevel,
int width,
- int height,
- bool bCmykOutput);
+ int height);
bool StartRendering();
void EndRendering();
void SaveState();
@@ -123,7 +122,6 @@
bool m_bInited = false;
bool m_bGraphStateSet = false;
- bool m_bCmykOutput;
bool m_bColorSet = false;
int m_PSLevel = 0;
uint32_t m_LastColor = 0;
diff --git a/core/fxge/win32/cps_printer_driver.cpp b/core/fxge/win32/cps_printer_driver.cpp
index 852aa34..d5e562a 100644
--- a/core/fxge/win32/cps_printer_driver.cpp
+++ b/core/fxge/win32/cps_printer_driver.cpp
@@ -20,9 +20,8 @@
CPSPrinterDriver::CPSPrinterDriver(HDC hDC,
WindowsPrintMode mode,
- bool bCmykOutput,
const EncoderIface* pEncoderIface)
- : m_hDC(hDC), m_bCmykOutput(bCmykOutput), m_PSRenderer(pEncoderIface) {
+ : m_hDC(hDC), m_PSRenderer(pEncoderIface) {
// |mode| should be PostScript.
ASSERT(mode == WindowsPrintMode::kModePostScript2 ||
mode == WindowsPrintMode::kModePostScript3 ||
@@ -45,7 +44,7 @@
m_nBitsPerPixel = ::GetDeviceCaps(m_hDC, BITSPIXEL);
m_PSRenderer.Init(pdfium::MakeRetain<CPSOutput>(m_hDC, output_mode), pslevel,
- m_Width, m_Height, bCmykOutput);
+ m_Width, m_Height);
HRGN hRgn = ::CreateRectRgn(0, 0, 1, 1);
if (::GetClipRgn(m_hDC, hRgn) == 1) {
DWORD dwCount = ::GetRegionData(hRgn, 0, nullptr);
@@ -87,7 +86,7 @@
case FXDC_BITS_PIXEL:
return m_nBitsPerPixel;
case FXDC_RENDER_CAPS:
- return m_bCmykOutput ? FXRC_BIT_MASK | FXRC_CMYK_OUTPUT : FXRC_BIT_MASK;
+ return FXRC_BIT_MASK;
case FXDC_HORZ_SIZE:
return m_HorzSize;
case FXDC_VERT_SIZE:
diff --git a/core/fxge/win32/cps_printer_driver.h b/core/fxge/win32/cps_printer_driver.h
index 7975048..229afab 100644
--- a/core/fxge/win32/cps_printer_driver.h
+++ b/core/fxge/win32/cps_printer_driver.h
@@ -19,7 +19,6 @@
public:
CPSPrinterDriver(HDC hDC,
WindowsPrintMode mode,
- bool bCmykOutput,
const EncoderIface* pEncoderIface);
~CPSPrinterDriver() override;
@@ -74,7 +73,6 @@
const CFX_TextRenderOptions& options) override;
HDC m_hDC;
- const bool m_bCmykOutput;
int m_Width;
int m_Height;
int m_nBitsPerPixel;