2006-02-22 04:44:31 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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/. */
|
2006-02-22 04:44:31 +03:00
|
|
|
|
|
|
|
#include "gfxPlatformMac.h"
|
|
|
|
|
|
|
|
#include "gfxQuartzSurface.h"
|
2008-02-06 09:48:47 +03:00
|
|
|
#include "gfxQuartzImageSurface.h"
|
2011-11-02 23:55:03 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2006-02-22 04:44:31 +03:00
|
|
|
|
2009-08-16 17:52:12 +04:00
|
|
|
#include "gfxMacPlatformFontList.h"
|
2010-03-10 15:46:41 +03:00
|
|
|
#include "gfxMacFont.h"
|
|
|
|
#include "gfxCoreTextShaper.h"
|
2014-09-16 13:58:12 +04:00
|
|
|
#include "gfxTextRun.h"
|
2008-10-01 07:01:53 +04:00
|
|
|
#include "gfxUserFontSet.h"
|
2009-03-30 04:31:51 +04:00
|
|
|
|
2009-01-18 23:14:14 +03:00
|
|
|
#include "nsTArray.h"
|
2011-06-12 06:30:16 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2014-11-19 00:28:42 +03:00
|
|
|
#include "mozilla/VsyncDispatcher.h"
|
2009-04-07 20:02:11 +04:00
|
|
|
#include "qcms.h"
|
2013-10-08 03:15:59 +04:00
|
|
|
#include "gfx2DGlue.h"
|
2007-07-24 02:02:17 +04:00
|
|
|
|
2011-05-11 04:44:35 +04:00
|
|
|
#include <dlfcn.h>
|
2014-11-19 00:28:42 +03:00
|
|
|
#include <CoreVideo/CoreVideo.h>
|
2011-05-11 04:44:35 +04:00
|
|
|
|
2013-12-19 20:42:19 +04:00
|
|
|
#include "nsCocoaFeatures.h"
|
2014-12-18 19:30:06 +03:00
|
|
|
#include "mozilla/layers/CompositorParent.h"
|
|
|
|
#include "VsyncSource.h"
|
2013-12-19 20:42:19 +04:00
|
|
|
|
2011-06-12 06:30:16 +04:00
|
|
|
using namespace mozilla;
|
2011-11-02 23:55:03 +04:00
|
|
|
using namespace mozilla::gfx;
|
2011-06-12 06:30:16 +04:00
|
|
|
|
2011-05-11 04:44:35 +04:00
|
|
|
// cribbed from CTFontManager.h
|
|
|
|
enum {
|
|
|
|
kAutoActivationDisabled = 1
|
|
|
|
};
|
|
|
|
typedef uint32_t AutoActivationSetting;
|
|
|
|
|
|
|
|
// bug 567552 - disable auto-activation of fonts
|
|
|
|
|
2014-12-18 19:30:06 +03:00
|
|
|
static void
|
2011-05-11 04:44:35 +04:00
|
|
|
DisableFontActivation()
|
|
|
|
{
|
|
|
|
// get the main bundle identifier
|
|
|
|
CFBundleRef mainBundle = ::CFBundleGetMainBundle();
|
2013-07-31 19:44:31 +04:00
|
|
|
CFStringRef mainBundleID = nullptr;
|
2011-05-11 04:44:35 +04:00
|
|
|
|
|
|
|
if (mainBundle) {
|
|
|
|
mainBundleID = ::CFBundleGetIdentifier(mainBundle);
|
|
|
|
}
|
|
|
|
|
2014-03-05 23:18:38 +04:00
|
|
|
// bug 969388 and bug 922590 - mainBundlID as null is sometimes problematic
|
|
|
|
if (!mainBundleID) {
|
|
|
|
NS_WARNING("missing bundle ID, packaging set up incorrectly");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-11 04:44:35 +04:00
|
|
|
// if possible, fetch CTFontManagerSetAutoActivationSetting
|
|
|
|
void (*CTFontManagerSetAutoActivationSettingPtr)
|
|
|
|
(CFStringRef, AutoActivationSetting);
|
|
|
|
CTFontManagerSetAutoActivationSettingPtr =
|
|
|
|
(void (*)(CFStringRef, AutoActivationSetting))
|
|
|
|
dlsym(RTLD_DEFAULT, "CTFontManagerSetAutoActivationSetting");
|
|
|
|
|
|
|
|
// bug 567552 - disable auto-activation of fonts
|
|
|
|
if (CTFontManagerSetAutoActivationSettingPtr) {
|
|
|
|
CTFontManagerSetAutoActivationSettingPtr(mainBundleID,
|
|
|
|
kAutoActivationDisabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-22 04:44:31 +03:00
|
|
|
gfxPlatformMac::gfxPlatformMac()
|
|
|
|
{
|
2013-03-08 03:00:07 +04:00
|
|
|
DisableFontActivation();
|
2008-05-01 13:07:17 +04:00
|
|
|
mFontAntiAliasingThreshold = ReadAntiAliasingThreshold();
|
2012-07-25 04:45:58 +04:00
|
|
|
|
2014-01-10 23:06:16 +04:00
|
|
|
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) |
|
|
|
|
BackendTypeBit(BackendType::SKIA) |
|
|
|
|
BackendTypeBit(BackendType::COREGRAPHICS);
|
2014-09-30 07:12:28 +04:00
|
|
|
uint32_t contentMask = BackendTypeBit(BackendType::COREGRAPHICS);
|
2014-01-10 23:06:16 +04:00
|
|
|
InitBackendPrefs(canvasMask, BackendType::COREGRAPHICS,
|
2014-09-30 07:12:28 +04:00
|
|
|
contentMask, BackendType::COREGRAPHICS);
|
2015-02-02 23:24:01 +03:00
|
|
|
|
|
|
|
// XXX: Bug 1036682 - we run out of fds on Mac when using tiled layers because
|
|
|
|
// with 256x256 tiles we can easily hit the soft limit of 800 when using double
|
|
|
|
// buffered tiles in e10s, so let's bump the soft limit to the hard limit for the OS
|
2015-02-06 22:29:26 +03:00
|
|
|
// up to a new cap of OPEN_MAX.
|
2015-02-02 23:24:01 +03:00
|
|
|
struct rlimit limits;
|
|
|
|
if (getrlimit(RLIMIT_NOFILE, &limits) == 0) {
|
2015-02-06 22:29:26 +03:00
|
|
|
limits.rlim_cur = std::min(rlim_t(OPEN_MAX), limits.rlim_max);
|
2015-02-02 23:24:01 +03:00
|
|
|
if (setrlimit(RLIMIT_NOFILE, &limits) != 0) {
|
|
|
|
NS_WARNING("Unable to bump RLIMIT_NOFILE to the maximum number on this OS");
|
|
|
|
}
|
|
|
|
}
|
2009-03-30 04:31:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxPlatformMac::~gfxPlatformMac()
|
|
|
|
{
|
2010-03-10 15:46:41 +03:00
|
|
|
gfxCoreTextShaper::Shutdown();
|
2006-02-22 04:44:31 +03:00
|
|
|
}
|
|
|
|
|
2009-08-16 17:52:12 +04:00
|
|
|
gfxPlatformFontList*
|
|
|
|
gfxPlatformMac::CreatePlatformFontList()
|
|
|
|
{
|
2010-11-08 14:02:27 +03:00
|
|
|
gfxPlatformFontList* list = new gfxMacPlatformFontList();
|
|
|
|
if (NS_SUCCEEDED(list->InitFontList())) {
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
gfxPlatformFontList::Shutdown();
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2009-08-16 17:52:12 +04:00
|
|
|
}
|
|
|
|
|
2006-03-25 03:34:48 +03:00
|
|
|
already_AddRefed<gfxASurface>
|
2014-02-09 12:04:38 +04:00
|
|
|
gfxPlatformMac::CreateOffscreenSurface(const IntSize& size,
|
2013-09-25 00:45:13 +04:00
|
|
|
gfxContentType contentType)
|
2006-02-22 04:44:31 +03:00
|
|
|
{
|
2013-04-28 15:52:10 +04:00
|
|
|
nsRefPtr<gfxASurface> newSurface =
|
2014-09-30 07:12:28 +04:00
|
|
|
new gfxQuartzSurface(ThebesIntSize(size),
|
2014-02-09 12:04:38 +04:00
|
|
|
OptimalFormatForContent(contentType));
|
2013-04-28 15:52:10 +04:00
|
|
|
return newSurface.forget();
|
2006-02-22 04:44:31 +03:00
|
|
|
}
|
2012-01-09 22:54:44 +04:00
|
|
|
|
2012-09-24 19:02:49 +04:00
|
|
|
TemporaryRef<ScaledFont>
|
2012-07-24 14:18:37 +04:00
|
|
|
gfxPlatformMac::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
2011-11-02 23:55:03 +04:00
|
|
|
{
|
|
|
|
gfxMacFont *font = static_cast<gfxMacFont*>(aFont);
|
2012-09-24 19:02:49 +04:00
|
|
|
return font->GetScaledFont(aTarget);
|
2011-11-02 23:55:03 +04:00
|
|
|
}
|
|
|
|
|
2008-03-13 13:32:50 +03:00
|
|
|
nsresult
|
|
|
|
gfxPlatformMac::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName)
|
|
|
|
{
|
2009-08-16 17:52:12 +04:00
|
|
|
gfxPlatformFontList::PlatformFontList()->GetStandardFamilyName(aFontName, aFamilyName);
|
2008-03-13 13:32:50 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-04-02 23:06:16 +04:00
|
|
|
gfxFontGroup *
|
2014-06-06 10:09:23 +04:00
|
|
|
gfxPlatformMac::CreateFontGroup(const FontFamilyList& aFontFamilyList,
|
2008-10-01 07:01:53 +04:00
|
|
|
const gfxFontStyle *aStyle,
|
|
|
|
gfxUserFontSet *aUserFontSet)
|
2007-04-02 23:06:16 +04:00
|
|
|
{
|
2014-06-06 10:09:23 +04:00
|
|
|
return new gfxFontGroup(aFontFamilyList, aStyle, aUserFontSet);
|
2008-10-01 07:01:53 +04:00
|
|
|
}
|
|
|
|
|
2009-08-16 17:52:12 +04:00
|
|
|
// these will move to gfxPlatform once all platforms support the fontlist
|
2008-10-01 07:01:53 +04:00
|
|
|
gfxFontEntry*
|
2014-09-08 11:23:19 +04:00
|
|
|
gfxPlatformMac::LookupLocalFont(const nsAString& aFontName,
|
|
|
|
uint16_t aWeight,
|
|
|
|
int16_t aStretch,
|
|
|
|
bool aItalic)
|
2008-10-01 07:01:53 +04:00
|
|
|
{
|
2014-09-08 11:23:19 +04:00
|
|
|
return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aFontName,
|
|
|
|
aWeight,
|
|
|
|
aStretch,
|
|
|
|
aItalic);
|
2008-10-01 07:01:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxFontEntry*
|
2014-09-08 11:23:19 +04:00
|
|
|
gfxPlatformMac::MakePlatformFont(const nsAString& aFontName,
|
|
|
|
uint16_t aWeight,
|
|
|
|
int16_t aStretch,
|
|
|
|
bool aItalic,
|
|
|
|
const uint8_t* aFontData,
|
|
|
|
uint32_t aLength)
|
2008-10-01 07:01:53 +04:00
|
|
|
{
|
2009-10-07 18:13:40 +04:00
|
|
|
// Ownership of aFontData is received here, and passed on to
|
|
|
|
// gfxPlatformFontList::MakePlatformFont(), which must ensure the data
|
|
|
|
// is released with NS_Free when no longer needed
|
2014-09-08 11:23:19 +04:00
|
|
|
return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aFontName,
|
|
|
|
aWeight,
|
|
|
|
aStretch,
|
|
|
|
aItalic,
|
2009-10-07 18:13:40 +04:00
|
|
|
aFontData,
|
|
|
|
aLength);
|
2008-10-01 07:01:53 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
gfxPlatformMac::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags)
|
2008-10-01 07:01:53 +04:00
|
|
|
{
|
2009-01-13 08:16:58 +03:00
|
|
|
// check for strange format flags
|
|
|
|
NS_ASSERTION(!(aFormatFlags & gfxUserFontSet::FLAG_FORMAT_NOT_USED),
|
|
|
|
"strange font format hint set");
|
|
|
|
|
|
|
|
// accept supported formats
|
2014-10-04 14:36:05 +04:00
|
|
|
if (aFormatFlags & (gfxUserFontSet::FLAG_FORMATS_COMMON |
|
2009-01-13 08:16:58 +03:00
|
|
|
gfxUserFontSet::FLAG_FORMAT_TRUETYPE_AAT)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2008-10-01 07:01:53 +04:00
|
|
|
}
|
|
|
|
|
2009-01-13 08:16:58 +03:00
|
|
|
// reject all other formats, known and unknown
|
|
|
|
if (aFormatFlags != 0) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-01-13 08:16:58 +03:00
|
|
|
}
|
2008-10-01 07:01:53 +04:00
|
|
|
|
2009-01-13 08:16:58 +03:00
|
|
|
// no format hint set, need to look at data
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2007-04-02 23:06:16 +04:00
|
|
|
}
|
|
|
|
|
2009-08-16 17:52:12 +04:00
|
|
|
// these will also move to gfxPlatform once all platforms support the fontlist
|
2006-11-22 03:52:09 +03:00
|
|
|
nsresult
|
2010-02-24 20:57:57 +03:00
|
|
|
gfxPlatformMac::GetFontList(nsIAtom *aLangGroup,
|
2006-11-22 03:52:09 +03:00
|
|
|
const nsACString& aGenericFamily,
|
2009-01-18 23:14:14 +03:00
|
|
|
nsTArray<nsString>& aListOfFonts)
|
2006-11-22 03:52:09 +03:00
|
|
|
{
|
2009-08-16 17:52:12 +04:00
|
|
|
gfxPlatformFontList::PlatformFontList()->GetFontList(aLangGroup, aGenericFamily, aListOfFonts);
|
2006-11-22 03:52:09 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2006-12-22 06:56:37 +03:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
gfxPlatformMac::UpdateFontList()
|
|
|
|
{
|
2009-08-16 17:52:12 +04:00
|
|
|
gfxPlatformFontList::PlatformFontList()->UpdateFontList();
|
2006-12-22 06:56:37 +03:00
|
|
|
return NS_OK;
|
2007-02-08 23:47:48 +03:00
|
|
|
}
|
2007-07-24 02:02:17 +04:00
|
|
|
|
2012-03-09 06:05:24 +04:00
|
|
|
static const char kFontArialUnicodeMS[] = "Arial Unicode MS";
|
|
|
|
static const char kFontAppleBraille[] = "Apple Braille";
|
2014-04-15 03:45:18 +04:00
|
|
|
static const char kFontAppleColorEmoji[] = "Apple Color Emoji";
|
2012-03-09 06:05:24 +04:00
|
|
|
static const char kFontAppleSymbols[] = "Apple Symbols";
|
2014-04-15 03:45:18 +04:00
|
|
|
static const char kFontDevanagariSangamMN[] = "Devanagari Sangam MN";
|
|
|
|
static const char kFontEuphemiaUCAS[] = "Euphemia UCAS";
|
2012-03-09 06:05:24 +04:00
|
|
|
static const char kFontGeneva[] = "Geneva";
|
|
|
|
static const char kFontGeezaPro[] = "Geeza Pro";
|
2014-04-15 03:45:18 +04:00
|
|
|
static const char kFontGujaratiSangamMN[] = "Gujarati Sangam MN";
|
|
|
|
static const char kFontGurmukhiMN[] = "Gurmukhi MN";
|
2012-03-09 06:05:24 +04:00
|
|
|
static const char kFontHiraginoKakuGothic[] = "Hiragino Kaku Gothic ProN";
|
2014-04-15 03:45:18 +04:00
|
|
|
static const char kFontHiraginoSansGB[] = "Hiragino Sans GB";
|
|
|
|
static const char kFontKefa[] = "Kefa";
|
|
|
|
static const char kFontKhmerMN[] = "Khmer MN";
|
|
|
|
static const char kFontLaoMN[] = "Lao MN";
|
2012-03-09 06:05:24 +04:00
|
|
|
static const char kFontLucidaGrande[] = "Lucida Grande";
|
|
|
|
static const char kFontMenlo[] = "Menlo";
|
2014-04-15 03:45:18 +04:00
|
|
|
static const char kFontMicrosoftTaiLe[] = "Microsoft Tai Le";
|
|
|
|
static const char kFontMingLiUExtB[] = "MingLiU-ExtB";
|
|
|
|
static const char kFontMyanmarMN[] = "Myanmar MN";
|
2012-03-09 06:05:24 +04:00
|
|
|
static const char kFontPlantagenetCherokee[] = "Plantagenet Cherokee";
|
2014-04-15 03:45:18 +04:00
|
|
|
static const char kFontSimSunExtB[] = "SimSun-ExtB";
|
|
|
|
static const char kFontSongtiSC[] = "Songti SC";
|
2012-03-09 06:05:24 +04:00
|
|
|
static const char kFontSTHeiti[] = "STHeiti";
|
2014-04-15 03:45:18 +04:00
|
|
|
static const char kFontSTIXGeneral[] = "STIXGeneral";
|
|
|
|
static const char kFontTamilMN[] = "Tamil MN";
|
2012-03-09 06:05:24 +04:00
|
|
|
|
|
|
|
void
|
2014-09-30 10:27:55 +04:00
|
|
|
gfxPlatformMac::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aRunScript,
|
2012-03-09 06:05:24 +04:00
|
|
|
nsTArray<const char*>& aFontList)
|
|
|
|
{
|
2014-09-30 10:27:55 +04:00
|
|
|
if (aNextCh == 0xfe0f) {
|
|
|
|
aFontList.AppendElement(kFontAppleColorEmoji);
|
|
|
|
}
|
|
|
|
|
2012-03-09 06:05:24 +04:00
|
|
|
aFontList.AppendElement(kFontLucidaGrande);
|
|
|
|
|
|
|
|
if (!IS_IN_BMP(aCh)) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t p = aCh >> 16;
|
2014-04-15 03:45:18 +04:00
|
|
|
uint32_t b = aCh >> 8;
|
2012-03-09 06:05:24 +04:00
|
|
|
if (p == 1) {
|
2014-04-15 03:45:18 +04:00
|
|
|
if (b >= 0x1f0 && b < 0x1f7) {
|
|
|
|
aFontList.AppendElement(kFontAppleColorEmoji);
|
|
|
|
} else {
|
|
|
|
aFontList.AppendElement(kFontAppleSymbols);
|
|
|
|
aFontList.AppendElement(kFontSTIXGeneral);
|
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
}
|
|
|
|
} else if (p == 2) {
|
|
|
|
// OSX installations with MS Office may have these fonts
|
|
|
|
aFontList.AppendElement(kFontMingLiUExtB);
|
|
|
|
aFontList.AppendElement(kFontSimSunExtB);
|
2012-03-09 06:05:24 +04:00
|
|
|
}
|
|
|
|
} else {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t b = (aCh >> 8) & 0xff;
|
2012-03-09 06:05:24 +04:00
|
|
|
|
|
|
|
switch (b) {
|
|
|
|
case 0x03:
|
|
|
|
case 0x05:
|
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
break;
|
|
|
|
case 0x07:
|
|
|
|
aFontList.AppendElement(kFontGeezaPro);
|
|
|
|
break;
|
2014-04-15 03:45:18 +04:00
|
|
|
case 0x09:
|
|
|
|
aFontList.AppendElement(kFontDevanagariSangamMN);
|
|
|
|
break;
|
|
|
|
case 0x0a:
|
|
|
|
aFontList.AppendElement(kFontGurmukhiMN);
|
|
|
|
aFontList.AppendElement(kFontGujaratiSangamMN);
|
|
|
|
break;
|
|
|
|
case 0x0b:
|
|
|
|
aFontList.AppendElement(kFontTamilMN);
|
|
|
|
break;
|
|
|
|
case 0x0e:
|
|
|
|
aFontList.AppendElement(kFontLaoMN);
|
|
|
|
break;
|
|
|
|
case 0x0f:
|
|
|
|
aFontList.AppendElement(kFontSongtiSC);
|
|
|
|
break;
|
2012-03-09 06:05:24 +04:00
|
|
|
case 0x10:
|
|
|
|
aFontList.AppendElement(kFontMenlo);
|
2014-04-15 03:45:18 +04:00
|
|
|
aFontList.AppendElement(kFontMyanmarMN);
|
2012-03-09 06:05:24 +04:00
|
|
|
break;
|
|
|
|
case 0x13: // Cherokee
|
|
|
|
aFontList.AppendElement(kFontPlantagenetCherokee);
|
2014-04-15 03:45:18 +04:00
|
|
|
aFontList.AppendElement(kFontKefa);
|
2012-03-09 06:05:24 +04:00
|
|
|
break;
|
2014-04-15 03:45:18 +04:00
|
|
|
case 0x14: // Unified Canadian Aboriginal Syllabics
|
|
|
|
case 0x15:
|
|
|
|
case 0x16:
|
|
|
|
aFontList.AppendElement(kFontEuphemiaUCAS);
|
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
break;
|
|
|
|
case 0x18: // Mongolian, UCAS
|
2012-03-09 06:05:24 +04:00
|
|
|
aFontList.AppendElement(kFontSTHeiti);
|
2014-04-15 03:45:18 +04:00
|
|
|
aFontList.AppendElement(kFontEuphemiaUCAS);
|
|
|
|
break;
|
|
|
|
case 0x19: // Khmer
|
|
|
|
aFontList.AppendElement(kFontKhmerMN);
|
|
|
|
aFontList.AppendElement(kFontMicrosoftTaiLe);
|
2012-03-09 06:05:24 +04:00
|
|
|
break;
|
|
|
|
case 0x1d:
|
|
|
|
case 0x1e:
|
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
break;
|
|
|
|
case 0x20: // Symbol ranges
|
|
|
|
case 0x21:
|
|
|
|
case 0x22:
|
|
|
|
case 0x23:
|
|
|
|
case 0x24:
|
|
|
|
case 0x25:
|
|
|
|
case 0x26:
|
|
|
|
case 0x27:
|
|
|
|
case 0x29:
|
|
|
|
case 0x2a:
|
|
|
|
case 0x2b:
|
|
|
|
case 0x2e:
|
2014-08-20 11:54:38 +04:00
|
|
|
aFontList.AppendElement(kFontHiraginoKakuGothic);
|
2012-03-09 06:05:24 +04:00
|
|
|
aFontList.AppendElement(kFontAppleSymbols);
|
|
|
|
aFontList.AppendElement(kFontMenlo);
|
2014-04-15 03:45:18 +04:00
|
|
|
aFontList.AppendElement(kFontSTIXGeneral);
|
2012-03-09 06:05:24 +04:00
|
|
|
aFontList.AppendElement(kFontGeneva);
|
2014-04-15 03:45:18 +04:00
|
|
|
aFontList.AppendElement(kFontAppleColorEmoji);
|
2012-03-09 06:05:24 +04:00
|
|
|
break;
|
|
|
|
case 0x2c:
|
2014-04-15 03:45:18 +04:00
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
break;
|
2012-03-09 06:05:24 +04:00
|
|
|
case 0x2d:
|
2014-04-15 03:45:18 +04:00
|
|
|
aFontList.AppendElement(kFontKefa);
|
2012-03-09 06:05:24 +04:00
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
break;
|
|
|
|
case 0x28: // Braille
|
|
|
|
aFontList.AppendElement(kFontAppleBraille);
|
|
|
|
break;
|
2014-04-15 03:45:18 +04:00
|
|
|
case 0x31:
|
|
|
|
aFontList.AppendElement(kFontHiraginoSansGB);
|
|
|
|
break;
|
2012-03-09 06:05:24 +04:00
|
|
|
case 0x4d:
|
|
|
|
aFontList.AppendElement(kFontAppleSymbols);
|
|
|
|
break;
|
|
|
|
case 0xa0: // Yi
|
|
|
|
case 0xa1:
|
|
|
|
case 0xa2:
|
|
|
|
case 0xa3:
|
|
|
|
case 0xa4:
|
|
|
|
aFontList.AppendElement(kFontSTHeiti);
|
|
|
|
break;
|
|
|
|
case 0xa6:
|
|
|
|
case 0xa7:
|
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
aFontList.AppendElement(kFontAppleSymbols);
|
|
|
|
break;
|
2014-04-15 03:45:18 +04:00
|
|
|
case 0xab:
|
|
|
|
aFontList.AppendElement(kFontKefa);
|
|
|
|
break;
|
2012-03-09 06:05:24 +04:00
|
|
|
case 0xfc:
|
|
|
|
case 0xff:
|
|
|
|
aFontList.AppendElement(kFontAppleSymbols);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Arial Unicode MS has lots of glyphs for obscure, use it as a last resort
|
|
|
|
aFontList.AppendElement(kFontArialUnicodeMS);
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2008-05-01 13:07:17 +04:00
|
|
|
gfxPlatformMac::ReadAntiAliasingThreshold()
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t threshold = 0; // default == no threshold
|
2014-11-19 00:28:42 +03:00
|
|
|
|
2008-05-01 13:07:17 +04:00
|
|
|
// first read prefs flag to determine whether to use the setting or not
|
2011-09-29 10:19:26 +04:00
|
|
|
bool useAntiAliasingThreshold = Preferences::GetBool("gfx.use_text_smoothing_setting", false);
|
2011-06-12 06:30:16 +04:00
|
|
|
|
2008-05-01 13:07:17 +04:00
|
|
|
// if the pref setting is disabled, return 0 which effectively disables this feature
|
|
|
|
if (!useAntiAliasingThreshold)
|
|
|
|
return threshold;
|
2014-11-19 00:28:42 +03:00
|
|
|
|
2008-05-01 13:07:17 +04:00
|
|
|
// value set via Appearance pref panel, "Turn off text smoothing for font sizes xxx and smaller"
|
|
|
|
CFNumberRef prefValue = (CFNumberRef)CFPreferencesCopyAppValue(CFSTR("AppleAntiAliasingThreshold"), kCFPreferencesCurrentApplication);
|
|
|
|
|
|
|
|
if (prefValue) {
|
|
|
|
if (!CFNumberGetValue(prefValue, kCFNumberIntType, &threshold)) {
|
|
|
|
threshold = 0;
|
|
|
|
}
|
|
|
|
CFRelease(prefValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
return threshold;
|
|
|
|
}
|
2008-01-31 03:23:36 +03:00
|
|
|
|
2012-07-31 19:17:43 +04:00
|
|
|
bool
|
|
|
|
gfxPlatformMac::UseAcceleratedCanvas()
|
|
|
|
{
|
|
|
|
// Lion or later is required
|
2014-03-28 09:40:42 +04:00
|
|
|
return nsCocoaFeatures::OnLionOrLater() && Preferences::GetBool("gfx.canvas.azure.accelerated", false);
|
2012-07-31 19:17:43 +04:00
|
|
|
}
|
2012-01-09 22:54:44 +04:00
|
|
|
|
2014-11-07 22:17:14 +03:00
|
|
|
bool
|
|
|
|
gfxPlatformMac::UseProgressivePaint()
|
|
|
|
{
|
|
|
|
// Progressive painting requires cross-process mutexes, which don't work so
|
|
|
|
// well on OS X 10.6 so we disable there.
|
|
|
|
return nsCocoaFeatures::OnLionOrLater() && gfxPlatform::UseProgressivePaint();
|
|
|
|
}
|
|
|
|
|
2014-11-19 00:28:42 +03:00
|
|
|
// This is the renderer output callback function, called on the vsync thread
|
|
|
|
static CVReturn VsyncCallback(CVDisplayLinkRef aDisplayLink,
|
|
|
|
const CVTimeStamp* aNow,
|
|
|
|
const CVTimeStamp* aOutputTime,
|
|
|
|
CVOptionFlags aFlagsIn,
|
|
|
|
CVOptionFlags* aFlagsOut,
|
2015-01-09 11:37:00 +03:00
|
|
|
void* aDisplayLinkContext);
|
2014-11-19 00:28:42 +03:00
|
|
|
|
2014-12-18 19:30:06 +03:00
|
|
|
class OSXVsyncSource MOZ_FINAL : public VsyncSource
|
2014-11-19 00:28:42 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
OSXVsyncSource()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-12-18 19:30:06 +03:00
|
|
|
virtual Display& GetGlobalDisplay() MOZ_OVERRIDE
|
2014-11-19 00:28:42 +03:00
|
|
|
{
|
2014-12-18 19:30:06 +03:00
|
|
|
return mGlobalDisplay;
|
|
|
|
}
|
|
|
|
|
|
|
|
class OSXDisplay MOZ_FINAL : public VsyncSource::Display
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OSXDisplay()
|
2015-01-20 19:31:21 +03:00
|
|
|
: mDisplayLink(nullptr)
|
2014-12-18 19:30:06 +03:00
|
|
|
{
|
2015-03-19 02:17:26 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
|
2014-11-19 00:28:42 +03:00
|
|
|
}
|
|
|
|
|
2014-12-18 19:30:06 +03:00
|
|
|
~OSXDisplay()
|
|
|
|
{
|
2015-03-19 02:17:26 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
mTimer->Cancel();
|
|
|
|
mTimer = nullptr;
|
2014-12-18 19:30:06 +03:00
|
|
|
DisableVsync();
|
|
|
|
}
|
|
|
|
|
2015-03-19 02:17:26 +03:00
|
|
|
static void RetryEnableVsync(nsITimer* aTimer, void* aOsxDisplay)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
OSXDisplay* osxDisplay = static_cast<OSXDisplay*>(aOsxDisplay);
|
|
|
|
MOZ_ASSERT(osxDisplay);
|
|
|
|
osxDisplay->EnableVsync();
|
|
|
|
}
|
|
|
|
|
2014-12-18 19:30:06 +03:00
|
|
|
virtual void EnableVsync() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2015-01-20 19:31:22 +03:00
|
|
|
if (IsVsyncEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-12-18 19:30:06 +03:00
|
|
|
|
|
|
|
// Create a display link capable of being used with all active displays
|
|
|
|
// TODO: See if we need to create an active DisplayLink for each monitor in multi-monitor
|
|
|
|
// situations. According to the docs, it is compatible with all displays running on the computer
|
|
|
|
// But if we have different monitors at different display rates, we may hit issues.
|
|
|
|
if (CVDisplayLinkCreateWithActiveCGDisplays(&mDisplayLink) != kCVReturnSuccess) {
|
2015-03-19 02:17:26 +03:00
|
|
|
NS_WARNING("Could not create a display link with all active displays. Retrying\n");
|
2015-03-15 07:23:53 +03:00
|
|
|
CVDisplayLinkRelease(mDisplayLink);
|
2015-03-19 02:17:26 +03:00
|
|
|
mDisplayLink = nullptr;
|
2015-03-15 07:23:53 +03:00
|
|
|
|
2015-03-19 02:17:26 +03:00
|
|
|
// bug 1142708 - When coming back from sleep,
|
|
|
|
// or when changing displays, active displays may not be ready yet,
|
|
|
|
// even if listening for the kIOMessageSystemHasPoweredOn event
|
|
|
|
// from OS X sleep notifications.
|
2015-03-15 07:23:53 +03:00
|
|
|
// Active displays are those that are drawable.
|
2015-03-19 02:17:26 +03:00
|
|
|
// bug 1144638 - When changing display configurations and getting
|
|
|
|
// notifications from CGDisplayReconfigurationCallBack, the
|
|
|
|
// callback gets called twice for each active display
|
|
|
|
// so it's difficult to know when all displays are active.
|
|
|
|
// Instead, try again soon. The delay is arbitrary. 100ms chosen
|
|
|
|
// because on a late 2013 15" retina, it takes about that
|
|
|
|
// long to come back up from sleep.
|
|
|
|
uint32_t delay = 100;
|
|
|
|
mTimer->InitWithFuncCallback(RetryEnableVsync, this, delay, nsITimer::TYPE_ONE_SHOT);
|
|
|
|
return;
|
2014-12-18 19:30:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (CVDisplayLinkSetOutputCallback(mDisplayLink, &VsyncCallback, this) != kCVReturnSuccess) {
|
|
|
|
NS_WARNING("Could not set displaylink output callback");
|
2015-03-15 07:23:53 +03:00
|
|
|
CVDisplayLinkRelease(mDisplayLink);
|
|
|
|
mDisplayLink = nullptr;
|
2014-12-18 19:30:06 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-09 11:37:00 +03:00
|
|
|
mPreviousTimestamp = TimeStamp::Now();
|
2014-12-18 19:30:06 +03:00
|
|
|
if (CVDisplayLinkStart(mDisplayLink) != kCVReturnSuccess) {
|
|
|
|
NS_WARNING("Could not activate the display link");
|
2015-03-15 07:23:53 +03:00
|
|
|
CVDisplayLinkRelease(mDisplayLink);
|
2014-12-18 19:30:06 +03:00
|
|
|
mDisplayLink = nullptr;
|
|
|
|
}
|
2014-11-19 00:28:42 +03:00
|
|
|
}
|
|
|
|
|
2014-12-18 19:30:06 +03:00
|
|
|
virtual void DisableVsync() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2015-01-20 19:31:22 +03:00
|
|
|
if (!IsVsyncEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-12-18 19:30:06 +03:00
|
|
|
|
|
|
|
// Release the display link
|
|
|
|
if (mDisplayLink) {
|
|
|
|
CVDisplayLinkRelease(mDisplayLink);
|
|
|
|
mDisplayLink = nullptr;
|
|
|
|
}
|
2014-11-19 00:28:42 +03:00
|
|
|
}
|
|
|
|
|
2014-12-18 19:30:06 +03:00
|
|
|
virtual bool IsVsyncEnabled() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
return mDisplayLink != nullptr;
|
2014-11-19 00:28:42 +03:00
|
|
|
}
|
|
|
|
|
2015-01-09 11:37:00 +03:00
|
|
|
// The vsync timestamps given by the CVDisplayLinkCallback are
|
|
|
|
// in the future for the NEXT frame. Large parts of Gecko, such
|
|
|
|
// as animations assume a timestamp at either now or in the past.
|
|
|
|
// Normalize the timestamps given to the VsyncDispatchers to the vsync
|
|
|
|
// that just occured, not the vsync that is upcoming.
|
|
|
|
TimeStamp mPreviousTimestamp;
|
|
|
|
|
2014-12-18 19:30:06 +03:00
|
|
|
private:
|
|
|
|
// Manages the display link render thread
|
|
|
|
CVDisplayLinkRef mDisplayLink;
|
2015-03-19 02:17:26 +03:00
|
|
|
nsRefPtr<nsITimer> mTimer;
|
2014-12-18 19:30:06 +03:00
|
|
|
}; // OSXDisplay
|
2014-11-19 00:28:42 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~OSXVsyncSource()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-12-18 19:30:06 +03:00
|
|
|
OSXDisplay mGlobalDisplay;
|
2014-11-19 00:28:42 +03:00
|
|
|
}; // OSXVsyncSource
|
|
|
|
|
2015-01-09 11:37:00 +03:00
|
|
|
static CVReturn VsyncCallback(CVDisplayLinkRef aDisplayLink,
|
|
|
|
const CVTimeStamp* aNow,
|
|
|
|
const CVTimeStamp* aOutputTime,
|
|
|
|
CVOptionFlags aFlagsIn,
|
|
|
|
CVOptionFlags* aFlagsOut,
|
|
|
|
void* aDisplayLinkContext)
|
|
|
|
{
|
|
|
|
// Executed on OS X hardware vsync thread
|
|
|
|
OSXVsyncSource::OSXDisplay* display = (OSXVsyncSource::OSXDisplay*) aDisplayLinkContext;
|
|
|
|
int64_t nextVsyncTimestamp = aOutputTime->hostTime;
|
|
|
|
mozilla::TimeStamp nextVsync = mozilla::TimeStamp::FromSystemTime(nextVsyncTimestamp);
|
|
|
|
|
|
|
|
mozilla::TimeStamp previousVsync = display->mPreviousTimestamp;
|
|
|
|
display->mPreviousTimestamp = nextVsync;
|
|
|
|
MOZ_ASSERT(TimeStamp::Now() > previousVsync);
|
|
|
|
|
|
|
|
display->NotifyVsync(previousVsync);
|
|
|
|
return kCVReturnSuccess;
|
|
|
|
}
|
|
|
|
|
2014-12-18 19:30:06 +03:00
|
|
|
already_AddRefed<mozilla::gfx::VsyncSource>
|
|
|
|
gfxPlatformMac::CreateHardwareVsyncSource()
|
2014-11-19 00:28:42 +03:00
|
|
|
{
|
|
|
|
nsRefPtr<VsyncSource> osxVsyncSource = new OSXVsyncSource();
|
2015-03-05 01:37:55 +03:00
|
|
|
VsyncSource::Display& primaryDisplay = osxVsyncSource->GetGlobalDisplay();
|
|
|
|
primaryDisplay.EnableVsync();
|
|
|
|
if (!primaryDisplay.IsVsyncEnabled()) {
|
|
|
|
NS_WARNING("OS X Vsync source not enabled. Falling back to software vsync.\n");
|
|
|
|
return gfxPlatform::CreateHardwareVsyncSource();
|
|
|
|
}
|
|
|
|
|
|
|
|
primaryDisplay.DisableVsync();
|
2014-12-18 19:30:06 +03:00
|
|
|
return osxVsyncSource.forget();
|
2014-11-19 00:28:42 +03:00
|
|
|
}
|
|
|
|
|
2013-11-07 14:20:08 +04:00
|
|
|
void
|
|
|
|
gfxPlatformMac::GetPlatformCMSOutputProfile(void* &mem, size_t &size)
|
2007-07-24 02:02:17 +04:00
|
|
|
{
|
2013-11-07 14:20:08 +04:00
|
|
|
mem = nullptr;
|
|
|
|
size = 0;
|
|
|
|
|
2013-10-09 09:53:37 +04:00
|
|
|
CGColorSpaceRef cspace = ::CGDisplayCopyColorSpace(::CGMainDisplayID());
|
|
|
|
if (!cspace) {
|
|
|
|
cspace = ::CGColorSpaceCreateDeviceRGB();
|
|
|
|
}
|
|
|
|
if (!cspace) {
|
2013-11-07 14:20:08 +04:00
|
|
|
return;
|
2013-10-09 09:53:37 +04:00
|
|
|
}
|
2007-07-24 02:02:17 +04:00
|
|
|
|
2013-10-09 09:53:37 +04:00
|
|
|
CFDataRef iccp = ::CGColorSpaceCopyICCProfile(cspace);
|
2009-10-03 22:33:55 +04:00
|
|
|
|
2013-10-09 09:53:37 +04:00
|
|
|
::CFRelease(cspace);
|
|
|
|
|
|
|
|
if (!iccp) {
|
2013-11-07 14:20:08 +04:00
|
|
|
return;
|
2007-07-24 02:02:17 +04:00
|
|
|
}
|
|
|
|
|
2013-11-07 14:20:08 +04:00
|
|
|
// copy to external buffer
|
|
|
|
size = static_cast<size_t>(::CFDataGetLength(iccp));
|
|
|
|
if (size > 0) {
|
|
|
|
void *data = malloc(size);
|
|
|
|
if (data) {
|
|
|
|
memcpy(data, ::CFDataGetBytePtr(iccp), size);
|
|
|
|
mem = data;
|
|
|
|
} else {
|
|
|
|
size = 0;
|
|
|
|
}
|
|
|
|
}
|
2013-10-09 09:53:37 +04:00
|
|
|
|
|
|
|
::CFRelease(iccp);
|
2007-07-24 02:02:17 +04:00
|
|
|
}
|