[Libreoffice-commits] core.git: drawinglayer/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 15 05:21:41 UTC 2020


 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |   79 ++++++++--------
 drawinglayer/source/processor2d/vclpixelprocessor2d.hxx |    2 
 2 files changed, 44 insertions(+), 37 deletions(-)

New commits:
commit eae4bd69727bcdb15b9951061fd997f48ddf0ea4
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Apr 12 13:30:56 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Apr 15 07:21:04 2020 +0200

    move GlowPrimitive processing in VclPixelProcessor to own method
    
    The new method is processGlowPrimitive.
    
    Change-Id: I3e7eb9fc5ac45095dd0f6c3bff7d036e05864d89
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92224
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 9102230f4305..e94637a9a7fe 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -40,6 +40,7 @@
 #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
 #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
+#include <drawinglayer/primitive2d/glowprimitive2d.hxx>
 #include <primitive2d/pointarrayprimitive2d.hxx>
 #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
 #include <drawinglayer/primitive2d/controlprimitive2d.hxx>
@@ -356,43 +357,7 @@ namespace drawinglayer::processor2d
                 }
                 case PRIMITIVE2D_ID_GLOWPRIMITIVE2D:
                 {
-                    basegfx::B2DRange aRange(rCandidate.getB2DRange(getViewInformation2D()));
-                    aRange.transform(maCurrentTransformation);
-                    aRange.grow(10.0);
-                    impBufferDevice aBufferDevice(*mpOutputDevice, aRange);
-                    if(aBufferDevice.isVisible())
-                    {
-                        // remember last OutDev and set to content
-                        OutputDevice* pLastOutputDevice = mpOutputDevice;
-                        mpOutputDevice = &aBufferDevice.getTransparence();
-                        // paint content to virtual device
-                        mpOutputDevice->Erase();
-                        process(rCandidate);
-
-                        // obtain result as a bitmap
-                        auto bitmap = mpOutputDevice->GetBitmapEx(Point(aRange.getMinX(), aRange.getMinY()), Size(aRange.getWidth(), aRange.getHeight()));
-                        constexpr double nRadius = 5.0;
-                        bitmap.Scale(Size(aRange.getWidth()-nRadius, aRange.getHeight()-nRadius));
-                        // use bitmap later as mask
-                        auto mask = bitmap.GetBitmap();
-
-                        mpOutputDevice = &aBufferDevice.getContent();
-                        process(rCandidate);
-                        bitmap = mpOutputDevice->GetBitmapEx(Point(aRange.getMinX(), aRange.getMinY()), Size(aRange.getWidth(), aRange.getHeight()));
-                        bitmap.Scale(Size(aRange.getWidth()-nRadius, aRange.getHeight()-nRadius));
-
-                        // calculate blurry effect
-                        BitmapFilterStackBlur glowFilter(nRadius);
-                        BitmapFilter::Filter(bitmap, glowFilter);
-                        // back to old OutDev
-                        mpOutputDevice = pLastOutputDevice;
-                        mpOutputDevice->DrawBitmapEx(Point(aRange.getMinX()-nRadius/2, aRange.getMinY()-nRadius/2), BitmapEx(bitmap.GetBitmap(), mask));
-
-                        // paint result
-                        //aBufferDevice.paint();
-                    }
-                    else
-                        SAL_WARN("drawinglayer", "Temporary buffered virtual device is not visible");
+                    processGlowPrimitive2D(static_cast<const drawinglayer::primitive2d::GlowPrimitive2D&>(rCandidate));
                     break;
                 }
                 default :
@@ -880,6 +845,46 @@ namespace drawinglayer::processor2d
             }
         }
 
+        void VclPixelProcessor2D::processGlowPrimitive2D(const primitive2d::GlowPrimitive2D& rCandidate)
+        {
+            basegfx::B2DRange aRange(rCandidate.getB2DRange(getViewInformation2D()));
+            aRange.transform(maCurrentTransformation);
+            aRange.grow(10.0);
+            impBufferDevice aBufferDevice(*mpOutputDevice, aRange);
+            if (aBufferDevice.isVisible())
+            {
+                // remember last OutDev and set to content
+                OutputDevice* pLastOutputDevice = mpOutputDevice;
+                mpOutputDevice = &aBufferDevice.getTransparence();
+                // paint content to virtual device
+                mpOutputDevice->Erase();
+                process(rCandidate);
+
+                // obtain result as a bitmap
+                auto bitmap = mpOutputDevice->GetBitmapEx(Point(aRange.getMinX(), aRange.getMinY()), Size(aRange.getWidth(), aRange.getHeight()));
+                constexpr double nRadius = 5.0;
+                bitmap.Scale(Size(aRange.getWidth()-nRadius, aRange.getHeight()-nRadius));
+                // use bitmap later as mask
+                auto mask = bitmap.GetBitmap();
+
+                mpOutputDevice = &aBufferDevice.getContent();
+                process(rCandidate);
+                bitmap = mpOutputDevice->GetBitmapEx(Point(aRange.getMinX(), aRange.getMinY()), Size(aRange.getWidth(), aRange.getHeight()));
+                bitmap.Scale(Size(aRange.getWidth()-nRadius, aRange.getHeight()-nRadius));
+
+                // calculate blurry effect
+                BitmapFilterStackBlur glowFilter(nRadius);
+                BitmapFilter::Filter(bitmap, glowFilter);
+                // back to old OutDev
+                mpOutputDevice = pLastOutputDevice;
+                mpOutputDevice->DrawBitmapEx(Point(aRange.getMinX()-nRadius/2, aRange.getMinY()-nRadius/2), BitmapEx(bitmap.GetBitmap(), mask));
+
+                // paint result
+                //aBufferDevice.paint();
+            }
+            else
+                SAL_WARN("drawinglayer", "Temporary buffered virtual device is not visible");
+        }
 } // end of namespace
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx
index 5c834056c947..fd72efe41d16 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx
@@ -39,6 +39,7 @@ class PolygonStrokePrimitive2D;
 class FillHatchPrimitive2D;
 class BackgroundColorPrimitive2D;
 class BorderLinePrimitive2D;
+class GlowPrimitive2D;
 }
 
 namespace drawinglayer::processor2d
@@ -93,6 +94,7 @@ class VclPixelProcessor2D final : public VclProcessor2D
     processBorderLinePrimitive2D(const drawinglayer::primitive2d::BorderLinePrimitive2D& rBorder);
     void processInvertPrimitive2D(const primitive2d::BasePrimitive2D& rCandidate);
     void processMetaFilePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate);
+    void processGlowPrimitive2D(const primitive2d::GlowPrimitive2D& rCandidate);
 
 public:
     /// constructor/destructor


More information about the Libreoffice-commits mailing list