summaryrefslogtreecommitdiffstats
path: root/gfx/2d
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /gfx/2d
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/2d')
-rw-r--r--gfx/2d/BasePoint.h32
-rw-r--r--gfx/2d/DrawTargetCairo.cpp17
-rw-r--r--gfx/2d/ScaledFontDWrite.cpp6
-rw-r--r--gfx/2d/unittest/TestPoint.cpp53
-rw-r--r--gfx/2d/unittest/TestPoint.h18
5 files changed, 33 insertions, 93 deletions
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 <type_traits>
#include "mozilla/Attributes.h"
#include "mozilla/FloatingPoint.h"
+#include "Coord.h"
namespace mozilla {
namespace gfx {
+template <class T, typename EnableT = void>
+struct FloatType;
+
+template <typename T>
+struct FloatType<T, typename std::enable_if_t<std::is_integral_v<T>>> {
+ using type = float;
+};
+
+template <typename T>
+struct FloatType<T, typename std::enable_if_t<std::is_floating_point_v<T>>> {
+ using type = T;
+};
+
+template <typename Units, typename Rep>
+struct FloatType<IntCoordTyped<Units, Rep>> {
+ using type = CoordTyped<Units, float>;
+};
+
+template <typename Units, typename Rep>
+struct FloatType<CoordTyped<Units, Rep>> {
+ using type = CoordTyped<Units, Rep>;
+};
+
+template <typename T>
+using FloatType_t = typename FloatType<T>::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<decltype(x.value)>(hypot(x.value, y.value));
+ FloatType_t<Coord> Length() const {
+ return FloatType_t<Coord>(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
}
}
@@ -1746,16 +1739,6 @@ already_AddRefed<DrawTarget> DrawTargetCairo::CreateSimilarDrawTarget(
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,
GfxFormatToCairoContent(aFormat),
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 <vector>
-#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<UnscaledFont> 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();
-};