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 "core/fpdfapi/page/cpdf_pageimagecache.h"
12#include "core/fpdfapi/page/cpdf_pageobject.h"
13#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
14#include "core/fpdfapi/parser/cpdf_dictionary.h"
15#include "core/fpdfapi/parser/cpdf_document.h"
16#include "core/fpdfapi/render/cpdf_progressiverenderer.h"
17#include "core/fpdfapi/render/cpdf_renderoptions.h"
18#include "core/fpdfapi/render/cpdf_renderstatus.h"
19#include "core/fpdfapi/render/cpdf_textrenderer.h"
20#include "core/fxge/cfx_defaultrenderdevice.h"
21#include "core/fxge/cfx_renderdevice.h"
22#include "core/fxge/dib/cfx_dibitmap.h"
23#include "core/fxge/dib/fx_dib.h"
24#include "third_party/base/check.h"
25
33
35
37 CFX_RenderDevice* device,
38 const CPDF_PageObject* object,
39 const CPDF_RenderOptions* options,
40 const CFX_Matrix& matrix) {
42 0xffffffff);
43 Render(device, object, options, &matrix);
44}
45
47 const CPDF_PageObject* object,
48 const CFX_Matrix& matrix) {
49 CFX_DefaultRenderDevice device;
50 device.Attach(std::move(bitmap));
51 GetBackgroundToDevice(&device, object, /*options=*/nullptr, matrix);
52}
53
55 const CFX_Matrix& mtObject2Device) {
56 m_Layers.emplace_back(pObjectHolder, mtObject2Device);
57}
58
60 const CPDF_PageObject* pStopObj,
61 const CPDF_RenderOptions* pOptions,
62 const CFX_Matrix* pLastMatrix) {
63 for (auto& layer : m_Layers) {
64 CFX_RenderDevice::StateRestorer restorer(pDevice);
65 CPDF_RenderStatus status(this, pDevice);
66 if (pOptions)
67 status.SetOptions(*pOptions);
68 status.SetStopObject(pStopObj);
69 status.SetTransparency(layer.GetObjectHolder()->GetTransparency());
70 CFX_Matrix final_matrix = layer.GetMatrix();
71 if (pLastMatrix) {
72 final_matrix *= *pLastMatrix;
73 status.SetDeviceMatrix(*pLastMatrix);
74 }
75 status.Initialize(nullptr, nullptr);
76 status.RenderObjectList(layer.GetObjectHolder(), final_matrix);
77 if (status.GetRenderOptions().GetOptions().bLimitedImageCache) {
78 m_pPageCache->CacheOptimization(
79 status.GetRenderOptions().GetCacheSizeLimit());
80 }
81 if (status.IsStopped())
82 break;
83 }
84}
85
87 const CFX_Matrix& matrix)
88 : m_pObjectHolder(pHolder), m_Matrix(matrix) {}
89
90CPDF_RenderContext::Layer::Layer(const Layer& that) = default;
91
92CPDF_RenderContext::Layer::~Layer() = default;
bool Attach(RetainPtr< CFX_DIBitmap > pBitmap)
CFX_Matrix(const CFX_Matrix &other)=default
bool FillRect(const FX_RECT &rect, uint32_t color)
int GetHeight() const
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 GetBackgroundToBitmap(RetainPtr< CFX_DIBitmap > bitmap, const CPDF_PageObject *object, 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)