Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
27
CPDF_RenderContext
::
CPDF_RenderContext
(
28
CPDF_Document
* pDoc,
29
RetainPtr
<
CPDF_Dictionary
> pPageResources,
30
CPDF_PageImageCache
* pPageCache)
31
:
m_pDocument
(
pDoc
),
32
m_pPageResources
(
std
::
move
(
pPageResources
)),
33
m_pPageCache
(
pPageCache
) {}
34
35
CPDF_RenderContext
::~
CPDF_RenderContext
() =
default
;
36
37
void
CPDF_RenderContext
::
GetBackgroundToDevice
(
38
CFX_RenderDevice
* device,
39
const
CPDF_PageObject
* object,
40
const
CPDF_RenderOptions
* options,
41
const
CFX_Matrix
& matrix) {
42
device
->
FillRect
(
FX_RECT
(
0
,
0
,
device
->
GetWidth
(
)
,
device
->
GetHeight
(
)
)
,
43
0xffffffff
)
;
44
Render
(
device
,
object
,
options
,
&matrix
)
;
45
}
46
47
#
if
BUILDFLAG
(
IS_WIN
)
48
void
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
57
void
CPDF_RenderContext
::
AppendLayer
(
CPDF_PageObjectHolder
* pObjectHolder,
58
const
CFX_Matrix
& mtObject2Device) {
59
m_Layers.emplace_back(pObjectHolder, mtObject2Device);
60
}
61
62
void
CPDF_RenderContext
::
Render
(
CFX_RenderDevice
* pDevice,
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
89
CPDF_RenderContext
::
Layer
::
Layer
(
CPDF_PageObjectHolder
* pHolder,
90
const
CFX_Matrix
& matrix)
91
:
m_pObjectHolder
(
pHolder
), m_Matrix
(
matrix
)
{}
92
93
CPDF_RenderContext
::
Layer
::
Layer
(
const
Layer
& that) =
default
;
94
95
CPDF_RenderContext
::
Layer
::~
Layer
() =
default
;
CFX_Matrix
Definition
fx_coordinates.h:440
CFX_Matrix::CFX_Matrix
CFX_Matrix(const CFX_Matrix &other)=default
CFX_RenderDevice
Definition
cfx_renderdevice.h:39
CFX_RenderDevice::FillRect
bool FillRect(const FX_RECT &rect, uint32_t color)
Definition
cfx_renderdevice.cpp:797
CFX_RenderDevice::GetHeight
int GetHeight() const
Definition
cfx_renderdevice.h:61
CFX_RenderDevice::GetWidth
int GetWidth() const
Definition
cfx_renderdevice.h:60
CPDF_Dictionary::DictMap
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
Definition
cpdf_dictionary.h:31
CPDF_Document
Definition
cpdf_document.h:29
CPDF_PageImageCache
Definition
cpdf_pageimagecache.h:27
CPDF_PageObjectHolder
Definition
cpdf_pageobjectholder.h:51
CPDF_PageObject
Definition
cpdf_pageobject.h:27
CPDF_RenderContext::Layer
Definition
cpdf_rendercontext.h:29
CPDF_RenderContext::Layer::Layer
Layer(const Layer &that)
CPDF_RenderContext::Layer::Layer
Layer(CPDF_PageObjectHolder *pHolder, const CFX_Matrix &matrix)
Definition
cpdf_rendercontext.cpp:89
CPDF_RenderContext::Layer::~Layer
~Layer()
CPDF_RenderContext
Definition
cpdf_rendercontext.h:27
CPDF_RenderContext::AppendLayer
void AppendLayer(CPDF_PageObjectHolder *pObjectHolder, const CFX_Matrix &mtObject2Device)
Definition
cpdf_rendercontext.cpp:57
CPDF_RenderContext::CPDF_RenderContext
CPDF_RenderContext(CPDF_Document *pDoc, RetainPtr< CPDF_Dictionary > pPageResources, CPDF_PageImageCache *pPageCache)
Definition
cpdf_rendercontext.cpp:27
CPDF_RenderContext::GetBackgroundToDevice
void GetBackgroundToDevice(CFX_RenderDevice *device, const CPDF_PageObject *object, const CPDF_RenderOptions *options, const CFX_Matrix &matrix)
Definition
cpdf_rendercontext.cpp:37
CPDF_RenderContext::~CPDF_RenderContext
~CPDF_RenderContext()
CPDF_RenderContext::Render
void Render(CFX_RenderDevice *pDevice, const CPDF_PageObject *pStopObj, const CPDF_RenderOptions *pOptions, const CFX_Matrix *pLastMatrix)
Definition
cpdf_rendercontext.cpp:62
CPDF_RenderOptions
Definition
cpdf_renderoptions.h:19
fxcrt::RetainPtr
Definition
retain_ptr.h:28
FX_RECT
Definition
fx_coordinates.h:144
FX_RECT::FX_RECT
constexpr FX_RECT(int l, int t, int r, int b)
Definition
fx_coordinates.h:146
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fpdfapi
render
cpdf_rendercontext.cpp
Generated on
for Qt by
1.18.0