vcl/inc/svdata.hxx                            |    4 
 vcl/source/app/svmain.cxx                     |    3 
 vcl/source/gdi/FileDefinitionWidgetDraw.cxx   |  146 +++++++++++++++-----------
 vcl/uiconfig/theme_definitions/definition.xml |    2 
 4 files changed, 96 insertions(+), 59 deletions(-)

New commits:
commit fe4da4c2ec02159afe6206db78920e8fde7691d0
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Mar 11 17:08:18 2019 +0100
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Tue Mar 12 00:38:24 2019 +0100

    widget theme: change the tab item height to (min) 32 px
    
    Change-Id: I1919300071a06242fe832880b46c944989daa4b6
    Reviewed-on: https://gerrit.libreoffice.org/69057
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 212a40aaf7ec3316d5209b688f5f79821f99fbdc)

diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx 
b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index a15010014aa4..06b85f9a2928 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -775,10 +775,12 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion(
             if (!pPart)
                 return false;
 
-            rNativeBoundingRegion = tools::Rectangle(
-                rBoundingControlRegion.TopLeft(),
-                Size(rBoundingControlRegion.GetWidth() + pPart->mnMarginWidth,
-                     rBoundingControlRegion.GetHeight() + 
pPart->mnMarginHeight));
+            long nWidth = std::max(rBoundingControlRegion.GetWidth() + 
pPart->mnMarginWidth,
+                                   long(pPart->mnWidth));
+            long nHeight = std::max(rBoundingControlRegion.GetHeight() + 
pPart->mnMarginHeight,
+                                    long(pPart->mnHeight));
+
+            rNativeBoundingRegion = tools::Rectangle(aLocation, Size(nWidth, 
nHeight));
             rNativeContentRegion = rNativeBoundingRegion;
             return true;
         }
diff --git a/vcl/uiconfig/theme_definitions/definition.xml 
b/vcl/uiconfig/theme_definitions/definition.xml
index e91953109554..5a4be114ea97 100644
--- a/vcl/uiconfig/theme_definitions/definition.xml
+++ b/vcl/uiconfig/theme_definitions/definition.xml
@@ -320,7 +320,7 @@
     </progress>
 
     <tabitem>
-        <part value="Entire" margin-width="20" margin-height="6">
+        <part value="Entire" margin-width="8" height="32">
             <state selected="false" extra="first">
                 <external source="tabitem-first.svgx" />
             </state>
commit 7a6e7ed16ed57e131079ee79d06b03141117d9d7
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Mar 11 16:52:37 2019 +0100
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Tue Mar 12 00:38:11 2019 +0100

    better adjustment algorithm for dynamic sized widgets
    
    A algorithm that gives better results for dynamically sized
    widgets is to increase proportionally only the points in shapes
    that are over the half of the widget width (or height, when
    adjusting the other dimension). This preserves the margins and
    doesn't distort the shape of the paths, which is especially
    visible when the source needs to be largely resized in one
    dimension only.
    
    Change-Id: I2cceb249063387c0f7400ef8d75adb5899aa8c23
    Reviewed-on: https://gerrit.libreoffice.org/69056
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 897f6f6252f38e93764aa0e72135768ab1ec3679)

diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx 
b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index ae303d966897..a15010014aa4 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -168,24 +168,18 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, 
SalGraphics& rGraphics
 
                 basegfx::B2DRange aInputRectangle(rRectangle.maRectangle);
 
