2012-05-21 08:27:32 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-01-21 08:44:33 -08:00
|
|
|
#ifdef MOZ_LOGGING
|
|
|
|
#define FORCE_PR_LOG /* Allow logging in the release build */
|
|
|
|
#endif
|
2012-07-13 08:25:29 -07:00
|
|
|
|
2012-08-25 18:27:28 -07:00
|
|
|
#include "mozilla/layers/CompositorChild.h"
|
2012-07-13 08:25:29 -07:00
|
|
|
#include "mozilla/layers/CompositorParent.h"
|
2012-07-13 12:38:09 -07:00
|
|
|
#include "mozilla/layers/ImageBridgeChild.h"
|
2013-11-14 13:54:25 -08:00
|
|
|
#include "mozilla/layers/ISurfaceAllocator.h" // for GfxMemoryImageReporter
|
2012-07-13 08:25:29 -07:00
|
|
|
|
2011-01-21 08:44:33 -08:00
|
|
|
#include "prlog.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "gfxPlatform.h"
|
|
|
|
|
2013-11-06 19:18:23 -08:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include <process.h>
|
|
|
|
#define getpid _getpid
|
2013-11-08 06:04:30 -08:00
|
|
|
#else
|
|
|
|
#include <unistd.h>
|
2013-11-06 19:18:23 -08:00
|
|
|
#endif
|
|
|
|
|
2012-07-13 08:25:29 -07:00
|
|
|
#include "nsXULAppAPI.h"
|
2013-11-06 15:11:18 -08:00
|
|
|
#include "nsDirectoryServiceUtils.h"
|
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2012-07-13 08:25:29 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
#include "gfxWindowsPlatform.h"
|
2011-06-24 10:41:18 -07:00
|
|
|
#include "gfxD2DSurface.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
#include "gfxPlatformMac.h"
|
2013-07-09 18:02:41 -07:00
|
|
|
#include "gfxQuartzSurface.h"
|
2012-06-27 17:15:32 -07:00
|
|
|
#elif defined(MOZ_WIDGET_GTK)
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "gfxPlatformGtk.h"
|
2008-04-19 06:19:04 -07:00
|
|
|
#elif defined(MOZ_WIDGET_QT)
|
|
|
|
#include "gfxQtPlatform.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#elif defined(XP_OS2)
|
|
|
|
#include "gfxOS2Platform.h"
|
2010-05-11 10:27:36 -07:00
|
|
|
#elif defined(ANDROID)
|
|
|
|
#include "gfxAndroidPlatform.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2012-03-29 14:08:43 -07:00
|
|
|
#include "nsGkAtoms.h"
|
2009-08-16 06:52:12 -07:00
|
|
|
#include "gfxPlatformFontList.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "gfxImageSurface.h"
|
2012-02-24 02:15:46 -08:00
|
|
|
#include "nsUnicodeProperties.h"
|
2012-04-21 14:24:39 -07:00
|
|
|
#include "harfbuzz/hb.h"
|
2011-12-09 14:32:29 -08:00
|
|
|
#include "gfxGraphiteShaper.h"
|
2013-10-07 16:15:59 -07:00
|
|
|
#include "gfx2DGlue.h"
|
2013-11-07 20:50:39 -08:00
|
|
|
#include "gfxGradientCache.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-10-07 08:26:58 -07:00
|
|
|
#include "nsUnicodeRange.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2009-01-18 12:14:14 -08:00
|
|
|
#include "nsTArray.h"
|
2009-10-07 08:26:58 -07:00
|
|
|
#include "nsILocaleService.h"
|
2013-11-01 06:52:06 -07:00
|
|
|
#include "nsIObserverService.h"
|
2013-11-26 23:33:39 -08:00
|
|
|
#include "MainThreadUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-08 14:47:26 -07:00
|
|
|
#include "nsWeakReference.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "cairo.h"
|
2009-04-07 09:02:11 -07:00
|
|
|
#include "qcms.h"
|
2007-07-23 15:02:17 -07:00
|
|
|
|
2008-01-30 16:23:36 -08:00
|
|
|
#include "plstr.h"
|
2009-10-07 07:13:40 -07:00
|
|
|
#include "nsCRT.h"
|
2010-07-19 21:05:42 -07:00
|
|
|
#include "GLContext.h"
|
|
|
|
#include "GLContextProvider.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-20 12:20:51 -07:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
#include "TexturePoolOGL.h"
|
|
|
|
#endif
|
|
|
|
|
2013-06-28 19:48:35 -07:00
|
|
|
#ifdef USE_SKIA
|
2013-10-22 12:15:24 -07:00
|
|
|
#include "mozilla/Hal.h"
|
2013-06-28 19:48:35 -07:00
|
|
|
#include "skia/SkGraphics.h"
|
|
|
|
#endif
|
|
|
|
|
2011-06-11 19:30:16 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
2012-05-15 12:41:20 -07:00
|
|
|
#include "mozilla/Assertions.h"
|
2012-06-12 21:14:28 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-08-04 00:46:17 -07:00
|
|
|
#include "mozilla/Mutex.h"
|
2010-04-05 19:28:54 -07:00
|
|
|
|
2010-08-28 07:18:41 -07:00
|
|
|
#include "nsIGfxInfo.h"
|
|
|
|
|
2011-06-11 19:30:16 -07:00
|
|
|
using namespace mozilla;
|
2012-07-13 08:25:29 -07:00
|
|
|
using namespace mozilla::layers;
|
2011-06-11 19:30:16 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
gfxPlatform *gPlatform = nullptr;
|
2011-04-21 12:36:49 -07:00
|
|
|
static bool gEverInitialized = false;
|
2008-07-16 20:09:08 -07:00
|
|
|
|
2013-08-04 00:46:17 -07:00
|
|
|
static Mutex* gGfxPlatformPrefsLock = nullptr;
|
|
|
|
|
2013-09-06 20:08:36 -07:00
|
|
|
// These two may point to the same profile
|
|
|
|
static qcms_profile *gCMSOutputProfile = nullptr;
|
|
|
|
static qcms_profile *gCMSsRGBProfile = nullptr;
|
|
|
|
|
|
|
|
static qcms_transform *gCMSRGBTransform = nullptr;
|
|
|
|
static qcms_transform *gCMSInverseRGBTransform = nullptr;
|
|
|
|
static qcms_transform *gCMSRGBATransform = nullptr;
|
|
|
|
|
|
|
|
static bool gCMSInitialized = false;
|
|
|
|
static eCMSMode gCMSMode = eCMSMode_Off;
|
|
|
|
static int gCMSIntent = -2;
|
|
|
|
|
|
|
|
static void ShutdownCMS();
|
|
|
|
static void MigratePrefs();
|
|
|
|
|
2013-07-06 09:19:52 -07:00
|
|
|
static bool sDrawFrameCounter = false;
|
2013-03-21 10:08:01 -07:00
|
|
|
|
2011-06-24 10:41:18 -07:00
|
|
|
#include "mozilla/gfx/2D.h"
|
|
|
|
using namespace mozilla::gfx;
|
2011-01-21 08:44:33 -08:00
|
|
|
|
|
|
|
// logs shared across gfx
|
|
|
|
#ifdef PR_LOGGING
|
2012-07-30 07:20:58 -07:00
|
|
|
static PRLogModuleInfo *sFontlistLog = nullptr;
|
|
|
|
static PRLogModuleInfo *sFontInitLog = nullptr;
|
|
|
|
static PRLogModuleInfo *sTextrunLog = nullptr;
|
|
|
|
static PRLogModuleInfo *sTextrunuiLog = nullptr;
|
|
|
|
static PRLogModuleInfo *sCmapDataLog = nullptr;
|
2013-11-24 20:59:56 -08:00
|
|
|
static PRLogModuleInfo *sTextPerfLog = nullptr;
|
2011-01-21 08:44:33 -08:00
|
|
|
#endif
|
|
|
|
|
2013-09-06 20:08:36 -07:00
|
|
|
/* Class to listen for pref changes so that chrome code can dynamically
|
|
|
|
force sRGB as an output profile. See Bug #452125. */
|
|
|
|
class SRGBOverrideObserver MOZ_FINAL : public nsIObserver,
|
|
|
|
public nsSupportsWeakReference
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS2(SRGBOverrideObserver, nsIObserver, nsISupportsWeakReference)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
SRGBOverrideObserver::Observe(nsISupports *aSubject,
|
|
|
|
const char *aTopic,
|
|
|
|
const PRUnichar *someData)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_strcmp(someData,
|
|
|
|
NS_LITERAL_STRING("gfx.color_mangement.force_srgb").get()),
|
|
|
|
"Restarting CMS on wrong pref!");
|
|
|
|
ShutdownCMS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-05-26 22:05:30 -07:00
|
|
|
#define GFX_DOWNLOADABLE_FONTS_ENABLED "gfx.downloadable_fonts.enabled"
|
|
|
|
|
2011-04-11 04:17:31 -07:00
|
|
|
#define GFX_PREF_HARFBUZZ_SCRIPTS "gfx.font_rendering.harfbuzz.scripts"
|
2012-02-24 02:15:46 -08:00
|
|
|
#define HARFBUZZ_SCRIPTS_DEFAULT mozilla::unicode::SHAPING_DEFAULT
|
2012-03-08 18:05:40 -08:00
|
|
|
#define GFX_PREF_FALLBACK_USE_CMAPS "gfx.font_rendering.fallback.always_use_cmaps"
|
2009-10-07 10:16:52 -07:00
|
|
|
|
2012-09-05 21:57:54 -07:00
|
|
|
#define GFX_PREF_OPENTYPE_SVG "gfx.font_rendering.opentype_svg.enabled"
|
|
|
|
|
2013-09-10 18:36:57 -07:00
|
|
|
#define GFX_PREF_WORD_CACHE_CHARLIMIT "gfx.font_rendering.wordcache.charlimit"
|
2013-09-10 18:36:57 -07:00
|
|
|
#define GFX_PREF_WORD_CACHE_MAXENTRIES "gfx.font_rendering.wordcache.maxentries"
|
2013-09-10 18:36:57 -07:00
|
|
|
|
2011-12-09 14:32:29 -08:00
|
|
|
#define GFX_PREF_GRAPHITE_SHAPING "gfx.font_rendering.graphite.enabled"
|
|
|
|
|
2011-12-06 04:39:19 -08:00
|
|
|
#define BIDI_NUMERAL_PREF "bidi.numeral"
|
|
|
|
|
2011-06-11 19:30:16 -07:00
|
|
|
static const char* kObservedPrefs[] = {
|
|
|
|
"gfx.downloadable_fonts.",
|
|
|
|
"gfx.font_rendering.",
|
2011-12-06 04:39:19 -08:00
|
|
|
"bidi.numeral",
|
2012-07-30 07:20:58 -07:00
|
|
|
nullptr
|
2011-06-11 19:30:16 -07:00
|
|
|
};
|
|
|
|
|
2012-06-12 21:14:28 -07:00
|
|
|
class FontPrefsObserver MOZ_FINAL : public nsIObserver
|
2010-05-26 22:05:30 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(FontPrefsObserver, nsIObserver)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
FontPrefsObserver::Observe(nsISupports *aSubject,
|
|
|
|
const char *aTopic,
|
|
|
|
const PRUnichar *someData)
|
|
|
|
{
|
2011-06-11 19:30:16 -07:00
|
|
|
if (!someData) {
|
2010-05-26 22:05:30 -07:00
|
|
|
NS_ERROR("font pref observer code broken");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2011-06-11 19:30:16 -07:00
|
|
|
NS_ASSERTION(gfxPlatform::GetPlatform(), "the singleton instance has gone");
|
|
|
|
gfxPlatform::GetPlatform()->FontsPrefsChanged(NS_ConvertUTF16toUTF8(someData).get());
|
2010-05-26 22:05:30 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-07 15:34:38 -08:00
|
|
|
class OrientationSyncPrefsObserver MOZ_FINAL : public nsIObserver
|
2012-11-21 18:40:57 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(OrientationSyncPrefsObserver, nsIObserver)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
OrientationSyncPrefsObserver::Observe(nsISupports *aSubject,
|
|
|
|
const char *aTopic,
|
|
|
|
const PRUnichar *someData)
|
|
|
|
{
|
|
|
|
if (!someData) {
|
|
|
|
NS_ERROR("orientation sync pref observer broken");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
NS_ASSERTION(gfxPlatform::GetPlatform(), "the singleton instance has gone");
|
|
|
|
gfxPlatform::GetPlatform()->OrientationSyncPrefsObserverChanged();
|
2010-05-26 22:05:30 -07:00
|
|
|
|
2012-11-21 18:40:57 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2008-09-08 14:47:26 -07:00
|
|
|
|
2013-11-01 06:52:06 -07:00
|
|
|
class MemoryPressureObserver MOZ_FINAL : public nsIObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(MemoryPressureObserver, nsIObserver)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MemoryPressureObserver::Observe(nsISupports *aSubject,
|
|
|
|
const char *aTopic,
|
|
|
|
const PRUnichar *someData)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(strcmp(aTopic, "memory-pressure") == 0, "unexpected event topic");
|
2013-12-04 20:52:03 -08:00
|
|
|
Factory::PurgeAllCaches();
|
2013-11-01 06:52:06 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-01-30 16:23:36 -08:00
|
|
|
// this needs to match the list of pref font.default.xx entries listed in all.js!
|
|
|
|
// the order *must* match the order in eFontPrefLang
|
|
|
|
static const char *gPrefLangNames[] = {
|
|
|
|
"x-western",
|
|
|
|
"x-central-euro",
|
|
|
|
"ja",
|
|
|
|
"zh-TW",
|
|
|
|
"zh-CN",
|
|
|
|
"zh-HK",
|
|
|
|
"ko",
|
|
|
|
"x-cyrillic",
|
|
|
|
"x-baltic",
|
|
|
|
"el",
|
|
|
|
"tr",
|
|
|
|
"th",
|
|
|
|
"he",
|
|
|
|
"ar",
|
|
|
|
"x-devanagari",
|
|
|
|
"x-tamil",
|
|
|
|
"x-armn",
|
|
|
|
"x-beng",
|
|
|
|
"x-cans",
|
|
|
|
"x-ethi",
|
|
|
|
"x-geor",
|
|
|
|
"x-gujr",
|
|
|
|
"x-guru",
|
|
|
|
"x-khmr",
|
|
|
|
"x-mlym",
|
2008-04-03 21:23:18 -07:00
|
|
|
"x-orya",
|
|
|
|
"x-telu",
|
|
|
|
"x-knda",
|
|
|
|
"x-sinh",
|
2010-03-04 00:55:53 -08:00
|
|
|
"x-tibt",
|
2008-01-30 16:23:36 -08:00
|
|
|
"x-unicode",
|
|
|
|
"x-user-def"
|
|
|
|
};
|
|
|
|
|
2010-05-26 22:05:30 -07:00
|
|
|
gfxPlatform::gfxPlatform()
|
2013-08-16 06:18:36 -07:00
|
|
|
: mAzureCanvasBackendCollector(MOZ_THIS_IN_INITIALIZER_LIST(),
|
|
|
|
&gfxPlatform::GetAzureBackendInfo)
|
2013-08-02 15:50:17 -07:00
|
|
|
, mDrawLayerBorders(false)
|
|
|
|
, mDrawTileBorders(false)
|
|
|
|
, mDrawBigImageBorders(false)
|
2010-05-26 22:05:30 -07:00
|
|
|
{
|
2011-04-11 04:17:31 -07:00
|
|
|
mUseHarfBuzzScripts = UNINITIALIZED_VALUE;
|
2010-05-26 22:05:30 -07:00
|
|
|
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
|
2012-03-08 18:05:40 -08:00
|
|
|
mFallbackUsesCmaps = UNINITIALIZED_VALUE;
|
|
|
|
|
2013-09-10 18:36:57 -07:00
|
|
|
mWordCacheCharLimit = UNINITIALIZED_VALUE;
|
2013-09-10 18:36:57 -07:00
|
|
|
mWordCacheMaxEntries = UNINITIALIZED_VALUE;
|
2011-12-09 14:32:29 -08:00
|
|
|
mGraphiteShapingEnabled = UNINITIALIZED_VALUE;
|
2013-05-16 09:32:41 -07:00
|
|
|
mOpenTypeSVGEnabled = UNINITIALIZED_VALUE;
|
2011-12-06 04:39:19 -08:00
|
|
|
mBidiNumeralOption = UNINITIALIZED_VALUE;
|
2012-01-27 14:38:00 -08:00
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
mLayersPreferMemoryOverShmem =
|
|
|
|
XRE_GetProcessType() == GeckoProcessType_Default &&
|
|
|
|
Preferences::GetBool("layers.prefer-memory-over-shmem", true);
|
|
|
|
|
|
|
|
mLayersUseDeprecated =
|
|
|
|
Preferences::GetBool("layers.use-deprecated-textures", true);
|
|
|
|
|
2013-08-02 15:50:17 -07:00
|
|
|
Preferences::AddBoolVarCache(&mDrawLayerBorders,
|
|
|
|
"layers.draw-borders",
|
|
|
|
false);
|
|
|
|
Preferences::AddBoolVarCache(&mDrawTileBorders,
|
|
|
|
"layers.draw-tile-borders",
|
|
|
|
false);
|
|
|
|
Preferences::AddBoolVarCache(&mDrawBigImageBorders,
|
|
|
|
"layers.draw-bigimage-borders",
|
|
|
|
false);
|
|
|
|
|
2012-11-06 18:27:09 -08:00
|
|
|
uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA);
|
2013-08-14 15:49:45 -07:00
|
|
|
uint32_t contentMask = 1 << BACKEND_CAIRO;
|
2013-11-05 11:54:12 -08:00
|
|
|
InitBackendPrefs(canvasMask, BACKEND_CAIRO,
|
|
|
|
contentMask, BACKEND_CAIRO);
|
2010-05-26 22:05:30 -07:00
|
|
|
}
|
2008-01-30 16:23:36 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
gfxPlatform*
|
|
|
|
gfxPlatform::GetPlatform()
|
|
|
|
{
|
2011-04-21 12:36:49 -07:00
|
|
|
if (!gPlatform) {
|
|
|
|
Init();
|
|
|
|
}
|
2007-03-29 14:48:46 -07:00
|
|
|
return gPlatform;
|
|
|
|
}
|
|
|
|
|
2013-04-09 10:37:56 -07:00
|
|
|
int RecordingPrefChanged(const char *aPrefName, void *aClosure)
|
|
|
|
{
|
|
|
|
if (Preferences::GetBool("gfx.2d.recording", false)) {
|
|
|
|
nsAutoCString fileName;
|
|
|
|
nsAdoptingString prefFileName = Preferences::GetString("gfx.2d.recordingfile");
|
|
|
|
|
|
|
|
if (prefFileName) {
|
|
|
|
fileName.Append(NS_ConvertUTF16toUTF8(prefFileName));
|
|
|
|
} else {
|
2013-11-06 15:11:18 -08:00
|
|
|
nsCOMPtr<nsIFile> tmpFile;
|
|
|
|
if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile)))) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
fileName.AppendPrintf("moz2drec_%i_%i.aer", XRE_GetProcessType(), getpid());
|
|
|
|
|
|
|
|
nsresult rv = tmpFile->AppendNative(fileName);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rv = tmpFile->GetNativePath(fileName);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return 0;
|
2013-04-09 10:37:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
gPlatform->mRecorder = Factory::CreateEventRecorderForFile(fileName.BeginReading());
|
2013-11-06 15:11:18 -08:00
|
|
|
printf_stderr("Recording to %s\n", fileName.get());
|
2013-04-09 10:37:56 -07:00
|
|
|
Factory::SetGlobalEventRecorder(gPlatform->mRecorder);
|
|
|
|
} else {
|
|
|
|
Factory::SetGlobalEventRecorder(nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-21 12:36:53 -07:00
|
|
|
void
|
2007-03-29 14:48:46 -07:00
|
|
|
gfxPlatform::Init()
|
|
|
|
{
|
2011-04-21 12:36:49 -07:00
|
|
|
if (gEverInitialized) {
|
|
|
|
NS_RUNTIMEABORT("Already started???");
|
|
|
|
}
|
|
|
|
gEverInitialized = true;
|
2010-02-24 09:57:57 -08:00
|
|
|
|
2011-01-21 08:44:33 -08:00
|
|
|
#ifdef PR_LOGGING
|
2013-11-24 20:59:56 -08:00
|
|
|
sFontlistLog = PR_NewLogModule("fontlist");
|
|
|
|
sFontInitLog = PR_NewLogModule("fontinit");
|
|
|
|
sTextrunLog = PR_NewLogModule("textrun");
|
|
|
|
sTextrunuiLog = PR_NewLogModule("textrunui");
|
|
|
|
sCmapDataLog = PR_NewLogModule("cmapdata");
|
|
|
|
sTextPerfLog = PR_NewLogModule("textperf");
|
2011-01-21 08:44:33 -08:00
|
|
|
#endif
|
|
|
|
|
2013-08-04 00:46:17 -07:00
|
|
|
gGfxPlatformPrefsLock = new Mutex("gfxPlatform::gGfxPlatformPrefsLock");
|
|
|
|
|
2010-08-28 07:18:41 -07:00
|
|
|
/* Initialize the GfxInfo service.
|
|
|
|
* Note: we can't call functions on GfxInfo that depend
|
|
|
|
* on gPlatform until after it has been initialized
|
|
|
|
* below. GfxInfo initialization annotates our
|
|
|
|
* crash reports so we want to do it before
|
|
|
|
* we try to load any drivers and do device detection
|
|
|
|
* incase that code crashes. See bug #591561. */
|
|
|
|
nsCOMPtr<nsIGfxInfo> gfxInfo;
|
|
|
|
/* this currently will only succeed on Windows */
|
|
|
|
gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#if defined(XP_WIN)
|
2007-03-29 14:48:46 -07:00
|
|
|
gPlatform = new gfxWindowsPlatform;
|
2007-03-22 10:30:00 -07:00
|
|
|
#elif defined(XP_MACOSX)
|
2007-03-29 14:48:46 -07:00
|
|
|
gPlatform = new gfxPlatformMac;
|
2012-06-27 17:15:32 -07:00
|
|
|
#elif defined(MOZ_WIDGET_GTK)
|
2007-03-29 14:48:46 -07:00
|
|
|
gPlatform = new gfxPlatformGtk;
|
2008-04-19 06:19:04 -07:00
|
|
|
#elif defined(MOZ_WIDGET_QT)
|
|
|
|
gPlatform = new gfxQtPlatform;
|
2007-03-22 10:30:00 -07:00
|
|
|
#elif defined(XP_OS2)
|
2007-03-29 14:48:46 -07:00
|
|
|
gPlatform = new gfxOS2Platform;
|
2010-05-11 10:27:36 -07:00
|
|
|
#elif defined(ANDROID)
|
|
|
|
gPlatform = new gfxAndroidPlatform;
|
2011-04-16 18:22:41 -07:00
|
|
|
#else
|
|
|
|
#error "No gfxPlatform implementation available"
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2007-03-29 14:48:46 -07:00
|
|
|
|
2012-05-12 16:23:56 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
mozilla::gl::GLContext::StaticInit();
|
|
|
|
#endif
|
|
|
|
|
2013-08-19 00:13:32 -07:00
|
|
|
bool useOffMainThreadCompositing = OffMainThreadCompositionRequired() ||
|
|
|
|
GetPrefLayersOffMainThreadCompositionEnabled();
|
2013-06-20 14:32:04 -07:00
|
|
|
|
2013-08-19 00:13:32 -07:00
|
|
|
if (!OffMainThreadCompositionRequired()) {
|
|
|
|
useOffMainThreadCompositing &= GetPlatform()->SupportsOffMainThreadCompositing();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (useOffMainThreadCompositing && (XRE_GetProcessType() == GeckoProcessType_Default)) {
|
2013-06-20 14:32:04 -07:00
|
|
|
CompositorParent::StartUp();
|
2013-08-19 00:13:32 -07:00
|
|
|
if (Preferences::GetBool("layers.async-video.enabled", false)) {
|
2013-06-20 14:32:04 -07:00
|
|
|
ImageBridgeChild::StartUp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-29 14:48:46 -07:00
|
|
|
nsresult rv;
|
|
|
|
|
2010-07-15 23:03:45 -07:00
|
|
|
#if defined(XP_MACOSX) || defined(XP_WIN) || defined(ANDROID) // temporary, until this is implemented on others
|
2009-08-16 06:52:12 -07:00
|
|
|
rv = gfxPlatformFontList::Init();
|
2007-03-29 14:48:46 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
2011-04-21 12:36:53 -07:00
|
|
|
NS_RUNTIMEABORT("Could not initialize gfxPlatformFontList");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-03-29 14:48:46 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-11-08 03:02:27 -08:00
|
|
|
gPlatform->mScreenReferenceSurface =
|
|
|
|
gPlatform->CreateOffscreenSurface(gfxIntSize(1,1),
|
2013-09-24 13:45:13 -07:00
|
|
|
GFX_CONTENT_COLOR_ALPHA);
|
2010-11-08 03:02:27 -08:00
|
|
|
if (!gPlatform->mScreenReferenceSurface) {
|
2011-04-21 12:36:53 -07:00
|
|
|
NS_RUNTIMEABORT("Could not initialize mScreenReferenceSurface");
|
2010-11-08 03:02:27 -08:00
|
|
|
}
|
|
|
|
|
2013-10-24 08:50:26 -07:00
|
|
|
if (gPlatform->SupportsAzureContent()) {
|
|
|
|
gPlatform->mScreenReferenceDrawTarget =
|
|
|
|
gPlatform->CreateOffscreenContentDrawTarget(IntSize(1, 1),
|
|
|
|
FORMAT_B8G8R8A8);
|
|
|
|
if (!gPlatform->mScreenReferenceDrawTarget) {
|
|
|
|
NS_RUNTIMEABORT("Could not initialize mScreenReferenceDrawTarget");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-03 20:32:43 -07:00
|
|
|
rv = gfxFontCache::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
2011-04-21 12:36:53 -07:00
|
|
|
NS_RUNTIMEABORT("Could not initialize gfxFontCache");
|
2007-04-03 20:32:43 -07:00
|
|
|
}
|
|
|
|
|
2013-09-06 20:08:36 -07:00
|
|
|
/* Pref migration hook. */
|
|
|
|
MigratePrefs();
|
|
|
|
|
|
|
|
/* Create and register our CMS Override observer. */
|
|
|
|
gPlatform->mSRGBOverrideObserver = new SRGBOverrideObserver();
|
|
|
|
Preferences::AddWeakObserver(gPlatform->mSRGBOverrideObserver, "gfx.color_management.force_srgb");
|
2011-06-11 19:30:16 -07:00
|
|
|
|
|
|
|
gPlatform->mFontPrefsObserver = new FontPrefsObserver();
|
|
|
|
Preferences::AddStrongObservers(gPlatform->mFontPrefsObserver, kObservedPrefs);
|
2011-04-21 12:36:49 -07:00
|
|
|
|
2012-11-21 18:40:57 -08:00
|
|
|
gPlatform->mOrientationSyncPrefsObserver = new OrientationSyncPrefsObserver();
|
|
|
|
Preferences::AddStrongObserver(gPlatform->mOrientationSyncPrefsObserver, "layers.orientation.sync.timeout");
|
|
|
|
|
2012-04-10 08:49:10 -07:00
|
|
|
gPlatform->mWorkAroundDriverBugs = Preferences::GetBool("gfx.work-around-driver-bugs", true);
|
|
|
|
|
2012-12-16 11:25:04 -08:00
|
|
|
mozilla::Preferences::AddBoolVarCache(&gPlatform->mWidgetUpdateFlashing,
|
|
|
|
"nglayout.debug.widget_update_flashing");
|
|
|
|
|
2012-11-06 14:39:38 -08:00
|
|
|
mozilla::gl::GLContext::PlatformStartup();
|
|
|
|
|
2012-07-20 12:20:51 -07:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
// Texture pool init
|
|
|
|
mozilla::gl::TexturePoolOGL::Init();
|
|
|
|
#endif
|
|
|
|
|
2011-04-21 12:36:49 -07:00
|
|
|
// Force registration of the gfx component, thus arranging for
|
|
|
|
// ::Shutdown to be called.
|
|
|
|
nsCOMPtr<nsISupports> forceReg
|
|
|
|
= do_CreateInstance("@mozilla.org/gfx/init;1");
|
2012-09-24 08:02:50 -07:00
|
|
|
|
2013-04-09 10:37:56 -07:00
|
|
|
Preferences::RegisterCallbackAndCall(RecordingPrefChanged, "gfx.2d.recording", nullptr);
|
2012-11-21 18:40:57 -08:00
|
|
|
|
|
|
|
gPlatform->mOrientationSyncMillis = Preferences::GetUint("layers.orientation.sync.timeout", (uint32_t)0);
|
2013-03-21 20:12:30 -07:00
|
|
|
|
2013-07-06 09:19:52 -07:00
|
|
|
mozilla::Preferences::AddBoolVarCache(&sDrawFrameCounter,
|
|
|
|
"layers.frame-counter",
|
|
|
|
false);
|
2013-09-06 20:08:36 -07:00
|
|
|
|
|
|
|
CreateCMSOutputProfile();
|
2013-11-01 06:52:06 -07:00
|
|
|
|
|
|
|
#ifdef USE_SKIA
|
|
|
|
gPlatform->InitializeSkiaCaches();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Listen to memory pressure event so we can purge DrawTarget caches
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
if (obs) {
|
|
|
|
gPlatform->mMemoryPressureObserver = new MemoryPressureObserver();
|
|
|
|
obs->AddObserver(gPlatform->mMemoryPressureObserver, "memory-pressure", false);
|
|
|
|
}
|
2013-11-14 13:54:25 -08:00
|
|
|
|
2013-11-06 21:35:30 -08:00
|
|
|
RegisterStrongMemoryReporter(new GfxMemoryImageReporter());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxPlatform::Shutdown()
|
|
|
|
{
|
2007-03-29 14:48:46 -07:00
|
|
|
// These may be called before the corresponding subsystems have actually
|
|
|
|
// started up. That's OK, they can handle it.
|
2007-04-03 20:32:43 -07:00
|
|
|
gfxFontCache::Shutdown();
|
2010-02-24 09:57:44 -08:00
|
|
|
gfxFontGroup::Shutdown();
|
2013-11-07 20:50:39 -08:00
|
|
|
gfxGradientCache::Shutdown();
|
2011-12-09 14:32:29 -08:00
|
|
|
gfxGraphiteShaper::Shutdown();
|
2009-10-07 07:13:40 -07:00
|
|
|
#if defined(XP_MACOSX) || defined(XP_WIN) // temporary, until this is implemented on others
|
2009-08-16 06:52:12 -07:00
|
|
|
gfxPlatformFontList::Shutdown();
|
2007-03-29 14:48:46 -07:00
|
|
|
#endif
|
2008-07-16 20:09:08 -07:00
|
|
|
|
|
|
|
// Free the various non-null transforms and loaded profiles
|
2013-09-06 20:08:36 -07:00
|
|
|
ShutdownCMS();
|
2008-07-16 20:09:08 -07:00
|
|
|
|
2011-06-11 19:30:16 -07:00
|
|
|
// In some cases, gPlatform may not be created but Shutdown() called,
|
|
|
|
// e.g., during xpcshell tests.
|
|
|
|
if (gPlatform) {
|
2013-09-06 20:08:36 -07:00
|
|
|
/* Unregister our CMS Override callback. */
|
|
|
|
NS_ASSERTION(gPlatform->mSRGBOverrideObserver, "mSRGBOverrideObserver has alreay gone");
|
|
|
|
Preferences::RemoveObserver(gPlatform->mSRGBOverrideObserver, "gfx.color_management.force_srgb");
|
|
|
|
gPlatform->mSRGBOverrideObserver = nullptr;
|
|
|
|
|
2011-06-11 19:30:16 -07:00
|
|
|
NS_ASSERTION(gPlatform->mFontPrefsObserver, "mFontPrefsObserver has alreay gone");
|
|
|
|
Preferences::RemoveObservers(gPlatform->mFontPrefsObserver, kObservedPrefs);
|
2012-07-30 07:20:58 -07:00
|
|
|
gPlatform->mFontPrefsObserver = nullptr;
|
2013-11-01 06:52:06 -07:00
|
|
|
|
|
|
|
NS_ASSERTION(gPlatform->mMemoryPressureObserver, "mMemoryPressureObserver has already gone");
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
if (obs) {
|
|
|
|
obs->RemoveObserver(gPlatform->mMemoryPressureObserver, "memory-pressure");
|
|
|
|
}
|
|
|
|
|
|
|
|
gPlatform->mMemoryPressureObserver = nullptr;
|
2011-06-11 19:30:16 -07:00
|
|
|
}
|
2009-09-09 18:22:03 -07:00
|
|
|
|
2012-07-20 12:20:51 -07:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
// Shut down the texture pool
|
|
|
|
mozilla::gl::TexturePoolOGL::Shutdown();
|
|
|
|
#endif
|
|
|
|
|
2012-02-09 11:05:11 -08:00
|
|
|
// Shut down the default GL context provider.
|
2010-07-19 21:05:42 -07:00
|
|
|
mozilla::gl::GLContextProvider::Shutdown();
|
2012-02-09 11:05:11 -08:00
|
|
|
|
2012-02-06 19:09:28 -08:00
|
|
|
#if defined(XP_WIN)
|
2012-02-09 11:05:11 -08:00
|
|
|
// The above shutdown calls operate on the available context providers on
|
|
|
|
// most platforms. Windows is a "special snowflake", though, and has three
|
|
|
|
// context providers available, so we have to shut all of them down.
|
|
|
|
// We should only support the default GL provider on Windows; then, this
|
|
|
|
// could go away. Unfortunately, we currently support WGL (the default) for
|
|
|
|
// WebGL on Optimus.
|
2012-02-06 19:09:28 -08:00
|
|
|
mozilla::gl::GLContextProviderEGL::Shutdown();
|
|
|
|
#endif
|
2010-07-19 21:05:42 -07:00
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
// This will block this thread untill the ImageBridge protocol is completely
|
|
|
|
// deleted.
|
|
|
|
ImageBridgeChild::ShutDown();
|
|
|
|
|
2012-07-13 08:25:29 -07:00
|
|
|
CompositorParent::ShutDown();
|
|
|
|
|
2013-08-04 00:46:17 -07:00
|
|
|
delete gGfxPlatformPrefsLock;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
delete gPlatform;
|
2012-07-30 07:20:58 -07:00
|
|
|
gPlatform = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxPlatform::~gfxPlatform()
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
mScreenReferenceSurface = nullptr;
|
2013-10-24 08:50:26 -07:00
|
|
|
mScreenReferenceDrawTarget = nullptr;
|
2012-05-11 14:21:41 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// The cairo folks think we should only clean up in debug builds,
|
|
|
|
// but we're generally in the habit of trying to shut down as
|
|
|
|
// cleanly as possible even in production code, so call this
|
|
|
|
// cairo_debug_* function unconditionally.
|
2007-10-25 18:21:50 -07:00
|
|
|
//
|
|
|
|
// because cairo can assert and thus crash on shutdown, don't do this in release builds
|
2013-06-28 19:48:35 -07:00
|
|
|
#if defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING) || defined(NS_TRACE_MALLOC) || defined(MOZ_VALGRIND)
|
|
|
|
#ifdef USE_SKIA
|
|
|
|
// must do Skia cleanup before Cairo cleanup, because Skia may be referencing
|
|
|
|
// Cairo objects e.g. through SkCairoFTTypeface
|
|
|
|
SkGraphics::Term();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if MOZ_TREE_CAIRO
|
2007-03-22 10:30:00 -07:00
|
|
|
cairo_debug_reset_static_data();
|
2007-10-25 18:21:50 -07:00
|
|
|
#endif
|
2013-06-28 19:48:35 -07:00
|
|
|
#endif
|
2007-10-06 00:26:13 -07:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
// It would be nice to do this (although it might need to be after
|
|
|
|
// the cairo shutdown that happens in ~gfxPlatform). It even looks
|
|
|
|
// idempotent. But it has fatal assertions that fire if stuff is
|
|
|
|
// leaked, and we hit them.
|
|
|
|
FcFini();
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::PreferMemoryOverShmem() const {
|
|
|
|
MOZ_ASSERT(!CompositorParent::IsInCompositorThread());
|
|
|
|
return mLayersPreferMemoryOverShmem;
|
|
|
|
}
|
|
|
|
|
2012-06-25 19:43:31 -07:00
|
|
|
already_AddRefed<gfxASurface>
|
|
|
|
gfxPlatform::CreateOffscreenImageSurface(const gfxIntSize& aSize,
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxContentType aContentType)
|
2012-11-06 15:23:13 -08:00
|
|
|
{
|
2012-06-25 19:43:31 -07:00
|
|
|
nsRefPtr<gfxASurface> newSurface;
|
|
|
|
newSurface = new gfxImageSurface(aSize, OptimalFormatForContent(aContentType));
|
|
|
|
|
|
|
|
return newSurface.forget();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
already_AddRefed<gfxASurface>
|
2007-11-27 01:35:18 -08:00
|
|
|
gfxPlatform::OptimizeImage(gfxImageSurface *aSurface,
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxImageFormat format)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
const gfxIntSize& surfaceSize = aSurface->GetSize();
|
|
|
|
|
2010-02-25 22:36:07 -08:00
|
|
|
#ifdef XP_WIN
|
2012-11-06 15:23:13 -08:00
|
|
|
if (gfxWindowsPlatform::GetPlatform()->GetRenderMode() ==
|
2010-02-25 22:36:07 -08:00
|
|
|
gfxWindowsPlatform::RENDER_DIRECT2D) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-02-25 22:36:07 -08:00
|
|
|
}
|
|
|
|
#endif
|
2010-09-16 14:34:53 -07:00
|
|
|
nsRefPtr<gfxASurface> optSurface = CreateOffscreenSurface(surfaceSize, gfxASurface::ContentFromFormat(format));
|
2007-11-27 01:35:18 -08:00
|
|
|
if (!optSurface || optSurface->CairoStatus() != 0)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-12-31 20:42:49 -08:00
|
|
|
gfxContext tmpCtx(optSurface);
|
|
|
|
tmpCtx.SetOperator(gfxContext::OPERATOR_SOURCE);
|
|
|
|
tmpCtx.SetSource(aSurface);
|
|
|
|
tmpCtx.Paint();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-22 04:15:59 -07:00
|
|
|
return optSurface.forget();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-06-24 10:41:18 -07:00
|
|
|
cairo_user_data_key_t kDrawTarget;
|
|
|
|
|
|
|
|
RefPtr<DrawTarget>
|
2012-07-24 03:18:38 -07:00
|
|
|
gfxPlatform::CreateDrawTargetForSurface(gfxASurface *aSurface, const IntSize& aSize)
|
2011-06-24 10:41:18 -07:00
|
|
|
{
|
2012-07-24 03:18:38 -07:00
|
|
|
RefPtr<DrawTarget> drawTarget = Factory::CreateDrawTargetForCairoSurface(aSurface->CairoSurface(), aSize);
|
2013-07-31 08:44:31 -07:00
|
|
|
aSurface->SetData(&kDrawTarget, drawTarget, nullptr);
|
2012-01-27 10:09:20 -08:00
|
|
|
return drawTarget;
|
2011-06-24 10:41:18 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 18:02:41 -07:00
|
|
|
// This is a temporary function used by ContentClient to build a DrawTarget
|
|
|
|
// around the gfxASurface. This should eventually be replaced by plumbing
|
|
|
|
// the DrawTarget through directly
|
|
|
|
RefPtr<DrawTarget>
|
|
|
|
gfxPlatform::CreateDrawTargetForUpdateSurface(gfxASurface *aSurface, const IntSize& aSize)
|
|
|
|
{
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// this is a bit of a hack that assumes that the buffer associated with the CGContext
|
|
|
|
// will live around long enough that nothing bad will happen.
|
2013-09-24 13:45:13 -07:00
|
|
|
if (aSurface->GetType() == gfxSurfaceTypeQuartz) {
|
2013-07-09 18:02:41 -07:00
|
|
|
return Factory::CreateDrawTargetForCairoCGContext(static_cast<gfxQuartzSurface*>(aSurface)->GetCGContext(), aSize);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
MOZ_CRASH();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-24 10:41:18 -07:00
|
|
|
cairo_user_data_key_t kSourceSurface;
|
|
|
|
|
2012-10-07 19:44:36 -07:00
|
|
|
/**
|
|
|
|
* Record the backend that was used to construct the SourceSurface.
|
|
|
|
* When getting the cached SourceSurface for a gfxASurface/DrawTarget pair,
|
|
|
|
* we check to make sure the DrawTarget's backend matches the backend
|
|
|
|
* for the cached SourceSurface, and only use it if they match. This
|
|
|
|
* can avoid expensive and unnecessary readbacks.
|
|
|
|
*/
|
|
|
|
struct SourceSurfaceUserData
|
2011-06-24 10:41:18 -07:00
|
|
|
{
|
2012-10-07 19:44:36 -07:00
|
|
|
RefPtr<SourceSurface> mSrcSurface;
|
|
|
|
BackendType mBackendType;
|
|
|
|
};
|
|
|
|
|
|
|
|
void SourceBufferDestroy(void *srcSurfUD)
|
|
|
|
{
|
|
|
|
delete static_cast<SourceSurfaceUserData*>(srcSurfUD);
|
2011-06-24 10:41:18 -07:00
|
|
|
}
|
|
|
|
|
2013-05-31 15:23:05 -07:00
|
|
|
#if MOZ_TREE_CAIRO
|
2012-10-10 04:15:30 -07:00
|
|
|
void SourceSnapshotDetached(cairo_surface_t *nullSurf)
|
2012-01-30 21:15:23 -08:00
|
|
|
{
|
2012-10-10 04:15:30 -07:00
|
|
|
gfxImageSurface* origSurf =
|
|
|
|
static_cast<gfxImageSurface*>(cairo_surface_get_user_data(nullSurf, &kSourceSurface));
|
|
|
|
|
2013-07-31 08:44:31 -07:00
|
|
|
origSurf->SetData(&kSourceSurface, nullptr, nullptr);
|
2012-01-30 21:15:23 -08:00
|
|
|
}
|
2013-05-31 15:23:05 -07:00
|
|
|
#else
|
|
|
|
void SourceSnapshotDetached(void *nullSurf)
|
|
|
|
{
|
|
|
|
gfxImageSurface* origSurf = static_cast<gfxImageSurface*>(nullSurf);
|
2013-07-31 08:44:31 -07:00
|
|
|
origSurf->SetData(&kSourceSurface, nullptr, nullptr);
|
2013-05-31 15:23:05 -07:00
|
|
|
}
|
|
|
|
#endif
|
2012-01-30 21:15:23 -08:00
|
|
|
|
2013-07-11 19:44:29 -07:00
|
|
|
void
|
|
|
|
gfxPlatform::ClearSourceSurfaceForSurface(gfxASurface *aSurface)
|
|
|
|
{
|
|
|
|
aSurface->SetData(&kSourceSurface, nullptr, nullptr);
|
|
|
|
}
|
|
|
|
|
2011-06-24 10:41:18 -07:00
|
|
|
RefPtr<SourceSurface>
|
|
|
|
gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurface)
|
|
|
|
{
|
2013-10-24 07:35:29 -07:00
|
|
|
if (!aSurface->CairoSurface() || aSurface->CairoStatus()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2011-06-24 10:41:18 -07:00
|
|
|
void *userData = aSurface->GetData(&kSourceSurface);
|
|
|
|
|
|
|
|
if (userData) {
|
2012-10-07 19:44:36 -07:00
|
|
|
SourceSurfaceUserData *surf = static_cast<SourceSurfaceUserData*>(userData);
|
2012-07-27 17:33:08 -07:00
|
|
|
|
2012-10-07 19:44:36 -07:00
|
|
|
if (surf->mSrcSurface->IsValid() && surf->mBackendType == aTarget->GetType()) {
|
|
|
|
return surf->mSrcSurface;
|
2012-07-27 17:33:08 -07:00
|
|
|
}
|
|
|
|
// We can just continue here as when setting new user data the destroy
|
|
|
|
// function will be called for the old user data.
|
2011-06-24 10:41:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
SurfaceFormat format;
|
2013-09-24 13:45:13 -07:00
|
|
|
if (aSurface->GetContentType() == GFX_CONTENT_ALPHA) {
|
2011-06-24 10:41:18 -07:00
|
|
|
format = FORMAT_A8;
|
2013-09-24 13:45:13 -07:00
|
|
|
} else if (aSurface->GetContentType() == GFX_CONTENT_COLOR) {
|
2011-06-24 10:41:18 -07:00
|
|
|
format = FORMAT_B8G8R8X8;
|
|
|
|
} else {
|
|
|
|
format = FORMAT_B8G8R8A8;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<SourceSurface> srcBuffer;
|
|
|
|
|
|
|
|
#ifdef XP_WIN
|
2013-09-24 13:45:13 -07:00
|
|
|
if (aSurface->GetType() == gfxSurfaceTypeD2D &&
|
2013-07-28 15:12:37 -07:00
|
|
|
format != FORMAT_A8) {
|
2011-06-24 10:41:18 -07:00
|
|
|
NativeSurface surf;
|
|
|
|
surf.mFormat = format;
|
|
|
|
surf.mType = NATIVE_SURFACE_D3D10_TEXTURE;
|
|
|
|
surf.mSurface = static_cast<gfxD2DSurface*>(aSurface)->GetTexture();
|
|
|
|
mozilla::gfx::DrawTarget *dt = static_cast<mozilla::gfx::DrawTarget*>(aSurface->GetData(&kDrawTarget));
|
|
|
|
if (dt) {
|
|
|
|
dt->Flush();
|
|
|
|
}
|
|
|
|
srcBuffer = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
|
2012-09-02 16:07:05 -07:00
|
|
|
} else
|
2012-08-27 03:27:40 -07:00
|
|
|
#endif
|
2012-09-02 16:07:05 -07:00
|
|
|
if (aSurface->CairoSurface() && aTarget->GetType() == BACKEND_CAIRO) {
|
|
|
|
// If this is an xlib cairo surface we don't want to fetch it into memory
|
|
|
|
// because this is a major slow down.
|
|
|
|
NativeSurface surf;
|
|
|
|
surf.mFormat = format;
|
|
|
|
surf.mType = NATIVE_SURFACE_CAIRO_SURFACE;
|
|
|
|
surf.mSurface = aSurface->CairoSurface();
|
|
|
|
srcBuffer = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
|
|
|
|
|
|
|
|
if (srcBuffer) {
|
|
|
|
// It's cheap enough to make a new one so we won't keep it around and
|
|
|
|
// keeping it creates a cycle.
|
|
|
|
return srcBuffer;
|
|
|
|
}
|
|
|
|
}
|
2011-06-24 10:41:18 -07:00
|
|
|
|
|
|
|
if (!srcBuffer) {
|
|
|
|
nsRefPtr<gfxImageSurface> imgSurface = aSurface->GetAsImageSurface();
|
|
|
|
|
2012-07-24 03:18:38 -07:00
|
|
|
bool isWin32ImageSurf = imgSurface &&
|
2013-09-24 13:45:13 -07:00
|
|
|
aSurface->GetType() == gfxSurfaceTypeWin32;
|
2012-05-21 08:27:32 -07:00
|
|
|
|
2011-06-24 10:41:18 -07:00
|
|
|
if (!imgSurface) {
|
2012-05-25 21:38:17 -07:00
|
|
|
imgSurface = new gfxImageSurface(aSurface->GetSize(), OptimalFormatForContent(aSurface->GetContentType()));
|
2011-06-24 10:41:18 -07:00
|
|
|
nsRefPtr<gfxContext> ctx = new gfxContext(imgSurface);
|
|
|
|
ctx->SetSource(aSurface);
|
|
|
|
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
|
|
|
ctx->Paint();
|
|
|
|
}
|
|
|
|
|
2011-11-02 12:55:03 -07:00
|
|
|
gfxImageFormat cairoFormat = imgSurface->Format();
|
|
|
|
switch(cairoFormat) {
|
2013-09-24 13:45:13 -07:00
|
|
|
case gfxImageFormatARGB32:
|
2011-11-02 12:55:03 -07:00
|
|
|
format = FORMAT_B8G8R8A8;
|
|
|
|
break;
|
2013-09-24 13:45:13 -07:00
|
|
|
case gfxImageFormatRGB24:
|
2011-11-02 12:55:03 -07:00
|
|
|
format = FORMAT_B8G8R8X8;
|
|
|
|
break;
|
2013-09-24 13:45:13 -07:00
|
|
|
case gfxImageFormatA8:
|
2011-11-02 12:55:03 -07:00
|
|
|
format = FORMAT_A8;
|
|
|
|
break;
|
2013-09-24 13:45:13 -07:00
|
|
|
case gfxImageFormatRGB16_565:
|
2011-11-02 12:55:03 -07:00
|
|
|
format = FORMAT_R5G6B5;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_RUNTIMEABORT("Invalid surface format!");
|
|
|
|
}
|
|
|
|
|
2012-05-21 08:27:32 -07:00
|
|
|
IntSize size = IntSize(imgSurface->GetSize().width, imgSurface->GetSize().height);
|
2011-06-24 10:41:18 -07:00
|
|
|
srcBuffer = aTarget->CreateSourceSurfaceFromData(imgSurface->Data(),
|
2012-05-21 08:27:32 -07:00
|
|
|
size,
|
2011-06-24 10:41:18 -07:00
|
|
|
imgSurface->Stride(),
|
|
|
|
format);
|
2012-01-30 21:15:23 -08:00
|
|
|
|
2012-05-21 08:27:32 -07:00
|
|
|
if (!srcBuffer) {
|
|
|
|
// We need to check if our gfxASurface will keep the underlying data
|
2012-07-24 03:18:38 -07:00
|
|
|
// alive. This is true if gfxASurface actually -is- an ImageSurface or
|
|
|
|
// if it is a gfxWindowsSurface which supports GetAsImageSurface.
|
2012-05-21 08:27:32 -07:00
|
|
|
if (imgSurface != aSurface && !isWin32ImageSurf) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-05-21 08:27:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
srcBuffer = Factory::CreateWrappingDataSourceSurface(imgSurface->Data(),
|
|
|
|
imgSurface->Stride(),
|
|
|
|
size, format);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-05-31 15:23:05 -07:00
|
|
|
#if MOZ_TREE_CAIRO
|
2012-10-10 04:15:30 -07:00
|
|
|
cairo_surface_t *nullSurf =
|
|
|
|
cairo_null_surface_create(CAIRO_CONTENT_COLOR_ALPHA);
|
|
|
|
cairo_surface_set_user_data(nullSurf,
|
|
|
|
&kSourceSurface,
|
|
|
|
imgSurface,
|
2013-07-31 08:44:31 -07:00
|
|
|
nullptr);
|
2012-10-10 04:15:30 -07:00
|
|
|
cairo_surface_attach_snapshot(imgSurface->CairoSurface(), nullSurf, SourceSnapshotDetached);
|
|
|
|
cairo_surface_destroy(nullSurf);
|
2013-05-31 15:23:05 -07:00
|
|
|
#else
|
|
|
|
cairo_surface_set_mime_data(imgSurface->CairoSurface(), "mozilla/magic", (const unsigned char*) "data", 4, SourceSnapshotDetached, imgSurface.get());
|
|
|
|
#endif
|
2011-06-24 10:41:18 -07:00
|
|
|
}
|
|
|
|
|
2012-10-07 19:44:36 -07:00
|
|
|
SourceSurfaceUserData *srcSurfUD = new SourceSurfaceUserData;
|
|
|
|
srcSurfUD->mBackendType = aTarget->GetType();
|
|
|
|
srcSurfUD->mSrcSurface = srcBuffer;
|
|
|
|
aSurface->SetData(&kSourceSurface, srcSurfUD, SourceBufferDestroy);
|
2011-06-24 10:41:18 -07:00
|
|
|
|
|
|
|
return srcBuffer;
|
|
|
|
}
|
|
|
|
|
2012-09-24 08:02:49 -07:00
|
|
|
TemporaryRef<ScaledFont>
|
2012-07-24 03:18:37 -07:00
|
|
|
gfxPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
2011-06-24 10:41:18 -07:00
|
|
|
{
|
2012-01-10 10:26:59 -08:00
|
|
|
NativeFont nativeFont;
|
|
|
|
nativeFont.mType = NATIVE_FONT_CAIRO_FONT_FACE;
|
2012-07-24 03:18:39 -07:00
|
|
|
nativeFont.mFont = aFont->GetCairoScaledFont();
|
2012-01-10 10:26:59 -08:00
|
|
|
RefPtr<ScaledFont> scaledFont =
|
|
|
|
Factory::CreateScaledFontForNativeFont(nativeFont,
|
|
|
|
aFont->GetAdjustedSize());
|
|
|
|
return scaledFont;
|
2011-06-24 10:41:18 -07:00
|
|
|
}
|
|
|
|
|
2012-07-25 19:30:20 -07:00
|
|
|
cairo_user_data_key_t kDrawSourceSurface;
|
|
|
|
static void
|
|
|
|
DataSourceSurfaceDestroy(void *dataSourceSurface)
|
|
|
|
{
|
|
|
|
static_cast<DataSourceSurface*>(dataSourceSurface)->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
cairo_user_data_key_t kDrawTargetForSurface;
|
|
|
|
static void
|
|
|
|
DataDrawTargetDestroy(void *aTarget)
|
2012-01-13 06:48:29 -08:00
|
|
|
{
|
2012-07-25 19:30:20 -07:00
|
|
|
static_cast<DrawTarget*>(aTarget)->Release();
|
2012-01-13 06:48:29 -08:00
|
|
|
}
|
|
|
|
|
2013-05-27 15:04:37 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::SupportsAzureContentForDrawTarget(DrawTarget* aTarget)
|
|
|
|
{
|
|
|
|
if (!aTarget) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-08-08 16:32:19 -07:00
|
|
|
return SupportsAzureContentForType(aTarget->GetType());
|
2013-05-27 15:04:37 -07:00
|
|
|
}
|
|
|
|
|
2012-11-30 15:58:00 -08:00
|
|
|
bool
|
|
|
|
gfxPlatform::UseAcceleratedSkiaCanvas()
|
|
|
|
{
|
|
|
|
return Preferences::GetBool("gfx.canvas.azure.accelerated", false) &&
|
|
|
|
mPreferredCanvasBackend == BACKEND_SKIA;
|
|
|
|
}
|
|
|
|
|
2013-10-22 12:15:24 -07:00
|
|
|
void
|
|
|
|
gfxPlatform::InitializeSkiaCaches()
|
|
|
|
{
|
|
|
|
#ifdef USE_SKIA_GPU
|
|
|
|
if (UseAcceleratedSkiaCanvas()) {
|
|
|
|
bool usingDynamicCache = Preferences::GetBool("gfx.canvas.skiagl.dynamic-cache", false);
|
|
|
|
|
|
|
|
int cacheItemLimit = Preferences::GetInt("gfx.canvas.skiagl.cache-items", 256);
|
|
|
|
int cacheSizeLimit = Preferences::GetInt("gfx.canvas.skiagl.cache-size", 96);
|
|
|
|
|
|
|
|
// Prefs are in megabytes, but we want the sizes in bytes
|
|
|
|
cacheSizeLimit *= 1024*1024;
|
|
|
|
|
|
|
|
if (usingDynamicCache) {
|
|
|
|
uint32_t totalMemory = mozilla::hal::GetTotalSystemMemory();
|
|
|
|
|
|
|
|
if (totalMemory <= 256*1024*1024) {
|
|
|
|
// We need a very minimal cache on 256 meg devices
|
|
|
|
cacheSizeLimit = 2*1024*1024;
|
|
|
|
} else if (totalMemory > 0) {
|
|
|
|
cacheSizeLimit = totalMemory / 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf_stderr("Determined SkiaGL cache limits: Size %i, Items: %i\n", cacheSizeLimit, cacheItemLimit);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Factory::SetGlobalSkiaCacheLimits(cacheItemLimit, cacheSizeLimit);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-06-24 10:41:18 -07:00
|
|
|
already_AddRefed<gfxASurface>
|
|
|
|
gfxPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
|
|
|
|
{
|
2012-01-27 10:09:20 -08:00
|
|
|
if (aTarget->GetType() == BACKEND_CAIRO) {
|
|
|
|
cairo_surface_t* csurf =
|
|
|
|
static_cast<cairo_surface_t*>(aTarget->GetNativeSurface(NATIVE_SURFACE_CAIRO_SURFACE));
|
2013-10-25 14:25:39 -07:00
|
|
|
if (csurf) {
|
|
|
|
return gfxASurface::Wrap(csurf);
|
|
|
|
}
|
2012-07-25 19:30:20 -07:00
|
|
|
}
|
2011-11-02 12:55:03 -07:00
|
|
|
|
2012-07-25 19:30:20 -07:00
|
|
|
// The semantics of this part of the function are sort of weird. If we
|
|
|
|
// don't have direct support for the backend, we snapshot the first time
|
|
|
|
// and then return the snapshotted surface for the lifetime of the draw
|
|
|
|
// target. Sometimes it seems like this works out, but it seems like it
|
|
|
|
// might result in no updates ever.
|
|
|
|
RefPtr<SourceSurface> source = aTarget->Snapshot();
|
|
|
|
RefPtr<DataSourceSurface> data = source->GetDataSurface();
|
2011-11-02 12:55:03 -07:00
|
|
|
|
2012-07-25 19:30:20 -07:00
|
|
|
if (!data) {
|
2013-04-28 04:52:10 -07:00
|
|
|
return nullptr;
|
2012-01-27 10:09:20 -08:00
|
|
|
}
|
2012-01-13 06:48:29 -08:00
|
|
|
|
2012-07-25 19:30:20 -07:00
|
|
|
IntSize size = data->GetSize();
|
2013-11-07 06:20:58 -08:00
|
|
|
gfxImageFormat format = SurfaceFormatToImageFormat(data->GetFormat());
|
2012-07-25 19:30:20 -07:00
|
|
|
|
|
|
|
|
|
|
|
nsRefPtr<gfxASurface> surf =
|
|
|
|
new gfxImageSurface(data->GetData(), gfxIntSize(size.width, size.height),
|
|
|
|
data->Stride(), format);
|
|
|
|
|
|
|
|
surf->SetData(&kDrawSourceSurface, data.forget().drop(), DataSourceSurfaceDestroy);
|
|
|
|
// keep the draw target alive as long as we need its data
|
|
|
|
aTarget->AddRef();
|
|
|
|
surf->SetData(&kDrawTargetForSurface, aTarget, DataDrawTargetDestroy);
|
2012-01-13 06:48:29 -08:00
|
|
|
|
|
|
|
return surf.forget();
|
2011-11-02 12:55:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<DrawTarget>
|
2012-07-24 17:45:58 -07:00
|
|
|
gfxPlatform::CreateDrawTargetForBackend(BackendType aBackend, const IntSize& aSize, SurfaceFormat aFormat)
|
2011-11-02 12:55:03 -07:00
|
|
|
{
|
2012-01-27 10:09:20 -08:00
|
|
|
// There is a bunch of knowledge in the gfxPlatform heirarchy about how to
|
|
|
|
// create the best offscreen surface for the current system and situation. We
|
|
|
|
// can easily take advantage of this for the Cairo backend, so that's what we
|
|
|
|
// do.
|
|
|
|
// mozilla::gfx::Factory can get away without having all this knowledge for
|
|
|
|
// now, but this might need to change in the future (using
|
|
|
|
// CreateOffscreenSurface() and CreateDrawTargetForSurface() for all
|
|
|
|
// backends).
|
2012-07-24 17:45:58 -07:00
|
|
|
if (aBackend == BACKEND_CAIRO) {
|
2012-01-27 10:09:20 -08:00
|
|
|
nsRefPtr<gfxASurface> surf = CreateOffscreenSurface(ThebesIntSize(aSize),
|
|
|
|
ContentForFormat(aFormat));
|
2012-07-31 00:57:28 -07:00
|
|
|
if (!surf || surf->CairoStatus()) {
|
2013-07-31 08:44:31 -07:00
|
|
|
return nullptr;
|
2012-07-24 03:18:38 -07:00
|
|
|
}
|
2012-01-27 10:09:20 -08:00
|
|
|
|
2012-07-24 03:18:38 -07:00
|
|
|
return CreateDrawTargetForSurface(surf, aSize);
|
2012-01-27 10:09:20 -08:00
|
|
|
} else {
|
2012-07-24 17:45:58 -07:00
|
|
|
return Factory::CreateDrawTarget(aBackend, aSize, aFormat);
|
2012-01-27 10:09:20 -08:00
|
|
|
}
|
2011-06-24 10:41:18 -07:00
|
|
|
}
|
|
|
|
|
2012-07-24 17:45:58 -07:00
|
|
|
RefPtr<DrawTarget>
|
2013-08-22 23:13:55 -07:00
|
|
|
gfxPlatform::CreateOffscreenCanvasDrawTarget(const IntSize& aSize, SurfaceFormat aFormat)
|
2012-07-24 17:45:58 -07:00
|
|
|
{
|
2012-10-12 02:42:51 -07:00
|
|
|
NS_ASSERTION(mPreferredCanvasBackend, "No backend.");
|
2012-07-30 23:30:10 -07:00
|
|
|
RefPtr<DrawTarget> target = CreateDrawTargetForBackend(mPreferredCanvasBackend, aSize, aFormat);
|
2012-07-24 17:45:58 -07:00
|
|
|
if (target ||
|
|
|
|
mFallbackCanvasBackend == BACKEND_NONE) {
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CreateDrawTargetForBackend(mFallbackCanvasBackend, aSize, aFormat);
|
|
|
|
}
|
|
|
|
|
2013-08-22 23:13:55 -07:00
|
|
|
RefPtr<DrawTarget>
|
|
|
|
gfxPlatform::CreateOffscreenContentDrawTarget(const IntSize& aSize, SurfaceFormat aFormat)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mContentBackend, "No backend.");
|
|
|
|
return CreateDrawTargetForBackend(mContentBackend, aSize, aFormat);
|
|
|
|
}
|
2012-07-24 17:45:58 -07:00
|
|
|
|
2012-04-02 12:15:08 -07:00
|
|
|
RefPtr<DrawTarget>
|
|
|
|
gfxPlatform::CreateDrawTargetForData(unsigned char* aData, const IntSize& aSize, int32_t aStride, SurfaceFormat aFormat)
|
|
|
|
{
|
2013-08-13 21:31:05 -07:00
|
|
|
NS_ASSERTION(mContentBackend, "No backend.");
|
|
|
|
if (mContentBackend == BACKEND_CAIRO) {
|
|
|
|
nsRefPtr<gfxImageSurface> image = new gfxImageSurface(aData, gfxIntSize(aSize.width, aSize.height), aStride, SurfaceFormatToImageFormat(aFormat));
|
|
|
|
return Factory::CreateDrawTargetForCairoSurface(image->CairoSurface(), aSize);
|
|
|
|
}
|
|
|
|
return Factory::CreateDrawTargetForData(mContentBackend, aData, aSize, aStride, aFormat);
|
2012-04-02 12:15:08 -07:00
|
|
|
}
|
|
|
|
|
2012-07-24 17:45:58 -07:00
|
|
|
/* static */ BackendType
|
|
|
|
gfxPlatform::BackendTypeForName(const nsCString& aName)
|
|
|
|
{
|
|
|
|
if (aName.EqualsLiteral("cairo"))
|
|
|
|
return BACKEND_CAIRO;
|
|
|
|
if (aName.EqualsLiteral("skia"))
|
|
|
|
return BACKEND_SKIA;
|
|
|
|
if (aName.EqualsLiteral("direct2d"))
|
|
|
|
return BACKEND_DIRECT2D;
|
|
|
|
if (aName.EqualsLiteral("cg"))
|
|
|
|
return BACKEND_COREGRAPHICS;
|
|
|
|
return BACKEND_NONE;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult
|
2010-02-24 09:57:57 -08:00
|
|
|
gfxPlatform::GetFontList(nsIAtom *aLangGroup,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsACString& aGenericFamily,
|
2009-01-18 12:14:14 -08:00
|
|
|
nsTArray<nsString>& aListOfFonts)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
gfxPlatform::UpdateFontList()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2008-09-30 20:01:53 -07:00
|
|
|
gfxPlatform::DownloadableFontsEnabled()
|
|
|
|
{
|
2010-05-26 22:05:30 -07:00
|
|
|
if (mAllowDownloadableFonts == UNINITIALIZED_VALUE) {
|
2010-10-07 00:59:19 -07:00
|
|
|
mAllowDownloadableFonts =
|
2011-09-28 23:19:26 -07:00
|
|
|
Preferences::GetBool(GFX_DOWNLOADABLE_FONTS_ENABLED, false);
|
2008-09-30 20:01:53 -07:00
|
|
|
}
|
|
|
|
|
2010-05-26 22:05:30 -07:00
|
|
|
return mAllowDownloadableFonts;
|
2008-09-30 20:01:53 -07:00
|
|
|
}
|
|
|
|
|
2012-03-08 18:05:40 -08:00
|
|
|
bool
|
|
|
|
gfxPlatform::UseCmapsDuringSystemFallback()
|
|
|
|
{
|
|
|
|
if (mFallbackUsesCmaps == UNINITIALIZED_VALUE) {
|
|
|
|
mFallbackUsesCmaps =
|
|
|
|
Preferences::GetBool(GFX_PREF_FALLBACK_USE_CMAPS, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mFallbackUsesCmaps;
|
|
|
|
}
|
|
|
|
|
2013-05-16 09:32:41 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::OpenTypeSVGEnabled()
|
|
|
|
{
|
|
|
|
if (mOpenTypeSVGEnabled == UNINITIALIZED_VALUE) {
|
|
|
|
mOpenTypeSVGEnabled =
|
|
|
|
Preferences::GetBool(GFX_PREF_OPENTYPE_SVG, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mOpenTypeSVGEnabled > 0;
|
|
|
|
}
|
|
|
|
|
2013-09-10 18:36:57 -07:00
|
|
|
uint32_t
|
|
|
|
gfxPlatform::WordCacheCharLimit()
|
|
|
|
{
|
|
|
|
if (mWordCacheCharLimit == UNINITIALIZED_VALUE) {
|
|
|
|
mWordCacheCharLimit =
|
|
|
|
Preferences::GetInt(GFX_PREF_WORD_CACHE_CHARLIMIT, 32);
|
|
|
|
if (mWordCacheCharLimit < 0) {
|
|
|
|
mWordCacheCharLimit = 32;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return uint32_t(mWordCacheCharLimit);
|
|
|
|
}
|
|
|
|
|
2013-09-10 18:36:57 -07:00
|
|
|
uint32_t
|
|
|
|
gfxPlatform::WordCacheMaxEntries()
|
|
|
|
{
|
|
|
|
if (mWordCacheMaxEntries == UNINITIALIZED_VALUE) {
|
|
|
|
mWordCacheMaxEntries =
|
|
|
|
Preferences::GetInt(GFX_PREF_WORD_CACHE_MAXENTRIES, 10000);
|
|
|
|
if (mWordCacheMaxEntries < 0) {
|
|
|
|
mWordCacheMaxEntries = 10000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return uint32_t(mWordCacheMaxEntries);
|
|
|
|
}
|
|
|
|
|
2011-12-09 14:32:29 -08:00
|
|
|
bool
|
|
|
|
gfxPlatform::UseGraphiteShaping()
|
|
|
|
{
|
|
|
|
if (mGraphiteShapingEnabled == UNINITIALIZED_VALUE) {
|
|
|
|
mGraphiteShapingEnabled =
|
|
|
|
Preferences::GetBool(GFX_PREF_GRAPHITE_SHAPING, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mGraphiteShapingEnabled;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-08-22 08:56:38 -07:00
|
|
|
gfxPlatform::UseHarfBuzzForScript(int32_t aScriptCode)
|
2009-10-07 10:16:52 -07:00
|
|
|
{
|
2011-04-11 04:17:31 -07:00
|
|
|
if (mUseHarfBuzzScripts == UNINITIALIZED_VALUE) {
|
2011-06-11 19:30:16 -07:00
|
|
|
mUseHarfBuzzScripts = Preferences::GetInt(GFX_PREF_HARFBUZZ_SCRIPTS, HARFBUZZ_SCRIPTS_DEFAULT);
|
2009-10-07 10:16:52 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t shapingType = mozilla::unicode::ScriptShapingType(aScriptCode);
|
2011-04-11 04:17:31 -07:00
|
|
|
|
|
|
|
return (mUseHarfBuzzScripts & shapingType) != 0;
|
2009-10-07 10:16:52 -07:00
|
|
|
}
|
|
|
|
|
2009-08-30 06:55:24 -07:00
|
|
|
gfxFontEntry*
|
|
|
|
gfxPlatform::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint8_t *aFontData,
|
|
|
|
uint32_t aLength)
|
2009-08-30 06:55:24 -07:00
|
|
|
{
|
|
|
|
// Default implementation does not handle activating downloaded fonts;
|
|
|
|
// just free the data and return.
|
|
|
|
// Platforms that support @font-face must override this,
|
|
|
|
// using the data to instantiate the font, and taking responsibility
|
|
|
|
// for freeing it when no longer required.
|
|
|
|
if (aFontData) {
|
|
|
|
NS_Free((void*)aFontData);
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-08-30 06:55:24 -07:00
|
|
|
}
|
2008-09-30 20:01:53 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static void
|
2010-02-24 09:57:57 -08:00
|
|
|
AppendGenericFontFromPref(nsString& aFonts, nsIAtom *aLangGroup, const char *aGenericName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-09-14 03:00:31 -07:00
|
|
|
NS_ENSURE_TRUE_VOID(Preferences::GetRootBranch());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString prefName, langGroupString;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-02-24 09:57:57 -08:00
|
|
|
aLangGroup->ToUTF8String(langGroupString);
|
|
|
|
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString genericDotLang;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aGenericName) {
|
2009-04-04 02:43:42 -07:00
|
|
|
genericDotLang.Assign(aGenericName);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
|
|
|
prefName.AssignLiteral("font.default.");
|
2010-02-24 09:57:57 -08:00
|
|
|
prefName.Append(langGroupString);
|
2011-06-11 19:30:16 -07:00
|
|
|
genericDotLang = Preferences::GetCString(prefName.get());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
genericDotLang.AppendLiteral(".");
|
2010-02-24 09:57:57 -08:00
|
|
|
genericDotLang.Append(langGroupString);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-11-06 15:23:13 -08:00
|
|
|
// fetch font.name.xxx value
|
2007-03-22 10:30:00 -07:00
|
|
|
prefName.AssignLiteral("font.name.");
|
|
|
|
prefName.Append(genericDotLang);
|
2011-06-11 19:30:16 -07:00
|
|
|
nsAdoptingString nameValue = Preferences::GetString(prefName.get());
|
|
|
|
if (nameValue) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!aFonts.IsEmpty())
|
|
|
|
aFonts.AppendLiteral(", ");
|
2011-06-11 19:30:16 -07:00
|
|
|
aFonts += nameValue;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-11-06 15:23:13 -08:00
|
|
|
// fetch font.name-list.xxx value
|
2007-03-22 10:30:00 -07:00
|
|
|
prefName.AssignLiteral("font.name-list.");
|
|
|
|
prefName.Append(genericDotLang);
|
2011-06-11 19:30:16 -07:00
|
|
|
nsAdoptingString nameListValue = Preferences::GetString(prefName.get());
|
|
|
|
if (nameListValue && !nameListValue.Equals(nameValue)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!aFonts.IsEmpty())
|
|
|
|
aFonts.AppendLiteral(", ");
|
2011-06-11 19:30:16 -07:00
|
|
|
aFonts += nameListValue;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-28 23:19:26 -07:00
|
|
|
gfxPlatform::GetPrefFonts(nsIAtom *aLanguage, nsString& aFonts, bool aAppendUnicode)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
aFonts.Truncate();
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
AppendGenericFontFromPref(aFonts, aLanguage, nullptr);
|
2007-07-18 07:22:06 -07:00
|
|
|
if (aAppendUnicode)
|
2012-07-30 07:20:58 -07:00
|
|
|
AppendGenericFontFromPref(aFonts, nsGkAtoms::Unicode, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
bool gfxPlatform::ForEachPrefFont(eFontPrefLang aLangArray[], uint32_t aLangArrayLen, PrefFontCallback aCallback,
|
2008-01-30 16:23:36 -08:00
|
|
|
void *aClosure)
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_ENSURE_TRUE(Preferences::GetRootBranch(), false);
|
2008-01-30 16:23:36 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t i;
|
2008-01-30 16:23:36 -08:00
|
|
|
for (i = 0; i < aLangArrayLen; i++) {
|
|
|
|
eFontPrefLang prefLang = aLangArray[i];
|
|
|
|
const char *langGroup = GetPrefLangName(prefLang);
|
2012-11-06 15:23:13 -08:00
|
|
|
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString prefName;
|
2012-11-06 15:23:13 -08:00
|
|
|
|
2008-01-30 16:23:36 -08:00
|
|
|
prefName.AssignLiteral("font.default.");
|
|
|
|
prefName.Append(langGroup);
|
2011-06-11 19:30:16 -07:00
|
|
|
nsAdoptingCString genericDotLang = Preferences::GetCString(prefName.get());
|
2012-11-06 15:23:13 -08:00
|
|
|
|
2008-01-30 16:23:36 -08:00
|
|
|
genericDotLang.AppendLiteral(".");
|
|
|
|
genericDotLang.Append(langGroup);
|
2012-11-06 15:23:13 -08:00
|
|
|
|
|
|
|
// fetch font.name.xxx value
|
2008-01-30 16:23:36 -08:00
|
|
|
prefName.AssignLiteral("font.name.");
|
|
|
|
prefName.Append(genericDotLang);
|
2011-06-11 19:30:16 -07:00
|
|
|
nsAdoptingCString nameValue = Preferences::GetCString(prefName.get());
|
|
|
|
if (nameValue) {
|
2009-04-04 02:43:42 -07:00
|
|
|
if (!aCallback(prefLang, NS_ConvertUTF8toUTF16(nameValue), aClosure))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2008-01-30 16:23:36 -08:00
|
|
|
}
|
2012-11-06 15:23:13 -08:00
|
|
|
|
|
|
|
// fetch font.name-list.xxx value
|
2008-01-30 16:23:36 -08:00
|
|
|
prefName.AssignLiteral("font.name-list.");
|
|
|
|
prefName.Append(genericDotLang);
|
2011-06-11 19:30:16 -07:00
|
|
|
nsAdoptingCString nameListValue = Preferences::GetCString(prefName.get());
|
|
|
|
if (nameListValue && !nameListValue.Equals(nameValue)) {
|
2009-10-07 07:13:40 -07:00
|
|
|
const char kComma = ',';
|
|
|
|
const char *p, *p_end;
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString list(nameListValue);
|
2009-10-07 07:13:40 -07:00
|
|
|
list.BeginReading(p);
|
|
|
|
list.EndReading(p_end);
|
|
|
|
while (p < p_end) {
|
|
|
|
while (nsCRT::IsAsciiSpace(*p)) {
|
|
|
|
if (++p == p_end)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (p == p_end)
|
|
|
|
break;
|
|
|
|
const char *start = p;
|
|
|
|
while (++p != p_end && *p != kComma)
|
|
|
|
/* nothing */ ;
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString fontName(Substring(start, p));
|
2011-10-17 07:59:28 -07:00
|
|
|
fontName.CompressWhitespace(false, true);
|
2009-10-07 07:13:40 -07:00
|
|
|
if (!aCallback(prefLang, NS_ConvertUTF8toUTF16(fontName), aClosure))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-10-07 07:13:40 -07:00
|
|
|
p++;
|
|
|
|
}
|
2008-01-30 16:23:36 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2008-01-30 16:23:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
eFontPrefLang
|
|
|
|
gfxPlatform::GetFontPrefLangFor(const char* aLang)
|
|
|
|
{
|
|
|
|
if (!aLang || !aLang[0])
|
|
|
|
return eFontPrefLang_Others;
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < uint32_t(eFontPrefLang_LangCount); ++i) {
|
2008-01-30 16:23:36 -08:00
|
|
|
if (!PL_strcasecmp(gPrefLangNames[i], aLang))
|
|
|
|
return eFontPrefLang(i);
|
|
|
|
}
|
|
|
|
return eFontPrefLang_Others;
|
|
|
|
}
|
|
|
|
|
2010-02-24 09:57:57 -08:00
|
|
|
eFontPrefLang
|
|
|
|
gfxPlatform::GetFontPrefLangFor(nsIAtom *aLang)
|
|
|
|
{
|
|
|
|
if (!aLang)
|
|
|
|
return eFontPrefLang_Others;
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString lang;
|
2010-02-24 09:57:57 -08:00
|
|
|
aLang->ToUTF8String(lang);
|
|
|
|
return GetFontPrefLangFor(lang.get());
|
|
|
|
}
|
|
|
|
|
2008-01-30 16:23:36 -08:00
|
|
|
const char*
|
|
|
|
gfxPlatform::GetPrefLangName(eFontPrefLang aLang)
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
if (uint32_t(aLang) < uint32_t(eFontPrefLang_AllCount))
|
|
|
|
return gPrefLangNames[uint32_t(aLang)];
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2008-01-30 16:23:36 -08:00
|
|
|
}
|
|
|
|
|
2009-10-07 08:26:58 -07:00
|
|
|
eFontPrefLang
|
2012-08-22 08:56:38 -07:00
|
|
|
gfxPlatform::GetFontPrefLangFor(uint8_t aUnicodeRange)
|
2009-10-07 08:26:58 -07:00
|
|
|
{
|
|
|
|
switch (aUnicodeRange) {
|
|
|
|
case kRangeSetLatin: return eFontPrefLang_Western;
|
|
|
|
case kRangeCyrillic: return eFontPrefLang_Cyrillic;
|
|
|
|
case kRangeGreek: return eFontPrefLang_Greek;
|
|
|
|
case kRangeTurkish: return eFontPrefLang_Turkish;
|
|
|
|
case kRangeHebrew: return eFontPrefLang_Hebrew;
|
|
|
|
case kRangeArabic: return eFontPrefLang_Arabic;
|
|
|
|
case kRangeBaltic: return eFontPrefLang_Baltic;
|
|
|
|
case kRangeThai: return eFontPrefLang_Thai;
|
|
|
|
case kRangeKorean: return eFontPrefLang_Korean;
|
|
|
|
case kRangeJapanese: return eFontPrefLang_Japanese;
|
|
|
|
case kRangeSChinese: return eFontPrefLang_ChineseCN;
|
|
|
|
case kRangeTChinese: return eFontPrefLang_ChineseTW;
|
|
|
|
case kRangeDevanagari: return eFontPrefLang_Devanagari;
|
|
|
|
case kRangeTamil: return eFontPrefLang_Tamil;
|
|
|
|
case kRangeArmenian: return eFontPrefLang_Armenian;
|
|
|
|
case kRangeBengali: return eFontPrefLang_Bengali;
|
|
|
|
case kRangeCanadian: return eFontPrefLang_Canadian;
|
|
|
|
case kRangeEthiopic: return eFontPrefLang_Ethiopic;
|
|
|
|
case kRangeGeorgian: return eFontPrefLang_Georgian;
|
|
|
|
case kRangeGujarati: return eFontPrefLang_Gujarati;
|
|
|
|
case kRangeGurmukhi: return eFontPrefLang_Gurmukhi;
|
|
|
|
case kRangeKhmer: return eFontPrefLang_Khmer;
|
|
|
|
case kRangeMalayalam: return eFontPrefLang_Malayalam;
|
2011-03-31 01:47:02 -07:00
|
|
|
case kRangeOriya: return eFontPrefLang_Oriya;
|
|
|
|
case kRangeTelugu: return eFontPrefLang_Telugu;
|
|
|
|
case kRangeKannada: return eFontPrefLang_Kannada;
|
|
|
|
case kRangeSinhala: return eFontPrefLang_Sinhala;
|
|
|
|
case kRangeTibetan: return eFontPrefLang_Tibetan;
|
2009-10-07 08:26:58 -07:00
|
|
|
case kRangeSetCJK: return eFontPrefLang_CJKSet;
|
|
|
|
default: return eFontPrefLang_Others;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-06 15:23:13 -08:00
|
|
|
bool
|
2008-01-30 16:23:36 -08:00
|
|
|
gfxPlatform::IsLangCJK(eFontPrefLang aLang)
|
|
|
|
{
|
2010-03-08 01:14:56 -08:00
|
|
|
switch (aLang) {
|
|
|
|
case eFontPrefLang_Japanese:
|
|
|
|
case eFontPrefLang_ChineseTW:
|
|
|
|
case eFontPrefLang_ChineseCN:
|
|
|
|
case eFontPrefLang_ChineseHK:
|
|
|
|
case eFontPrefLang_Korean:
|
|
|
|
case eFontPrefLang_CJKSet:
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-03-08 01:14:56 -08:00
|
|
|
default:
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-03-08 01:14:56 -08:00
|
|
|
}
|
2008-01-30 16:23:36 -08:00
|
|
|
}
|
|
|
|
|
2013-08-02 15:50:17 -07:00
|
|
|
mozilla::layers::DiagnosticTypes
|
|
|
|
gfxPlatform::GetLayerDiagnosticTypes()
|
2013-03-21 10:08:01 -07:00
|
|
|
{
|
2013-08-02 15:50:17 -07:00
|
|
|
mozilla::layers::DiagnosticTypes type = DIAGNOSTIC_NONE;
|
|
|
|
if (mDrawLayerBorders) {
|
|
|
|
type |= mozilla::layers::DIAGNOSTIC_LAYER_BORDERS;
|
|
|
|
}
|
|
|
|
if (mDrawTileBorders) {
|
|
|
|
type |= mozilla::layers::DIAGNOSTIC_TILE_BORDERS;
|
|
|
|
}
|
|
|
|
if (mDrawBigImageBorders) {
|
|
|
|
type |= mozilla::layers::DIAGNOSTIC_BIGIMAGE_BORDERS;
|
|
|
|
}
|
|
|
|
return type;
|
2013-03-21 10:08:01 -07:00
|
|
|
}
|
|
|
|
|
2013-07-06 09:19:52 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::DrawFrameCounter()
|
|
|
|
{
|
|
|
|
return sDrawFrameCounter;
|
|
|
|
}
|
2013-03-21 10:08:01 -07:00
|
|
|
|
2012-11-06 15:23:13 -08:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
gfxPlatform::GetLangPrefs(eFontPrefLang aPrefLangs[], uint32_t &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang)
|
2009-10-07 08:26:58 -07:00
|
|
|
{
|
|
|
|
if (IsLangCJK(aCharLang)) {
|
|
|
|
AppendCJKPrefLangs(aPrefLangs, aLen, aCharLang, aPageLang);
|
|
|
|
} else {
|
|
|
|
AppendPrefLang(aPrefLangs, aLen, aCharLang);
|
|
|
|
}
|
|
|
|
|
|
|
|
AppendPrefLang(aPrefLangs, aLen, eFontPrefLang_Others);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
gfxPlatform::AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang)
|
2009-10-07 08:26:58 -07:00
|
|
|
{
|
|
|
|
// prefer the lang specified by the page *if* CJK
|
|
|
|
if (IsLangCJK(aPageLang)) {
|
|
|
|
AppendPrefLang(aPrefLangs, aLen, aPageLang);
|
|
|
|
}
|
2012-11-06 15:23:13 -08:00
|
|
|
|
2009-10-07 08:26:58 -07:00
|
|
|
// if not set up, set up the default CJK order, based on accept lang settings and locale
|
|
|
|
if (mCJKPrefLangs.Length() == 0) {
|
2012-11-06 15:23:13 -08:00
|
|
|
|
2009-10-07 08:26:58 -07:00
|
|
|
// temp array
|
|
|
|
eFontPrefLang tempPrefLangs[kMaxLenPrefLangList];
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t tempLen = 0;
|
2012-11-06 15:23:13 -08:00
|
|
|
|
2009-10-07 08:26:58 -07:00
|
|
|
// Add the CJK pref fonts from accept languages, the order should be same order
|
2011-06-11 19:30:16 -07:00
|
|
|
nsAdoptingCString list = Preferences::GetLocalizedCString("intl.accept_languages");
|
2010-03-15 11:29:55 -07:00
|
|
|
if (!list.IsEmpty()) {
|
2009-10-07 08:26:58 -07:00
|
|
|
const char kComma = ',';
|
|
|
|
const char *p, *p_end;
|
|
|
|
list.BeginReading(p);
|
|
|
|
list.EndReading(p_end);
|
|
|
|
while (p < p_end) {
|
|
|
|
while (nsCRT::IsAsciiSpace(*p)) {
|
|
|
|
if (++p == p_end)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (p == p_end)
|
|
|
|
break;
|
|
|
|
const char *start = p;
|
|
|
|
while (++p != p_end && *p != kComma)
|
|
|
|
/* nothing */ ;
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString lang(Substring(start, p));
|
2011-10-17 07:59:28 -07:00
|
|
|
lang.CompressWhitespace(false, true);
|
2009-10-07 08:26:58 -07:00
|
|
|
eFontPrefLang fpl = gfxPlatform::GetFontPrefLangFor(lang.get());
|
|
|
|
switch (fpl) {
|
|
|
|
case eFontPrefLang_Japanese:
|
|
|
|
case eFontPrefLang_Korean:
|
|
|
|
case eFontPrefLang_ChineseCN:
|
|
|
|
case eFontPrefLang_ChineseHK:
|
|
|
|
case eFontPrefLang_ChineseTW:
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, fpl);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
do { // to allow 'break' to abort this block if a call fails
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsILocaleService> ls =
|
|
|
|
do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
|
|
|
|
|
|
|
nsCOMPtr<nsILocale> appLocale;
|
|
|
|
rv = ls->GetApplicationLocale(getter_AddRefs(appLocale));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
|
|
|
|
|
|
|
nsString localeStr;
|
|
|
|
rv = appLocale->
|
|
|
|
GetCategory(NS_LITERAL_STRING(NSILOCALE_MESSAGE), localeStr);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
|
|
|
|
|
|
|
const nsAString& lang = Substring(localeStr, 0, 2);
|
|
|
|
if (lang.EqualsLiteral("ja")) {
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Japanese);
|
|
|
|
} else if (lang.EqualsLiteral("zh")) {
|
|
|
|
const nsAString& region = Substring(localeStr, 3, 2);
|
|
|
|
if (region.EqualsLiteral("CN")) {
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseCN);
|
|
|
|
} else if (region.EqualsLiteral("TW")) {
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseTW);
|
|
|
|
} else if (region.EqualsLiteral("HK")) {
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseHK);
|
|
|
|
}
|
|
|
|
} else if (lang.EqualsLiteral("ko")) {
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Korean);
|
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
// last resort... (the order is same as old gfx.)
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Japanese);
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Korean);
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseCN);
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseHK);
|
|
|
|
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseTW);
|
2012-11-06 15:23:13 -08:00
|
|
|
|
2009-10-07 08:26:58 -07:00
|
|
|
// copy into the cached array
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t j;
|
2009-10-07 08:26:58 -07:00
|
|
|
for (j = 0; j < tempLen; j++) {
|
|
|
|
mCJKPrefLangs.AppendElement(tempPrefLangs[j]);
|
|
|
|
}
|
|
|
|
}
|
2012-11-06 15:23:13 -08:00
|
|
|
|
2009-10-07 08:26:58 -07:00
|
|
|
// append in cached CJK langs
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t i, numCJKlangs = mCJKPrefLangs.Length();
|
2012-11-06 15:23:13 -08:00
|
|
|
|
2009-10-07 08:26:58 -07:00
|
|
|
for (i = 0; i < numCJKlangs; i++) {
|
|
|
|
AppendPrefLang(aPrefLangs, aLen, (eFontPrefLang) (mCJKPrefLangs[i]));
|
|
|
|
}
|
2012-11-06 15:23:13 -08:00
|
|
|
|
2009-10-07 08:26:58 -07:00
|
|
|
}
|
|
|
|
|
2012-11-06 15:23:13 -08:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
gfxPlatform::AppendPrefLang(eFontPrefLang aPrefLangs[], uint32_t& aLen, eFontPrefLang aAddLang)
|
2008-01-30 16:23:36 -08:00
|
|
|
{
|
|
|
|
if (aLen >= kMaxLenPrefLangList) return;
|
2012-11-06 15:23:13 -08:00
|
|
|
|
2008-01-30 16:23:36 -08:00
|
|
|
// make sure
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t i = 0;
|
2008-01-30 16:23:36 -08:00
|
|
|
while (i < aLen && aPrefLangs[i] != aAddLang) {
|
|
|
|
i++;
|
|
|
|
}
|
2012-11-06 15:23:13 -08:00
|
|
|
|
2008-01-30 16:23:36 -08:00
|
|
|
if (i == aLen) {
|
|
|
|
aPrefLangs[aLen] = aAddLang;
|
|
|
|
aLen++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-24 17:45:58 -07:00
|
|
|
void
|
2013-11-05 11:54:12 -08:00
|
|
|
gfxPlatform::InitBackendPrefs(uint32_t aCanvasBitmask, BackendType aCanvasDefault,
|
|
|
|
uint32_t aContentBitmask, BackendType aContentDefault)
|
2012-07-24 17:45:58 -07:00
|
|
|
{
|
2012-11-06 18:27:09 -08:00
|
|
|
mPreferredCanvasBackend = GetCanvasBackendPref(aCanvasBitmask);
|
2012-10-12 02:42:51 -07:00
|
|
|
if (!mPreferredCanvasBackend) {
|
2013-11-05 11:54:12 -08:00
|
|
|
mPreferredCanvasBackend = aCanvasDefault;
|
2012-10-12 02:42:51 -07:00
|
|
|
}
|
2013-11-05 11:54:12 -08:00
|
|
|
mFallbackCanvasBackend =
|
|
|
|
GetCanvasBackendPref(aCanvasBitmask & ~(1 << mPreferredCanvasBackend));
|
2013-08-25 21:13:24 -07:00
|
|
|
|
2013-05-27 15:04:37 -07:00
|
|
|
mContentBackendBitmask = aContentBitmask;
|
2013-08-25 21:13:24 -07:00
|
|
|
mContentBackend = GetContentBackendPref(mContentBackendBitmask);
|
2013-11-05 11:54:12 -08:00
|
|
|
if (!mContentBackend) {
|
|
|
|
mContentBackend = aContentDefault;
|
|
|
|
}
|
2012-09-16 17:20:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ BackendType
|
2012-11-06 18:27:09 -08:00
|
|
|
gfxPlatform::GetCanvasBackendPref(uint32_t aBackendBitmask)
|
2012-09-16 17:20:16 -07:00
|
|
|
{
|
2013-11-05 11:54:12 -08:00
|
|
|
return GetBackendPref("gfx.canvas.azure.backends", aBackendBitmask);
|
2012-09-16 20:23:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ BackendType
|
2013-08-25 21:13:24 -07:00
|
|
|
gfxPlatform::GetContentBackendPref(uint32_t &aBackendBitmask)
|
2012-09-16 20:23:00 -07:00
|
|
|
{
|
2013-11-05 11:54:12 -08:00
|
|
|
return GetBackendPref("gfx.content.azure.backends", aBackendBitmask);
|
2012-09-16 20:23:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ BackendType
|
2013-11-05 11:54:12 -08:00
|
|
|
gfxPlatform::GetBackendPref(const char* aBackendPrefName, uint32_t &aBackendBitmask)
|
2012-09-16 20:23:00 -07:00
|
|
|
{
|
2012-10-09 02:45:35 -07:00
|
|
|
nsTArray<nsCString> backendList;
|
|
|
|
nsCString prefString;
|
|
|
|
if (NS_SUCCEEDED(Preferences::GetCString(aBackendPrefName, &prefString))) {
|
|
|
|
ParseString(prefString, ',', backendList);
|
2012-07-24 17:45:58 -07:00
|
|
|
}
|
|
|
|
|
2013-08-25 21:13:24 -07:00
|
|
|
uint32_t allowedBackends = 0;
|
|
|
|
BackendType result = BACKEND_NONE;
|
2012-10-09 02:45:35 -07:00
|
|
|
for (uint32_t i = 0; i < backendList.Length(); ++i) {
|
2013-08-25 21:13:24 -07:00
|
|
|
BackendType type = BackendTypeForName(backendList[i]);
|
|
|
|
if ((1 << type) & aBackendBitmask) {
|
|
|
|
allowedBackends |= (1 << type);
|
|
|
|
if (result == BACKEND_NONE) {
|
|
|
|
result = type;
|
|
|
|
}
|
2012-07-24 17:45:58 -07:00
|
|
|
}
|
|
|
|
}
|
2013-08-25 21:13:24 -07:00
|
|
|
|
|
|
|
aBackendBitmask = allowedBackends;
|
|
|
|
return result;
|
2012-07-24 17:45:58 -07:00
|
|
|
}
|
|
|
|
|
2012-07-06 11:38:50 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::UseProgressiveTilePainting()
|
|
|
|
{
|
2012-07-24 17:45:58 -07:00
|
|
|
static bool sUseProgressiveTilePainting;
|
|
|
|
static bool sUseProgressiveTilePaintingPrefCached = false;
|
|
|
|
|
|
|
|
if (!sUseProgressiveTilePaintingPrefCached) {
|
|
|
|
sUseProgressiveTilePaintingPrefCached = true;
|
|
|
|
mozilla::Preferences::AddBoolVarCache(&sUseProgressiveTilePainting,
|
|
|
|
"layers.progressive-paint",
|
|
|
|
false);
|
|
|
|
}
|
2012-07-06 11:38:50 -07:00
|
|
|
|
2012-07-24 17:45:58 -07:00
|
|
|
return sUseProgressiveTilePainting;
|
2012-07-06 11:38:50 -07:00
|
|
|
}
|
|
|
|
|
2012-11-21 14:34:20 -08:00
|
|
|
bool
|
|
|
|
gfxPlatform::UseLowPrecisionBuffer()
|
|
|
|
{
|
|
|
|
static bool sUseLowPrecisionBuffer;
|
|
|
|
static bool sUseLowPrecisionBufferPrefCached = false;
|
|
|
|
|
|
|
|
if (!sUseLowPrecisionBufferPrefCached) {
|
|
|
|
sUseLowPrecisionBufferPrefCached = true;
|
|
|
|
mozilla::Preferences::AddBoolVarCache(&sUseLowPrecisionBuffer,
|
|
|
|
"layers.low-precision-buffer",
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sUseLowPrecisionBuffer;
|
|
|
|
}
|
|
|
|
|
2012-12-05 09:10:41 -08:00
|
|
|
float
|
|
|
|
gfxPlatform::GetLowPrecisionResolution()
|
|
|
|
{
|
|
|
|
static float sLowPrecisionResolution;
|
|
|
|
static bool sLowPrecisionResolutionPrefCached = false;
|
|
|
|
|
|
|
|
if (!sLowPrecisionResolutionPrefCached) {
|
|
|
|
int32_t lowPrecisionResolution = 250;
|
|
|
|
sLowPrecisionResolutionPrefCached = true;
|
|
|
|
mozilla::Preferences::AddIntVarCache(&lowPrecisionResolution,
|
|
|
|
"layers.low-precision-resolution",
|
|
|
|
250);
|
|
|
|
sLowPrecisionResolution = lowPrecisionResolution / 1000.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sLowPrecisionResolution;
|
|
|
|
}
|
|
|
|
|
2012-08-25 18:27:28 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::OffMainThreadCompositingEnabled()
|
|
|
|
{
|
|
|
|
return XRE_GetProcessType() == GeckoProcessType_Default ?
|
|
|
|
CompositorParent::CompositorLoop() != nullptr :
|
|
|
|
CompositorChild::ChildProcessHasCompositor();
|
|
|
|
}
|
|
|
|
|
2013-09-06 20:08:36 -07:00
|
|
|
eCMSMode
|
|
|
|
gfxPlatform::GetCMSMode()
|
|
|
|
{
|
|
|
|
if (gCMSInitialized == false) {
|
|
|
|
gCMSInitialized = true;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
int32_t mode;
|
|
|
|
rv = Preferences::GetInt("gfx.color_management.mode", &mode);
|
|
|
|
if (NS_SUCCEEDED(rv) && (mode >= 0) && (mode < eCMSMode_AllCount)) {
|
|
|
|
gCMSMode = static_cast<eCMSMode>(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool enableV4;
|
|
|
|
rv = Preferences::GetBool("gfx.color_management.enablev4", &enableV4);
|
|
|
|
if (NS_SUCCEEDED(rv) && enableV4) {
|
|
|
|
qcms_enable_iccv4();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return gCMSMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
gfxPlatform::GetRenderingIntent()
|
|
|
|
{
|
|
|
|
if (gCMSIntent == -2) {
|
|
|
|
|
|
|
|
/* Try to query the pref system for a rendering intent. */
|
|
|
|
int32_t pIntent;
|
|
|
|
if (NS_SUCCEEDED(Preferences::GetInt("gfx.color_management.rendering_intent", &pIntent))) {
|
|
|
|
/* If the pref is within range, use it as an override. */
|
|
|
|
if ((pIntent >= QCMS_INTENT_MIN) && (pIntent <= QCMS_INTENT_MAX)) {
|
|
|
|
gCMSIntent = pIntent;
|
|
|
|
}
|
|
|
|
/* If the pref is out of range, use embedded profile. */
|
|
|
|
else {
|
|
|
|
gCMSIntent = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* If we didn't get a valid intent from prefs, use the default. */
|
|
|
|
else {
|
|
|
|
gCMSIntent = QCMS_INTENT_DEFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return gCMSIntent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxPlatform::TransformPixel(const gfxRGBA& in, gfxRGBA& out, qcms_transform *transform)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (transform) {
|
|
|
|
/* we want the bytes in RGB order */
|
|
|
|
#ifdef IS_LITTLE_ENDIAN
|
|
|
|
/* ABGR puts the bytes in |RGBA| order on little endian */
|
|
|
|
uint32_t packed = in.Packed(gfxRGBA::PACKED_ABGR);
|
|
|
|
qcms_transform_data(transform,
|
|
|
|
(uint8_t *)&packed, (uint8_t *)&packed,
|
|
|
|
1);
|
|
|
|
out.~gfxRGBA();
|
|
|
|
new (&out) gfxRGBA(packed, gfxRGBA::PACKED_ABGR);
|
|
|
|
#else
|
|
|
|
/* ARGB puts the bytes in |ARGB| order on big endian */
|
|
|
|
uint32_t packed = in.Packed(gfxRGBA::PACKED_ARGB);
|
|
|
|
/* add one to move past the alpha byte */
|
|
|
|
qcms_transform_data(transform,
|
|
|
|
(uint8_t *)&packed + 1, (uint8_t *)&packed + 1,
|
|
|
|
1);
|
|
|
|
out.~gfxRGBA();
|
|
|
|
new (&out) gfxRGBA(packed, gfxRGBA::PACKED_ARGB);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (&out != &in)
|
|
|
|
out = in;
|
|
|
|
}
|
|
|
|
|
2009-04-07 09:02:11 -07:00
|
|
|
qcms_profile *
|
2007-07-23 15:02:17 -07:00
|
|
|
gfxPlatform::GetPlatformCMSOutputProfile()
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-07-23 15:02:17 -07:00
|
|
|
}
|
|
|
|
|
2013-09-06 20:08:36 -07:00
|
|
|
void
|
|
|
|
gfxPlatform::CreateCMSOutputProfile()
|
|
|
|
{
|
|
|
|
if (!gCMSOutputProfile) {
|
|
|
|
/* Determine if we're using the internal override to force sRGB as
|
|
|
|
an output profile for reftests. See Bug 452125.
|
|
|
|
|
|
|
|
Note that we don't normally (outside of tests) set a
|
|
|
|
default value of this preference, which means nsIPrefBranch::GetBoolPref
|
|
|
|
will typically throw (and leave its out-param untouched).
|
|
|
|
*/
|
|
|
|
if (Preferences::GetBool("gfx.color_management.force_srgb", false)) {
|
|
|
|
gCMSOutputProfile = GetCMSsRGBProfile();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gCMSOutputProfile) {
|
|
|
|
nsAdoptingCString fname = Preferences::GetCString("gfx.color_management.display_profile");
|
|
|
|
if (!fname.IsEmpty()) {
|
|
|
|
gCMSOutputProfile = qcms_profile_from_path(fname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gCMSOutputProfile) {
|
|
|
|
gCMSOutputProfile =
|
|
|
|
gfxPlatform::GetPlatform()->GetPlatformCMSOutputProfile();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine if the profile looks bogus. If so, close the profile
|
|
|
|
* and use sRGB instead. See bug 460629, */
|
|
|
|
if (gCMSOutputProfile && qcms_profile_is_bogus(gCMSOutputProfile)) {
|
|
|
|
NS_ASSERTION(gCMSOutputProfile != GetCMSsRGBProfile(),
|
|
|
|
"Builtin sRGB profile tagged as bogus!!!");
|
|
|
|
qcms_profile_release(gCMSOutputProfile);
|
|
|
|
gCMSOutputProfile = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gCMSOutputProfile) {
|
|
|
|
gCMSOutputProfile = GetCMSsRGBProfile();
|
|
|
|
}
|
|
|
|
/* Precache the LUT16 Interpolations for the output profile. See
|
|
|
|
bug 444661 for details. */
|
|
|
|
qcms_profile_precache_output_transform(gCMSOutputProfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qcms_profile *
|
|
|
|
gfxPlatform::GetCMSOutputProfile()
|
|
|
|
{
|
|
|
|
return gCMSOutputProfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
qcms_profile *
|
|
|
|
gfxPlatform::GetCMSsRGBProfile()
|
|
|
|
{
|
|
|
|
if (!gCMSsRGBProfile) {
|
|
|
|
|
|
|
|
/* Create the profile using qcms. */
|
|
|
|
gCMSsRGBProfile = qcms_profile_sRGB();
|
|
|
|
}
|
|
|
|
return gCMSsRGBProfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
qcms_transform *
|
|
|
|
gfxPlatform::GetCMSRGBTransform()
|
|
|
|
{
|
|
|
|
if (!gCMSRGBTransform) {
|
|
|
|
qcms_profile *inProfile, *outProfile;
|
|
|
|
outProfile = GetCMSOutputProfile();
|
|
|
|
inProfile = GetCMSsRGBProfile();
|
|
|
|
|
|
|
|
if (!inProfile || !outProfile)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
gCMSRGBTransform = qcms_transform_create(inProfile, QCMS_DATA_RGB_8,
|
|
|
|
outProfile, QCMS_DATA_RGB_8,
|
|
|
|
QCMS_INTENT_PERCEPTUAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return gCMSRGBTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
qcms_transform *
|
|
|
|
gfxPlatform::GetCMSInverseRGBTransform()
|
|
|
|
{
|
|
|
|
if (!gCMSInverseRGBTransform) {
|
|
|
|
qcms_profile *inProfile, *outProfile;
|
|
|
|
inProfile = GetCMSOutputProfile();
|
|
|
|
outProfile = GetCMSsRGBProfile();
|
|
|
|
|
|
|
|
if (!inProfile || !outProfile)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
gCMSInverseRGBTransform = qcms_transform_create(inProfile, QCMS_DATA_RGB_8,
|
|
|
|
outProfile, QCMS_DATA_RGB_8,
|
|
|
|
QCMS_INTENT_PERCEPTUAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return gCMSInverseRGBTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
qcms_transform *
|
|
|
|
gfxPlatform::GetCMSRGBATransform()
|
|
|
|
{
|
|
|
|
if (!gCMSRGBATransform) {
|
|
|
|
qcms_profile *inProfile, *outProfile;
|
|
|
|
outProfile = GetCMSOutputProfile();
|
|
|
|
inProfile = GetCMSsRGBProfile();
|
|
|
|
|
|
|
|
if (!inProfile || !outProfile)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
gCMSRGBATransform = qcms_transform_create(inProfile, QCMS_DATA_RGBA_8,
|
|
|
|
outProfile, QCMS_DATA_RGBA_8,
|
|
|
|
QCMS_INTENT_PERCEPTUAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return gCMSRGBATransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Shuts down various transforms and profiles for CMS. */
|
|
|
|
static void ShutdownCMS()
|
|
|
|
{
|
|
|
|
|
|
|
|
if (gCMSRGBTransform) {
|
|
|
|
qcms_transform_release(gCMSRGBTransform);
|
|
|
|
gCMSRGBTransform = nullptr;
|
|
|
|
}
|
|
|
|
if (gCMSInverseRGBTransform) {
|
|
|
|
qcms_transform_release(gCMSInverseRGBTransform);
|
|
|
|
gCMSInverseRGBTransform = nullptr;
|
|
|
|
}
|
|
|
|
if (gCMSRGBATransform) {
|
|
|
|
qcms_transform_release(gCMSRGBATransform);
|
|
|
|
gCMSRGBATransform = nullptr;
|
|
|
|
}
|
|
|
|
if (gCMSOutputProfile) {
|
|
|
|
qcms_profile_release(gCMSOutputProfile);
|
|
|
|
|
|
|
|
// handle the aliased case
|
|
|
|
if (gCMSsRGBProfile == gCMSOutputProfile)
|
|
|
|
gCMSsRGBProfile = nullptr;
|
|
|
|
gCMSOutputProfile = nullptr;
|
|
|
|
}
|
|
|
|
if (gCMSsRGBProfile) {
|
|
|
|
qcms_profile_release(gCMSsRGBProfile);
|
|
|
|
gCMSsRGBProfile = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset the state variables
|
|
|
|
gCMSIntent = -2;
|
|
|
|
gCMSMode = eCMSMode_Off;
|
|
|
|
gCMSInitialized = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void MigratePrefs()
|
|
|
|
{
|
|
|
|
/* Migrate from the boolean color_management.enabled pref - we now use
|
|
|
|
color_management.mode. */
|
|
|
|
if (Preferences::HasUserValue("gfx.color_management.enabled")) {
|
|
|
|
if (Preferences::GetBool("gfx.color_management.enabled", false)) {
|
|
|
|
Preferences::SetInt("gfx.color_management.mode", static_cast<int32_t>(eCMSMode_All));
|
|
|
|
}
|
|
|
|
Preferences::ClearUser("gfx.color_management.enabled");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-07 08:26:58 -07:00
|
|
|
// default SetupClusterBoundaries, based on Unicode properties;
|
|
|
|
// platform subclasses may override if they wish
|
|
|
|
void
|
|
|
|
gfxPlatform::SetupClusterBoundaries(gfxTextRun *aTextRun, const PRUnichar *aString)
|
|
|
|
{
|
|
|
|
if (aTextRun->GetFlags() & gfxTextRunFactory::TEXT_IS_8BIT) {
|
|
|
|
// 8-bit text doesn't have clusters.
|
|
|
|
// XXX is this true in all languages???
|
|
|
|
// behdad: don't think so. Czech for example IIRC has a
|
|
|
|
// 'ch' grapheme.
|
2010-12-06 05:22:24 -08:00
|
|
|
// jfkthame: but that's not expected to behave as a grapheme cluster
|
|
|
|
// for selection/editing/etc.
|
2009-10-07 08:26:58 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-04 10:35:37 -08:00
|
|
|
aTextRun->SetupClusterBoundaries(0, aString, aTextRun->GetLength());
|
2011-12-06 04:39:19 -08:00
|
|
|
}
|
2010-12-06 05:22:24 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
2011-12-06 04:39:19 -08:00
|
|
|
gfxPlatform::GetBidiNumeralOption()
|
|
|
|
{
|
|
|
|
if (mBidiNumeralOption == UNINITIALIZED_VALUE) {
|
|
|
|
mBidiNumeralOption = Preferences::GetInt(BIDI_NUMERAL_PREF, 0);
|
2009-10-07 08:26:58 -07:00
|
|
|
}
|
2011-12-06 04:39:19 -08:00
|
|
|
return mBidiNumeralOption;
|
2009-10-07 08:26:58 -07:00
|
|
|
}
|
2010-05-26 22:05:30 -07:00
|
|
|
|
2013-09-10 18:36:57 -07:00
|
|
|
static void
|
|
|
|
FlushFontAndWordCaches()
|
|
|
|
{
|
|
|
|
gfxFontCache *fontCache = gfxFontCache::GetCache();
|
|
|
|
if (fontCache) {
|
|
|
|
fontCache->AgeAllGenerations();
|
|
|
|
fontCache->FlushShapedWordCaches();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-26 22:05:30 -07:00
|
|
|
void
|
2011-06-11 19:30:16 -07:00
|
|
|
gfxPlatform::FontsPrefsChanged(const char *aPref)
|
2010-05-26 22:05:30 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ASSERTION(aPref != nullptr, "null preference");
|
2010-05-26 22:05:30 -07:00
|
|
|
if (!strcmp(GFX_DOWNLOADABLE_FONTS_ENABLED, aPref)) {
|
|
|
|
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
|
2012-03-08 18:05:40 -08:00
|
|
|
} else if (!strcmp(GFX_PREF_FALLBACK_USE_CMAPS, aPref)) {
|
|
|
|
mFallbackUsesCmaps = UNINITIALIZED_VALUE;
|
2013-09-10 18:36:57 -07:00
|
|
|
} else if (!strcmp(GFX_PREF_WORD_CACHE_CHARLIMIT, aPref)) {
|
|
|
|
mWordCacheCharLimit = UNINITIALIZED_VALUE;
|
2013-09-10 18:36:57 -07:00
|
|
|
FlushFontAndWordCaches();
|
|
|
|
} else if (!strcmp(GFX_PREF_WORD_CACHE_MAXENTRIES, aPref)) {
|
|
|
|
mWordCacheMaxEntries = UNINITIALIZED_VALUE;
|
|
|
|
FlushFontAndWordCaches();
|
2011-12-09 14:32:29 -08:00
|
|
|
} else if (!strcmp(GFX_PREF_GRAPHITE_SHAPING, aPref)) {
|
|
|
|
mGraphiteShapingEnabled = UNINITIALIZED_VALUE;
|
2013-09-10 18:36:57 -07:00
|
|
|
FlushFontAndWordCaches();
|
2011-04-11 04:17:31 -07:00
|
|
|
} else if (!strcmp(GFX_PREF_HARFBUZZ_SCRIPTS, aPref)) {
|
|
|
|
mUseHarfBuzzScripts = UNINITIALIZED_VALUE;
|
2013-09-10 18:36:57 -07:00
|
|
|
FlushFontAndWordCaches();
|
2011-12-06 04:39:19 -08:00
|
|
|
} else if (!strcmp(BIDI_NUMERAL_PREF, aPref)) {
|
|
|
|
mBidiNumeralOption = UNINITIALIZED_VALUE;
|
2012-09-05 21:57:54 -07:00
|
|
|
} else if (!strcmp(GFX_PREF_OPENTYPE_SVG, aPref)) {
|
2013-05-16 09:32:41 -07:00
|
|
|
mOpenTypeSVGEnabled = UNINITIALIZED_VALUE;
|
2012-09-05 21:57:54 -07:00
|
|
|
gfxFontCache::GetCache()->AgeAllGenerations();
|
2010-05-26 22:05:30 -07:00
|
|
|
}
|
|
|
|
}
|
2011-01-21 08:44:33 -08:00
|
|
|
|
|
|
|
|
|
|
|
PRLogModuleInfo*
|
|
|
|
gfxPlatform::GetLog(eGfxLog aWhichLog)
|
|
|
|
{
|
|
|
|
#ifdef PR_LOGGING
|
|
|
|
switch (aWhichLog) {
|
|
|
|
case eGfxLog_fontlist:
|
|
|
|
return sFontlistLog;
|
|
|
|
break;
|
|
|
|
case eGfxLog_fontinit:
|
|
|
|
return sFontInitLog;
|
|
|
|
break;
|
|
|
|
case eGfxLog_textrun:
|
|
|
|
return sTextrunLog;
|
|
|
|
break;
|
|
|
|
case eGfxLog_textrunui:
|
|
|
|
return sTextrunuiLog;
|
|
|
|
break;
|
2012-03-08 18:05:14 -08:00
|
|
|
case eGfxLog_cmapdata:
|
|
|
|
return sCmapDataLog;
|
|
|
|
break;
|
2013-11-24 20:59:56 -08:00
|
|
|
case eGfxLog_textperf:
|
|
|
|
return sTextPerfLog;
|
|
|
|
break;
|
2011-01-21 08:44:33 -08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-01-21 08:44:33 -08:00
|
|
|
#else
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-01-21 08:44:33 -08:00
|
|
|
#endif
|
|
|
|
}
|
2012-05-15 12:41:20 -07:00
|
|
|
|
|
|
|
int
|
|
|
|
gfxPlatform::GetScreenDepth() const
|
|
|
|
{
|
2012-07-06 06:19:27 -07:00
|
|
|
NS_WARNING("GetScreenDepth not implemented on this platform -- returning 0!");
|
2012-05-15 12:41:20 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2012-05-25 21:38:17 -07:00
|
|
|
|
|
|
|
mozilla::gfx::SurfaceFormat
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxPlatform::Optimal2DFormatForContent(gfxContentType aContent)
|
2012-05-25 21:38:17 -07:00
|
|
|
{
|
|
|
|
switch (aContent) {
|
2013-09-24 13:45:13 -07:00
|
|
|
case GFX_CONTENT_COLOR:
|
2012-06-19 21:03:24 -07:00
|
|
|
switch (GetOffscreenFormat()) {
|
2013-09-24 13:45:13 -07:00
|
|
|
case gfxImageFormatARGB32:
|
2012-06-19 21:03:24 -07:00
|
|
|
return mozilla::gfx::FORMAT_B8G8R8A8;
|
2013-09-24 13:45:13 -07:00
|
|
|
case gfxImageFormatRGB24:
|
2012-06-19 21:03:24 -07:00
|
|
|
return mozilla::gfx::FORMAT_B8G8R8X8;
|
2013-09-24 13:45:13 -07:00
|
|
|
case gfxImageFormatRGB16_565:
|
2012-06-19 21:03:24 -07:00
|
|
|
return mozilla::gfx::FORMAT_R5G6B5;
|
|
|
|
default:
|
2013-09-24 13:45:13 -07:00
|
|
|
NS_NOTREACHED("unknown gfxImageFormat for GFX_CONTENT_COLOR");
|
2012-06-19 21:03:24 -07:00
|
|
|
return mozilla::gfx::FORMAT_B8G8R8A8;
|
|
|
|
}
|
2013-09-24 13:45:13 -07:00
|
|
|
case GFX_CONTENT_ALPHA:
|
2012-05-25 21:38:17 -07:00
|
|
|
return mozilla::gfx::FORMAT_A8;
|
2013-09-24 13:45:13 -07:00
|
|
|
case GFX_CONTENT_COLOR_ALPHA:
|
2012-05-25 21:38:17 -07:00
|
|
|
return mozilla::gfx::FORMAT_B8G8R8A8;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unknown gfxContentType");
|
|
|
|
return mozilla::gfx::FORMAT_B8G8R8A8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxImageFormat
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxPlatform::OptimalFormatForContent(gfxContentType aContent)
|
2012-05-25 21:38:17 -07:00
|
|
|
{
|
|
|
|
switch (aContent) {
|
2013-09-24 13:45:13 -07:00
|
|
|
case GFX_CONTENT_COLOR:
|
2012-05-25 21:38:17 -07:00
|
|
|
return GetOffscreenFormat();
|
2013-09-24 13:45:13 -07:00
|
|
|
case GFX_CONTENT_ALPHA:
|
|
|
|
return gfxImageFormatA8;
|
|
|
|
case GFX_CONTENT_COLOR_ALPHA:
|
|
|
|
return gfxImageFormatARGB32;
|
2012-05-25 21:38:17 -07:00
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unknown gfxContentType");
|
2013-09-24 13:45:13 -07:00
|
|
|
return gfxImageFormatARGB32;
|
2012-05-25 21:38:17 -07:00
|
|
|
}
|
|
|
|
}
|
2012-11-21 18:40:57 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
gfxPlatform::OrientationSyncPrefsObserverChanged()
|
|
|
|
{
|
|
|
|
mOrientationSyncMillis = Preferences::GetUint("layers.orientation.sync.timeout", (uint32_t)0);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
gfxPlatform::GetOrientationSyncMillis() const
|
|
|
|
{
|
|
|
|
return mOrientationSyncMillis;
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* There are a number of layers acceleration (or layers in general) preferences
|
|
|
|
* that should be consistent for the lifetime of the application (bug 840967).
|
|
|
|
* As such, we will evaluate them all as soon as one of them is evaluated
|
|
|
|
* and remember the values. Changing these preferences during the run will
|
|
|
|
* not have any effect until we restart.
|
|
|
|
*/
|
|
|
|
static bool sPrefLayersOffMainThreadCompositionEnabled = false;
|
|
|
|
static bool sPrefLayersOffMainThreadCompositionTestingEnabled = false;
|
2013-06-20 14:32:04 -07:00
|
|
|
static bool sPrefLayersOffMainThreadCompositionForceEnabled = false;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
static bool sPrefLayersAccelerationForceEnabled = false;
|
|
|
|
static bool sPrefLayersAccelerationDisabled = false;
|
|
|
|
static bool sPrefLayersPreferOpenGL = false;
|
|
|
|
static bool sPrefLayersPreferD3D9 = false;
|
2013-11-17 13:47:40 -08:00
|
|
|
static bool sPrefLayersDump = false;
|
2013-12-03 07:49:46 -08:00
|
|
|
static bool sPrefLayersScrollGraph = false;
|
2013-11-15 08:28:40 -08:00
|
|
|
static bool sLayersSupportsD3D9 = false;
|
2013-07-08 17:06:14 -07:00
|
|
|
static int sPrefLayoutFrameRate = -1;
|
2013-08-04 00:46:17 -07:00
|
|
|
static bool sBufferRotationEnabled = false;
|
2013-08-08 16:30:19 -07:00
|
|
|
static bool sComponentAlphaEnabled = true;
|
2013-08-19 00:13:32 -07:00
|
|
|
static bool sPrefBrowserTabsRemote = false;
|
2013-08-04 00:46:17 -07:00
|
|
|
|
|
|
|
static bool sLayersAccelerationPrefsInitialized = false;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
|
2013-08-04 00:46:17 -07:00
|
|
|
void
|
|
|
|
InitLayersAccelerationPrefs()
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
{
|
|
|
|
if (!sLayersAccelerationPrefsInitialized)
|
|
|
|
{
|
2013-11-26 23:33:39 -08:00
|
|
|
// If this is called for the first time on a non-main thread, we're screwed.
|
|
|
|
// At the moment there's no explicit guarantee that the main thread calls
|
|
|
|
// this before the compositor thread, but let's at least make the assumption
|
|
|
|
// explicit.
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "can only initialize prefs on the main thread");
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
sPrefLayersOffMainThreadCompositionEnabled = Preferences::GetBool("layers.offmainthreadcomposition.enabled", false);
|
|
|
|
sPrefLayersOffMainThreadCompositionTestingEnabled = Preferences::GetBool("layers.offmainthreadcomposition.testing.enabled", false);
|
2013-06-20 14:32:04 -07:00
|
|
|
sPrefLayersOffMainThreadCompositionForceEnabled = Preferences::GetBool("layers.offmainthreadcomposition.force-enabled", false);
|
2013-06-23 22:27:29 -07:00
|
|
|
sPrefLayersAccelerationForceEnabled = Preferences::GetBool("layers.acceleration.force-enabled", false);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
sPrefLayersAccelerationDisabled = Preferences::GetBool("layers.acceleration.disabled", false);
|
|
|
|
sPrefLayersPreferOpenGL = Preferences::GetBool("layers.prefer-opengl", false);
|
|
|
|
sPrefLayersPreferD3D9 = Preferences::GetBool("layers.prefer-d3d9", false);
|
2013-11-17 13:47:40 -08:00
|
|
|
sPrefLayersDump = Preferences::GetBool("layers.dump", false);
|
2013-12-03 07:49:46 -08:00
|
|
|
sPrefLayersScrollGraph = Preferences::GetBool("layers.scroll-graph", false);
|
2013-07-08 17:06:14 -07:00
|
|
|
sPrefLayoutFrameRate = Preferences::GetInt("layout.frame_rate", -1);
|
2013-08-04 00:46:17 -07:00
|
|
|
sBufferRotationEnabled = Preferences::GetBool("layers.bufferrotation.enabled", true);
|
2013-08-08 16:30:19 -07:00
|
|
|
sComponentAlphaEnabled = Preferences::GetBool("layers.componentalpha.enabled", true);
|
2013-08-19 00:13:32 -07:00
|
|
|
sPrefBrowserTabsRemote = Preferences::GetBool("browser.tabs.remote", false);
|
2013-08-04 00:46:17 -07:00
|
|
|
|
2013-11-15 08:28:40 -08:00
|
|
|
#ifdef XP_WIN
|
|
|
|
if (sPrefLayersAccelerationForceEnabled) {
|
|
|
|
sLayersSupportsD3D9 = true;
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
|
|
|
|
if (gfxInfo) {
|
|
|
|
int32_t status;
|
|
|
|
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS, &status))) {
|
|
|
|
if (status == nsIGfxInfo::FEATURE_NO_INFO) {
|
|
|
|
sLayersSupportsD3D9 = true;
|
|
|
|
}
|
2013-08-04 00:46:17 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-15 08:28:40 -08:00
|
|
|
#endif
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
|
|
|
|
sLayersAccelerationPrefsInitialized = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-04 00:46:17 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::GetPrefLayersOffMainThreadCompositionEnabled()
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
{
|
|
|
|
InitLayersAccelerationPrefs();
|
|
|
|
return sPrefLayersOffMainThreadCompositionEnabled ||
|
2013-06-20 14:32:04 -07:00
|
|
|
sPrefLayersOffMainThreadCompositionForceEnabled ||
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
sPrefLayersOffMainThreadCompositionTestingEnabled;
|
|
|
|
}
|
|
|
|
|
2013-08-04 00:46:17 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::GetPrefLayersOffMainThreadCompositionForceEnabled()
|
2013-06-20 14:32:04 -07:00
|
|
|
{
|
|
|
|
InitLayersAccelerationPrefs();
|
|
|
|
return sPrefLayersOffMainThreadCompositionForceEnabled;
|
|
|
|
}
|
|
|
|
|
2013-08-04 00:46:17 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::GetPrefLayersAccelerationForceEnabled()
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
{
|
|
|
|
InitLayersAccelerationPrefs();
|
|
|
|
return sPrefLayersAccelerationForceEnabled;
|
|
|
|
}
|
|
|
|
|
2013-08-19 00:13:32 -07:00
|
|
|
bool gfxPlatform::OffMainThreadCompositionRequired()
|
|
|
|
{
|
|
|
|
InitLayersAccelerationPrefs();
|
2013-11-26 14:15:17 -08:00
|
|
|
#if defined(MOZ_WIDGET_GTK) && defined(NIGHTLY_BUILD)
|
|
|
|
// Linux users who chose OpenGL are being grandfathered in to OMTC
|
|
|
|
return sPrefBrowserTabsRemote ||
|
|
|
|
sPrefLayersAccelerationForceEnabled;
|
|
|
|
#else
|
2013-08-19 00:13:32 -07:00
|
|
|
return sPrefBrowserTabsRemote;
|
2013-11-26 14:15:17 -08:00
|
|
|
#endif
|
2013-08-19 00:13:32 -07:00
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::GetPrefLayersAccelerationDisabled()
|
|
|
|
{
|
|
|
|
InitLayersAccelerationPrefs();
|
|
|
|
return sPrefLayersAccelerationDisabled;
|
|
|
|
}
|
|
|
|
|
2013-08-04 00:46:17 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::GetPrefLayersPreferOpenGL()
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
{
|
|
|
|
InitLayersAccelerationPrefs();
|
|
|
|
return sPrefLayersPreferOpenGL;
|
|
|
|
}
|
|
|
|
|
2013-08-04 00:46:17 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::GetPrefLayersPreferD3D9()
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
{
|
|
|
|
InitLayersAccelerationPrefs();
|
|
|
|
return sPrefLayersPreferD3D9;
|
|
|
|
}
|
2013-07-08 17:06:14 -07:00
|
|
|
|
2013-08-04 00:46:17 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::CanUseDirect3D9()
|
|
|
|
{
|
|
|
|
// this function is called from the compositor thread, so it is not
|
|
|
|
// safe to init the prefs etc. from here.
|
|
|
|
MOZ_ASSERT(sLayersAccelerationPrefsInitialized);
|
|
|
|
return sLayersSupportsD3D9;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
gfxPlatform::GetPrefLayoutFrameRate()
|
2013-07-08 17:06:14 -07:00
|
|
|
{
|
|
|
|
InitLayersAccelerationPrefs();
|
|
|
|
return sPrefLayoutFrameRate;
|
|
|
|
}
|
2013-08-04 00:46:17 -07:00
|
|
|
|
2013-11-17 13:47:40 -08:00
|
|
|
bool
|
|
|
|
gfxPlatform::GetPrefLayersDump()
|
|
|
|
{
|
|
|
|
InitLayersAccelerationPrefs();
|
|
|
|
return sPrefLayersDump;
|
|
|
|
}
|
|
|
|
|
2013-12-03 07:49:46 -08:00
|
|
|
bool
|
|
|
|
gfxPlatform::GetPrefLayersScrollGraph()
|
|
|
|
{
|
|
|
|
// this function is called from the compositor thread, so it is not
|
|
|
|
// safe to init the prefs etc. from here.
|
|
|
|
MOZ_ASSERT(sLayersAccelerationPrefsInitialized);
|
|
|
|
return sPrefLayersScrollGraph;
|
|
|
|
}
|
|
|
|
|
2013-08-04 00:46:17 -07:00
|
|
|
bool
|
|
|
|
gfxPlatform::BufferRotationEnabled()
|
|
|
|
{
|
|
|
|
MutexAutoLock autoLock(*gGfxPlatformPrefsLock);
|
|
|
|
|
|
|
|
InitLayersAccelerationPrefs();
|
|
|
|
return sBufferRotationEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxPlatform::DisableBufferRotation()
|
|
|
|
{
|
|
|
|
MutexAutoLock autoLock(*gGfxPlatformPrefsLock);
|
|
|
|
|
|
|
|
sBufferRotationEnabled = false;
|
|
|
|
}
|
2013-08-08 16:30:19 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
gfxPlatform::ComponentAlphaEnabled()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
InitLayersAccelerationPrefs();
|
|
|
|
return sComponentAlphaEnabled;
|
2013-08-16 06:18:36 -07:00
|
|
|
}
|