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
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
17namespace {
18
19constexpr CFX_Matrix kIdentityMatrix;
20
21} // namespace
22
24 public:
25 void SetUp() override {
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
37 m_driver->RestoreState(false);
38 m_driver.reset();
39 DeleteDC(m_hDC);
41 }
42
43 protected:
47};
48
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
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
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
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(CFX_WindowsRenderDeviceTest, SimpleClipTriangle)
void AppendRect(float left, float bottom, float right, float top)
Definition cfx_path.cpp:309
void AppendLine(const CFX_PointF &pt1, const CFX_PointF &pt2)
Definition cfx_path.cpp:297
void ClosePath()
Definition cfx_path.cpp:269
std::unique_ptr< CFX_WindowsRenderDevice > m_driver
void SetUp() override
void TearDown() override
constexpr FX_RECT(int l, int t, int r, int b)