summaryrefslogtreecommitdiff
path: root/core/fxge/ge/cfx_cliprgn.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-28 09:31:32 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-28 16:42:55 +0000
commitf0799fe84df4d86f25d342b03525f3016d674f86 (patch)
treed6839802a68b7b6ad6fb166179ede779c3560c75 /core/fxge/ge/cfx_cliprgn.cpp
parent31b08d4cdaa17d7a03f35e087096a77036af98ec (diff)
downloadpdfium-f0799fe84df4d86f25d342b03525f3016d674f86.tar.xz
Revert "Revert "Refcount all CFX_DIBSources (and subclasses) all the time.""
This reverts commit 31b08d4cdaa17d7a03f35e087096a77036af98ec. Re-landing the patch after fixing skia build issue. Change-Id: Ie7039890088b803a6ec5ce365d70f57277459b48 Reviewed-on: https://pdfium-review.googlesource.com/3245 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxge/ge/cfx_cliprgn.cpp')
-rw-r--r--core/fxge/ge/cfx_cliprgn.cpp43
1 files changed, 21 insertions, 22 deletions
diff --git a/core/fxge/ge/cfx_cliprgn.cpp b/core/fxge/ge/cfx_cliprgn.cpp
index ea3eb51f18..5193ce2944 100644
--- a/core/fxge/ge/cfx_cliprgn.cpp
+++ b/core/fxge/ge/cfx_cliprgn.cpp
@@ -6,6 +6,8 @@
#include "core/fxge/ge/cfx_cliprgn.h"
+#include <utility>
+
CFX_ClipRgn::CFX_ClipRgn(int width, int height)
: m_Type(RectI), m_Box(0, 0, width, height) {}
@@ -20,7 +22,7 @@ CFX_ClipRgn::~CFX_ClipRgn() {}
void CFX_ClipRgn::Reset(const FX_RECT& rect) {
m_Type = RectI;
m_Box = rect;
- m_Mask.SetNull();
+ m_Mask = nullptr;
}
void CFX_ClipRgn::IntersectRect(const FX_RECT& rect) {
@@ -36,8 +38,7 @@ void CFX_ClipRgn::IntersectRect(const FX_RECT& rect) {
void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect,
FX_RECT mask_rect,
- CFX_DIBitmapRef Mask) {
- const CFX_DIBitmap* mask_dib = Mask.GetObject();
+ const CFX_RetainPtr<CFX_DIBitmap>& pMask) {
m_Type = MaskF;
m_Box = rect;
m_Box.Intersect(mask_rect);
@@ -46,28 +47,29 @@ void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect,
return;
}
if (m_Box == mask_rect) {
- m_Mask = Mask;
+ m_Mask = pMask;
return;
}
- CFX_DIBitmap* new_dib = m_Mask.Emplace();
- new_dib->Create(m_Box.Width(), m_Box.Height(), FXDIB_8bppMask);
+ m_Mask = pdfium::MakeRetain<CFX_DIBitmap>();
+ m_Mask->Create(m_Box.Width(), m_Box.Height(), FXDIB_8bppMask);
for (int row = m_Box.top; row < m_Box.bottom; row++) {
uint8_t* dest_scan =
- new_dib->GetBuffer() + new_dib->GetPitch() * (row - m_Box.top);
+ m_Mask->GetBuffer() + m_Mask->GetPitch() * (row - m_Box.top);
uint8_t* src_scan =
- mask_dib->GetBuffer() + mask_dib->GetPitch() * (row - mask_rect.top);
+ pMask->GetBuffer() + pMask->GetPitch() * (row - mask_rect.top);
for (int col = m_Box.left; col < m_Box.right; col++)
dest_scan[col - m_Box.left] = src_scan[col - mask_rect.left];
}
}
-void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) {
- const CFX_DIBitmap* mask_dib = Mask.GetObject();
- ASSERT(mask_dib->GetFormat() == FXDIB_8bppMask);
- FX_RECT mask_box(left, top, left + mask_dib->GetWidth(),
- top + mask_dib->GetHeight());
+void CFX_ClipRgn::IntersectMaskF(int left,
+ int top,
+ const CFX_RetainPtr<CFX_DIBitmap>& pMask) {
+ ASSERT(pMask->GetFormat() == FXDIB_8bppMask);
+ FX_RECT mask_box(left, top, left + pMask->GetWidth(),
+ top + pMask->GetHeight());
if (m_Type == RectI) {
- IntersectMaskRect(m_Box, mask_box, Mask);
+ IntersectMaskRect(m_Box, mask_box, pMask);
return;
}
if (m_Type == MaskF) {
@@ -75,19 +77,16 @@ void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) {
new_box.Intersect(mask_box);
if (new_box.IsEmpty()) {
m_Type = RectI;
- m_Mask.SetNull();
+ m_Mask = nullptr;
m_Box = new_box;
return;
}
- CFX_DIBitmapRef new_mask;
- CFX_DIBitmap* new_dib = new_mask.Emplace();
+ auto new_dib = pdfium::MakeRetain<CFX_DIBitmap>();
new_dib->Create(new_box.Width(), new_box.Height(), FXDIB_8bppMask);
- const CFX_DIBitmap* old_dib = m_Mask.GetObject();
for (int row = new_box.top; row < new_box.bottom; row++) {
uint8_t* old_scan =
- old_dib->GetBuffer() + (row - m_Box.top) * old_dib->GetPitch();
- uint8_t* mask_scan =
- mask_dib->GetBuffer() + (row - top) * mask_dib->GetPitch();
+ m_Mask->GetBuffer() + (row - m_Box.top) * m_Mask->GetPitch();
+ uint8_t* mask_scan = pMask->GetBuffer() + (row - top) * pMask->GetPitch();
uint8_t* new_scan =
new_dib->GetBuffer() + (row - new_box.top) * new_dib->GetPitch();
for (int col = new_box.left; col < new_box.right; col++) {
@@ -96,7 +95,7 @@ void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) {
}
}
m_Box = new_box;
- m_Mask = new_mask;
+ m_Mask = std::move(new_dib);
return;
}
ASSERT(false);