[Libreoffice-commits] core.git: canvas/source drawinglayer/source editeng/source filter/source include/vcl slideshow/source svx/source sw/source vcl/source

Noel (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 13 13:37:22 UTC 2021


 canvas/source/vcl/canvashelper.cxx                         |    4 ++--
 canvas/source/vcl/canvashelper_texturefill.cxx             |    4 ++--
 drawinglayer/source/primitive2d/graphicprimitive2d.cxx     |    6 +++---
 drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx |    2 +-
 editeng/source/items/frmitems.cxx                          |    2 +-
 filter/source/msfilter/escherex.cxx                        |    4 ++--
 include/vcl/GraphicAttributes.hxx                          |    8 ++++----
 slideshow/source/engine/shapes/shapeimporter.cxx           |    2 +-
 svx/source/sdr/contact/viewcontactofgraphic.cxx            |    4 ++--
 svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx          |    4 ++--
 svx/source/svdraw/svdograf.cxx                             |    2 +-
 sw/source/core/graphic/ndgrf.cxx                           |    2 +-
 sw/source/core/layout/paintfrm.cxx                         |    4 ++--
 sw/source/filter/ww8/wrtw8esh.cxx                          |    2 +-
 sw/source/filter/ww8/ww8graf.cxx                           |    2 +-
 vcl/source/graphic/GraphicObject.cxx                       |    2 +-
 vcl/source/graphic/grfattr.cxx                             |    4 ++--
 17 files changed, 29 insertions(+), 29 deletions(-)

New commits:
commit 502f6372aeb6689f3d61cea7a77b2e8db160d767
Author:     Noel <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jan 13 08:47:11 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jan 13 14:36:27 2021 +0100

    transparency->alpha in GraphicAttr
    
    Change-Id: I1fe9311871724ff8b7b8960f5dba6e890198565c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109211
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx
index c3d31557c09d..501741301d8e 100644
--- a/canvas/source/vcl/canvashelper.cxx
+++ b/canvas/source/vcl/canvashelper.cxx
@@ -752,9 +752,9 @@ namespace vclcanvas
                     // transOrig*transModulate (which would be
                     // equivalent to the origAlpha*modulateAlpha the
                     // DX canvas performs)
-                    aGrfAttr.SetTransparency(
+                    aGrfAttr.SetAlpha(
                         static_cast< sal_uInt8 >(
-                            ::basegfx::fround( 255.0*( 1.0 - nAlphaModulation ) ) ) );
+                            ::basegfx::fround( 255.0 * nAlphaModulation ) ) );
                 }
 
                 if( ::basegfx::fTools::equalZero( nShearX ) )
diff --git a/canvas/source/vcl/canvashelper_texturefill.cxx b/canvas/source/vcl/canvashelper_texturefill.cxx
index 857710acb102..c0ef516d4c0a 100644
--- a/canvas/source/vcl/canvashelper_texturefill.cxx
+++ b/canvas/source/vcl/canvashelper_texturefill.cxx
@@ -941,9 +941,9 @@ namespace vclcanvas
                             // transOrig*transModulate (which would be
                             // equivalent to the origAlpha*modulateAlpha
                             // the DX canvas performs)
-                            aGrfAttr.SetTransparency(
+                            aGrfAttr.SetAlpha(
                                 static_cast< sal_uInt8 >(
-                                    ::basegfx::fround( 255.0*( 1.0 - textures[0].Alpha ) ) ) );
+                                    ::basegfx::fround( 255.0 * textures[0].Alpha ) ) );
                         }
 
                         rOutDev.IntersectClipRegion( aPolygonDeviceRect );
diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
index 2f029914bf19..40549e6eface 100644
--- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
@@ -33,7 +33,7 @@ namespace drawinglayer::primitive2d
 void GraphicPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer,
                                                const geometry::ViewInformation2D&) const
 {
-    if (255 == getGraphicAttr().GetTransparency())
+    if (0 == getGraphicAttr().GetAlpha())
     {
         // content is invisible, done
         return;
@@ -70,7 +70,7 @@ void GraphicPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer,
     aSuppressGraphicAttr.SetCrop(0, 0, 0, 0);
     aSuppressGraphicAttr.SetRotation(0_deg10);
     aSuppressGraphicAttr.SetMirrorFlags(BmpMirrorFlags::NONE);
-    aSuppressGraphicAttr.SetTransparency(0);
+    aSuppressGraphicAttr.SetAlpha(255);
 
     const GraphicObject& rGraphicObject = getGraphicObject();
     Graphic aTransformedGraphic(rGraphicObject.GetGraphic());
@@ -134,7 +134,7 @@ void GraphicPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer,
     {
         // check for transparency
         const double fTransparency(
-            std::clamp(getGraphicAttr().GetTransparency() * (1.0 / 255.0), 0.0, 1.0));
+            std::clamp((255 - getGraphicAttr().GetAlpha()) * (1.0 / 255.0), 0.0, 1.0));
 
         if (!basegfx::fTools::equalZero(fTransparency))
         {
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index 8bf1d3977d79..dba886f1cc32 100644
--- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
@@ -1069,7 +1069,7 @@ void VclMetafileProcessor2D::processGraphicPrimitive2D(
     // object transformation, thus aCurrentRect *is* the clip region while aCropRect is the expanded,
     // uncropped region. Thus, correct order is aCropRect, aCurrentRect
     mpPDFExtOutDevData->EndGroup(rGraphicPrimitive.getGraphicObject().GetGraphic(),
-                                 rAttr.GetTransparency(), aCropRect, aCurrentRect);
+                                 255 - rAttr.GetAlpha(), aCropRect, aCurrentRect);
 }
 
 void VclMetafileProcessor2D::processControlPrimitive2D(
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index e90f2f9586a3..589bde044152 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -3311,7 +3311,7 @@ void SvxBrushItem::ApplyGraphicTransparency_Impl()
     if (xGraphicObject)
     {
         GraphicAttr aAttr(xGraphicObject->GetAttr());
-        aAttr.SetTransparency(lcl_PercentToTransparency(
+        aAttr.SetAlpha(255 - lcl_PercentToTransparency(
                             nGraphicTransparency));
         xGraphicObject->SetAttr(aAttr);
     }
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 1cc14d87ff83..5df267f3f954 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -1679,7 +1679,7 @@ bool EscherPropertyContainer::CreateGraphicProperties(const uno::Reference<beans
 
                 if(nTransparency)
                 {
-                    pGraphicAttr->SetTransparency((nTransparency * 255) / 100);
+                    pGraphicAttr->SetAlpha(255 - (nTransparency * 255) / 100);
                 }
 
                 if(nRed)
@@ -3935,7 +3935,7 @@ EscherBlibEntry::EscherBlibEntry( sal_uInt32 nPictureOffset, const GraphicObject
                .WriteInt16( pGraphicAttr->GetChannelB() )
                .WriteDouble( pGraphicAttr->GetGamma() );
             aSt.WriteBool( pGraphicAttr->IsInvert() )
-               .WriteUChar( pGraphicAttr->GetTransparency() );
+               .WriteUChar( 255 - pGraphicAttr->GetAlpha() ); // transparency
             mnIdentifier[ 1 ] = rtl_crc32( 0, aSt.GetData(), aSt.Tell() );
         }
         else
diff --git a/include/vcl/GraphicAttributes.hxx b/include/vcl/GraphicAttributes.hxx
index 4fca512956c6..480953982ede 100644
--- a/include/vcl/GraphicAttributes.hxx
+++ b/include/vcl/GraphicAttributes.hxx
@@ -47,7 +47,7 @@ private:
     short mnGPercent;
     short mnBPercent;
     bool mbInvert;
-    sal_uInt8 mcTransparency;
+    sal_uInt8 mcAlpha;
     GraphicDrawMode meDrawMode;
 
 public:
@@ -99,8 +99,8 @@ public:
     void SetInvert(bool bInvert) { mbInvert = bInvert; }
     bool IsInvert() const { return mbInvert; }
 
-    void SetTransparency(sal_uInt8 cTransparency) { mcTransparency = cTransparency; }
-    sal_uInt8 GetTransparency() const { return mcTransparency; }
+    void SetAlpha(sal_uInt8 cAlpha) { mcAlpha = cAlpha; }
+    sal_uInt8 GetAlpha() const { return mcAlpha; }
 
     bool IsSpecialDrawMode() const { return (meDrawMode != GraphicDrawMode::Standard); }
     bool IsMirrored() const { return mnMirrFlags != BmpMirrorFlags::NONE; }
@@ -109,7 +109,7 @@ public:
         return (mnLeftCrop != 0 || mnTopCrop != 0 || mnRightCrop != 0 || mnBottomCrop != 0);
     }
     bool IsRotated() const { return ((mnRotate10 % 3600_deg10) != 0_deg10); }
-    bool IsTransparent() const { return (mcTransparency > 0); }
+    bool IsTransparent() const { return (mcAlpha < 255); }
     bool IsAdjusted() const
     {
         return (mnLumPercent != 0 || mnContPercent != 0 || mnRPercent != 0 || mnGPercent != 0
diff --git a/slideshow/source/engine/shapes/shapeimporter.cxx b/slideshow/source/engine/shapes/shapeimporter.cxx
index 877f4217348a..d896caa559ae 100644
--- a/slideshow/source/engine/shapes/shapeimporter.cxx
+++ b/slideshow/source/engine/shapes/shapeimporter.cxx
@@ -295,7 +295,7 @@ ShapeSharedPtr ShapeImporter::createShape(
         aGraphAttrs.SetChannelG( nGreen );
         aGraphAttrs.SetChannelB( nBlue );
         aGraphAttrs.SetGamma( nGamma );
-        aGraphAttrs.SetTransparency( static_cast<sal_uInt8>(nTransparency) );
+        aGraphAttrs.SetAlpha( 255 - static_cast<sal_uInt8>(nTransparency) );
         aGraphAttrs.SetRotation( Degree10(static_cast<sal_Int16>(nRotation*10)) );
 
         text::GraphicCrop aGraphCrop;
diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx
index e2e0b452a296..7450b25be1a4 100644
--- a/svx/source/sdr/contact/viewcontactofgraphic.cxx
+++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx
@@ -296,13 +296,13 @@ namespace sdr::contact
             aLocalGrafInfo.SetChannelG(rItemSet.Get(SDRATTR_GRAFGREEN).GetValue());
             aLocalGrafInfo.SetChannelB(rItemSet.Get(SDRATTR_GRAFBLUE).GetValue());
             aLocalGrafInfo.SetGamma(rItemSet.Get(SDRATTR_GRAFGAMMA).GetValue() * 0.01);
-            aLocalGrafInfo.SetTransparency(static_cast<sal_uInt8>(::basegfx::fround(std::min(nTrans, sal_uInt16(100)) * 2.55)));
+            aLocalGrafInfo.SetAlpha(255 - static_cast<sal_uInt8>(::basegfx::fround(std::min(nTrans, sal_uInt16(100)) * 2.55)));
             aLocalGrafInfo.SetInvert(rItemSet.Get(SDRATTR_GRAFINVERT).GetValue());
             aLocalGrafInfo.SetDrawMode(rItemSet.Get(SDRATTR_GRAFMODE).GetValue());
             aLocalGrafInfo.SetCrop(rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom());
 
             // we have content if graphic is not completely transparent
-            const bool bHasContent(255L != aLocalGrafInfo.GetTransparency());
+            const bool bHasContent(0 != aLocalGrafInfo.GetAlpha());
             drawinglayer::attribute::SdrLineFillEffectsTextAttribute aAttribute(
                 drawinglayer::primitive2d::createNewSdrLineFillEffectsTextAttribute(
                     rItemSet,
diff --git a/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx
index 36f34106e1fd..b0683ad2fd9e 100644
--- a/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx
+++ b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx
@@ -46,7 +46,7 @@ void SdrGrafPrimitive2D::create2DDecomposition(
     }
 
     // add graphic content
-    if (255 != getGraphicAttr().GetTransparency())
+    if (0 != getGraphicAttr().GetAlpha())
     {
         // standard graphic fill
         const Primitive2DReference xGraphicContentPrimitive(
@@ -154,7 +154,7 @@ bool SdrGrafPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
 
 bool SdrGrafPrimitive2D::isTransparent() const
 {
-    return ((0 != getGraphicAttr().GetTransparency()) || (getGraphicObject().IsTransparent()));
+    return ((255 != getGraphicAttr().GetAlpha()) || (getGraphicObject().IsTransparent()));
 }
 
 // provide unique ID
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index e11d1b54528b..925b714cb5ff 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -1046,7 +1046,7 @@ void SdrGrafObj::ImpSetAttrToGrafInfo()
     aGrafInfo.SetChannelG( rSet.Get( SDRATTR_GRAFGREEN ).GetValue() );
     aGrafInfo.SetChannelB( rSet.Get( SDRATTR_GRAFBLUE ).GetValue() );
     aGrafInfo.SetGamma( rSet.Get( SDRATTR_GRAFGAMMA ).GetValue() * 0.01 );
-    aGrafInfo.SetTransparency( static_cast<sal_uInt8>(FRound( std::min( nTrans, sal_uInt16(100) )  * 2.55 )) );
+    aGrafInfo.SetAlpha( 255 - static_cast<sal_uInt8>(FRound( std::min( nTrans, sal_uInt16(100) )  * 2.55 )) );
     aGrafInfo.SetInvert( rSet.Get( SDRATTR_GRAFINVERT ).GetValue() );
     aGrafInfo.SetDrawMode( rSet.Get( SDRATTR_GRAFMODE ).GetValue() );
     aGrafInfo.SetCrop( rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom() );
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 19db918cc8ff..83e8a33a3527 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -792,7 +792,7 @@ GraphicAttr& SwGrfNode::GetGraphicAttr( GraphicAttr& rGA,
     rGA.SetInvert( rSet.GetInvertGrf().GetValue() );
 
     const sal_uInt16 nTrans = rSet.GetTransparencyGrf().GetValue();
-    rGA.SetTransparency( static_cast<sal_uInt8>(FRound(
+    rGA.SetAlpha( 255 - static_cast<sal_uInt8>(FRound(
                                 std::min( nTrans, sal_uInt16(100) )  * 2.55 )) );
 
     return rGA;
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index c1205226ea86..4167950415e1 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -1579,7 +1579,7 @@ static void lcl_implDrawGraphicBackgrd( const SvxBrushItem& _rBackgrdBrush,
     ///     "no fill"/"auto fill" --> draw transparent
     {
         bDrawTransparent = true;
-        nTransparencyPercent = (_rGraphicObj.GetAttr().GetTransparency()*100 + 0x7F)/0xFF;
+        nTransparencyPercent = 100 - (_rGraphicObj.GetAttr().GetAlpha() * 100 + 127) / 255;
     }
 
     if ( bDrawTransparent )
@@ -2008,7 +2008,7 @@ void DrawGraphic(
                    )
                 {
                     bTransparentGrfWithNoFillBackgrd = true;
-                    nGrfTransparency = aGrfAttr.GetTransparency();
+                    nGrfTransparency = 255 - aGrfAttr.GetAlpha();
                 }
             }
             if ( pGrf->IsTransparent() )
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 48bf34fc9881..fa1c5ea5c48f 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1854,7 +1854,7 @@ void SwBasicEscherEx::WriteBrushAttr(const SvxBrushItem &rBrush,
                 rPropOpt.AddOpt(ESCHER_Prop_fillBlip,nBlibId,true);
         }
 
-        nOpaque = pGraphicObject->GetAttr().GetTransparency();
+        nOpaque = 255 - pGraphicObject->GetAttr().GetAlpha();
         if (0 != nOpaque)
             bSetOpacity = true;
 
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index c04770c53f3c..674ca5649dca 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -1883,7 +1883,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj,
                     {
                         GraphicAttr aAttr(aGrfObj.GetAttr());
 
-                        aAttr.SetTransparency(nTrans);
+                        aAttr.SetAlpha(255 - nTrans);
                         aGrfObj.SetAttr(aAttr);
                     }
 
diff --git a/vcl/source/graphic/GraphicObject.cxx b/vcl/source/graphic/GraphicObject.cxx
index 95e80ffa8c35..b127b2d03c3d 100644
--- a/vcl/source/graphic/GraphicObject.cxx
+++ b/vcl/source/graphic/GraphicObject.cxx
@@ -178,7 +178,7 @@ void lclImplAdjust( BitmapEx& rBmpEx, const GraphicAttr& rAttr, GraphicAdjustmen
 
     if( ( nAdjustmentFlags & GraphicAdjustmentFlags::TRANSPARENCY ) && aAttr.IsTransparent() )
     {
-        rBmpEx.AdjustTransparency(aAttr.GetTransparency());
+        rBmpEx.AdjustTransparency(255 - aAttr.GetAlpha());
     }
 }
 
diff --git a/vcl/source/graphic/grfattr.cxx b/vcl/source/graphic/grfattr.cxx
index 35acaf50b841..586b15e16013 100644
--- a/vcl/source/graphic/grfattr.cxx
+++ b/vcl/source/graphic/grfattr.cxx
@@ -33,7 +33,7 @@ GraphicAttr::GraphicAttr() :
     mnGPercent      ( 0 ),
     mnBPercent      ( 0 ),
     mbInvert        ( false ),
-    mcTransparency  ( 0 ),
+    mcAlpha         ( 255 ),
     meDrawMode      ( GraphicDrawMode::Standard )
 {
 }
@@ -53,7 +53,7 @@ bool GraphicAttr::operator==( const GraphicAttr& rAttr ) const
             ( mnGPercent == rAttr.mnGPercent ) &&
             ( mnBPercent == rAttr.mnBPercent ) &&
             ( mbInvert == rAttr.mbInvert ) &&
-            ( mcTransparency == rAttr.mcTransparency ) &&
+            ( mcAlpha == rAttr.mcAlpha ) &&
             ( meDrawMode == rAttr.meDrawMode ) );
 }
 


More information about the Libreoffice-commits mailing list