basegfx/test/B2DHomMatrixTest.cxx | 32 ++++++++++++++++++++++++++++++++ include/o3tl/hash_combine.hxx | 29 +++++++++++++++++++++++++++++ o3tl/qa/test-lru_map.cxx | 6 +++--- 3 files changed, 64 insertions(+), 3 deletions(-)
New commits: commit f3b3981da81b05e6e89010b73724503924989044 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed May 27 12:50:14 2020 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed May 27 12:50:14 2020 +0200 basegfx: test of coordinate system conversion Change-Id: I059d1f272f0633c450287f272083bb09732357b0 diff --git a/basegfx/test/B2DHomMatrixTest.cxx b/basegfx/test/B2DHomMatrixTest.cxx index 8063587ac2dd..e5b923e6dd82 100644 --- a/basegfx/test/B2DHomMatrixTest.cxx +++ b/basegfx/test/B2DHomMatrixTest.cxx @@ -503,6 +503,36 @@ public: CPPUNIT_ASSERT_DOUBLES_EQUAL(26, aRange.getMaxY(), 1E-12); } + void testCoordinateSystemConversion() + { + // Use case when we convert + + B2DRange aWindow(50, 50, 150, 150); + + B2DRange aSubPage(0, 0, 2000, 2000); + + B2DHomMatrix aB2DMatrix; + aB2DMatrix.scale(aWindow.getWidth() / aSubPage.getWidth(), + aWindow.getHeight() / aSubPage.getHeight()); + aB2DMatrix.translate(aWindow.getMinX(), aWindow.getMinY()); + + B2DPoint aPoint1(0, 0); + aPoint1 *= aB2DMatrix; + + CPPUNIT_ASSERT_DOUBLES_EQUAL(50, aPoint1.getX(), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(50, aPoint1.getY(), 1E-12); + + B2DPoint aPoint2(1000, 1000); + aPoint2 *= aB2DMatrix; + CPPUNIT_ASSERT_DOUBLES_EQUAL(100, aPoint2.getX(), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(100, aPoint2.getY(), 1E-12); + + B2DPoint aPoint3(2000, 2000); + aPoint3 *= aB2DMatrix; + CPPUNIT_ASSERT_DOUBLES_EQUAL(150, aPoint3.getX(), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(150, aPoint3.getY(), 1E-12); + } + // Change the following lines only, if you add, remove or rename // member functions of the current class, // because these macros are need by auto register mechanism. @@ -520,6 +550,8 @@ public: CPPUNIT_TEST(testMultiplyWithAnotherMatrix); CPPUNIT_TEST(testTransformPoint); CPPUNIT_TEST(testTransformRange); + CPPUNIT_TEST(testCoordinateSystemConversion); + CPPUNIT_TEST_SUITE_END(); }; // class b2dhommatrix commit fba09cc6c291e359594709a5aff86a4b2179c25a Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed May 27 12:49:05 2020 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed May 27 12:49:05 2020 +0200 add o3tl version of hash_combine to not depend on boost for this Change-Id: I081f8d116ef811baa8aa5de35a6cb51fa4de7d56 diff --git a/include/o3tl/hash_combine.hxx b/include/o3tl/hash_combine.hxx new file mode 100644 index 000000000000..17419b3e2c0f --- /dev/null +++ b/include/o3tl/hash_combine.hxx @@ -0,0 +1,29 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +namespace o3tl +{ +template <typename T, typename N, std::enable_if_t<(sizeof(N) == 4), bool> = false> +inline void hash_combine(N& nSeed, T const& nValue) +{ + static_assert(sizeof(nSeed) == 4); + nSeed ^= std::hash<T>{}(nValue) + 0x9E3779B9u + (nSeed << 6) + (nSeed >> 2); +} + +template <typename T, typename N, std::enable_if_t<(sizeof(N) == 8), bool> = false> +inline void hash_combine(N& nSeed, T const& nValue) +{ + static_assert(sizeof(nSeed) == 8); + nSeed ^= std::hash<T>{}(nValue) + 0x9E3779B97F4A7C15llu + (nSeed << 12) + (nSeed >> 4); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/o3tl/qa/test-lru_map.cxx b/o3tl/qa/test-lru_map.cxx index a03a6bf37200..3ab285c4329a 100644 --- a/o3tl/qa/test-lru_map.cxx +++ b/o3tl/qa/test-lru_map.cxx @@ -15,7 +15,7 @@ #include <o3tl/lru_map.hxx> -#include <boost/functional/hash.hpp> +#include <o3tl/hash_combine.hxx> using namespace ::o3tl; @@ -206,8 +206,8 @@ struct TestClassKeyHashFunction std::size_t operator()(TestClassKey const& aKey) const { std::size_t seed = 0; - boost::hash_combine(seed, aKey.mA); - boost::hash_combine(seed, aKey.mB); + o3tl::hash_combine(seed, aKey.mA); + o3tl::hash_combine(seed, aKey.mB); return seed; } }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits