From d2afac1e9200478997e308eecc582a073185d7ab Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Fri, 12 May 2017 21:22:08 -0400 Subject: Convert CPSOutput to an IFX_WriteStream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This Cl updates CPSOutput to inherit from IFX_WriteStream and converts the CFX_PSRenderer to accept an IFX_WriteStream instead of a CPSOutput. Change-Id: Ibde5c7da1c2f6df0a10cb6e9a470e18fbab167b8 Reviewed-on: https://pdfium-review.googlesource.com/5431 Reviewed-by: Nicolás Peña Commit-Queue: dsinclair --- core/fxge/win32/cpsoutput.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'core/fxge/win32/cpsoutput.cpp') diff --git a/core/fxge/win32/cpsoutput.cpp b/core/fxge/win32/cpsoutput.cpp index 7a8434ec33..7139340a6e 100644 --- a/core/fxge/win32/cpsoutput.cpp +++ b/core/fxge/win32/cpsoutput.cpp @@ -10,26 +10,17 @@ #include "core/fxcrt/fx_system.h" -CPSOutput::CPSOutput(HDC hDC) { - m_hDC = hDC; -} +CPSOutput::CPSOutput(HDC hDC) : m_hDC(hDC) {} CPSOutput::~CPSOutput() {} -void CPSOutput::Release() { - delete this; -} - -void CPSOutput::OutputPS(const char* str, int len) { - if (len < 0) - len = static_cast(FXSYS_strlen(str)); - +bool CPSOutput::WriteBlock(const void* str, size_t len) { int sent_len = 0; while (len > 0) { char buffer[1026]; - int send_len = std::min(len, 1024); + size_t send_len = std::min(len, static_cast(1024)); *(reinterpret_cast(buffer)) = send_len; - memcpy(buffer + 2, str + sent_len, send_len); + memcpy(buffer + 2, static_cast(str) + sent_len, send_len); // TODO(thestig/rbpotter): Do PASSTHROUGH for non-Chromium usage. // ExtEscape(m_hDC, PASSTHROUGH, send_len + 2, buffer, 0, nullptr); @@ -37,4 +28,9 @@ void CPSOutput::OutputPS(const char* str, int len) { sent_len += send_len; len -= send_len; } + return true; +} + +bool CPSOutput::WriteString(const CFX_ByteStringC& str) { + return WriteBlock(str.c_str(), str.GetLength()); } -- cgit v1.2.3