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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Feb 16 15:09:03 UTC 2021


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

New commits:
commit c4957b237eeb3e7895a102f9a01d7cf087cc5373
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Feb 16 09:18:39 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Feb 16 16:08:19 2021 +0100

    ofz#1473106 Uninitialized scalar field
    
    Change-Id: If38a5ad4e5db287a3105bb0faca031bc98c47fd3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110979
    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 4ac30e703ba7..d64e1ba1d7f0 100644
--- a/canvas/source/opengl/ogl_canvashelper.cxx
+++ b/canvas/source/opengl/ogl_canvashelper.cxx
@@ -69,14 +69,6 @@ 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;
@@ -85,12 +77,13 @@ namespace oglcanvas
         rendering::ARGBColor            maARGBColor;
         ::basegfx::B2DPolyPolygonVector maPolyPolys;
 
-        functor maFunction;
-
-        Action(const functor& rFunction)
-            : maFunction(rFunction)
-        {
-        }
+        std::function< bool (
+                            const CanvasHelper&,
+                            const ::basegfx::B2DHomMatrix&,
+                            GLenum,
+                            GLenum,
+                            const rendering::ARGBColor&,
+                            const ::basegfx::B2DPolyPolygonVector&)> maFunction;
     };
 
     namespace
@@ -392,13 +385,13 @@ namespace oglcanvas
     {
         if( mpDevice )
         {
-            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)));
-
+            mpRecordedActions->push_back( Action() );
             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);
         }
     }
 
@@ -411,17 +404,18 @@ namespace oglcanvas
         if( !mpDevice )
             return;
 
-        // 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)));
-
+        mpRecordedActions->push_back( Action() );
         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*/,
@@ -434,13 +428,15 @@ namespace oglcanvas
 
         if( mpDevice )
         {
-            mpRecordedActions->push_back(Action(lcl_drawPolyPolygon));
+            mpRecordedActions->push_back( Action() );
             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.
@@ -458,14 +454,16 @@ namespace oglcanvas
 
         if( mpDevice )
         {
-            // TODO(F3): fallback to drawPolyPolygon currently
-            mpRecordedActions->push_back(Action(lcl_drawPolyPolygon));
+            mpRecordedActions->push_back( Action() );
             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.
@@ -515,13 +513,15 @@ namespace oglcanvas
 
         if( mpDevice )
         {
-            mpRecordedActions->push_back(Action(lcl_fillPolyPolygon));
+            mpRecordedActions->push_back( Action() );
             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(nullptr) );
+            mpRecordedActions->push_back( Action() );
             Action& rAct=mpRecordedActions->back();
 
             setupGraphicsState( rAct, viewState, renderState );
@@ -718,7 +718,7 @@ namespace oglcanvas
                 // set font
                 pVDev->SetFont(aFont);
 
-                mpRecordedActions->push_back(Action(lcl_fillPolyPolygon));
+                mpRecordedActions->push_back( Action() );
                 Action& rAct=mpRecordedActions->back();
 
                 setupGraphicsState( rAct, viewState, renderState );
@@ -755,6 +755,8 @@ namespace oglcanvas
                 // own copy, for thread safety
                 for( auto& rPoly : rAct.maPolyPolys )
                     rPoly.makeUnique();
+
+                rAct.maFunction = &lcl_fillPolyPolygon;
             }
         }
 
@@ -779,13 +781,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(std::bind(lcl_drawOwnBitmap,
-                                               std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5,
-                                               *pOwnBitmap)));
-
+                mpRecordedActions->push_back( Action() );
                 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
             {
@@ -808,16 +810,16 @@ namespace oglcanvas
                             aPixelData,
                             canvas::tools::getStdColorSpace()));
 
-                    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()))));
-
+                    mpRecordedActions->push_back( Action() );
                     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