+                double fDeltaX = aTargetSurface.getWidth() - 
aSVGRect.getWidth();
+                double fDeltaY = aTargetSurface.getHeight() - 
aSVGRect.getHeight();
+
                 basegfx::B2DRange aFinalRectangle(
-                    aTargetSurface.getMinX() + aInputRectangle.getMinX(),
-                    aTargetSurface.getMinY() + aInputRectangle.getMinY(),
-                    aTargetSurface.getMaxX() - (aSVGRect.getMaxX() - 
aInputRectangle.getMaxX()),
-                    aTargetSurface.getMaxY() - (aSVGRect.getMaxY() - 
aInputRectangle.getMaxY()));
-
-                
aInputRectangle.transform(basegfx::utils::createTranslateB2DHomMatrix(
-                    -aInputRectangle.getMinX(), -aInputRectangle.getMinY()));
-                
aInputRectangle.transform(basegfx::utils::createScaleB2DHomMatrix(
-                    aFinalRectangle.getWidth() / aInputRectangle.getWidth(),
-                    aFinalRectangle.getHeight() / 
aInputRectangle.getHeight()));
-                
aInputRectangle.transform(basegfx::utils::createTranslateB2DHomMatrix(
-                    aFinalRectangle.getMinX() - 0.5,
-                    aFinalRectangle.getMinY()
-                        - 0.5)); // compensate 0.5 for different 
interpretation of where the center of a pixel is
+                    aInputRectangle.getMinX(), aInputRectangle.getMinY(),
+                    aInputRectangle.getMaxX() + fDeltaX, 
aInputRectangle.getMaxY() + fDeltaY);
+
+                
aFinalRectangle.transform(basegfx::utils::createTranslateB2DHomMatrix(
+                    aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 
0.5));
 
                 basegfx::B2DPolygon aB2DPolygon = 
basegfx::utils::createPolygonFromRect(
-                    aInputRectangle, rRectangle.mnRx / 
aFinalRectangle.getWidth() * 2.0,
+                    aFinalRectangle, rRectangle.mnRx / 
aFinalRectangle.getWidth() * 2.0,
                     rRectangle.mnRy / aFinalRectangle.getHeight() * 2.0);
 
                 if (rRectangle.mpFillColor)
@@ -209,29 +203,27 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, 
SalGraphics& rGraphics
             {
                 auto const& rPath = static_cast<gfx::DrawPath 
const&>(*pDrawBase);
 
-                basegfx::B2DRange 
aPolyPolygonRange(rPath.maPolyPolygon.getB2DRange());
-                basegfx::B2DPolyPolygon aPolyPolygon(rPath.maPolyPolygon);
-
-                basegfx::B2DRange aFinalRectangle(
-                    aTargetSurface.getMinX() + aPolyPolygonRange.getMinX(),
-                    aTargetSurface.getMinY() + aPolyPolygonRange.getMinY(),
-                    aTargetSurface.getMaxX() - (aSVGRect.getMaxX() - 
aPolyPolygonRange.getMaxX()),
-                    aTargetSurface.getMaxY() - (aSVGRect.getMaxY() - 
aPolyPolygonRange.getMaxY()));
-
-                
aPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix(
-                    -aPolyPolygonRange.getMinX(), 
-aPolyPolygonRange.getMinY()));
-
-                double fScaleX = 1.0;
-                double fScaleY = 1.0;
-                if (aPolyPolygonRange.getWidth() > 0.0)
-                    fScaleX = aFinalRectangle.getWidth() / 
aPolyPolygonRange.getWidth();
-                if (aPolyPolygonRange.getHeight() > 0.0)
-                    fScaleY = aFinalRectangle.getHeight() / 
aPolyPolygonRange.getHeight();
-
-                
aPolyPolygon.transform(basegfx::utils::createScaleB2DHomMatrix(fScaleX, 
fScaleY));
+                double fDeltaX = aTargetSurface.getWidth() - 
aSVGRect.getWidth();
+                double fDeltaY = aTargetSurface.getHeight() - 
aSVGRect.getHeight();
 
