[Libreoffice-commits] core.git: Branch 'feature/slidehack' - sd/source

Michael Meeks michael.meeks at suse.com
Fri Apr 12 10:23:25 PDT 2013


 sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx |   34 +----
 sd/source/ui/slidesorter/view/SlideSorterView.cxx          |    2 
 sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx     |   86 ++++---------
 3 files changed, 35 insertions(+), 87 deletions(-)

New commits:
commit e0e0c0c6b771f73b42494f734c64b9ba55d2ddde
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Fri Apr 12 18:21:11 2013 +0100

    slidesorter - cleanup redundant caches and notifications.
    
    Change-Id: Ibe8106a77899f141d1e3722bcae615ab905b2568

diff --git a/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx b/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx
index 6697de4..e083e9e 100644
--- a/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx
+++ b/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx
@@ -46,8 +46,6 @@ public:
         OutputDevice& rDevice,
         const model::SharedPageDescriptor& rpDescriptor);
 
-    void NotifyResize (const bool bForce = false);
-
     /** Called when the theme changes, either because it is replaced with
         another or because the system colors have changed.  So, even when
         the given theme is the same object as the one already in use by this
@@ -72,32 +70,27 @@ public:
 
 private:
     const Layouter& mrLayouter;
-    ::boost::shared_ptr<PageObjectLayouter> mpPageObjectLayouter;
     ::boost::shared_ptr<cache::PageCache> mpCache;
     ::boost::shared_ptr<controller::Properties> mpProperties;
     ::boost::shared_ptr<view::Theme> mpTheme;
     ::boost::shared_ptr<Font> mpPageNumberFont;
     ::boost::scoped_ptr<FramePainter> mpShadowPainter;
     ::boost::scoped_ptr<FramePainter> mpFocusBorderPainter;
-    Bitmap maNormalBackground;
-    Bitmap maSelectionBackground;
-    Bitmap maFocusedSelectionBackground;
-    Bitmap maFocusedBackground;
-    Bitmap maMouseOverBackground;
-    Bitmap maMouseOverFocusedBackground;
-    Bitmap maMouseOverSelectedAndFocusedBackground;
-    Size maSize;
 
     void PaintBackground (
+        PageObjectLayouter *pPageObjectLayouter,
         OutputDevice& rDevice,
-        const model::SharedPageDescriptor& rpDescriptor);
+        const model::SharedPageDescriptor& rpDescriptor) const;
     void PaintPreview (
+        PageObjectLayouter *pPageObjectLayouter,
         OutputDevice& rDevice,
         const model::SharedPageDescriptor& rpDescriptor) const;
     void PaintPageNumber (
+        PageObjectLayouter *pPageObjectLayouter,
         OutputDevice& rDevice,
         const model::SharedPageDescriptor& rpDescriptor) const;
     void PaintTransitionEffect (
+        PageObjectLayouter *pPageObjectLayouter,
         OutputDevice& rDevice,
         const model::SharedPageDescriptor& rpDescriptor) const;
     void PaintBorder (
@@ -105,28 +98,15 @@ private:
         const Theme::GradientColorType eColorType,
         const Rectangle& rBox) const;
     void PaintBackgroundDetail(
+        PageObjectLayouter *pPageObjectLayouter,
         OutputDevice& rDevice,
-        const model::SharedPageDescriptor& rpDescriptor);
+        const model::SharedPageDescriptor& rpDescriptor) const;
 
-#if 0
-    Bitmap& GetBackgroundForState (
-        const OutputDevice& rTemplateDevice);
-    Bitmap& GetBackground(
-        Bitmap& rBackground,
-        Theme::GradientColorType eType,
-        const OutputDevice& rTemplateDevice,
-        const bool bHasFocusBorder);
-    Bitmap CreateBackgroundBitmap(
-        const OutputDevice& rReferenceDevice,
-        const Theme::GradientColorType eType,
-        const bool bHasFocusBorder) const;
-#endif
     Bitmap CreateMarkedPreview(
         const Size& rSize,
         const Bitmap& rPreview,
         const BitmapEx& rOverlay,
         const OutputDevice* pReferenceDevice) const;
-    void InvalidateBitmaps (void);
 };
 
 } } } // end of namespace sd::slidesorter::view
diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
index 66b1015..3ebd938 100644
--- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx
+++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
@@ -438,8 +438,6 @@ void SlideSorterView::Layout ()
             model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement());
             pDescriptor->SetBoundingBox(mpLayouter->GetPageObjectBox(pDescriptor->GetPageIndex()));
         }
-
-        GetPageObjectPainter()->NotifyResize();
     }
 
     InvalidatePageObjectVisibilities ();
diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
index 9cb53fa..cb6b664 100644
--- a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
+++ b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
@@ -17,7 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
 #include "view/SlsPageObjectPainter.hxx"
 
 #include "model/SlsPageDescriptor.hxx"
@@ -45,19 +44,12 @@ namespace sd { namespace slidesorter { namespace view {
 PageObjectPainter::PageObjectPainter (
     const SlideSorter& rSlideSorter)
     : mrLayouter(rSlideSorter.GetView().GetLayouter()),
-      mpPageObjectLayouter(),
       mpCache(rSlideSorter.GetView().GetPreviewCache()),
       mpProperties(rSlideSorter.GetProperties()),
       mpTheme(rSlideSorter.GetTheme()),
       mpPageNumberFont(Theme::GetFont(Theme::Font_PageNumber, *rSlideSorter.GetContentWindow())),
       mpShadowPainter(new FramePainter(mpTheme->GetIcon(Theme::Icon_RawShadow))),
-      mpFocusBorderPainter(new FramePainter(mpTheme->GetIcon(Theme::Icon_FocusBorder))),
-      maNormalBackground(),
-      maSelectionBackground(),
-      maFocusedSelectionBackground(),
-      maMouseOverBackground(),
-      maMouseOverFocusedBackground(),
-      maSize()
+      mpFocusBorderPainter(new FramePainter(mpTheme->GetIcon(Theme::Icon_FocusBorder)))
 {
     // Replace the color (not the alpha values) in the focus border with a
     // color derived from the current selection color.
@@ -78,10 +70,10 @@ void PageObjectPainter::PaintPageObject (
 {
     // The page object layouter is quite volatile. It may have been replaced
     // since the last call.  Update it now.
-    mpPageObjectLayouter = mrLayouter.GetPageObjectLayouter();
-    if ( ! mpPageObjectLayouter)
+    PageObjectLayouter *pPageObjectLayouter = mrLayouter.GetPageObjectLayouter().get();
+    if ( ! pPageObjectLayouter)
     {
-        OSL_ASSERT(mpPageObjectLayouter);
+        OSL_FAIL("no page object layouter");
         return;
     }
 
@@ -90,53 +82,25 @@ void PageObjectPainter::PaintPageObject (
     const sal_uInt16 nSavedAntialiasingMode (rDevice.GetAntialiasing());
     rDevice.SetAntialiasing(nSavedAntialiasingMode & ~ANTIALIASING_ENABLE_B2DDRAW);
 
-    PaintBackground(rDevice, rpDescriptor);
-    PaintPreview(rDevice, rpDescriptor);
-    PaintPageNumber(rDevice, rpDescriptor);
-    PaintTransitionEffect(rDevice, rpDescriptor);
+    PaintBackground(pPageObjectLayouter, rDevice, rpDescriptor);
+    PaintPreview(pPageObjectLayouter, rDevice, rpDescriptor);
+    PaintPageNumber(pPageObjectLayouter, rDevice, rpDescriptor);
+    PaintTransitionEffect(pPageObjectLayouter, rDevice, rpDescriptor);
 
     rDevice.SetAntialiasing(nSavedAntialiasingMode);
 }
 
-void PageObjectPainter::NotifyResize (const bool bForce)
-{
-    mpPageObjectLayouter = mrLayouter.GetPageObjectLayouter();
-    if (bForce || ! mpPageObjectLayouter)
-        InvalidateBitmaps();
-    else
-    {
-        const Size aSize (mpPageObjectLayouter->GetGridMaxSize(
-                PageObjectLayouter::WindowCoordinateSystem));
-        if (maSize != aSize)
-        {
-            maSize = aSize;
-            InvalidateBitmaps();
-        }
-    }
-}
-
-void PageObjectPainter::InvalidateBitmaps (void)
-{
-    maNormalBackground.SetEmpty();
-    maSelectionBackground.SetEmpty();
-    maFocusedSelectionBackground.SetEmpty();
-    maFocusedBackground.SetEmpty();
-    maMouseOverBackground.SetEmpty();
-    maMouseOverFocusedBackground.SetEmpty();
-    maMouseOverSelectedAndFocusedBackground.SetEmpty();
-}
-
 void PageObjectPainter::SetTheme (const ::boost::shared_ptr<view::Theme>& rpTheme)
 {
     mpTheme = rpTheme;
-    NotifyResize(true);
 }
 
 void PageObjectPainter::PaintBackground (
+    PageObjectLayouter *pPageObjectLayouter,
     OutputDevice& rDevice,
-    const model::SharedPageDescriptor& rpDescriptor)
+    const model::SharedPageDescriptor& rpDescriptor) const
 {
-    PaintBackgroundDetail(rDevice, rpDescriptor);
+    PaintBackgroundDetail(pPageObjectLayouter, rDevice, rpDescriptor);
 
     // Fill the interior of the preview area with the default background
     // color of the page.
@@ -145,7 +109,7 @@ void PageObjectPainter::PaintBackground (
     {
         rDevice.SetFillColor(pPage->GetPageBackgroundColor(NULL));
         rDevice.SetLineColor(pPage->GetPageBackgroundColor(NULL));
-        const Rectangle aPreviewBox (mpPageObjectLayouter->GetBoundingBox(
+        const Rectangle aPreviewBox (pPageObjectLayouter->GetBoundingBox(
             rpDescriptor,
             PageObjectLayouter::Preview,
             PageObjectLayouter::ModelCoordinateSystem));
@@ -154,10 +118,11 @@ void PageObjectPainter::PaintBackground (
 }
 
 void PageObjectPainter::PaintPreview (
+    PageObjectLayouter *pPageObjectLayouter,
     OutputDevice& rDevice,
     const model::SharedPageDescriptor& rpDescriptor) const
 {
-    const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
+    const Rectangle aBox (pPageObjectLayouter->GetBoundingBox(
         rpDescriptor,
         PageObjectLayouter::Preview,
         PageObjectLayouter::ModelCoordinateSystem));
@@ -214,8 +179,10 @@ Bitmap PageObjectPainter::GetPreviewBitmap (
 
     if (bIsExcluded)
     {
+        PageObjectLayouter *pPageObjectLayouter = mrLayouter.GetPageObjectLayouter().get();
+
         Bitmap aMarkedPreview (mpCache->GetMarkedPreviewBitmap(pPage,false));
-        const Rectangle aPreviewBox (mpPageObjectLayouter->GetBoundingBox(
+        const Rectangle aPreviewBox (pPageObjectLayouter->GetBoundingBox(
             rpDescriptor,
             PageObjectLayouter::Preview,
             PageObjectLayouter::ModelCoordinateSystem));
@@ -237,10 +204,11 @@ Bitmap PageObjectPainter::GetPreviewBitmap (
 }
 
 void PageObjectPainter::PaintPageNumber (
+    PageObjectLayouter *pPageObjectLayouter,
     OutputDevice& rDevice,
     const model::SharedPageDescriptor& rpDescriptor) const
 {
-    const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
+    const Rectangle aBox (pPageObjectLayouter->GetBoundingBox(
         rpDescriptor,
         PageObjectLayouter::PageNumber,
         PageObjectLayouter::ModelCoordinateSystem));
@@ -289,26 +257,28 @@ void PageObjectPainter::PaintPageNumber (
 }
 
 void PageObjectPainter::PaintTransitionEffect (
+    PageObjectLayouter *pPageObjectLayouter,
     OutputDevice& rDevice,
     const model::SharedPageDescriptor& rpDescriptor) const
 {
     const SdPage* pPage = rpDescriptor->GetPage();
     if (pPage!=NULL && pPage->getTransitionType() > 0)
     {
-        const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
+        const Rectangle aBox (pPageObjectLayouter->GetBoundingBox(
             rpDescriptor,
             PageObjectLayouter::TransitionEffectIndicator,
             PageObjectLayouter::ModelCoordinateSystem));
 
         rDevice.DrawBitmapEx(
             aBox.TopLeft(),
-            mpPageObjectLayouter->GetTransitionEffectIcon().GetBitmapEx());
+            pPageObjectLayouter->GetTransitionEffectIcon().GetBitmapEx());
     }
 }
 
 void PageObjectPainter::PaintBackgroundDetail(
-        OutputDevice& rDevice,
-        const model::SharedPageDescriptor& rpDescriptor)
+    PageObjectLayouter *pPageObjectLayouter,
+    OutputDevice& rDevice,
+    const model::SharedPageDescriptor& rpDescriptor) const
 {
     enum State { None = 0x00, Selected = 0x01, MouseOver = 0x02, Focused = 0x04 };
     const int eState =
@@ -359,12 +329,12 @@ void PageObjectPainter::PaintBackgroundDetail(
             break;
     }
 
-    const Rectangle aFocusSize (mpPageObjectLayouter->GetBoundingBox(
+    const Rectangle aFocusSize (pPageObjectLayouter->GetBoundingBox(
                                         rpDescriptor,
                                         PageObjectLayouter::FocusIndicator,
                                         PageObjectLayouter::ModelCoordinateSystem));
 
-    const Rectangle aPageObjectBox (mpPageObjectLayouter->GetBoundingBox(
+    const Rectangle aPageObjectBox (pPageObjectLayouter->GetBoundingBox(
                                         rpDescriptor,
                                         PageObjectLayouter::PageObject,
                                         PageObjectLayouter::ModelCoordinateSystem));
@@ -423,7 +393,7 @@ void PageObjectPainter::PaintBackgroundDetail(
 
     // Get bounding box of the preview around which a shadow is painted.
     // Compensate for the border around the preview.
-    const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
+    const Rectangle aBox (pPageObjectLayouter->GetBoundingBox(
                                 rpDescriptor,
                                 PageObjectLayouter::Preview,
                                 PageObjectLayouter::ModelCoordinateSystem));


More information about the Libreoffice-commits mailing list