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::kArgb,
19 /*pBackdropBitmap=*/nullptr));
20
21 EXPECT_EQ(FX_RECT(0, 0, 16, 16), device.GetClipBox());
22}
23
25 // Matrix that transposes and translates by 1 unit on each axis.
26 const CFX_Matrix object_to_device(0, 1, 1, 0, 1, -1);
27
28 // Fill type cannot be none.
29 const CFX_FillRenderOptions fill_options(
31
32 CFX_DefaultRenderDevice device;
33 ASSERT_TRUE(device.Create(/*width=*/16, /*height=*/16, FXDIB_Format::kArgb,
34 /*pBackdropBitmap=*/nullptr));
35
36 CFX_Path path;
37 path.AppendRect(2, 4, 14, 12);
38 EXPECT_TRUE(device.SetClip_PathFill(path, &object_to_device, fill_options));
39
40 EXPECT_EQ(FX_RECT(5, 1, 13, 13), device.GetClipBox());
41}
42
44 // Matrix that transposes and translates by 1 unit on each axis.
45 const CFX_Matrix object_to_device(0, 1, 1, 0, 1, -1);
46
47 // Default line width is 1.
48 const CFX_GraphStateData graphics_state;
49
50 CFX_DefaultRenderDevice device;
51 ASSERT_TRUE(device.Create(/*width=*/16, /*height=*/16, FXDIB_Format::kArgb,
52 /*pBackdropBitmap=*/nullptr));
53
54 CFX_Path path;
55 path.AppendRect(2, 4, 14, 12);
56 EXPECT_TRUE(
57 device.SetClip_PathStroke(path, &object_to_device, &graphics_state));
58
59 EXPECT_EQ(FX_RECT(4, 0, 14, 14), device.GetClipBox());
60}
61
63 CFX_DefaultRenderDevice device;
64 ASSERT_TRUE(device.Create(/*width=*/16, /*height=*/16, FXDIB_Format::kArgb,
65 /*pBackdropBitmap=*/nullptr));
66
67 EXPECT_TRUE(device.SetClip_Rect({2, 4, 14, 12}));
68
69 EXPECT_EQ(FX_RECT(2, 4, 14, 12), device.GetClipBox());
70}
71
73 CFX_DefaultRenderDevice device;
74 ASSERT_TRUE(device.Create(/*width=*/16, /*height=*/16, FXDIB_Format::kArgb,
75 /*pBackdropBitmap=*/nullptr));
76
77 EXPECT_TRUE(device.SetClip_Rect({2, 8, 14, 8}));
78
79 EXPECT_TRUE(device.GetClipBox().IsEmpty());
80}
bool Create(int width, int height, FXDIB_Format format, RetainPtr< CFX_DIBitmap > pBackdropBitmap)
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:309
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:19
constexpr CFX_FillRenderOptions(FillType fill_type)
constexpr FX_RECT(int l, int t, int r, int b)