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_agg_cliprgn.cpp
Go to the documentation of this file.
1
// Copyright 2016 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
"core/fxge/agg/cfx_agg_cliprgn.h"
8
9
#
include
<
stdint
.
h
>
10
11
#
include
<
utility
>
12
13
#
include
"core/fxcrt/check_op.h"
14
#
include
"core/fxcrt/notreached.h"
15
#
include
"core/fxcrt/stl_util.h"
16
#
include
"core/fxge/dib/cfx_dibitmap.h"
17
18
CFX_AggClipRgn
::
CFX_AggClipRgn
(
int
width,
int
height)
19
: m_Box
(
0
,
0
,
width
,
height
)
{}
20
21
CFX_AggClipRgn
::
CFX_AggClipRgn
(
const
CFX_AggClipRgn
& src) =
default
;
22
23
CFX_AggClipRgn
::~
CFX_AggClipRgn
() =
default
;
24
25
void
CFX_AggClipRgn
::
IntersectRect
(
const
FX_RECT
& rect) {
26
if
(m_Type ==
kRectI
) {
27
m_Box
.
Intersect
(
rect
)
;
28
return
;
29
}
30
IntersectMaskRect(rect, m_Box, m_Mask);
31
}
32
33
void
CFX_AggClipRgn
::IntersectMaskRect(
FX_RECT
rect,
34
FX_RECT
mask_rect,
35
RetainPtr
<CFX_DIBitmap> pOldMask) {
36
m_Type =
kMaskF
;
37
m_Box
=
rect;
38
m_Box
.
Intersect
(
mask_rect
)
;
39
if
(m_Box
.
IsEmpty
(
)
) {
40
m_Type =
kRectI
;
41
return
;
42
}
43
if
(m_Box
==
mask_rect) {
44
m_Mask = std::move(pOldMask);
45
return
;
46
}
47
m_Mask = pdfium::MakeRetain<CFX_DIBitmap>();
48
CHECK
(m_Mask->Create(m_Box.Width(), m_Box.Height(), FXDIB_Format::k8bppMask));
49
const
int
offset = m_Box
.
left
- mask_rect
.
left
;
50
for
(
int
row = m_Box
.
top
; row < m_Box
.
bottom
; row++) {
51
pdfium::span<uint8_t> dest_scan =
52
m_Mask->GetWritableScanline(row - m_Box.top);
53
pdfium::span<
const
uint8_t> src_scan =
54
pOldMask->GetScanline(row - mask_rect
.
top
);
55
fxcrt
::Copy(src_scan.subspan(offset, m_Box
.
Width
(
)
), dest_scan);
56
}
57
}
58
59
void
CFX_AggClipRgn
::
IntersectMaskF
(
int
left,
60
int
top,
61
RetainPtr
<CFX_DIBitmap> pMask) {
62
FX_RECT
mask_box(left, top, left + pMask->GetWidth(),
63
top + pMask->GetHeight());
64
if
(!mask_box
.
IsEmpty
(
)
) {
65
// Make sure non-empty masks have the right format. If the mask is empty,
66
// then the format does not matter as it will not get used.
67
CHECK_EQ
(pMask->GetFormat(),
FXDIB_Format
::
k8bppMask
);
68
}
69
if
(m_Type ==
kRectI
) {
70
IntersectMaskRect(m_Box, mask_box,
std
::move(pMask));
71
return
;
72
}
73
74
FX_RECT
new_box = m_Box;
75
new_box
.
Intersect
(
mask_box
)
;
76
if
(new_box
.
IsEmpty
(
)
) {
77
m_Type =
kRectI
;
78
m_Mask =
nullptr
;
79
m_Box
=
new_box;
80
return
;
81
}
82
auto
new_dib =
pdfium
::MakeRetain<CFX_DIBitmap>();
83
CHECK
(new_dib->Create(new_box
.
Width
(
)
, new_box
.
Height
(
)
,
84
FXDIB_Format
::
k8bppMask
));
85
for
(
int
row = new_box
.
top
; row < new_box
.
bottom
; row++) {
86
pdfium::span<
const
uint8_t> old_scan = m_Mask->GetScanline(row - m_Box.top);
87
pdfium::span<
const
uint8_t> mask_scan = pMask->GetScanline(row - top);
88
auto
new_scan = new_dib->GetWritableScanline(row - new_box
.
top
);
89
for
(
int
col = new_box
.
left
; col < new_box
.
right
; col++) {
90
new_scan[col - new_box
.
left
] =
91
old_scan[col - m_Box
.
left
] * mask_scan[col - left] / 255;
92
}
93
}
94
m_Box
=
new_box;
95
m_Mask = std::move(new_dib);
96
}
CHECK_EQ
#define CHECK_EQ(x, y)
Definition
check_op.h:10
CFX_AggClipRgn
Definition
cfx_agg_cliprgn.h:15
CFX_AggClipRgn::CFX_AggClipRgn
CFX_AggClipRgn(const CFX_AggClipRgn &src)
CFX_AggClipRgn::IntersectRect
void IntersectRect(const FX_RECT &rect)
Definition
cfx_agg_cliprgn.cpp:25
CFX_AggClipRgn::kMaskF
@ kMaskF
Definition
cfx_agg_cliprgn.h:17
CFX_AggClipRgn::kRectI
@ kRectI
Definition
cfx_agg_cliprgn.h:17
CFX_AggClipRgn::CFX_AggClipRgn
CFX_AggClipRgn(int device_width, int device_height)
Definition
cfx_agg_cliprgn.cpp:18
CFX_AggClipRgn::IntersectMaskF
void IntersectMaskF(int left, int top, RetainPtr< CFX_DIBitmap > Mask)
Definition
cfx_agg_cliprgn.cpp:59
CFX_AggClipRgn::~CFX_AggClipRgn
~CFX_AggClipRgn()
fxcrt::RetainPtr
Definition
retain_ptr.h:28
pdfium::CFDETextOutLargeBitmapTest
Definition
cfde_textout_unittest.cpp:117
FXDIB_Format
FXDIB_Format
Definition
fx_dib.h:21
FXDIB_Format::k8bppMask
@ k8bppMask
Definition
fx_dib.h:28
fxcrt
Definition
stl_util.h:17
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
CHECK
#define CHECK(cvref)
Definition
q23utility.cpp:15
FX_RECT
Definition
fx_coordinates.h:144
FX_RECT::operator=
FX_RECT & operator=(const FX_RECT &that)=default
FX_RECT::Height
int Height() const
Definition
fx_coordinates.h:152
FX_RECT::bottom
int32_t bottom
Definition
fx_coordinates.h:181
FX_RECT::operator==
bool operator==(const FX_RECT &src) const
Definition
fx_coordinates.h:169
FX_RECT::right
int32_t right
Definition
fx_coordinates.h:180
FX_RECT::Width
int Width() const
Definition
fx_coordinates.h:151
FX_RECT::top
int32_t top
Definition
fx_coordinates.h:179
FX_RECT::left
int32_t left
Definition
fx_coordinates.h:178
FX_RECT::Intersect
void Intersect(const FX_RECT &src)
Definition
fx_coordinates.cpp:93
FX_RECT::IsEmpty
bool IsEmpty() const
Definition
fx_coordinates.h:153
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
agg
cfx_agg_cliprgn.cpp
Generated on
for Qt by
1.18.0