+                basegfx::B2DPolyPolygon aPolyPolygon(rPath.maPolyPolygon);
+                for (auto& rPolygon : aPolyPolygon)
+                {
+                    for (size_t i = 0; i < rPolygon.count(); ++i)
+                    {
+                        auto& rPoint = rPolygon.getB2DPoint(i);
+                        double x = rPoint.getX();
+                        double y = rPoint.getY();
+
+                        if (x > aSVGRect.getCenterX())
+                            x = x + fDeltaX;
+                        if (y > aSVGRect.getCenterY())
+                            y = y + fDeltaY;
+                        rPolygon.setB2DPoint(i, basegfx::B2DPoint(x, y));
+                    }
+                }
                 
aPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix(
-                    aFinalRectangle.getMinX() - 0.5, aFinalRectangle.getMinY() 
- 0.5));
+                    aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 
0.5));
 
                 if (rPath.mpFillColor)
                 {
commit 8307ecbd6afd5012d46841d7bac34befea1b6d05
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Mar 11 16:38:32 2019 +0100
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Tue Mar 12 00:37:49 2019 +0100

    cache file based widget images and draw commands
    
    It is wasteful to parse svg icons all the time so lets cache the
    result when this make sense in a LRU map.
    
    Change-Id: I95cc317c9301138a9e384d270223ba147a123e59
    Reviewed-on: https://gerrit.libreoffice.org/69055
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 805b15ce536e3d6c40d0dc4f98b5aa6ffa5344c0)

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index f35ea6da1730..10051ec30660 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -40,6 +40,7 @@
 #include <boost/functional/hash.hpp>
 #include "ControlCacheKey.hxx"
 #include "schedulerimpl.hxx"
+#include <basegfx/DrawCommands.hxx>
 
 struct ImplPostEventData;
 struct ImplTimerData;
@@ -191,6 +192,9 @@ struct ImplSVGDIData
     long                    mnAppFontX = 0;                 // AppFont 
X-Numenator for 40/tel Width
     long                    mnAppFontY = 0;                 // AppFont 
Y-Numenator for 80/tel Height
     bool                    mbFontSubChanged = false;       // true: 
FontSubstitution was changed between Begin/End
+
+    o3tl::lru_map<OUString, BitmapEx> maThemeImageCache = 
o3tl::lru_map<OUString, BitmapEx>(10);
+    o3tl::lru_map<OUString, gfx::DrawRoot> maThemeDrawCommandsCache = 
o3tl::lru_map<OUString, gfx::DrawRoot>(50);
 };
 
 struct ImplSVWinData
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 3a444e9c6119..cbf2f6b63054 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -701,6 +701,9 @@ void DeInitVCL()
     delete pSVData->maGDIData.mpScreenFontCache;
     pSVData->maGDIData.mpScreenFontCache = nullptr;
 
