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_defaultrenderdevice_unittest.cpp
Go to the documentation of this file.
1// Copyright 2023 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_defaultrenderdevice.h"
6
7#include "core/fxcrt/fx_coordinates.h"
8#include "core/fxcrt/retain_ptr.h"
9#include "core/fxge/cfx_fillrenderoptions.h"
10#include "core/fxge/cfx_graphstatedata.h"
11#include "core/fxge/cfx_path.h"
12#include "core/fxge/dib/cfx_dibitmap.h"
13#include "core/fxge/dib/fx_dib.h"
14#include "testing/gtest/include/gtest/gtest.h"
15
17 CFX_DefaultRenderDevice device;
18 ASSERT_TRUE(device.Create(/*width=*/16, /*height=*/16, FXDIB_Format::kBgra));
19
20 EXPECT_EQ(FX_RECT(0, 0, 16, 16), device.GetClipBox());
21}
22
24 // Matrix that transposes and translates by 1 unit on each axis.
25 const CFX_Matrix object_to_device(0, 1, 1, 0, 1, -1);
26
27 // Fill type cannot be none.
28 const CFX_FillRenderOptions fill_options(
30
31 CFX_DefaultRenderDevice device;
32 ASSERT_TRUE(device.Create(/*width=*/16, /*height=*/16, FXDIB_Format::kBgra));
33
34 CFX_Path path;
35 path.AppendRect(2, 4, 14, 12);
36 EXPECT_TRUE(device.SetClip_PathFill(path, &object_to_device, fill_options));
37
38 EXPECT_EQ(FX_RECT(5, 1, 13, 13), device.GetClipBox());
39}
40
42 // Matrix that transposes and translates by 1 unit on each axis.
43 const CFX_Matrix object_to_device(0, 1, 1, 0, 1, -1);
44
45 // Default line width is 1.
46 const CFX_GraphStateData graphics_state;
47
48 CFX_DefaultRenderDevice device;
49 ASSERT_TRUE(device.Create(/*width=*/16, /*height=*/16, FXDIB_Format::kBgra));
50
51 CFX_Path path;
52 path.AppendRect(2, 4, 14, 12);
53 EXPECT_TRUE(
54 device.SetClip_PathStroke(path, &object_to_device, &graphics_state));
55
56 EXPECT_EQ(FX_RECT(4, 0, 14, 14), device.GetClipBox());
57}
58
60 CFX_DefaultRenderDevice device;
61 ASSERT_TRUE(device.Create(/*width=*/16, /*height=*/16, FXDIB_Format::kBgra));
62
63 EXPECT_TRUE(device.SetClip_Rect({2, 4, 14, 12}));
64
65 EXPECT_EQ(FX_RECT(2, 4, 14, 12), device.GetClipBox());
66}
67
69 CFX_DefaultRenderDevice device;
70 ASSERT_TRUE(device.Create(/*width=*/16, /*height=*/16, FXDIB_Format::kBgra));
71
72 EXPECT_TRUE(device.SetClip_Rect({2, 8, 14, 8}));
73
74 EXPECT_TRUE(device.GetClipBox().IsEmpty());
75}
bool Create(int width, int height, FXDIB_Format format)
constexpr CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
void AppendRect(float left, float bottom, float right, float top)
Definition cfx_path.cpp:310
bool SetClip_Rect(const FX_RECT &pRect)
bool SetClip_PathFill(const CFX_Path &path, const CFX_Matrix *pObject2Device, const CFX_FillRenderOptions &fill_options)
bool SetClip_PathStroke(const CFX_Path &path, const CFX_Matrix *pObject2Device, const CFX_GraphStateData *pGraphState)
const FX_RECT & GetClipBox() const
TEST(FXCRYPT, MD5GenerateEmtpyData)
FXDIB_Format
Definition fx_dib.h:21
constexpr CFX_FillRenderOptions(FillType fill_type)
constexpr FX_RECT(int l, int t, int r, int b)