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
cxfa_stipple.cpp
Go to the documentation of this file.
1
// Copyright 2017 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
"xfa/fxfa/parser/cxfa_stipple.h"
8
9
#
include
"fxjs/xfa/cjx_node.h"
10
#
include
"xfa/fgas/graphics/cfgas_gegraphics.h"
11
#
include
"xfa/fxfa/parser/cxfa_color.h"
12
#
include
"xfa/fxfa/parser/cxfa_document.h"
13
14
namespace
{
15
16
const
CXFA_Node
::
PropertyData
kStipplePropertyData[] = {
17
{
XFA_Element
::Color, 1, {}},
18
{
XFA_Element
::Extras, 1, {}},
19
};
20
21
const
CXFA_Node
::
AttributeData
kStippleAttributeData[] = {
22
{
XFA_Attribute
::Id,
XFA_AttributeType
::
CData
,
nullptr
},
23
{
XFA_Attribute
::Use,
XFA_AttributeType
::
CData
,
nullptr
},
24
{
XFA_Attribute
::Rate,
XFA_AttributeType
::
Integer
, (
void
*)50},
25
{
XFA_Attribute
::Usehref,
XFA_AttributeType
::
CData
,
nullptr
},
26
};
27
28
}
// namespace
29
30
CXFA_Stipple::CXFA_Stipple(CXFA_Document* doc,
XFA_PacketType
packet)
31
: CXFA_Node(doc,
32
packet,
33
{XFA_XDPPACKET::kTemplate, XFA_XDPPACKET::kForm},
34
XFA_ObjectType::Node,
35
XFA_Element::Stipple,
36
kStipplePropertyData,
37
kStippleAttributeData,
38
cppgc::MakeGarbageCollected<CJX_Node>(
39
doc->GetHeap()->GetAllocationHandle(),
40
this
)) {}
41
42
CXFA_Stipple::~
CXFA_Stipple
() =
default
;
43
44
CXFA_Color* CXFA_Stipple::GetColorIfExists() {
45
return
GetChild<CXFA_Color>(0,
XFA_Element
::Color,
false
);
46
}
47
48
int32_t CXFA_Stipple::GetRate() {
49
return
JSObject()
50
->TryInteger(
XFA_Attribute
::Rate,
true
)
51
.value_or(
GetDefaultRate
(
)
);
52
}
53
54
void
CXFA_Stipple::
Draw
(
CFGAS_GEGraphics
* pGS,
55
const
CFGAS_GEPath& fillPath,
56
const
CFX_RectF
& rtFill,
57
const
CFX_Matrix
& matrix) {
58
int32_t iRate = GetRate();
59
if
(iRate == 0)
60
iRate = 100;
61
62
CXFA_Color* pColor = GetColorIfExists();
63
FX_ARGB
crColor = pColor ? pColor
->
GetValue
(
)
: CXFA_Color
::
kBlackColor
;
64
65
auto
[alpha, colorref] = ArgbToAlphaAndColorRef(crColor);
66
FX_ARGB
cr = AlphaAndColorRefToArgb(iRate * alpha / 100, colorref);
67
68
CFGAS_GEGraphics
::
StateRestorer
restorer
(
pGS
)
;
69
pGS
->
SetFillColor
(
CFGAS_GEColor
(
cr
)
)
;
70
pGS
->
FillPath
(
fillPath
,
CFX_FillRenderOptions
::
FillType
::
kWinding
,
matrix
)
;
71
}
CFGAS_GEColor
Definition
cfgas_gecolor.h:19
CFGAS_GEColor::CFGAS_GEColor
CFGAS_GEColor(FX_ARGB argb)
Definition
cfgas_gecolor.cpp:9
CFGAS_GEGraphics::StateRestorer
Definition
cfgas_gegraphics.h:28
CFGAS_GEGraphics::StateRestorer::StateRestorer
StateRestorer(CFGAS_GEGraphics *graphics)
Definition
cfgas_gegraphics.cpp:421
CFGAS_GEGraphics
Definition
cfgas_gegraphics.h:26
CFGAS_GEGraphics::FillPath
void FillPath(const CFGAS_GEPath &path, CFX_FillRenderOptions::FillType fill_type, const CFX_Matrix &matrix)
Definition
cfgas_gegraphics.cpp:178
CFGAS_GEGraphics::SetFillColor
void SetFillColor(const CFGAS_GEColor &color)
Definition
cfgas_gegraphics.cpp:169
CFX_Matrix
Definition
fx_coordinates.h:440
CFX_RectF
Definition
fx_coordinates.h:276
CXFA_Color::GetValue
FX_ARGB GetValue() const
Definition
cxfa_color.cpp:101
CXFA_Color::kBlackColor
static constexpr FX_ARGB kBlackColor
Definition
cxfa_color.h:15
CXFA_Node
Definition
cxfa_node.h:94
CXFA_Stipple::~CXFA_Stipple
~CXFA_Stipple() override
CXFA_Stipple::Draw
void Draw(CFGAS_GEGraphics *pGS, const CFGAS_GEPath &fillPath, const CFX_RectF &rtFill, const CFX_Matrix &matrix)
Definition
cxfa_stipple.cpp:54
CXFA_Stipple::GetDefaultRate
static int32_t GetDefaultRate()
Definition
cxfa_stipple.h:19
FX_ARGB
uint32_t FX_ARGB
Definition
fx_dib.h:36
XFA_AttributeType
XFA_AttributeType
Definition
fxfa_basic.h:83
XFA_AttributeType::Integer
@ Integer
Definition
fxfa_basic.h:87
XFA_AttributeType::CData
@ CData
Definition
fxfa_basic.h:85
XFA_Attribute
XFA_Attribute
Definition
fxfa_basic.h:67
XFA_Element
XFA_Element
Definition
fxfa_basic.h:75
XFA_PacketType
XFA_PacketType
Definition
fxfa_basic.h:44
CFX_FillRenderOptions
Definition
cfx_fillrenderoptions.h:11
CFX_FillRenderOptions::FillType
FillType
Definition
cfx_fillrenderoptions.h:13
CFX_FillRenderOptions::FillType::kWinding
@ kWinding
Definition
cfx_fillrenderoptions.h:23
CXFA_Node::AttributeData
Definition
cxfa_node.h:110
CXFA_Node::PropertyData
Definition
cxfa_node.h:96
qtwebengine
src
3rdparty
chromium
third_party
pdfium
xfa
fxfa
parser
cxfa_stipple.cpp
Generated on
for Qt by
1.18.0