+    pSVData->maGDIData.maThemeDrawCommandsCache.clear();
+    pSVData->maGDIData.maThemeImageCache.clear();
+
     // Deinit Sal
     if (pSVData->mpDefInst)
     {
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx 
b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index 0799c68d8775..ae303d966897 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -342,9 +342,26 @@ void 
munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom
                     nScaleFactor = comphelper::LibreOfficeKit::getDPIScale();
 
                 auto const& rDrawCommand = static_cast<ImageDrawCommand 
const&>(*pDrawCommand);
-                SvFileStream aFileStream(rDrawCommand.msSource, 
StreamMode::READ);
+                auto& rCacheImages = 
ImplGetSVData()->maGDIData.maThemeImageCache;
+                OUString rCacheKey = rDrawCommand.msSource + "@" + 
OUString::number(nScaleFactor);
+                auto& aIterator = rCacheImages.find(rCacheKey);
+
                 BitmapEx aBitmap;
-                vcl::bitmap::loadFromSvg(aFileStream, "", aBitmap, 
nScaleFactor);
+                if (aIterator == rCacheImages.end())
+                {
+                    SvFileStream aFileStream(rDrawCommand.msSource, 
StreamMode::READ);
+
+                    vcl::bitmap::loadFromSvg(aFileStream, "", aBitmap, 
nScaleFactor);
+                    if (!!aBitmap)
+                    {
+                        rCacheImages.insert(std::make_pair(rCacheKey, 
aBitmap));
+                    }
+                }
+                else
+                {
+                    aBitmap = aIterator->second;
+                }
+
                 long nImageWidth = aBitmap.GetSizePixel().Width();
                 long nImageHeight = aBitmap.GetSizePixel().Height();
                 SalTwoRect aTR(0, 0, nImageWidth, nImageHeight, nX, nY, 
nImageWidth / nScaleFactor,
@@ -369,27 +386,46 @@ void 
munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom
             case DrawCommandType::EXTERNAL:
             {
                 auto const& rDrawCommand = static_cast<ImageDrawCommand 
const&>(*pDrawCommand);
-                SvFileStream aFileStream(rDrawCommand.msSource, 
StreamMode::READ);
 
-                uno::Reference<uno::XComponentContext> xContext(
-                    comphelper::getProcessComponentContext());
-                const uno::Reference<graphic::XSvgParser> xSvgParser
-                    = graphic::SvgTools::create(xContext);
+                auto& rCacheDrawCommands = 
ImplGetSVData()->maGDIData.maThemeDrawCommandsCache;
 
-                std::size_t nSize = aFileStream.remainingSize();
-                std::vector<sal_Int8> aBuffer(nSize + 1);
-                aFileStream.ReadBytes(aBuffer.data(), nSize);
-                aBuffer[nSize] = 0;
+                auto& aIterator = 
rCacheDrawCommands.find(rDrawCommand.msSource);
 
-                uno::Sequence<sal_Int8> aData(aBuffer.data(), nSize + 1);
-                uno::Reference<io::XInputStream> aInputStream(
-                    new comphelper::SequenceInputStream(aData));
+                gfx::DrawRoot aDrawRoot;
 
-                uno::Any aAny = xSvgParser->getDrawCommands(aInputStream, "");
-                if (aAny.has<sal_uInt64>())
+                if (aIterator == rCacheDrawCommands.end())
+                {
+                    SvFileStream aFileStream(rDrawCommand.msSource, 
StreamMode::READ);
+
+                    uno::Reference<uno::XComponentContext> xContext(
+                        comphelper::getProcessComponentContext());
+                    const uno::Reference<graphic::XSvgParser> xSvgParser
+                        = graphic::SvgTools::create(xContext);
+
+                    std::size_t nSize = aFileStream.remainingSize();
+                    std::vector<sal_Int8> aBuffer(nSize + 1);
+                    aFileStream.ReadBytes(aBuffer.data(), nSize);
+                    aBuffer[nSize] = 0;
+
+                    uno::Sequence<sal_Int8> aData(aBuffer.data(), nSize + 1);
+                    uno::Reference<io::XInputStream> aInputStream(
+                        new comphelper::SequenceInputStream(aData));
+
+                    uno::Any aAny = xSvgParser->getDrawCommands(aInputStream, 
"");
+                    if (aAny.has<sal_uInt64>())
+                    {
+                        auto* pDrawRoot = 
reinterpret_cast<gfx::DrawRoot*>(aAny.get<sal_uInt64>());
+                        if (pDrawRoot)
+                        {
+                            rCacheDrawCommands.insert(
+                                std::make_pair(rDrawCommand.msSource, 
*pDrawRoot));
+                            drawFromDrawCommands(*pDrawRoot, rGraphics, nX, 
nY, nWidth, nHeight);
+                        }
+                    }
+                }
+                else
                 {
-                    auto* pDrawRoot = 
reinterpret_cast<gfx::DrawRoot*>(aAny.get<sal_uInt64>());
-                    drawFromDrawCommands(*pDrawRoot, rGraphics, nX, nY, 
nWidth, nHeight);
+                    drawFromDrawCommands(aIterator->second, rGraphics, nX, nY, 
nWidth, nHeight);
                 }
             }
             break;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to