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
cpdf_rendercontext.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/fpdfapi/render/cpdf_rendercontext.h"
8
9#include <utility>
10
11#include "build/build_config.h"
12#include "core/fpdfapi/page/cpdf_pageimagecache.h"
13#include "core/fpdfapi/page/cpdf_pageobject.h"
14#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
15#include "core/fpdfapi/parser/cpdf_dictionary.h"
16#include "core/fpdfapi/parser/cpdf_document.h"
17#include "core/fpdfapi/render/cpdf_progressiverenderer.h"
18#include "core/fpdfapi/render/cpdf_renderoptions.h"
19#include "core/fpdfapi/render/cpdf_renderstatus.h"
20#include "core/fpdfapi/render/cpdf_textrenderer.h"
21#include "core/fxcrt/check.h"
22#include "core/fxge/cfx_defaultrenderdevice.h"
23#include "core/fxge/cfx_renderdevice.h"
24#include "core/fxge/dib/cfx_dibitmap.h"
25#include "core/fxge/dib/fx_dib.h"
26
34
36
38 CFX_RenderDevice* device,
39 const CPDF_PageObject* object,
40 const CPDF_RenderOptions* options,
41 const CFX_Matrix& matrix) {
43 0xffffffff);
44 Render(device, object, options, &matrix);
45}
46
47#if BUILDFLAG(IS_WIN)
48void CPDF_RenderContext::GetBackgroundToBitmap(RetainPtr<CFX_DIBitmap> bitmap,
49 const CPDF_PageObject* object,
50 const CFX_Matrix& matrix) {
51 CFX_DefaultRenderDevice device;
52 device.Attach(std::move(bitmap));
53 GetBackgroundToDevice(&device, object, /*options=*/nullptr, matrix);
54}
55#endif
56
58 const CFX_Matrix& mtObject2Device) {
59 m_Layers.emplace_back(pObjectHolder, mtObject2Device);
60}
61
63 const CPDF_PageObject* pStopObj,
64 const CPDF_RenderOptions* pOptions,
65 const CFX_Matrix* pLastMatrix) {
66 for (auto& layer : m_Layers) {
67 CFX_RenderDevice::StateRestorer restorer(pDevice);
68 CPDF_RenderStatus status(this, pDevice);
69 if (pOptions)
70 status.SetOptions(*pOptions);
71 status.SetStopObject(pStopObj);
72 status.SetTransparency(layer.GetObjectHolder()->GetTransparency());
73 CFX_Matrix final_matrix = layer.GetMatrix();
74 if (pLastMatrix) {
75 final_matrix *= *pLastMatrix;
76 status.SetDeviceMatrix(*pLastMatrix);
77 }
78 status.Initialize(nullptr, nullptr);
79 status.RenderObjectList(layer.GetObjectHolder(), final_matrix);
80 if (status.GetRenderOptions().GetOptions().bLimitedImageCache) {
81 m_pPageCache->CacheOptimization(
82 status.GetRenderOptions().GetCacheSizeLimit());
83 }
84 if (status.IsStopped())
85 break;
86 }
87}
88
90 const CFX_Matrix& matrix)
91 : m_pObjectHolder(pHolder), m_Matrix(matrix) {}
92
93CPDF_RenderContext::Layer::Layer(const Layer& that) = default;
94
95CPDF_RenderContext::Layer::~Layer() = default;
CFX_Matrix(const CFX_Matrix &other)=default
bool FillRect(const FX_RECT &rect, uint32_t color)
int GetHeight() const
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
Layer(const Layer &that)
Layer(CPDF_PageObjectHolder *pHolder, const CFX_Matrix &matrix)
void AppendLayer(CPDF_PageObjectHolder *pObjectHolder, const CFX_Matrix &mtObject2Device)
CPDF_RenderContext(CPDF_Document *pDoc, RetainPtr< CPDF_Dictionary > pPageResources, CPDF_PageImageCache *pPageCache)
void GetBackgroundToDevice(CFX_RenderDevice *device, const CPDF_PageObject *object, const CPDF_RenderOptions *options, const CFX_Matrix &matrix)
void Render(CFX_RenderDevice *pDevice, const CPDF_PageObject *pStopObj, const CPDF_RenderOptions *pOptions, const CFX_Matrix *pLastMatrix)
constexpr FX_RECT(int l, int t, int r, int b)