/* -*- 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/. */
// Android 12+ doesn't read font configuration XML files directly. // It means that it is slow to call font API at first. if (jni::GetAPIVersion() < 31) { return;
}
// This will be called before XPCOM service isn't started. So don't check // preferences. if (IsFontAPIDisabled(true)) { return;
}
// These two calls are equivalent to FT_Init_FreeType(), but allow us to // provide a custom memory allocator.
FT_New_Library(&sFreetypeMemoryRecord, &gPlatformFTLibrary);
FT_Add_Default_Modules(gPlatformFTLibrary);
// Bug 1886573: At this point, we don't yet have primary screen depth. // This setting of screen depth to 0 is preserving existing behavior, // and should be fixed.
int32_t screenDepth = 0;
mOffscreenFormat = screenDepth == 16 ? SurfaceFormat::R5G6B5_UINT16
: SurfaceFormat::X8R8G8B8_UINT32;
if (StaticPrefs::gfx_android_rgb16_force_AtStartup()) {
mOffscreenFormat = SurfaceFormat::R5G6B5_UINT16;
}
}
if (PrefersColor(aPresentation)) {
aFontList.AppendElement(kNotoColorEmoji);
}
if (IS_IN_BMP(aCh)) { // try language-specific "Droid Sans *" and "Noto Sans *" fonts for // certain blocks, as most devices probably have these
uint8_t block = (aCh >> 8) & 0xff; switch (block) { case 0x05:
aFontList.AppendElement("Noto Sans Hebrew");
aFontList.AppendElement("Droid Sans Hebrew");
aFontList.AppendElement("Noto Sans Armenian");
aFontList.AppendElement("Droid Sans Armenian"); break; case 0x06:
aFontList.AppendElement("Noto Sans Arabic");
aFontList.AppendElement("Droid Sans Arabic"); break; case 0x09:
aFontList.AppendElement("Noto Sans Devanagari");
aFontList.AppendElement("Noto Sans Bengali");
aFontList.AppendElement("Droid Sans Devanagari"); break; case 0x0a:
aFontList.AppendElement("Noto Sans Gurmukhi");
aFontList.AppendElement("Noto Sans Gujarati"); break; case 0x0b:
aFontList.AppendElement("Noto Sans Tamil");
aFontList.AppendElement("Noto Sans Oriya");
aFontList.AppendElement("Droid Sans Tamil"); break; case 0x0c:
aFontList.AppendElement("Noto Sans Telugu");
aFontList.AppendElement("Noto Sans Kannada"); break; case 0x0d:
aFontList.AppendElement("Noto Sans Malayalam");
aFontList.AppendElement("Noto Sans Sinhala"); break; case 0x0e:
aFontList.AppendElement("Noto Sans Thai");
aFontList.AppendElement("Noto Sans Lao");
aFontList.AppendElement("Droid Sans Thai"); break; case 0x0f:
aFontList.AppendElement("Noto Sans Tibetan"); break; case 0x10: case 0x2d:
aFontList.AppendElement("Noto Sans Georgian");
aFontList.AppendElement("Droid Sans Georgian"); break; case 0x12: case 0x13:
aFontList.AppendElement("Noto Sans Ethiopic");
aFontList.AppendElement("Droid Sans Ethiopic"); break; case 0x21: case 0x23: case 0x24: case 0x26: case 0x27: case 0x29:
aFontList.AppendElement("Noto Sans Symbols"); break; case 0xf9: case 0xfa: if (IsJapaneseLocale()) {
aFontList.AppendElement(kMotoyaLMaru);
aFontList.AppendElement(kNotoSansCJKJP);
aFontList.AppendElement(kDroidSansJapanese);
} break; default: if (block >= 0x2e && block <= 0x9f && IsJapaneseLocale()) {
aFontList.AppendElement(kMotoyaLMaru);
aFontList.AppendElement(kNotoSansCJKJP);
aFontList.AppendElement(kDroidSansJapanese);
} break;
}
} // and try Droid Sans Fallback as a last resort
aFontList.AppendElement("Droid Sans Fallback");
}
bool gfxAndroidPlatform::FontHintingEnabled() { // In "mobile" builds, we sometimes use non-reflow-zoom, so we // might not want hinting. Let's see.
#ifdef MOZ_WIDGET_ANDROID // On Android, we currently only use gecko to render web // content that can always be be non-reflow-zoomed. So turn off // hinting. // // XXX when gecko-android-java is used as an "app runtime", we may // want to re-enable hinting for non-browser processes there. // // If this value is changed, we must ensure that the argument passed // to SkInitCairoFT() in GPUParent::RecvInit() is also updated. returnfalse; #endif// MOZ_WIDGET_ANDROID
// Currently, we don't have any other targets, but if/when we do, // decide how to handle them here.
MOZ_ASSERT_UNREACHABLE("oops, what platform is this?"); return gfxPlatform::FontHintingEnabled();
}
bool gfxAndroidPlatform::RequiresLinearZoom() { #ifdef MOZ_WIDGET_ANDROID // On Android, we currently only use gecko to render web // content that can always be be non-reflow-zoomed. // // XXX when gecko-android-java is used as an "app runtime", we may // want to use linear zoom only for the web browser process, not other apps. returntrue; #endif
MOZ_ASSERT_UNREACHABLE("oops, what platform is this?"); return gfxPlatform::RequiresLinearZoom();
}
bool gfxAndroidPlatform::CheckVariationFontSupport() { // Don't attempt to use variations on Android API versions up to Marshmallow, // because the system freetype version is too old and the parent process may // access it during printing (bug 1845174). return jni::GetAPIVersion() > 23;
}
class AndroidVsyncSource final : public VsyncSource, public widget::AndroidVsync::Observer { public:
AndroidVsyncSource() : mAndroidVsync(widget::AndroidVsync::GetInstance()) {}
// Override for the widget::AndroidVsync::Observer method void OnVsync(const TimeStamp& aTimeStamp) override { // Use the timebase from the frame callback as the vsync time, unless it // is in the future.
TimeStamp now = TimeStamp::Now();
TimeStamp vsyncTime = aTimeStamp < now ? aTimeStamp : now;
TimeStamp outputTime = vsyncTime + GetVsyncRate();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.