diff options
author | dan sinclair <dsinclair@chromium.org> | 2017-05-12 21:22:08 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-15 15:40:43 +0000 |
commit | d2afac1e9200478997e308eecc582a073185d7ab (patch) | |
tree | 1ec1a2c69168cb2ab3f1418fae0e9f1c754cebdb /core/fxge/win32/cpsoutput.cpp | |
parent | 017ebba6940e0fe5ff39122c033600f88f24539a (diff) | |
download | pdfium-d2afac1e9200478997e308eecc582a073185d7ab.tar.xz |
Convert CPSOutput to an IFX_WriteStream
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 <npm@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxge/win32/cpsoutput.cpp')
-rw-r--r-- | core/fxge/win32/cpsoutput.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
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<int>(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<size_t>(1024)); *(reinterpret_cast<uint16_t*>(buffer)) = send_len; - memcpy(buffer + 2, str + sent_len, send_len); + memcpy(buffer + 2, static_cast<const char*>(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()); } |