Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpsoutput.cpp
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "core/fxge/win32/cpsoutput.h"
8
9#include <algorithm>
10
11#include "core/fxcrt/fx_system.h"
12#include "third_party/base/containers/span.h"
13
14CPSOutput::CPSOutput(HDC hDC, OutputMode mode) : m_hDC(hDC), m_mode(mode) {}
15
16CPSOutput::~CPSOutput() = default;
17
18bool CPSOutput::WriteBlock(pdfium::span<const uint8_t> input) {
19 while (!input.empty()) {
20 uint8_t buffer[1026];
21 size_t send_len = std::min<size_t>(input.size(), 1024);
22 *(reinterpret_cast<uint16_t*>(buffer)) = static_cast<uint16_t>(send_len);
23 memcpy(buffer + 2, input.data(), send_len);
24 switch (m_mode) {
25 case OutputMode::kExtEscape:
26 ExtEscape(m_hDC, PASSTHROUGH, static_cast<int>(send_len + 2),
27 reinterpret_cast<const char*>(buffer), 0, nullptr);
28 break;
29 case OutputMode::kGdiComment:
30 GdiComment(m_hDC, static_cast<UINT>(send_len + 2), buffer);
31 break;
32 }
33 input = input.subspan(send_len);
34 }
35 return true;
36}
bool WriteBlock(pdfium::span< const uint8_t > input) override
Definition cpsoutput.cpp:18
~CPSOutput() override
CPSOutput(HDC hDC, OutputMode mode)
Definition cpsoutput.cpp:14