summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-10-31 21:30:27 +0100
committerLuboš Luňák <l.lunak@collabora.com>2019-11-27 09:55:14 +0100
commit29e6baf034cbb241461dd7a74a50eb05b1661d36 (patch)
tree259fd0ef709ddb0e2c3a2eb7dca543a408f23155 /vcl
parent2b2b63db94ef2fedeba6d6ebb9e829e429a62dbd (diff)
skia: add common function to check the input SalTwoRects
function is checkInvalidSourceOrDestination Change-Id: Id3b5dc69a3949f01b5335a9bdf0ce0ad165adab1
Diffstat (limited to 'vcl')
-rw-r--r--vcl/skia/gdiimpl.cxx23
1 files changed, 11 insertions, 12 deletions
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 0ab8be2f98cf..d0c2c1a08058 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -133,6 +133,14 @@ Color fromSkColor(SkColor color)
return Color(255 - SkColorGetA(color), SkColorGetR(color), SkColorGetG(color),
SkColorGetB(color));
}
+
+// returns true if the source or destination rectangles are invalid
+bool checkInvalidSourceOrDestination(SalTwoRect const& rPosAry)
+{
+ return rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0
+ || rPosAry.mnDestHeight <= 0;
+}
+
} // end anonymous namespace
// Class that triggers flushing the backing buffer when idle.
@@ -642,11 +650,8 @@ void SkiaSalGraphicsImpl::copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcG
bool SkiaSalGraphicsImpl::blendBitmap(const SalTwoRect& rPosAry, const SalBitmap& rBitmap)
{
- if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0
- || rPosAry.mnDestHeight <= 0)
- {
+ if (checkInvalidSourceOrDestination(rPosAry))
return false;
- }
assert(dynamic_cast<const SkiaSalBitmap*>(&rBitmap));
@@ -661,11 +666,8 @@ bool SkiaSalGraphicsImpl::blendAlphaBitmap(const SalTwoRect& rPosAry,
const SalBitmap& rMaskBitmap,
const SalBitmap& rAlphaBitmap)
{
- if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0
- || rPosAry.mnDestHeight <= 0)
- {
+ if (checkInvalidSourceOrDestination(rPosAry))
return false;
- }
assert(dynamic_cast<const SkiaSalBitmap*>(&rSrcBitmap));
assert(dynamic_cast<const SkiaSalBitmap*>(&rMaskBitmap));
@@ -701,11 +703,8 @@ bool SkiaSalGraphicsImpl::blendAlphaBitmap(const SalTwoRect& rPosAry,
void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap)
{
- if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0
- || rPosAry.mnDestHeight <= 0)
- {
+ if (checkInvalidSourceOrDestination(rPosAry))
return;
- }
assert(dynamic_cast<const SkiaSalBitmap*>(&rSalBitmap));
const SkiaSalBitmap& rSkiaSourceBitmap = static_cast<const SkiaSalBitmap&>(rSalBitmap);