summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-04-10 17:55:46 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-10 17:55:46 +0000
commit85ba2610cf05a75b52681f381bba2da3ba37b984 (patch)
treedcf1553a49ca032eaadab986fdc12f1fcf893b59 /core
parent537115b5a3ceccfe8ce2ca79577b61c5ec31c432 (diff)
downloadpdfium-85ba2610cf05a75b52681f381bba2da3ba37b984.tar.xz
Change FillRectWithBlend methods to take FX_RECT by const-ref.
They currently take const FX_RECT*, but the pointer is never nullptr. Also add a comment to explain why FX_RECT is the way it is. It has the same layout as a win32 RECT. Change-Id: Icf0e4c3eb25fe03317590a736578e053b9dccf7a Reviewed-on: https://pdfium-review.googlesource.com/30051 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fxcrt/fx_coordinates.h1
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp5
-rw-r--r--core/fxge/agg/fx_agg_driver.h2
-rw-r--r--core/fxge/cfx_renderdevice.cpp16
-rw-r--r--core/fxge/cfx_renderdevice.h4
-rw-r--r--core/fxge/renderdevicedriver_iface.cpp2
-rw-r--r--core/fxge/renderdevicedriver_iface.h2
-rw-r--r--core/fxge/skia/fx_skia_device.cpp11
-rw-r--r--core/fxge/skia/fx_skia_device.h2
-rw-r--r--core/fxge/win32/fx_win32_device.cpp5
-rw-r--r--core/fxge/win32/win32_int.h2
11 files changed, 26 insertions, 26 deletions
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index 2e8c1abca3..a458fa8b50 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -178,6 +178,7 @@ using CFX_VectorF = CFX_VTemplate<float>;
// TODO(tsepez): Consolidate all these different rectangle classes.
// LTRB rectangles (y-axis runs downwards).
+// Struct layout is compatible with win32 RECT.
struct FX_RECT {
FX_RECT() : left(0), top(0), right(0), bottom(0) {}
FX_RECT(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {}
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 9d8d8fa0a1..ab6ee49c7e 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -1407,7 +1407,7 @@ bool CFX_AggDeviceDriver::SetPixel(int x, int y, uint32_t color) {
return DibSetPixel(m_pBitmap, x, y, color);
}
-bool CFX_AggDeviceDriver::FillRectWithBlend(const FX_RECT* pRect,
+bool CFX_AggDeviceDriver::FillRectWithBlend(const FX_RECT& rect,
uint32_t fill_color,
int blend_type) {
if (blend_type != FXDIB_BLEND_NORMAL)
@@ -1419,8 +1419,7 @@ bool CFX_AggDeviceDriver::FillRectWithBlend(const FX_RECT* pRect,
FX_RECT clip_rect;
GetClipBox(&clip_rect);
FX_RECT draw_rect = clip_rect;
- if (pRect)
- draw_rect.Intersect(*pRect);
+ draw_rect.Intersect(rect);
if (draw_rect.IsEmpty())
return true;
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index adea810a67..4e94a00b63 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -59,7 +59,7 @@ class CFX_AggDeviceDriver : public RenderDeviceDriverIface {
int fill_mode,
int blend_type) override;
bool SetPixel(int x, int y, uint32_t color) override;
- bool FillRectWithBlend(const FX_RECT* pRect,
+ bool FillRectWithBlend(const FX_RECT& rect,
uint32_t fill_color,
int blend_type) override;
bool GetClipBox(FX_RECT* pRect) override;
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index 2fd48d2c80..a479517d0e 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -564,7 +564,7 @@ bool CFX_RenderDevice::DrawPathWithBlend(const CFX_PathData* pPathData,
--rect_i.bottom;
}
}
- if (FillRectWithBlend(&rect_i, fill_color, blend_type))
+ if (FillRectWithBlend(rect_i, fill_color, blend_type))
return true;
}
}
@@ -664,28 +664,28 @@ bool CFX_RenderDevice::DrawFillStrokePath(const CFX_PathData* pPathData,
FXDIB_BLEND_NORMAL);
}
-bool CFX_RenderDevice::FillRectWithBlend(const FX_RECT* pRect,
+bool CFX_RenderDevice::FillRectWithBlend(const FX_RECT& rect,
uint32_t fill_color,
int blend_type) {
- if (m_pDeviceDriver->FillRectWithBlend(pRect, fill_color, blend_type))
+ if (m_pDeviceDriver->FillRectWithBlend(rect, fill_color, blend_type))
return true;
if (!(m_RenderCaps & FXRC_GET_BITS))
return false;
auto bitmap = pdfium::MakeRetain<CFX_DIBitmap>();
- if (!CreateCompatibleBitmap(bitmap, pRect->Width(), pRect->Height()))
+ if (!CreateCompatibleBitmap(bitmap, rect.Width(), rect.Height()))
return false;
- if (!m_pDeviceDriver->GetDIBits(bitmap, pRect->left, pRect->top))
+ if (!m_pDeviceDriver->GetDIBits(bitmap, rect.left, rect.top))
return false;
- if (!bitmap->CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color,
+ if (!bitmap->CompositeRect(0, 0, rect.Width(), rect.Height(), fill_color,
0)) {
return false;
}
- FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height());
- m_pDeviceDriver->SetDIBits(bitmap, 0, &src_rect, pRect->left, pRect->top,
+ FX_RECT src_rect(0, 0, rect.Width(), rect.Height());
+ m_pDeviceDriver->SetDIBits(bitmap, 0, &src_rect, rect.left, rect.top,
FXDIB_BLEND_NORMAL);
return true;
}
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index 124e5e9995..6c91d55140 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -145,7 +145,7 @@ class CFX_RenderDevice {
int fill_mode,
int blend_type);
bool FillRect(const FX_RECT* pRect, uint32_t color) {
- return FillRectWithBlend(pRect, color, FXDIB_BLEND_NORMAL);
+ return FillRectWithBlend(*pRect, color, FXDIB_BLEND_NORMAL);
}
RetainPtr<CFX_DIBitmap> GetBackDrop();
@@ -290,7 +290,7 @@ class CFX_RenderDevice {
uint32_t color,
int fill_mode,
int blend_type);
- bool FillRectWithBlend(const FX_RECT* pRect, uint32_t color, int blend_type);
+ bool FillRectWithBlend(const FX_RECT& rect, uint32_t color, int blend_type);
RetainPtr<CFX_DIBitmap> m_pBitmap;
int m_Width;
diff --git a/core/fxge/renderdevicedriver_iface.cpp b/core/fxge/renderdevicedriver_iface.cpp
index b4d7fb0d2c..7023e021bd 100644
--- a/core/fxge/renderdevicedriver_iface.cpp
+++ b/core/fxge/renderdevicedriver_iface.cpp
@@ -29,7 +29,7 @@ bool RenderDeviceDriverIface::SetPixel(int x, int y, uint32_t color) {
return false;
}
-bool RenderDeviceDriverIface::FillRectWithBlend(const FX_RECT* pRect,
+bool RenderDeviceDriverIface::FillRectWithBlend(const FX_RECT& rect,
uint32_t fill_color,
int blend_type) {
return false;
diff --git a/core/fxge/renderdevicedriver_iface.h b/core/fxge/renderdevicedriver_iface.h
index 2d255f6e24..a0c148d117 100644
--- a/core/fxge/renderdevicedriver_iface.h
+++ b/core/fxge/renderdevicedriver_iface.h
@@ -50,7 +50,7 @@ class RenderDeviceDriverIface {
int fill_mode,
int blend_type) = 0;
virtual bool SetPixel(int x, int y, uint32_t color);
- virtual bool FillRectWithBlend(const FX_RECT* pRect,
+ virtual bool FillRectWithBlend(const FX_RECT& rect,
uint32_t fill_color,
int blend_type);
virtual bool DrawCosmeticLine(const CFX_PointF& ptMoveTo,
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 190ad9e80c..598dc480c2 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -1960,7 +1960,7 @@ bool CFX_SkiaDeviceDriver::DrawCosmeticLine(const CFX_PointF& ptMoveTo,
return false;
}
-bool CFX_SkiaDeviceDriver::FillRectWithBlend(const FX_RECT* pRect,
+bool CFX_SkiaDeviceDriver::FillRectWithBlend(const FX_RECT& rect,
uint32_t fill_color,
int blend_type) {
m_pCache->FlushForDraw();
@@ -1968,11 +1968,10 @@ bool CFX_SkiaDeviceDriver::FillRectWithBlend(const FX_RECT* pRect,
spaint.setAntiAlias(true);
spaint.setColor(fill_color);
spaint.setBlendMode(GetSkiaBlendMode(blend_type));
- SkRect rect =
- SkRect::MakeLTRB(pRect->left, SkTMin(pRect->top, pRect->bottom),
- pRect->right, SkTMax(pRect->bottom, pRect->top));
- DebugShowSkiaDrawRect(this, m_pCanvas, spaint, rect);
- m_pCanvas->drawRect(rect, spaint);
+ SkRect srect = SkRect::MakeLTRB(rect.left, SkTMin(rect.top, rect.bottom),
+ rect.right, SkTMax(rect.bottom, rect.top));
+ DebugShowSkiaDrawRect(this, m_pCanvas, spaint, srect);
+ m_pCanvas->drawRect(srect, spaint);
return true;
}
diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h
index e545f9cd47..8fdd4fd03f 100644
--- a/core/fxge/skia/fx_skia_device.h
+++ b/core/fxge/skia/fx_skia_device.h
@@ -64,7 +64,7 @@ class CFX_SkiaDeviceDriver : public RenderDeviceDriverIface {
int fill_mode,
int blend_type) override;
- bool FillRectWithBlend(const FX_RECT* pRect,
+ bool FillRectWithBlend(const FX_RECT& rect,
uint32_t fill_color,
int blend_type) override;
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index b857dde91b..337f9643d1 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -1061,7 +1061,7 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData,
return true;
}
-bool CGdiDeviceDriver::FillRectWithBlend(const FX_RECT* pRect,
+bool CGdiDeviceDriver::FillRectWithBlend(const FX_RECT& rect,
uint32_t fill_color,
int blend_type) {
if (blend_type != FXDIB_BLEND_NORMAL)
@@ -1077,7 +1077,8 @@ bool CGdiDeviceDriver::FillRectWithBlend(const FX_RECT* pRect,
return false;
HBRUSH hBrush = CreateSolidBrush(colorref);
- ::FillRect(m_hDC, (RECT*)pRect, hBrush);
+ const RECT* pRect = reinterpret_cast<const RECT*>(&rect);
+ ::FillRect(m_hDC, pRect, hBrush);
DeleteObject(hBrush);
return true;
}
diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h
index 34d307c2cd..b248522f0a 100644
--- a/core/fxge/win32/win32_int.h
+++ b/core/fxge/win32/win32_int.h
@@ -151,7 +151,7 @@ class CGdiDeviceDriver : public RenderDeviceDriverIface {
uint32_t stroke_color,
int fill_mode,
int blend_type) override;
- bool FillRectWithBlend(const FX_RECT* pRect,
+ bool FillRectWithBlend(const FX_RECT& rect,
uint32_t fill_color,
int blend_type) override;
bool DrawCosmeticLine(const CFX_PointF& ptMoveTo,