2013-01-18 04:45:11 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set ts=8 sts=4 et sw=4 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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/. */
|
2010-05-11 21:27:36 +04:00
|
|
|
|
2012-08-23 14:23:43 +04:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2010-05-11 21:27:36 +04:00
|
|
|
#include "gfxAndroidPlatform.h"
|
2011-11-02 23:55:03 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2014-08-25 23:34:00 +04:00
|
|
|
#include "mozilla/CountingAllocatorBase.h"
|
2017-03-13 06:39:22 +03:00
|
|
|
#include "mozilla/intl/LocaleService.h"
|
2017-03-22 10:27:14 +03:00
|
|
|
#include "mozilla/intl/OSPreferences.h"
|
2013-01-17 20:52:41 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2010-05-11 21:27:36 +04:00
|
|
|
|
2014-02-09 12:04:38 +04:00
|
|
|
#include "gfx2DGlue.h"
|
2011-09-23 15:15:36 +04:00
|
|
|
#include "gfxFT2FontList.h"
|
2010-05-11 21:27:36 +04:00
|
|
|
#include "gfxImageSurface.h"
|
2014-09-16 13:58:12 +04:00
|
|
|
#include "gfxTextRun.h"
|
2012-02-09 02:52:57 +04:00
|
|
|
#include "nsXULAppAPI.h"
|
2012-03-14 00:59:26 +04:00
|
|
|
#include "nsIScreen.h"
|
|
|
|
#include "nsIScreenManager.h"
|
2013-10-08 03:15:59 +04:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2017-11-12 10:36:24 +03:00
|
|
|
#include "nsUnicodeProperties.h"
|
2014-03-04 02:11:06 +04:00
|
|
|
#include "gfxPrefs.h"
|
2011-09-23 15:15:36 +04:00
|
|
|
#include "cairo.h"
|
2014-12-18 19:30:06 +03:00
|
|
|
#include "VsyncSource.h"
|
2010-05-11 21:27:36 +04:00
|
|
|
|
|
|
|
#include "ft2build.h"
|
|
|
|
#include FT_FREETYPE_H
|
2012-11-20 07:00:19 +04:00
|
|
|
#include FT_MODULE_H
|
|
|
|
|
2016-12-20 10:24:49 +03:00
|
|
|
#include "GeneratedJNINatives.h"
|
|
|
|
|
2011-11-02 23:55:03 +04:00
|
|
|
using namespace mozilla;
|
2012-08-23 14:23:43 +04:00
|
|
|
using namespace mozilla::dom;
|
2011-11-02 23:55:03 +04:00
|
|
|
using namespace mozilla::gfx;
|
2017-11-12 10:36:24 +03:00
|
|
|
using namespace mozilla::unicode;
|
2017-03-13 06:39:22 +03:00
|
|
|
using mozilla::intl::LocaleService;
|
2017-03-22 10:27:14 +03:00
|
|
|
using mozilla::intl::OSPreferences;
|
2010-05-11 21:27:36 +04:00
|
|
|
|
2013-07-31 19:44:31 +04:00
|
|
|
static FT_Library gPlatformFTLibrary = nullptr;
|
2010-05-11 21:27:36 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class FreetypeReporter final : public nsIMemoryReporter,
|
2018-11-30 13:46:48 +03:00
|
|
|
public CountingAllocatorBase<FreetypeReporter> {
|
|
|
|
private:
|
|
|
|
~FreetypeReporter() {}
|
2014-08-26 23:07:59 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2013-12-08 10:09:10 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
static void* Malloc(FT_Memory, long size) { return CountingMalloc(size); }
|
2012-11-20 07:00:19 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
static void Free(FT_Memory, void* p) { return CountingFree(p); }
|
2012-11-20 07:00:19 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
static void* Realloc(FT_Memory, long cur_size, long new_size, void* p) {
|
|
|
|
return CountingRealloc(p, new_size);
|
|
|
|
}
|
2012-11-20 07:00:19 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
|
|
|
nsISupports* aData, bool aAnonymize) override {
|
|
|
|
MOZ_COLLECT_REPORT("explicit/freetype", KIND_HEAP, UNITS_BYTES,
|
|
|
|
MemoryAllocated(), "Memory used by Freetype.");
|
2016-08-24 08:23:45 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-01-18 04:45:11 +04:00
|
|
|
};
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(FreetypeReporter, nsIMemoryReporter)
|
2013-12-08 10:09:10 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
template <>
|
|
|
|
CountingAllocatorBase<FreetypeReporter>::AmountType
|
2018-07-31 22:22:54 +03:00
|
|
|
CountingAllocatorBase<FreetypeReporter>::sAmount(0);
|
2013-01-18 04:45:11 +04:00
|
|
|
|
|
|
|
static FT_MemoryRec_ sFreetypeMemoryRecord;
|
2012-11-20 07:00:19 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
gfxAndroidPlatform::gfxAndroidPlatform() {
|
|
|
|
// A custom allocator. It counts allocations, enabling memory reporting.
|
|
|
|
sFreetypeMemoryRecord.user = nullptr;
|
|
|
|
sFreetypeMemoryRecord.alloc = FreetypeReporter::Malloc;
|
|
|
|
sFreetypeMemoryRecord.free = FreetypeReporter::Free;
|
|
|
|
sFreetypeMemoryRecord.realloc = FreetypeReporter::Realloc;
|
2012-11-20 07:00:19 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
// 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);
|
2012-11-20 07:00:19 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
Factory::SetFTLibrary(gPlatformFTLibrary);
|
2017-05-18 04:56:24 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
RegisterStrongMemoryReporter(new FreetypeReporter());
|
2012-03-14 00:59:26 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
mOffscreenFormat = GetScreenDepth() == 16 ? SurfaceFormat::R5G6B5_UINT16
|
|
|
|
: SurfaceFormat::X8R8G8B8_UINT32;
|
2013-01-17 20:52:41 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
if (gfxPrefs::AndroidRGB16Force()) {
|
|
|
|
mOffscreenFormat = SurfaceFormat::R5G6B5_UINT16;
|
|
|
|
}
|
2010-05-11 21:27:36 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
gfxAndroidPlatform::~gfxAndroidPlatform() {
|
|
|
|
FT_Done_Library(gPlatformFTLibrary);
|
|
|
|
gPlatformFTLibrary = nullptr;
|
2010-05-11 21:27:36 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
already_AddRefed<gfxASurface> gfxAndroidPlatform::CreateOffscreenSurface(
|
|
|
|
const IntSize& aSize, gfxImageFormat aFormat) {
|
|
|
|
if (!Factory::AllowedSurfaceSize(aSize)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2016-09-15 17:36:21 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
RefPtr<gfxASurface> newSurface;
|
|
|
|
newSurface = new gfxImageSurface(aSize, aFormat);
|
2010-05-11 21:27:36 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
return newSurface.forget();
|
2010-05-11 21:27:36 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
static bool IsJapaneseLocale() {
|
|
|
|
static bool sInitialized = false;
|
|
|
|
static bool sIsJapanese = false;
|
2013-04-07 01:04:30 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
if (!sInitialized) {
|
|
|
|
sInitialized = true;
|
2013-04-07 01:04:30 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
nsAutoCString appLocale;
|
|
|
|
LocaleService::GetInstance()->GetAppLocaleAsLangTag(appLocale);
|
2017-03-13 06:39:22 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
const nsDependentCSubstring lang(appLocale, 0, 2);
|
|
|
|
if (lang.EqualsLiteral("ja")) {
|
|
|
|
sIsJapanese = true;
|
|
|
|
} else {
|
|
|
|
OSPreferences::GetInstance()->GetSystemLocale(appLocale);
|
2017-03-22 10:27:14 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
const nsDependentCSubstring lang(appLocale, 0, 2);
|
|
|
|
if (lang.EqualsLiteral("ja")) {
|
|
|
|
sIsJapanese = true;
|
|
|
|
}
|
2013-04-07 01:04:30 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-04-07 01:04:30 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
return sIsJapanese;
|
2013-04-07 01:04:30 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
void gfxAndroidPlatform::GetCommonFallbackFonts(
|
|
|
|
uint32_t aCh, uint32_t aNextCh, Script aRunScript,
|
|
|
|
nsTArray<const char*>& aFontList) {
|
|
|
|
static const char kDroidSansJapanese[] = "Droid Sans Japanese";
|
|
|
|
static const char kMotoyaLMaru[] = "MotoyaLMaru";
|
|
|
|
static const char kNotoSansCJKJP[] = "Noto Sans CJK JP";
|
|
|
|
static const char kNotoColorEmoji[] = "Noto Color Emoji";
|
|
|
|
|
|
|
|
EmojiPresentation emoji = GetEmojiPresentation(aCh);
|
|
|
|
if (emoji != EmojiPresentation::TextOnly) {
|
|
|
|
if (aNextCh == kVariationSelector16 ||
|
|
|
|
(aNextCh != kVariationSelector15 &&
|
|
|
|
emoji == EmojiPresentation::EmojiDefault)) {
|
|
|
|
// if char is followed by VS16, try for a color emoji glyph
|
|
|
|
aFontList.AppendElement(kNotoColorEmoji);
|
2014-09-30 10:27:55 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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("Droid Sans Hebrew");
|
|
|
|
aFontList.AppendElement("Droid Sans Armenian");
|
|
|
|
break;
|
|
|
|
case 0x06:
|
|
|
|
aFontList.AppendElement("Droid Sans Arabic");
|
|
|
|
break;
|
|
|
|
case 0x09:
|
|
|
|
aFontList.AppendElement("Noto Sans Devanagari");
|
|
|
|
aFontList.AppendElement("Droid Sans Devanagari");
|
|
|
|
break;
|
|
|
|
case 0x0b:
|
|
|
|
aFontList.AppendElement("Noto Sans Tamil");
|
|
|
|
aFontList.AppendElement("Droid Sans Tamil");
|
|
|
|
break;
|
|
|
|
case 0x0e:
|
|
|
|
aFontList.AppendElement("Noto Sans Thai");
|
|
|
|
aFontList.AppendElement("Droid Sans Thai");
|
|
|
|
break;
|
|
|
|
case 0x10:
|
|
|
|
case 0x2d:
|
|
|
|
aFontList.AppendElement("Droid Sans Georgian");
|
|
|
|
break;
|
|
|
|
case 0x12:
|
|
|
|
case 0x13:
|
|
|
|
aFontList.AppendElement("Droid Sans Ethiopic");
|
|
|
|
break;
|
|
|
|
case 0xf9:
|
|
|
|
case 0xfa:
|
|
|
|
if (IsJapaneseLocale()) {
|
|
|
|
aFontList.AppendElement(kMotoyaLMaru);
|
|
|
|
aFontList.AppendElement(kNotoSansCJKJP);
|
|
|
|
aFontList.AppendElement(kDroidSansJapanese);
|
2013-03-04 21:03:16 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (block >= 0x2e && block <= 0x9f && IsJapaneseLocale()) {
|
|
|
|
aFontList.AppendElement(kMotoyaLMaru);
|
|
|
|
aFontList.AppendElement(kNotoSansCJKJP);
|
|
|
|
aFontList.AppendElement(kDroidSansJapanese);
|
|
|
|
}
|
|
|
|
break;
|
2013-03-04 21:03:16 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
// and try Droid Sans Fallback as a last resort
|
|
|
|
aFontList.AppendElement("Droid Sans Fallback");
|
2013-03-04 21:03:16 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
void gfxAndroidPlatform::GetSystemFontList(
|
|
|
|
InfallibleTArray<FontListEntry>* retValue) {
|
|
|
|
gfxFT2FontList::PlatformFontList()->GetSystemFontList(retValue);
|
2011-01-13 07:04:42 +03:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
gfxPlatformFontList* gfxAndroidPlatform::CreatePlatformFontList() {
|
|
|
|
gfxPlatformFontList* list = new gfxFT2FontList();
|
|
|
|
if (NS_SUCCEEDED(list->InitFontList())) {
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
gfxPlatformFontList::Shutdown();
|
|
|
|
return nullptr;
|
2010-07-16 10:03:45 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
gfxFontGroup* gfxAndroidPlatform::CreateFontGroup(
|
|
|
|
const FontFamilyList& aFontFamilyList, const gfxFontStyle* aStyle,
|
|
|
|
gfxTextPerfMetrics* aTextPerf, gfxUserFontSet* aUserFontSet,
|
|
|
|
gfxFloat aDevToCssSize) {
|
|
|
|
return new gfxFontGroup(aFontFamilyList, aStyle, aTextPerf, aUserFontSet,
|
|
|
|
aDevToCssSize);
|
2010-05-11 21:27:36 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
FT_Library gfxAndroidPlatform::GetFTLibrary() { return gPlatformFTLibrary; }
|
2010-05-11 21:27:36 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
bool gfxAndroidPlatform::FontHintingEnabled() {
|
|
|
|
// In "mobile" builds, we sometimes use non-reflow-zoom, so we
|
|
|
|
// might not want hinting. Let's see.
|
2013-01-15 19:19:28 +04:00
|
|
|
|
2016-09-08 17:03:34 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2018-11-30 13:46:48 +03:00
|
|
|
// 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.
|
|
|
|
return false;
|
|
|
|
#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();
|
2013-01-15 19:19:28 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
bool gfxAndroidPlatform::RequiresLinearZoom() {
|
2016-09-08 17:03:34 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2018-11-30 13:46:48 +03:00
|
|
|
// 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.
|
|
|
|
return true;
|
2013-01-15 19:19:28 +04:00
|
|
|
#endif
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("oops, what platform is this?");
|
|
|
|
return gfxPlatform::RequiresLinearZoom();
|
2012-02-09 02:52:57 +04:00
|
|
|
}
|
2012-05-15 23:41:20 +04:00
|
|
|
|
2016-12-20 10:24:49 +03:00
|
|
|
class AndroidVsyncSource final : public VsyncSource {
|
2018-11-30 13:46:48 +03:00
|
|
|
public:
|
|
|
|
class JavaVsyncSupport final
|
|
|
|
: public java::VsyncSource::Natives<JavaVsyncSupport> {
|
|
|
|
public:
|
|
|
|
using Base = java::VsyncSource::Natives<JavaVsyncSupport>;
|
|
|
|
using Base::DisposeNative;
|
|
|
|
|
|
|
|
static void NotifyVsync() {
|
|
|
|
GetDisplayInstance().NotifyVsync(TimeStamp::Now());
|
|
|
|
}
|
|
|
|
};
|
2016-12-20 10:24:49 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
class Display final : public VsyncSource::Display {
|
|
|
|
public:
|
|
|
|
Display()
|
|
|
|
: mJavaVsync(java::VsyncSource::INSTANCE()), mObservingVsync(false) {
|
|
|
|
JavaVsyncSupport::Init(); // To register native methods.
|
|
|
|
}
|
2016-12-20 10:24:49 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
~Display() { DisableVsync(); }
|
2016-12-20 10:24:49 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
bool IsVsyncEnabled() override {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(mJavaVsync);
|
2016-12-20 10:24:49 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
return mObservingVsync;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EnableVsync() override {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(mJavaVsync);
|
|
|
|
|
|
|
|
if (mObservingVsync) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bool ok = mJavaVsync->ObserveVsync(true);
|
|
|
|
if (ok && !mVsyncDuration) {
|
|
|
|
float fps = mJavaVsync->GetRefreshRate();
|
|
|
|
mVsyncDuration = TimeDuration::FromMilliseconds(1000.0 / fps);
|
|
|
|
}
|
|
|
|
mObservingVsync = ok;
|
|
|
|
MOZ_ASSERT(mObservingVsync);
|
|
|
|
}
|
2016-12-20 10:24:49 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
void DisableVsync() override {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(mJavaVsync);
|
2016-12-20 10:24:49 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
if (!mObservingVsync) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mObservingVsync = mJavaVsync->ObserveVsync(false);
|
|
|
|
MOZ_ASSERT(!mObservingVsync);
|
|
|
|
}
|
2016-12-20 10:24:49 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
TimeDuration GetVsyncRate() override { return mVsyncDuration; }
|
2016-12-20 10:24:49 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
void Shutdown() override {
|
|
|
|
DisableVsync();
|
|
|
|
mJavaVsync = nullptr;
|
|
|
|
}
|
2016-12-20 10:24:49 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
private:
|
|
|
|
java::VsyncSource::GlobalRef mJavaVsync;
|
|
|
|
bool mObservingVsync;
|
|
|
|
TimeDuration mVsyncDuration;
|
|
|
|
};
|
2016-12-20 10:24:49 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
Display& GetGlobalDisplay() final { return GetDisplayInstance(); }
|
2016-12-20 10:24:49 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
private:
|
|
|
|
virtual ~AndroidVsyncSource() {}
|
2016-12-20 10:24:49 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
static Display& GetDisplayInstance() {
|
|
|
|
static Display globalDisplay;
|
|
|
|
return globalDisplay;
|
|
|
|
}
|
2016-12-20 10:24:49 +03:00
|
|
|
};
|
|
|
|
|
2014-12-18 19:30:06 +03:00
|
|
|
already_AddRefed<mozilla::gfx::VsyncSource>
|
2018-11-30 13:46:48 +03:00
|
|
|
gfxAndroidPlatform::CreateHardwareVsyncSource() {
|
|
|
|
// Vsync was introduced since JB (API 16~18) but inaccurate. Enable only for
|
|
|
|
// KK (API 19) and later.
|
|
|
|
if (AndroidBridge::Bridge() &&
|
|
|
|
AndroidBridge::Bridge()->GetAPIVersion() >= 19) {
|
|
|
|
RefPtr<AndroidVsyncSource> vsyncSource = new AndroidVsyncSource();
|
|
|
|
return vsyncSource.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_WARNING("Vsync not supported. Falling back to software vsync");
|
|
|
|
return gfxPlatform::CreateHardwareVsyncSource();
|
2014-12-18 19:30:06 +03:00
|
|
|
}
|