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_radial.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_radial.h"
8
9
#
include
<
math
.
h
>
10
11
#
include
<
utility
>
12
13
#
include
"fxjs/xfa/cjx_node.h"
14
#
include
"xfa/fgas/graphics/cfgas_gegraphics.h"
15
#
include
"xfa/fgas/graphics/cfgas_geshading.h"
16
#
include
"xfa/fxfa/parser/cxfa_color.h"
17
#
include
"xfa/fxfa/parser/cxfa_document.h"
18
19
namespace
{
20
21
const
CXFA_Node
::
PropertyData
kRadialPropertyData[] = {
22
{
XFA_Element
::Color, 1, {}},
23
{
XFA_Element
::Extras, 1, {}},
24
};
25
26
const
CXFA_Node
::
AttributeData
kRadialAttributeData[] = {
27
{
XFA_Attribute
::Id,
XFA_AttributeType
::
CData
,
nullptr
},
28
{
XFA_Attribute
::Use,
XFA_AttributeType
::
CData
,
nullptr
},
29
{
XFA_Attribute
::Type,
XFA_AttributeType
::
Enum
,
30
(
void
*)
XFA_AttributeValue
::ToEdge},
31
{
XFA_Attribute
::Usehref,
XFA_AttributeType
::
CData
,
nullptr
},
32
};
33
34
}
// namespace
35
36
CXFA_Radial::CXFA_Radial(CXFA_Document* doc,
XFA_PacketType
packet)
37
: CXFA_Node(doc,
38
packet,
39
{XFA_XDPPACKET::kTemplate, XFA_XDPPACKET::kForm},
40
XFA_ObjectType::Node,
41
XFA_Element::Radial,
42
kRadialPropertyData,
43
kRadialAttributeData,
44
cppgc::MakeGarbageCollected<CJX_Node>(
45
doc->GetHeap()->GetAllocationHandle(),
46
this
)) {}
47
48
CXFA_Radial::~
CXFA_Radial
() =
default
;
49
50
bool
CXFA_Radial::IsToEdge() {
51
auto
value = JSObject()->TryEnum(
XFA_Attribute
::Type,
true
);
52
return
!value.has_value() || value.value() ==
XFA_AttributeValue
::ToEdge;
53
}
54
55
CXFA_Color* CXFA_Radial::GetColorIfExists() {
56
return
GetChild<CXFA_Color>(0,
XFA_Element
::Color,
false
);
57
}
58
59
void
CXFA_Radial::
Draw
(
CFGAS_GEGraphics
* pGS,
60
const
CFGAS_GEPath& fillPath,
61
FX_ARGB
crStart,
62
const
CFX_RectF
& rtFill,
63
const
CFX_Matrix
& matrix) {
64
CXFA_Color* pColor = GetColorIfExists();
65
FX_ARGB
crEnd = pColor ? pColor
->
GetValue
(
)
: CXFA_Color
::
kBlackColor
;
66
if
(!IsToEdge())
67
std
::swap(crStart, crEnd);
68
69
float
end_radius = hypotf(rtFill
.
Width
(
)
, rtFill
.
Height
(
)
) / 2;
70
CFGAS_GEShading shading(rtFill.Center(), rtFill.Center(), 0, end_radius,
true
,
71
true
, crStart, crEnd);
72
73
CFGAS_GEGraphics
::
StateRestorer
restorer
(
pGS
)
;
74
pGS
->
SetFillColor
(
CFGAS_GEColor
(
&shading
)
)
;
75
pGS
->
FillPath
(
fillPath
,
CFX_FillRenderOptions
::
FillType
::
kWinding
,
matrix
)
;
76
}
CFGAS_GEColor
Definition
cfgas_gecolor.h:19
CFGAS_GEColor::CFGAS_GEColor
CFGAS_GEColor(CFGAS_GEShading *shading)
Definition
cfgas_gecolor.cpp:14
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
CFX_RectF::Width
float Width() const
Definition
fx_coordinates.h:384
CFX_RectF::Height
float Height() const
Definition
fx_coordinates.h:385
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_Radial::Draw
void Draw(CFGAS_GEGraphics *pGS, const CFGAS_GEPath &fillPath, FX_ARGB crStart, const CFX_RectF &rtFill, const CFX_Matrix &matrix)
Definition
cxfa_radial.cpp:59
CXFA_Radial::~CXFA_Radial
~CXFA_Radial() override
FX_ARGB
uint32_t FX_ARGB
Definition
fx_dib.h:36
XFA_AttributeType
XFA_AttributeType
Definition
fxfa_basic.h:83
XFA_AttributeType::Enum
@ Enum
Definition
fxfa_basic.h:84
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_AttributeValue
XFA_AttributeValue
Definition
fxfa_basic.h:60
XFA_PacketType
XFA_PacketType
Definition
fxfa_basic.h:44
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
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_radial.cpp
Generated on
for Qt by
1.18.0