desktop/source/lib/init.cxx | 1 sc/source/ui/view/formatsh.cxx | 67 ++++++++++++++++++--------- sfx2/source/control/unoctitm.cxx | 3 - svx/sdi/svx.sdi | 2 vcl/headless/svpinst.cxx | 40 ++++++++-------- vcl/inc/svdata.hxx | 40 +++++++++++++++- vcl/source/app/salvtables.cxx | 4 - vcl/source/app/svmain.cxx | 2 vcl/source/bitmap/BitmapScaleSuperFilter.cxx | 11 ++-- 9 files changed, 122 insertions(+), 48 deletions(-)
New commits: commit ef541e3731ec6941b3c3fd0040404d74963da81f Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Wed Feb 26 06:59:09 2020 +0000 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Fri May 8 21:31:32 2020 +0100 lru_scale_cache - cache the same bitmap at multiple scales. Helps accelerate different views at different scales, as well as document / image thumbnailing on save, as well as stray views that can get rendered behind the scenes at odd scales on mobile. Each scale + bitmap combination is another key in the LRU table. Change-Id: Id82ce2e4180608082c9ca16fad35bba9e8c2e81a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89497 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Michael Meeks <michael.me...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89503 Tested-by: Jenkins diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index e41ec23488b3..654b9ec968f1 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -165,6 +165,44 @@ struct ImplSVAppData DECL_LINK(VclEventTestingHdl, Timer*, void); }; +/// Cache multiple scalings for the same bitmap +struct ScaleCacheKey { + SalBitmap *mpBitmap; + Size maDestSize; + ScaleCacheKey(SalBitmap *pBitmap, const Size &aDestSize) + { + mpBitmap = pBitmap; + maDestSize = aDestSize; + } + ScaleCacheKey(const ScaleCacheKey &key) + { + mpBitmap = key.mpBitmap; + maDestSize = key.maDestSize; + } + bool operator==(ScaleCacheKey const& rOther) const + { + return mpBitmap == rOther.mpBitmap && maDestSize == rOther.maDestSize; + } +}; + +namespace std +{ +template <> struct hash<ScaleCacheKey> +{ + std::size_t operator()(ScaleCacheKey const& k) const noexcept + { + std::size_t seed = 0; + boost::hash_combine(seed, k.mpBitmap); + boost::hash_combine(seed, k.maDestSize.getWidth()); + boost::hash_combine(seed, k.maDestSize.getHeight()); + return seed; + } +}; + +} // end std namespace + +typedef o3tl::lru_map<ScaleCacheKey, BitmapEx> lru_scale_cache; + struct ImplSVGDIData { ~ImplSVGDIData(); @@ -181,7 +219,7 @@ struct ImplSVGDIData std::unique_ptr<ImplPrnQueueList> mpPrinterQueueList; // List of all printer queue std::shared_ptr<PhysicalFontCollection> mxScreenFontList; // Screen-Font-List std::shared_ptr<ImplFontCache> mxScreenFontCache; // Screen-Font-Cache - o3tl::lru_map<SalBitmap*, BitmapEx> maScaleCache = o3tl::lru_map<SalBitmap*, BitmapEx>(10); // Cache for scaled images + lru_scale_cache maScaleCache = lru_scale_cache(10); // Cache for scaled images ImplDirectFontSubstitution* mpDirectFontSubst = nullptr; // Font-Substitutions defined in Tools->Options->Fonts GraphicConverter* mpGrfConverter = nullptr; // Converter for graphics long mnAppFontX = 0; // AppFont X-Numenator for 40/tel Width diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 9bfeb9997041..d9d25ee5494f 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -157,8 +157,8 @@ void SalBitmap::DropScaledCache() if (ImplSVData* pSVData = ImplGetSVData()) { auto& rCache = pSVData->maGDIData.maScaleCache; - rCache.remove_if([this] (const o3tl::lru_map<SalBitmap*, BitmapEx>::key_value_pair_t& rKeyValuePair) - { return rKeyValuePair.first == this; }); + rCache.remove_if([this] (const lru_scale_cache::key_value_pair_t& rKeyValuePair) + { return rKeyValuePair.first.mpBitmap == this; }); } } diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx index e032edcc710f..b0e3ce33b973 100644 --- a/vcl/source/app/svmain.cxx +++ b/vcl/source/app/svmain.cxx @@ -564,7 +564,7 @@ void DeInitVCL() pSVData->maGDIData.mxScreenFontList.reset(); pSVData->maGDIData.mxScreenFontCache.reset(); - pSVData->maGDIData.maScaleCache.remove_if([](const o3tl::lru_map<SalBitmap*, BitmapEx>::key_value_pair_t&) + pSVData->maGDIData.maScaleCache.remove_if([](const lru_scale_cache::key_value_pair_t&) { return true; }); pSVData->maGDIData.maThemeDrawCommandsCache.clear(); diff --git a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx index 9ee6e80c7b40..bd6b7bd00b56 100644 --- a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx +++ b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx @@ -1016,8 +1016,6 @@ BitmapScaleSuperFilter::~BitmapScaleSuperFilter() BitmapEx BitmapScaleSuperFilter::execute(BitmapEx const& rBitmap) const { Bitmap aBitmap(rBitmap.GetBitmap()); - SalBitmap* pKey = aBitmap.ImplGetSalBitmap().get(); - bool bRet = false; const Size aSizePix(rBitmap.GetSizePixel()); @@ -1037,13 +1035,18 @@ BitmapEx BitmapScaleSuperFilter::execute(BitmapEx const& rBitmap) const return BitmapEx(); // check cache for a previously scaled version of this + ScaleCacheKey aKey(aBitmap.ImplGetSalBitmap().get(), + Size(nDstW, nDstH)); + ImplSVData* pSVData = ImplGetSVData(); auto& rCache = pSVData->maGDIData.maScaleCache; - auto aFind = rCache.find(pKey); + auto aFind = rCache.find(aKey); if (aFind != rCache.end()) { if (aFind->second.GetSizePixel().Width() == nDstW && aFind->second.GetSizePixel().Height() == nDstH) return aFind->second; + else + SAL_WARN("vcl.gdi", "Error: size mismatch in scale cache"); } { @@ -1187,7 +1190,7 @@ BitmapEx BitmapScaleSuperFilter::execute(BitmapEx const& rBitmap) const tools::Rectangle aRect(Point(0, 0), Point(nDstW, nDstH)); aBitmap.Crop(aRect); BitmapEx aRet(aBitmap); - rCache.insert(std::make_pair(pKey, aRet)); + rCache.insert(std::make_pair(aKey, aRet)); return aRet; } commit a55065b9781b8d11795c250d262c2f2c6b72fa33 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Mon Mar 30 11:26:50 2020 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Fri May 8 21:31:32 2020 +0100 FrameLineColor - add Color parameter, and share code for color params. Change-Id: I50483228221e817eb1a1d049d3c1ddf55a9c91d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91354 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.me...@collabora.com> diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index 5d0d52272621..9830e532214c 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -1642,6 +1642,27 @@ void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq ) } +namespace +{ + bool lcl_getColorFromStr(const SfxItemSet *pArgs, Color &rColor) + { + const SfxPoolItem* pColorStringItem = nullptr; + + if (pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pColorStringItem) && pColorStringItem) + { + OUString sColor; + sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); + + if (sColor == "transparent") + rColor = COL_TRANSPARENT; + else + rColor = Color(sColor.toInt32(16)); + return true; + } + return false; + } +} + void ScFormatShell::ExecuteAttr( SfxRequest& rReq ) { ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); @@ -1785,16 +1806,9 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq ) case SID_ATTR_CHAR_COLOR: case SID_SCATTR_PROTECTION : { - const SfxPoolItem* pColorStringItem = nullptr; - if ( SfxItemState::SET == pNewAttrs->GetItemState( SID_ATTR_COLOR_STR, false, &pColorStringItem ) ) + Color aColor; + if (lcl_getColorFromStr(pNewAttrs, aColor)) { - Color aColor; - OUString sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); - if ( sColor == "transparent" ) - aColor = Color( COL_TRANSPARENT ); - else - aColor = Color( sColor.toInt32( 16 ) ); - SvxColorItem aColorItem(pTabViewShell->GetSelectionPattern()-> GetItem( ATTR_FONT_COLOR ) ); aColorItem.SetValue(aColor); @@ -1870,18 +1884,20 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq ) case SID_FRAME_LINECOLOR: { ::editeng::SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine(); - const Color& rColor = pNewAttrs->Get( SID_FRAME_LINECOLOR ).GetValue(); + + Color aColor; + if (!lcl_getColorFromStr(pNewAttrs, aColor)) + aColor = pNewAttrs->Get( SID_FRAME_LINECOLOR ).GetValue(); // Update default line if ( pDefLine ) { - pDefLine->SetColor( rColor ); + pDefLine->SetColor( aColor ); pTabViewShell->SetSelectionFrameLines( pDefLine, true ); } else { - ::editeng::SvxBorderLine aDefLine( &rColor, 20, - SvxBorderLineStyle::SOLID ); + ::editeng::SvxBorderLine aDefLine( &aColor, 20, SvxBorderLineStyle::SOLID ); pTabViewShell->SetDefaultFrameLine( &aDefLine ); pTabViewShell->SetSelectionFrameLines( &aDefLine, false ); } @@ -1993,27 +2009,16 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq ) // ATTR_BACKGROUND (=SID_ATTR_BRUSH) has to be set to two IDs: case SID_BACKGROUND_COLOR: { - const SfxPoolItem* pColorStringItem = nullptr; Color aColor; - if ( SfxItemState::SET == pNewAttrs->GetItemState( SID_ATTR_COLOR_STR, false, &pColorStringItem ) ) - { - OUString sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); - if ( sColor == "transparent" ) - aColor = COL_TRANSPARENT; - else - aColor = Color( sColor.toInt32( 16 ) ); - } - else + if (!lcl_getColorFromStr(pNewAttrs, aColor)) { const SvxColorItem& rNewColorItem = pNewAttrs->Get( SID_BACKGROUND_COLOR ); aColor = rNewColorItem.GetValue(); } - SvxBrushItem aBrushItem( - pTabViewShell->GetSelectionPattern()-> - GetItem( ATTR_BACKGROUND ) ); - + SvxBrushItem aBrushItem( + pTabViewShell->GetSelectionPattern()->GetItem( ATTR_BACKGROUND ) ); aBrushItem.SetColor( aColor ); pTabViewShell->ApplyAttr( aBrushItem, false ); diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index b501e546e7bb..9e5880b7ce20 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -5483,7 +5483,7 @@ SfxVoidItem ArrowsToolbox SID_DRAWTBX_ARROWS ] SvxColorItem FrameLineColor SID_FRAME_LINECOLOR - +(SfxStringItem Color SID_ATTR_COLOR_STR, SvxColorItem FrameLineColor SID_FRAME_LINECOLOR) [ AutoUpdate = TRUE, FastCall = FALSE, commit 70e12fc5fc504df411bd0bd6719da78d2fd901e8 Author: Mert Tumer <mert.tu...@collabora.com> AuthorDate: Mon Jan 13 13:17:09 2020 +0300 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Fri May 8 21:31:32 2020 +0100 Fix FontColor does not change selected cells on calc Change-Id: Iae2f72bff4fd6986fc8cc07ba09996b1af4eb140 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86670 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index 3460d6e3d927..5d0d52272621 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -1784,10 +1784,32 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq ) break; case SID_ATTR_CHAR_COLOR: case SID_SCATTR_PROTECTION : - pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot) ), false); + { + const SfxPoolItem* pColorStringItem = nullptr; + if ( SfxItemState::SET == pNewAttrs->GetItemState( SID_ATTR_COLOR_STR, false, &pColorStringItem ) ) + { + Color aColor; + OUString sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); + if ( sColor == "transparent" ) + aColor = Color( COL_TRANSPARENT ); + else + aColor = Color( sColor.toInt32( 16 ) ); + + SvxColorItem aColorItem(pTabViewShell->GetSelectionPattern()-> + GetItem( ATTR_FONT_COLOR ) ); + aColorItem.SetValue(aColor); + pTabViewShell->ApplyAttr(aColorItem, false); + } + else + { + pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot) ), false); + } + rBindings.Invalidate( nSlot ); rBindings.Update( nSlot ); - break; + } + + break; case SID_ATTR_CHAR_FONT: case SID_ATTR_CHAR_FONTHEIGHT: commit a4cc4c88a86a4f31b22258ed3c555c740333ddc3 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Tue Mar 31 20:27:00 2020 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Fri May 8 21:31:32 2020 +0100 listen for and broadcast FrameLineColor state changes. Change-Id: I53efdcc4c5a3871761c4feffb079751286d6fbd6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91401 Tested-by: Jenkins Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 88e82c0ee3f1..622a94351edb 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2417,6 +2417,7 @@ static void doc_iniUnoCommands () OUString(".uno:NumberFormatCurrency"), OUString(".uno:NumberFormatPercent"), OUString(".uno:NumberFormatDate"), + OUString(".uno:FrameLineColor"), OUString(".uno:SortAscending"), OUString(".uno:SortDescending"), OUString(".uno:TrackChanges"), diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index f8e1b2821b6b..4354a9a35e54 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1034,7 +1034,8 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c aEvent.FeatureURL.Path == "BackgroundColor" || aEvent.FeatureURL.Path == "CharBackColor" || aEvent.FeatureURL.Path == "Color" || - aEvent.FeatureURL.Path == "FontColor") + aEvent.FeatureURL.Path == "FontColor" || + aEvent.FeatureURL.Path == "FrameLineColor") { sal_Int32 nColor = -1; aEvent.State >>= nColor; commit 22e0b2b900029e215bb4b5d9def18af89378602f Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Wed Apr 8 14:52:30 2020 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Fri May 8 21:31:32 2020 +0100 headless: re-work microsecond calculation to preserve accuracy. Should be an almost pure re-factor, that may save a few ms in some cases. Change-Id: Ie9c9e1a3610e1bcc8c12941f230109dd8eb77404 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91925 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 4a551966659a..b8b6dee5fc97 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -454,48 +454,46 @@ bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) // in kit case if (bWait && !bSkipPoll) { - int nTimeoutMS = 0; + sal_Int64 nTimeoutMicroS = 0; if (m_aTimeout.tv_sec) // Timer is started. { timeval Timeout; // determine remaining timeout. gettimeofday (&Timeout, nullptr); if (m_aTimeout > Timeout) - { - int nTimeoutMicroS = m_aTimeout.tv_usec - Timeout.tv_usec; - nTimeoutMS = (m_aTimeout.tv_sec - Timeout.tv_sec) * 1000 - + nTimeoutMicroS / 1000; - if ( nTimeoutMicroS % 1000 ) - nTimeoutMS += 1; - } + nTimeoutMicroS = ((m_aTimeout.tv_sec - Timeout.tv_sec) * 1000 * 1000 + + (m_aTimeout.tv_usec - Timeout.tv_usec)); } else - nTimeoutMS = -1; // wait until something happens + nTimeoutMicroS = -1; // wait until something happens sal_uInt32 nAcquireCount = ReleaseYieldMutexAll(); if (pSVData->mpPollCallback) { // Poll for events from the LOK client. - if (nTimeoutMS < 0) - nTimeoutMS = 5000; + if (nTimeoutMicroS < 0) + nTimeoutMicroS = 5000 * 1000; // External poll. if (pSVData->mpPollClosure != nullptr && - pSVData->mpPollCallback(pSVData->mpPollClosure, nTimeoutMS * 1000 /* us */) < 0) + pSVData->mpPollCallback(pSVData->mpPollClosure, nTimeoutMicroS) < 0) pSVData->maAppData.mbAppQuit = true; } else { std::unique_lock<std::mutex> g(pMutex->m_WakeUpMainMutex); // wait for doRelease() or Wakeup() to set the condition - if (nTimeoutMS == -1) + if (nTimeoutMicroS == -1) { pMutex->m_WakeUpMainCond.wait(g, [pMutex]() { return pMutex->m_wakeUpMain; }); } else { + int nTimeoutMS = nTimeoutMicroS / 1000; + if ( nTimeoutMicroS % 1000 ) + nTimeoutMS += 1; pMutex->m_WakeUpMainCond.wait_for(g, std::chrono::milliseconds(nTimeoutMS), [pMutex]() { return pMutex->m_wakeUpMain; }); commit 30e704c675e8c9a88de1e14e9a4fd638e3a14c17 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Wed Apr 8 15:10:45 2020 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Fri May 8 21:31:32 2020 +0100 tdf#131985 - ensure the Kit poll callback gets into fast idle loops. Comparing with the windows impl. it seems that it is possible to get timeout / idle starvation, and we need to poll and be responsive on our sockets even in this this case. As such, ensure we end up in the Kit poll callback, even when we have very short timeouts / busy-idle loops. Change-Id: I4bcac46af931de52a675f66fd189cd0ee14a0859 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91927 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 4687bf1dce4c..4a551966659a 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -439,13 +439,20 @@ bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) if (!bHandleAllCurrentEvents && bEvent) return true; - bEvent = CheckTimeout() || bEvent; + ImplSVData* pSVData = ImplGetSVData(); + + bool bTimeout = CheckTimeout(); + bool bSkipPoll = bEvent; + if (pSVData->mpPollCallback == nullptr) + bSkipPoll = bEvent || bTimeout; + // else - give the poll-callback visibility into waiting timeouts too. SvpSalYieldMutex *const pMutex(static_cast<SvpSalYieldMutex*>(GetYieldMutex())); if (IsMainThread()) { - if (bWait && ! bEvent) + // in kit case + if (bWait && !bSkipPoll) { int nTimeoutMS = 0; if (m_aTimeout.tv_sec) // Timer is started. @@ -465,7 +472,6 @@ bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) else nTimeoutMS = -1; // wait until something happens - ImplSVData* pSVData = ImplGetSVData(); sal_uInt32 nAcquireCount = ReleaseYieldMutexAll(); if (pSVData->mpPollCallback) @@ -498,7 +504,7 @@ bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) } AcquireYieldMutex( nAcquireCount ); } - else if (bEvent) + else if (bSkipPoll) { pMutex->m_NonMainWaitingYieldCond.set(); // wake up other threads } @@ -523,7 +529,7 @@ bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) } } - return bEvent; + return bSkipPoll; } bool SvpSalInstance::AnyInput( VclInputFlags nType ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits