[Libreoffice-commits] core.git: canvas/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Feb 15 17:21:56 UTC 2021


 canvas/source/opengl/ogl_canvashelper.cxx |   88 ++++++++++++++----------------
 1 file changed, 43 insertions(+), 45 deletions(-)

New commits:
commit b7ee599c2ee4287cc39752db3b09444dcb65c0c2
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sat Feb 13 21:23:55 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Feb 15 18:21:18 2021 +0100

    cid#1292911 experiment to see what the complaint is referring to
    
    Change-Id: I77d071e3536659c44ca8565bc2e5d90c53f8ee7e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110847
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx
index d64e1ba1d7f0..4ac30e703ba7 100644
--- a/canvas/source/opengl/ogl_canvashelper.cxx
+++ b/canvas/source/opengl/ogl_canvashelper.cxx
@@ -69,6 +69,14 @@ namespace oglcanvas
        Text: http://www.opengl.org/resources/features/fontsurvey/
      */
 
+    typedef std::function< bool (
+                            const CanvasHelper&,
+                            const ::basegfx::B2DHomMatrix&,
+                            GLenum,
+                            GLenum,
+                            const rendering::ARGBColor&,
+                            const ::basegfx::B2DPolyPolygonVector&)> functor;
+
     struct CanvasHelper::Action
     {
         ::basegfx::B2DHomMatrix         maTransform;
@@ -77,13 +85,12 @@ namespace oglcanvas
         rendering::ARGBColor            maARGBColor;
         ::basegfx::B2DPolyPolygonVector maPolyPolys;
 
-        std::function< bool (
-                            const CanvasHelper&,
-                            const ::basegfx::B2DHomMatrix&,
-                            GLenum,
-                            GLenum,
-                            const rendering::ARGBColor&,
-                            const ::basegfx::B2DPolyPolygonVector&)> maFunction;
+        functor maFunction;
+
+        Action(const functor& rFunction)
+            : maFunction(rFunction)
+        {
+        }
     };
 
     namespace
@@ -385,13 +392,13 @@ namespace oglcanvas
     {
         if( mpDevice )
         {
-            mpRecordedActions->push_back( Action() );
+            mpRecordedActions->push_back(Action(std::bind(lcl_drawLine,
+                                         std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5,
+                                         aStartPoint, aEndPoint)));
+
             Action& rAct=mpRecordedActions->back();
 
             setupGraphicsState( rAct, viewState, renderState );
-            rAct.maFunction = std::bind(&lcl_drawLine,
-                                          std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5,
-                                          aStartPoint, aEndPoint);
         }
     }
 
@@ -404,18 +411,17 @@ namespace oglcanvas
         if( !mpDevice )
             return;
 
-        mpRecordedActions->push_back( Action() );
+        // TODO(F2): subdivide&render whole curve
+        mpRecordedActions->push_back(Action(std::bind(lcl_drawLine,
+                                       std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5,
+                                       geometry::RealPoint2D(
+                                           aBezierSegment.Px,
+                                           aBezierSegment.Py),
+                                       aEndPoint)));
+
         Action& rAct=mpRecordedActions->back();
 
         setupGraphicsState( rAct, viewState, renderState );
-
-        // TODO(F2): subdivide&render whole curve
-        rAct.maFunction = std::bind(&lcl_drawLine,
-                                        std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5,
-                                        geometry::RealPoint2D(
-                                            aBezierSegment.Px,
-                                            aBezierSegment.Py),
-                                        aEndPoint);
     }
 
     uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawPolyPolygon( const rendering::XCanvas*                          /*pCanvas*/,
@@ -428,15 +434,13 @@ namespace oglcanvas
 
         if( mpDevice )
         {
-            mpRecordedActions->push_back( Action() );
+            mpRecordedActions->push_back(Action(lcl_drawPolyPolygon));
             Action& rAct=mpRecordedActions->back();
 
             setupGraphicsState( rAct, viewState, renderState );
             rAct.maPolyPolys.push_back(
                 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon));
             rAct.maPolyPolys.back().makeUnique(); // own copy, for thread safety
-
-            rAct.maFunction = &lcl_drawPolyPolygon;
         }
 
         // TODO(P1): Provide caching here.
