From b79a5cdcf0b98fef4b5bfeb380efcea322e9a51a Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Thu, 27 Apr 2023 15:05:03 +0200 Subject: EMF+ tdf#103859 Optimize EmfPlusFillRects and EmfPlusDrawRects Change-Id: Iac96cf2d4291646fb69cc87c471d2f68ed905d69 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151102 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek --- drawinglayer/source/tools/emfphelperdata.cxx | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'drawinglayer/source/tools') diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index a1e9b3b7adce..879d40b925d5 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1255,7 +1255,9 @@ namespace emfplushelper { // Silent MSVC warning C4701: potentially uninitialized local variable 'brushIndexOrColor' used sal_uInt32 brushIndexOrColor = 999; - sal_Int32 rectangles; + ::basegfx::B2DPolyPolygon polyPolygon; + sal_uInt32 rectangles; + float x, y, width, height; const bool isColor = (flags & 0x8000); ::basegfx::B2DPolygon polygon; @@ -1270,11 +1272,9 @@ namespace emfplushelper SAL_INFO("drawinglayer.emf", "EMF+\t DrawRects"); } - rMS.ReadInt32(rectangles); - - for (int i = 0; i < rectangles; i++) + rMS.ReadUInt32(rectangles); + for (sal_uInt32 i = 0; i < rectangles; i++) { - float x, y, width, height; ReadRectangle(rMS, x, y, width, height, bool(flags & 0x4000)); polygon.clear(); polygon.append(Map(x, y)); @@ -1284,13 +1284,12 @@ namespace emfplushelper polygon.setClosed(true); SAL_INFO("drawinglayer.emf", "EMF+\t\t rectangle: " << x << ", "<< y << " " << width << "x" << height); - - ::basegfx::B2DPolyPolygon polyPolygon(polygon); - if (type == EmfPlusRecordTypeFillRects) - EMFPPlusFillPolygon(polyPolygon, isColor, brushIndexOrColor); - else - EMFPPlusDrawPolygon(polyPolygon, flags & 0xff); + polyPolygon.append(polygon); } + if (type == EmfPlusRecordTypeFillRects) + EMFPPlusFillPolygon(polyPolygon, isColor, brushIndexOrColor); + else + EMFPPlusDrawPolygon(polyPolygon, flags & 0xff); break; } case EmfPlusRecordTypeFillPolygon: -- cgit