Disable SkFontMgr::RefDefault() for Bazel buffet build
Along the way, I realized some of the tests fail on M1 Macs,
due to "-ffp-contract=on" being on by default and actually making
a difference in some unit tests. This adds some asserts/debugging
code that helped along the way.
Change-Id: I213f8d8967bd9ec0da2de635390a42dff4e9faaa
Bug: b/305780908
Bug: b/40045064
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/768079
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
diff --git a/BUILD.bazel b/BUILD.bazel
index 2989d90..cdf2516 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -99,19 +99,6 @@
visibility = ["//visibility:public"],
)
-# Font Manager Options. Pick at most one target starting with "default_font_manager" and as many
-# other font managers as desired (most clients only need one in practice).
-
-alias(
- # No fonts will be able to created using the default FontMgr either directly
- # or indirectly (e.g. via SkTypeface::MakeFromStream)
- name = "default_font_manager_empty",
- actual = "//src/ports:default_font_manager_empty",
- visibility = ["//visibility:public"],
-)
-
-# TODO(kjlubick) make other font manager options
-
# Load bearing comment below - gazelle looks here (and not in any other BUILD.bazel files)
# for a special comment indicating the prefix.
# gazelle:prefix go.skia.org/skia
diff --git a/example/external_client/BUILD.bazel b/example/external_client/BUILD.bazel
index 4adb0d3..fb0531f 100644
--- a/example/external_client/BUILD.bazel
+++ b/example/external_client/BUILD.bazel
@@ -18,7 +18,6 @@
name = "skia_core_and_pathops",
deps = [
"@skia//:core",
- "@skia//:default_font_manager_empty",
"@skia//:pathops",
],
)
@@ -33,7 +32,6 @@
],
deps = [
"@skia//:core",
- "@skia//:default_font_manager_empty",
"@skia//:png_decode_codec",
],
)
diff --git a/include/config/copts.bzl b/include/config/copts.bzl
index 326aac0..01d25d9 100644
--- a/include/config/copts.bzl
+++ b/include/config/copts.bzl
@@ -45,6 +45,13 @@
# (e.g. "undefined reference to `SkString::data()'").
"-fvisibility=hidden",
],
+}) + select({
+ "@platforms//os:windows": [],
+ "//conditions:default": [
+ # In Clang 14, this default was changed. We turn this off to (hopefully) make our
+ # GMs more consistent and avoid some floating-point related test failures on M1 macs.
+ "-ffp-contract=off",
+ ],
})
OPT_LEVEL = select({
diff --git a/include/ports/BUILD.bazel b/include/ports/BUILD.bazel
index c666258..f95aeda 100644
--- a/include/ports/BUILD.bazel
+++ b/include/ports/BUILD.bazel
@@ -76,3 +76,9 @@
}),
visibility = ["//include:__pkg__"],
)
+
+skia_filegroup(
+ name = "core_hdrs",
+ srcs = ["SkImageGeneratorCG.h"],
+ visibility = ["//src/core:__pkg__"],
+)
diff --git a/src/core/BUILD.bazel b/src/core/BUILD.bazel
index a4beb92..01c90ab 100644
--- a/src/core/BUILD.bazel
+++ b/src/core/BUILD.bazel
@@ -825,9 +825,13 @@
"//include/codec:core_hdrs",
"//include/core:core_hdrs",
"//include/effects:core_hdrs",
+ "//include/ports:core_hdrs",
"//include/sksl:core_hdrs",
"//include/utils:core_hdrs",
],
+ defines = [
+ "SK_DISABLE_LEGACY_FONTMGR_FACTORY",
+ ],
features = ["layering_check"],
local_defines = [
"SK_SLUG_DISABLE_LEGACY_DESERIALIZE",
diff --git a/src/ports/BUILD.bazel b/src/ports/BUILD.bazel
index 3c4fbcd..fd8a3b7 100644
--- a/src/ports/BUILD.bazel
+++ b/src/ports/BUILD.bazel
@@ -4,7 +4,6 @@
"exports_files_legacy",
"select_multi",
"skia_cc_deps",
- "skia_cc_library",
"skia_filegroup",
)
@@ -369,11 +368,3 @@
],
visibility = ["//src/core:__pkg__"],
)
-
-skia_cc_library(
- name = "default_font_manager_empty",
- srcs = [":fontmgr_empty_factory"],
- features = ["layering_check"],
- visibility = ["//:__pkg__"],
- deps = ["//src/core"],
-)
diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel
index a6e57d8..c184cf4 100644
--- a/tests/BUILD.bazel
+++ b/tests/BUILD.bazel
@@ -65,7 +65,6 @@
deps = [
":tests_base",
"//:core",
- "//:default_font_manager_empty",
],
)
@@ -76,7 +75,6 @@
deps = [
":tests_base",
"//:core",
- "//:default_font_manager_empty",
],
)
diff --git a/tests/FontNamesTest.cpp b/tests/FontNamesTest.cpp
index 64b7f04..05b4a1a 100644
--- a/tests/FontNamesTest.cpp
+++ b/tests/FontNamesTest.cpp
@@ -158,6 +158,7 @@
static const SkFontTableTag nameTag = SkSetFourByteTag('n','a','m','e');
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
+ SkASSERT_RELEASE(fm);
int count = std::min(fm->countFamilies(), MAX_FAMILIES);
for (int i = 0; i < count; ++i) {
sk_sp<SkFontStyleSet> set(fm->createStyleSet(i));
diff --git a/tests/GeometryTest.cpp b/tests/GeometryTest.cpp
index 54fe035..653e069 100644
--- a/tests/GeometryTest.cpp
+++ b/tests/GeometryTest.cpp
@@ -299,13 +299,15 @@
// Classify the cubic even if the results will be undefined: check for crashes and asserts.
SkCubicType actualType = SkClassifyCubic(bezierPoints.data());
if (!undefined) {
- REPORTER_ASSERT(reporter, actualType == expectedType);
+ REPORTER_ASSERT(reporter, actualType == expectedType,
+ "%d != %d", (int)actualType, (int)expectedType);
}
}
-static void check_cubic_around_rect(skiatest::Reporter* reporter,
+static void check_cubic_around_rect(std::string name, skiatest::Reporter* reporter,
float x1, float y1, float x2, float y2,
bool undefined = false) {
+ skiatest::ReporterContext subtest(reporter, name);
static constexpr SkCubicType expectations[24] = {
SkCubicType::kLoop,
SkCubicType::kCuspAtInfinity,
@@ -404,35 +406,38 @@
for (const auto& loop : kLinearCubics) {
check_cubic_type(reporter, loop, SkCubicType::kLineOrPoint);
}
- check_cubic_around_rect(reporter, 0, 0, 1, 1);
- check_cubic_around_rect(reporter,
+ check_cubic_around_rect("small box", reporter, 0, 0, 1, 1);
+ check_cubic_around_rect("biggest box", reporter,
-std::numeric_limits<float>::max(),
-std::numeric_limits<float>::max(),
+std::numeric_limits<float>::max(),
+std::numeric_limits<float>::max());
- check_cubic_around_rect(reporter, 1, 1,
+ check_cubic_around_rect("large quadrant", reporter, 1, 1,
+std::numeric_limits<float>::min(),
+std::numeric_limits<float>::max());
- check_cubic_around_rect(reporter,
+ check_cubic_around_rect("smallest box", reporter,
-std::numeric_limits<float>::min(),
-std::numeric_limits<float>::min(),
+std::numeric_limits<float>::min(),
+std::numeric_limits<float>::min());
- check_cubic_around_rect(reporter, +1, -std::numeric_limits<float>::min(), -1, -1);
- check_cubic_around_rect(reporter,
+ check_cubic_around_rect("slightly negative box",reporter,
+ +1, -std::numeric_limits<float>::min(), -1, -1);
+ check_cubic_around_rect("infinite box", reporter,
-std::numeric_limits<float>::infinity(),
-std::numeric_limits<float>::infinity(),
+std::numeric_limits<float>::infinity(),
+std::numeric_limits<float>::infinity(),
true);
- check_cubic_around_rect(reporter, 0, 0, 1, +std::numeric_limits<float>::infinity(), true);
- check_cubic_around_rect(reporter,
+ check_cubic_around_rect("one sided infinite box", reporter,
+ 0, 0, 1, +std::numeric_limits<float>::infinity(), true);
+ check_cubic_around_rect("nan box", reporter,
-std::numeric_limits<float>::quiet_NaN(),
-std::numeric_limits<float>::quiet_NaN(),
+std::numeric_limits<float>::quiet_NaN(),
+std::numeric_limits<float>::quiet_NaN(),
true);
- check_cubic_around_rect(reporter, 0, 0, 1, +std::numeric_limits<float>::quiet_NaN(), true);
+ check_cubic_around_rect("partial nan box", reporter,
+ 0, 0, 1, +std::numeric_limits<float>::quiet_NaN(), true);
}
static std::array<SkPoint, 4> kCusps[] = {
diff --git a/tests/testgroups.bzl b/tests/testgroups.bzl
index 3c828ba..f3483b1 100644
--- a/tests/testgroups.bzl
+++ b/tests/testgroups.bzl
@@ -43,13 +43,10 @@
"F16StagesTest.cpp",
"FillPathTest.cpp",
"FitsInTest.cpp",
- "FlattenDrawableTest.cpp",
"FlattenableFactoryToName.cpp",
"FlattenableNameToFactory.cpp",
"Float16Test.cpp",
"FloatingPointTest.cpp",
- "FontHostTest.cpp",
- "FontNamesTest.cpp",
"FontTest.cpp",
"FrontBufferedStreamTest.cpp",
"GeometryTest.cpp",
@@ -84,7 +81,6 @@
"OffsetSimplePolyTest.cpp",
"OnceTest.cpp",
"OverAlignedTest.cpp",
- "PaintTest.cpp",
"ParametricStageTest.cpp",
"ParseColorTest.cpp",
"ParsePathTest.cpp",
@@ -93,7 +89,6 @@
"PathMeasureTest.cpp",
"PictureBBHTest.cpp",
"PictureShaderTest.cpp",
- "PictureTest.cpp",
"PixelRefTest.cpp",
"Point3Test.cpp",
"PointTest.cpp",
@@ -134,7 +129,6 @@
"SkSharedMutexTest.cpp",
"SkSpanTest.cpp",
"SkStrikeCacheTest.cpp",
- "SkStrikeTest.cpp",
"SkStringViewTest.cpp",
"SkTBlockListTest.cpp",
"SkUTFTest.cpp",
@@ -162,6 +156,15 @@
"Skbug6389.cpp",
]
+FONT_TESTS = [
+ "FlattenDrawableTest.cpp",
+ "FontHostTest.cpp",
+ "FontNamesTest.cpp",
+ "PaintTest.cpp",
+ "PictureTest.cpp",
+ "SkStrikeTest.cpp",
+]
+
JSON_TESTS = [
"JSONTest.cpp",
]