[Libreoffice-commits] core.git: include/vcl svx/source vcl/Library_vcl.mk vcl/source
Chris Sherlock (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jan 8 07:25:29 UTC 2021
include/vcl/BitmapShadowFilter.hxx | 31 ++++++++++++++++++++
include/vcl/outdev.hxx | 3 -
svx/source/svdraw/svdoashp.cxx | 6 ++-
vcl/Library_vcl.mk | 3 +
vcl/source/bitmap/BitmapShadowFilter.cxx | 48 +++++++++++++++++++++++++++++++
vcl/source/outdev/bitmap.cxx | 24 ---------------
6 files changed, 85 insertions(+), 30 deletions(-)
New commits:
commit c8d564094ecb6e82ed924217651a8f88ce5039c8
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Sat Dec 26 11:26:37 2020 +1100
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jan 8 08:24:42 2021 +0100
vcl: migrate OutputDevice::DrawShadowBitmapEx() to BitmapShadowFilter
Change-Id: I5d8b92d91530feed92dcdf2e384448b05eebdb0f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108315
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/vcl/BitmapShadowFilter.hxx b/include/vcl/BitmapShadowFilter.hxx
new file mode 100644
index 000000000000..d4a3207a13b1
--- /dev/null
+++ b/include/vcl/BitmapShadowFilter.hxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <vcl/BitmapFilter.hxx>
+
+/** If the alpha is beyond a certain threshold, make it fully transparent
+ */
+class VCL_DLLPUBLIC BitmapShadowFilter final : public BitmapFilter
+{
+public:
+ BitmapShadowFilter(Color aShadowColor)
+ : maShadowColor(aShadowColor)
+ {
+ }
+
+ virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override;
+
+private:
+ Color maShadowColor;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index b909875a380f..d2e21fb0324c 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1482,9 +1482,6 @@ public:
const basegfx::B2DHomMatrix& rTransformation,
const BitmapEx& rBitmapEx);
- void DrawShadowBitmapEx(
- const BitmapEx& rBitmapEx,
- ::Color aShadowColor);
protected:
virtual void DrawDeviceBitmap(
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 835d4f139caf..fbe2b0a6b948 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <vcl/BitmapShadowFilter.hxx>
#include <svx/svdoashp.hxx>
#include <svx/unoapi.hxx>
#include <com/sun/star/loader/CannotActivateFactoryException.hpp>
@@ -346,13 +347,14 @@ static SdrObject* ImpCreateShadowObjectClone(const SdrObject& rOriginal, const S
if(bBitmapFillUsed)
{
GraphicObject aGraphicObject(rOriginalSet.Get(XATTR_FILLBITMAP).GetGraphicObject());
- const BitmapEx aBitmapEx(aGraphicObject.GetGraphic().GetBitmapEx());
+ BitmapEx aBitmapEx(aGraphicObject.GetGraphic().GetBitmapEx());
if(!aBitmapEx.IsEmpty())
{
ScopedVclPtr<VirtualDevice> pVirDev(VclPtr<VirtualDevice>::Create());
pVirDev->SetOutputSizePixel(aBitmapEx.GetSizePixel());
- pVirDev->DrawShadowBitmapEx(aBitmapEx, aShadowColor);
+ BitmapFilter::Filter(aBitmapEx, BitmapShadowFilter(aShadowColor));
+ pVirDev->DrawBitmapEx(Point(), aBitmapEx);
aGraphicObject.SetGraphic(Graphic(pVirDev->GetBitmapEx(Point(0,0), aBitmapEx.GetSizePixel())));
}
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index e222b72b574a..d937fceb0a69 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -345,6 +345,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/bitmap/dibtools \
vcl/source/bitmap/bmpfast \
vcl/source/bitmap/bitmapfilter \
+ vcl/source/bitmap/bitmappaint \
+ vcl/source/bitmap/BitmapShadowFilter \
vcl/source/bitmap/BitmapAlphaClampFilter \
vcl/source/bitmap/BitmapBasicMorphologyFilter \
vcl/source/bitmap/BitmapMonochromeFilter \
@@ -352,7 +354,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/bitmap/BitmapLightenFilter \
vcl/source/bitmap/BitmapDisabledImageFilter \
vcl/source/bitmap/BitmapColorizeFilter \
- vcl/source/bitmap/bitmappaint \
vcl/source/bitmap/BitmapGaussianSeparableBlurFilter \
vcl/source/bitmap/BitmapSobelGreyFilter \
vcl/source/bitmap/BitmapSolarizeFilter \
diff --git a/vcl/source/bitmap/BitmapShadowFilter.cxx b/vcl/source/bitmap/BitmapShadowFilter.cxx
new file mode 100644
index 000000000000..64c7ff470297
--- /dev/null
+++ b/vcl/source/bitmap/BitmapShadowFilter.cxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <vcl/bitmapex.hxx>
+#include <vcl/BitmapColor.hxx>
+#include <vcl/BitmapShadowFilter.hxx>
+
+#include <bitmapwriteaccess.hxx>
+
+BitmapEx BitmapShadowFilter::execute(BitmapEx const& rBitmapEx) const
+{
+ BitmapEx aBitmapEx(rBitmapEx);
+ BitmapScopedWriteAccess pWriteAccess(const_cast<Bitmap&>(aBitmapEx.GetBitmap()));
+
+ if (!pWriteAccess)
+ return rBitmapEx;
+
+ for (tools::Long y(0); y < pWriteAccess->Height(); y++)
+ {
+ Scanline pScanline = pWriteAccess->GetScanline(y);
+
+ for (tools::Long x(0); x < pWriteAccess->Width(); x++)
+ {
+ const BitmapColor aColor = pWriteAccess->GetColor(y, x);
+ sal_uInt16 nLuminance(static_cast<sal_uInt16>(aColor.GetLuminance()) + 1);
+ const BitmapColor aDestColor(
+ static_cast<sal_uInt8>(
+ (nLuminance * static_cast<sal_uInt16>(maShadowColor.GetRed())) >> 8),
+ static_cast<sal_uInt8>(
+ (nLuminance * static_cast<sal_uInt16>(maShadowColor.GetGreen())) >> 8),
+ static_cast<sal_uInt8>(
+ (nLuminance * static_cast<sal_uInt16>(maShadowColor.GetBlue())) >> 8));
+
+ pWriteAccess->SetPixelOnData(pScanline, x, aDestColor);
+ }
+ }
+
+ return aBitmapEx;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index a7e2bcb89b3d..88056ebb0a14 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -1446,30 +1446,6 @@ void OutputDevice::DrawTransformedBitmapEx(
DrawBitmapEx(aDestPt, aDestSize, aTransformed);
}
-void OutputDevice::DrawShadowBitmapEx(
- const BitmapEx& rBitmapEx,
- ::Color aShadowColor)
-{
- Bitmap::ScopedReadAccess pReadAccess(const_cast<Bitmap&>(rBitmapEx.maBitmap));
-
- if(!pReadAccess)
- return;
-
- for(tools::Long y(0); y < pReadAccess->Height(); y++)
- {
- for(tools::Long x(0); x < pReadAccess->Width(); x++)
- {
- const BitmapColor aColor = pReadAccess->GetColor(y, x);
- sal_uInt16 nLuminance(static_cast<sal_uInt16>(aColor.GetLuminance()) + 1);
- const Color aDestColor(
- static_cast<sal_uInt8>((nLuminance * static_cast<sal_uInt16>(aShadowColor.GetRed())) >> 8),
- static_cast<sal_uInt8>((nLuminance * static_cast<sal_uInt16>(aShadowColor.GetGreen())) >> 8),
- static_cast<sal_uInt8>((nLuminance * static_cast<sal_uInt16>(aShadowColor.GetBlue())) >> 8));
- DrawPixel(Point(x,y), aDestColor);
- }
- }
-}
-
void OutputDevice::DrawImage( const Point& rPos, const Image& rImage, DrawImageFlags nStyle )
{
assert(!is_double_buffered_window());
More information about the Libreoffice-commits
mailing list