From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- gfx/2d/BasePoint.h | 32 +++++++++++++++++++++++--- gfx/2d/DrawTargetCairo.cpp | 17 -------------- gfx/2d/ScaledFontDWrite.cpp | 6 +++-- gfx/2d/unittest/TestPoint.cpp | 53 ------------------------------------------- gfx/2d/unittest/TestPoint.h | 18 --------------- 5 files changed, 33 insertions(+), 93 deletions(-) delete mode 100644 gfx/2d/unittest/TestPoint.cpp delete mode 100644 gfx/2d/unittest/TestPoint.h (limited to 'gfx/2d') diff --git a/gfx/2d/BasePoint.h b/gfx/2d/BasePoint.h index 7f5dd7e1e3..b7b0adbabd 100644 --- a/gfx/2d/BasePoint.h +++ b/gfx/2d/BasePoint.h @@ -12,10 +12,37 @@ #include #include "mozilla/Attributes.h" #include "mozilla/FloatingPoint.h" +#include "Coord.h" namespace mozilla { namespace gfx { +template +struct FloatType; + +template +struct FloatType>> { + using type = float; +}; + +template +struct FloatType>> { + using type = T; +}; + +template +struct FloatType> { + using type = CoordTyped; +}; + +template +struct FloatType> { + using type = CoordTyped; +}; + +template +using FloatType_t = typename FloatType::type; + /** * Do not use this class directly. Subclass it, pass that subclass as the * Sub parameter, and only use that subclass. This allows methods to safely @@ -82,9 +109,8 @@ struct BasePoint { return x.value * aPoint.x.value + y.value * aPoint.y.value; } - // FIXME: Maybe Length() should return a float Coord event for integer Points? - Coord Length() const { - return static_cast(hypot(x.value, y.value)); + FloatType_t Length() const { + return FloatType_t(hypot(x.value, y.value)); } T LengthSquare() const { return x.value * x.value + y.value * y.value; } diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index e189fe2445..dac6793e32 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -665,9 +665,6 @@ void DrawTargetCairo::Link(const char* aDestination, const Rect& aRect) { // // We also need to escape any backslashes (bug 1748077), as per doc at // https://www.cairographics.org/manual/cairo-Tags-and-Links.html#cairo-tag-begin - // The cairo-pdf-interchange backend (used on all platforms EXCEPT macOS) - // actually requires that we *doubly* escape the backslashes (this may be a - // cairo bug), while the quartz backend is fine with them singly-escaped. // // (Encoding of non-ASCII chars etc gets handled later by the PDF backend.) nsAutoCString dest(aDestination); @@ -676,11 +673,7 @@ void DrawTargetCairo::Link(const char* aDestination, const Rect& aRect) { if (dest[i] == '\'') { dest.ReplaceLiteral(i, 1, "\\'"); } else if (dest[i] == '\\') { -#ifdef XP_MACOSX dest.ReplaceLiteral(i, 1, "\\\\"); -#else - dest.ReplaceLiteral(i, 1, "\\\\\\\\"); -#endif } } @@ -1745,16 +1738,6 @@ already_AddRefed DrawTargetCairo::CreateSimilarDrawTarget( similar = cairo_win32_surface_create_with_dib( GfxFormatToCairoFormat(aFormat), aSize.width, aSize.height); break; -#endif -#ifdef CAIRO_HAS_QUARTZ_SURFACE - case CAIRO_SURFACE_TYPE_QUARTZ: - if (StaticPrefs::gfx_cairo_quartz_cg_layer_enabled()) { - similar = cairo_quartz_surface_create_cg_layer( - mSurface, GfxFormatToCairoContent(aFormat), aSize.width, - aSize.height); - break; - } - [[fallthrough]]; #endif default: similar = cairo_surface_create_similar(mSurface, diff --git a/gfx/2d/ScaledFontDWrite.cpp b/gfx/2d/ScaledFontDWrite.cpp index f6a0d97504..e2dc4390ab 100644 --- a/gfx/2d/ScaledFontDWrite.cpp +++ b/gfx/2d/ScaledFontDWrite.cpp @@ -24,7 +24,7 @@ #include -#include "cairo-win32.h" +#include "cairo-dwrite.h" #include "HelpersWinFonts.h" @@ -696,13 +696,15 @@ cairo_font_face_t* ScaledFontDWrite::CreateCairoFontFace( return nullptr; } - return cairo_dwrite_font_face_create_for_dwrite_fontface(nullptr, mFontFace); + return cairo_dwrite_font_face_create_for_dwrite_fontface(mFontFace); } void ScaledFontDWrite::PrepareCairoScaledFont(cairo_scaled_font_t* aFont) { +#if 0 if (mGDIForced) { cairo_dwrite_scaled_font_set_force_GDI_classic(aFont, true); } +#endif } already_AddRefed UnscaledFontDWrite::CreateFromFontDescriptor( diff --git a/gfx/2d/unittest/TestPoint.cpp b/gfx/2d/unittest/TestPoint.cpp deleted file mode 100644 index e79ff01ab3..0000000000 --- a/gfx/2d/unittest/TestPoint.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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/. */ - -#include "TestPoint.h" - -#include "Point.h" - -using namespace mozilla::gfx; - -TestPoint::TestPoint() { - REGISTER_TEST(TestPoint, Addition); - REGISTER_TEST(TestPoint, Subtraction); - REGISTER_TEST(TestPoint, RoundToMultiple); -} - -void TestPoint::Addition() { - Point a, b; - a.x = 2; - a.y = 2; - b.x = 5; - b.y = -5; - - a += b; - - VERIFY(a.x == 7.f); - VERIFY(a.y == -3.f); -} - -void TestPoint::Subtraction() { - Point a, b; - a.x = 2; - a.y = 2; - b.x = 5; - b.y = -5; - - a -= b; - - VERIFY(a.x == -3.f); - VERIFY(a.y == 7.f); -} - -void TestPoint::RoundToMultiple() { - const int32_t roundTo = 2; - - IntPoint p(478, -394); - VERIFY(p.RoundedToMultiple(roundTo) == p); - - IntPoint p2(478, 393); - VERIFY(p2.RoundedToMultiple(roundTo) != p2); -} diff --git a/gfx/2d/unittest/TestPoint.h b/gfx/2d/unittest/TestPoint.h deleted file mode 100644 index cb5b6a3de3..0000000000 --- a/gfx/2d/unittest/TestPoint.h +++ /dev/null @@ -1,18 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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 - -#include "TestBase.h" - -class TestPoint : public TestBase { - public: - TestPoint(); - - void Addition(); - void Subtraction(); - void RoundToMultiple(); -}; -- cgit v1.2.3