@@ -454,16 +458,14 @@ namespace oglcanvas
 
         if( mpDevice )
         {
-            mpRecordedActions->push_back( Action() );
+            // TODO(F3): fallback to drawPolyPolygon currently
+            mpRecordedActions->push_back(Action(lcl_drawPolyPolygon));
             Action& rAct=mpRecordedActions->back();
 
             setupGraphicsState( rAct, viewState, renderState );
             rAct.maPolyPolys.push_back(
                 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon));
             rAct.maPolyPolys.back().makeUnique(); // own copy, for thread safety
-
-            // TODO(F3): fallback to drawPolyPolygon currently
-            rAct.maFunction = &lcl_drawPolyPolygon;
         }
 
         // TODO(P1): Provide caching here.
@@ -513,15 +515,13 @@ namespace oglcanvas
 
         if( mpDevice )
         {
-            mpRecordedActions->push_back( Action() );
+            mpRecordedActions->push_back(Action(lcl_fillPolyPolygon));
             Action& rAct=mpRecordedActions->back();
 
             setupGraphicsState( rAct, viewState, renderState );
             rAct.maPolyPolys.push_back(
                 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon));
             rAct.maPolyPolys.back().makeUnique(); // own copy, for thread safety
-
-            rAct.maFunction = &lcl_fillPolyPolygon;
         }
 
         // TODO(P1): Provide caching here.
@@ -539,7 +539,7 @@ namespace oglcanvas
 
         if( mpDevice )
         {
-            mpRecordedActions->push_back( Action() );
+            mpRecordedActions->push_back( Action(nullptr) );
             Action& rAct=mpRecordedActions->back();
 
             setupGraphicsState( rAct, viewState, renderState );
@@ -718,7 +718,7 @@ namespace oglcanvas
                 // set font
                 pVDev->SetFont(aFont);
 
-                mpRecordedActions->push_back( Action() );
+                mpRecordedActions->push_back(Action(lcl_fillPolyPolygon));
                 Action& rAct=mpRecordedActions->back();
 
                 setupGraphicsState( rAct, viewState, renderState );
@@ -755,8 +755,6 @@ namespace oglcanvas
                 // own copy, for thread safety
                 for( auto& rPoly : rAct.maPolyPolys )
                     rPoly.makeUnique();
-
-                rAct.maFunction = &lcl_fillPolyPolygon;
             }
         }
 
@@ -781,13 +779,13 @@ namespace oglcanvas
                 // insert as transformed copy of bitmap action vector -
                 // during rendering, this gets rendered into a temporary
                 // buffer, and then composited to the front
-                mpRecordedActions->push_back( Action() );
+                mpRecordedActions->push_back(Action(std::bind(lcl_drawOwnBitmap,
+                                               std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5,
+                                               *pOwnBitmap)));
+
                 Action& rAct=mpRecordedActions->back();
 
                 setupGraphicsState( rAct, viewState, renderState );
-                rAct.maFunction = std::bind(&lcl_drawOwnBitmap,
-                                                std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5,
-                                                *pOwnBitmap);
             }
             else
             {
@@ -810,16 +808,16 @@ namespace oglcanvas
                             aPixelData,
                             canvas::tools::getStdColorSpace()));
 
-                    mpRecordedActions->push_back( Action() );
+                    mpRecordedActions->push_back(Action(std::bind(lcl_drawGenericBitmap,
+                                                   std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5,
+                                                   aSize, aARGBBytes,
+                                                   rtl_crc32(0,
+                                                             aARGBBytes.getConstArray(),
+                                                             aARGBBytes.getLength()))));
+
                     Action& rAct=mpRecordedActions->back();
 
                     setupGraphicsState( rAct, viewState, renderState );
-                    rAct.maFunction = std::bind(&lcl_drawGenericBitmap,
-                                                    std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5,
-                                                    aSize, aARGBBytes,
-                                                    rtl_crc32(0,
-                                                              aARGBBytes.getConstArray(),
-                                                              aARGBBytes.getLength()));
                 }
                 // TODO(F1): handle non-integer case
             }


More information about the Libreoffice-commits mailing list