[Libreoffice-commits] core.git: include/vcl vcl/qa vcl/source

Chris Sherlock (via logerrit) logerrit at kemper.freedesktop.org
Thu May 14 08:14:18 UTC 2020


 include/vcl/gdimtf.hxx         |    2 +
 include/vcl/metaact.hxx        |   10 +++++++
 vcl/qa/cppunit/svm/svmtest.cxx |    1 
 vcl/source/gdi/gdimtf.cxx      |   25 ++++++++++++++++++
 vcl/source/gdi/print2.cxx      |   54 ++---------------------------------------
 5 files changed, 41 insertions(+), 51 deletions(-)

New commits:
commit 6da4777b647157aa7ed65e271778bb00373098a0
Author:     Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Mon May 11 07:28:22 2020 +1000
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu May 14 10:13:23 2020 +0200

    vcl: move transparency checks into MetaAction and GDIMetaFile
    
    I want to remove the final bits of meOutDevType but need to refactor
    the function OutputDevice::RemoveTransparenciesFromMetaFile(). This
    is the start.
    
    Change-Id: I7c5330540fb396f033b40831b24028c7bfec4832
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93940
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx
index 661caf863a22..3727f6531eff 100644
--- a/include/vcl/gdimtf.hxx
+++ b/include/vcl/gdimtf.hxx
@@ -118,6 +118,8 @@ public:
     void            Scale( const Fraction& rScaleX, const Fraction& rScaleY );
     void            Rotate( long nAngle10 );
     void            Clip( const tools::Rectangle& );
+    bool            HasTransparentActions() const;
+
     /* get the bound rect of the contained actions
      * caveats:
      * - clip actions will limit the contained actions,
diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx
index 92592bd209dc..fad89ec4b838 100644
--- a/include/vcl/metaact.hxx
+++ b/include/vcl/metaact.hxx
@@ -88,6 +88,10 @@ public:
     virtual void        Read( SvStream& rIStm, ImplMetaReadData* pData );
 
     MetaActionType      GetType() const { return mnType; }
+    /** \#i10613# Extracted from Printer::GetPreparedMetaFile. Returns true
+        if given action requires special transparency handling
+    */
+    virtual bool        IsTransparent() const { return false; }
 
 public:
     static MetaAction*  ReadMetaAction( SvStream& rIStm, ImplMetaReadData* pData );
@@ -768,6 +772,7 @@ public:
 
     const BitmapEx&     GetBitmapEx() const { return maBmpEx; }
     const Point&        GetPoint() const { return maPt; }
+    bool                IsTransparent() const override { return GetBitmapEx().IsTransparent(); }
 };
 
 class VCL_DLLPUBLIC MetaBmpExScaleAction final : public MetaAction
@@ -801,6 +806,7 @@ public:
     const BitmapEx&     GetBitmapEx() const { return maBmpEx; }
     const Point&        GetPoint() const { return maPt; }
     const Size&         GetSize() const { return maSz; }
+    bool                IsTransparent() const override { return GetBitmapEx().IsTransparent(); }
 };
 
 class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaBmpExScalePartAction final : public MetaAction
@@ -839,6 +845,7 @@ public:
     const Size&         GetDestSize() const { return maDstSz; }
     const Point&        GetSrcPoint() const { return maSrcPt; }
     const Size&         GetSrcSize() const { return maSrcSz; }
+    bool                IsTransparent() const override { return GetBitmapEx().IsTransparent(); }
 };
 
 class SAL_DLLPUBLIC_RTTI MetaMaskAction final : public MetaAction
@@ -1523,6 +1530,8 @@ public:
 
     const tools::PolyPolygon&  GetPolyPolygon() const { return maPolyPoly; }
     sal_uInt16              GetTransparence() const { return mnTransPercent; }
+
+    bool                IsTransparent() const override { return true; }
 };
 
 class SAL_DLLPUBLIC_RTTI MetaFloatTransparentAction final : public MetaAction
@@ -1558,6 +1567,7 @@ public:
     const Point&        GetPoint() const { return maPoint; }
     const Size&         GetSize() const { return maSize; }
     const Gradient&     GetGradient() const { return maGradient; }
+    bool                IsTransparent() const override { return true; }
 };
 
 class VCL_DLLPUBLIC MetaEPSAction final : public MetaAction
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index 9f2629960cf5..413c3b7f69f4 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -1654,6 +1654,7 @@ void SvmTest::testTransparent()
 
     pVirtualDev->DrawTransparent(aPolygon, 50);
 
+    CPPUNIT_ASSERT(aGDIMetaFile.HasTransparentActions());
     checkTransparent(writeAndReadStream(aGDIMetaFile));
     checkTransparent(readFile("transparent.svm"));
 }
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 2353af9e0d39..46a145750609 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -154,6 +154,31 @@ GDIMetaFile::~GDIMetaFile()
     Clear();
 }
 
+bool GDIMetaFile::HasTransparentActions() const
+{
+    MetaAction* pCurrAct;
+
+    // watch for transparent drawing actions
+    for(pCurrAct = const_cast<GDIMetaFile*>(this)->FirstAction();
+        pCurrAct;
+        pCurrAct = const_cast<GDIMetaFile*>(this)->NextAction())
+    {
+        // #i10613# determine if the action is transparency capable
+
+        // #107169# Also examine metafiles with masked bitmaps in
+        // detail. Further down, this is optimized in such a way
+        // that there's no unnecessary painting of masked bitmaps
+        // (which are _always_ subdivided into rectangular regions
+        // of uniform opacity): if a masked bitmap is printed over
+        // empty background, we convert to a plain bitmap with
+        // white background.
+        if (pCurrAct->IsTransparent())
+            return true;
+    }
+
+    return false;
+}
+
 size_t GDIMetaFile::GetActionSize() const
 {
     return m_aList.size();
diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx
index 927e40131f21..d60ba034742c 100644
--- a/vcl/source/gdi/print2.cxx
+++ b/vcl/source/gdi/print2.cxx
@@ -63,34 +63,6 @@ struct ConnectedComponents
 
 namespace {
 
-/** \#i10613# Extracted from Printer::GetPreparedMetaFile. Returns true
-    if given action requires special transparency handling
-*/
-bool IsTransparentAction( const MetaAction& rAct )
-{
-    switch( rAct.GetType() )
-    {
-        case MetaActionType::Transparent:
-            return true;
-
-        case MetaActionType::FLOATTRANSPARENT:
-            return true;
-
-        case MetaActionType::BMPEX:
-            return static_cast<const MetaBmpExAction&>(rAct).GetBitmapEx().IsTransparent();
-
-        case MetaActionType::BMPEXSCALE:
-            return static_cast<const MetaBmpExScaleAction&>(rAct).GetBitmapEx().IsTransparent();
-
-        case MetaActionType::BMPEXSCALEPART:
-            return static_cast<const MetaBmpExScalePartAction&>(rAct).GetBitmapEx().IsTransparent();
-
-        default:
-            return false;
-    }
-}
-
-
 /** Determines whether the action can handle transparency correctly
   (i.e. when painted on white background, does the action still look
   correct)?
@@ -657,28 +629,8 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
 
     rOutMtf.Clear();
 
-    if( ! bReduceTransparency || bTransparencyAutoMode )
-    {
-        // watch for transparent drawing actions
-        for( pCurrAct = const_cast<GDIMetaFile&>(rInMtf).FirstAction();
-             pCurrAct && !bTransparent;
-             pCurrAct = const_cast<GDIMetaFile&>(rInMtf).NextAction() )
-        {
-            // #i10613# determine if the action is transparency capable
-
-            // #107169# Also examine metafiles with masked bitmaps in
-            // detail. Further down, this is optimized in such a way
-            // that there's no unnecessary painting of masked bitmaps
-            // (which are _always_ subdivided into rectangular regions
-            // of uniform opacity): if a masked bitmap is printed over
-            // empty background, we convert to a plain bitmap with
-            // white background.
-            if( IsTransparentAction( *pCurrAct ) )
-            {
-                bTransparent = true;
-            }
-        }
-    }
+    if(!bReduceTransparency || bTransparencyAutoMode)
+        bTransparent = rInMtf.HasTransparentActions();
 
     // #i10613# Determine set of connected components containing transparent objects. These are
     // then processed as bitmaps, the original actions are removed from the metafile.
@@ -991,7 +943,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
                 // prev component(s) special -> this one, too
                 aTotalComponents.bIsSpecial = true;
             }
-            else if( !IsTransparentAction( *pCurrAct ) )
+            else if(!pCurrAct->IsTransparent())
             {
                 // added action and none of prev components special ->
                 // this one normal, too


More information about the Libreoffice-commits mailing list