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
cfx_windowsrenderdevice_embeddertest.cpp
Go to the documentation of this file.
1
// Copyright 2019 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
#
include
"core/fxge/cfx_windowsrenderdevice.h"
6
7
#
include
<
windows
.
h
>
8
9
#
include
<
memory
>
10
11
#
include
"core/fxge/cfx_fillrenderoptions.h"
12
#
include
"core/fxge/cfx_path.h"
13
#
include
"core/fxge/win32/cfx_psfonttracker.h"
14
#
include
"testing/embedder_test.h"
15
#
include
"testing/gtest/include/gtest/gtest.h"
16
17
namespace
{
18
19
constexpr
CFX_Matrix
kIdentityMatrix;
20
21
}
// namespace
22
23
class
CFX_WindowsRenderDeviceTest
:
public
EmbedderTest
{
24
public
:
25
void
SetUp
()
override
{
26
EmbedderTest
::
SetUp
();
27
28
// Get a device context with Windows GDI.
29
m_hDC = CreateCompatibleDC(
nullptr
);
30
ASSERT_TRUE(m_hDC);
31
m_driver = std::make_unique<CFX_WindowsRenderDevice>(
32
m_hDC, &m_PSFontTracker,
/*encoder_iface=*/
nullptr
);
33
m_driver->SaveState();
34
}
35
36
void
TearDown
()
override
{
37
m_driver->RestoreState(
false
);
38
m_driver.reset();
39
DeleteDC(m_hDC);
40
EmbedderTest
::
TearDown
();
41
}
42
43
protected
:
44
HDC
m_hDC
;
45
CFX_PSFontTracker
m_PSFontTracker
;
46
std
::
unique_ptr
<
CFX_WindowsRenderDevice
>
m_driver
;
47
};
48
49
TEST_F
(
CFX_WindowsRenderDeviceTest
,
SimpleClipTriangle
) {
50
CFX_Path
path_data;
51
CFX_PointF
p1(0.0f, 0.0f);
52
CFX_PointF
p2(0.0f, 100.0f);
53
CFX_PointF
p3(100.0f, 100.0f);
54
55
path_data
.
AppendLine
(
p1
,
p2
)
;
56
path_data
.
AppendLine
(
p2
,
p3
)
;
57
path_data
.
AppendLine
(
p3
,
p1
)
;
58
path_data
.
ClosePath
(
)
;
59
EXPECT_TRUE(m_driver->SetClip_PathFill(
60
path_data, &kIdentityMatrix, CFX_FillRenderOptions::WindingOptions()));
61
}
62
63
TEST_F
(
CFX_WindowsRenderDeviceTest
,
SimpleClipRect
) {
64
CFX_Path
path_data;
65
66
path_data
.
AppendRect
(
0.0f
,
100.0f
,
200.0f
,
0.0f
)
;
67
path_data
.
ClosePath
(
)
;
68
EXPECT_TRUE(m_driver->SetClip_PathFill(
69
path_data, &kIdentityMatrix, CFX_FillRenderOptions::WindingOptions()));
70
}
71
72
TEST_F
(
CFX_WindowsRenderDeviceTest
,
GargantuanClipRect
) {
73
CFX_Path
path_data;
74
75
path_data
.
AppendRect
(
-257698020.0f
,
-257697252.0f
,
257698044.0f
,
76
257698812.0f
)
;
77
path_data
.
ClosePath
(
)
;
78
// These coordinates for a clip path are valid, just very large. Using these
79
// for a clip path should allow IntersectClipRect() to return success;
80
// however they do not because the GDI API IntersectClipRect() errors out and
81
// affect subsequent imaging. crbug.com/1019026
82
EXPECT_FALSE(m_driver->SetClip_PathFill(
83
path_data, &kIdentityMatrix, CFX_FillRenderOptions::WindingOptions()));
84
}
85
86
TEST_F
(
CFX_WindowsRenderDeviceTest
,
GargantuanClipRectWithBaseClip
) {
87
CFX_Path
path_data;
88
const
FX_RECT
kBaseClip
(
0
,
0
,
5100
,
6600
)
;
89
90
m_driver->SetBaseClip(kBaseClip);
91
path_data
.
AppendRect
(
-257698020.0f
,
-257697252.0f
,
257698044.0f
,
92
257698812.0f
)
;
93
path_data
.
ClosePath
(
)
;
94
// Use of a reasonable base clip ensures that we avoid getting an error back
95
// from GDI API IntersectClipRect().
96
EXPECT_TRUE(m_driver->SetClip_PathFill(
97
path_data, &kIdentityMatrix, CFX_FillRenderOptions::WindingOptions()));
98
}
TEST_F
TEST_F(CFX_WindowsRenderDeviceTest, SimpleClipTriangle)
Definition
cfx_windowsrenderdevice_embeddertest.cpp:49
CFX_Matrix
Definition
fx_coordinates.h:440
CFX_PSFontTracker
Definition
cfx_psfonttracker.h:17
CFX_Path
Definition
cfx_path.h:18
CFX_Path::AppendRect
void AppendRect(float left, float bottom, float right, float top)
Definition
cfx_path.cpp:310
CFX_Path::AppendLine
void AppendLine(const CFX_PointF &pt1, const CFX_PointF &pt2)
Definition
cfx_path.cpp:298
CFX_Path::ClosePath
void ClosePath()
Definition
cfx_path.cpp:270
CFX_WindowsRenderDeviceTest
Definition
cfx_windowsrenderdevice_embeddertest.cpp:23
CFX_WindowsRenderDeviceTest::SetUp
void SetUp() override
Definition
cfx_windowsrenderdevice_embeddertest.cpp:25
CFX_WindowsRenderDeviceTest::m_PSFontTracker
CFX_PSFontTracker m_PSFontTracker
Definition
cfx_windowsrenderdevice_embeddertest.cpp:45
CFX_WindowsRenderDeviceTest::TearDown
void TearDown() override
Definition
cfx_windowsrenderdevice_embeddertest.cpp:36
CFX_WindowsRenderDeviceTest::m_hDC
HDC m_hDC
Definition
cfx_windowsrenderdevice_embeddertest.cpp:44
CFX_WindowsRenderDeviceTest::m_driver
std::unique_ptr< CFX_WindowsRenderDevice > m_driver
Definition
cfx_windowsrenderdevice_embeddertest.cpp:46
EmbedderTest
Definition
embedder_test.h:40
EmbedderTest::SetUp
void SetUp() override
Definition
embedder_test.cpp:276
EmbedderTest::TearDown
void TearDown() override
Definition
embedder_test.cpp:284
CFX_PointF
CFX_PTemplate< float > CFX_PointF
Definition
fx_coordinates.h:51
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
fxge
cfx_windowsrenderdevice_embeddertest.cpp
Generated on
for Qt by
1.18.0