mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
f5cf8c125c
--HG-- rename : gfx/thebes/src/GLContext.cpp => gfx/thebes/GLContext.cpp rename : gfx/thebes/public/GLContext.h => gfx/thebes/GLContext.h rename : gfx/thebes/public/GLContextProvider.h => gfx/thebes/GLContextProvider.h rename : gfx/thebes/src/GLContextProviderCGL.mm => gfx/thebes/GLContextProviderCGL.mm rename : gfx/thebes/src/GLContextProviderEGL.cpp => gfx/thebes/GLContextProviderEGL.cpp rename : gfx/thebes/src/GLContextProviderGLX.cpp => gfx/thebes/GLContextProviderGLX.cpp rename : gfx/thebes/src/GLContextProviderNull.cpp => gfx/thebes/GLContextProviderNull.cpp rename : gfx/thebes/src/GLContextProviderOSMesa.cpp => gfx/thebes/GLContextProviderOSMesa.cpp rename : gfx/thebes/src/GLContextProviderWGL.cpp => gfx/thebes/GLContextProviderWGL.cpp rename : gfx/thebes/public/GLDefs.h => gfx/thebes/GLDefs.h rename : gfx/thebes/public/GLXLibrary.h => gfx/thebes/GLXLibrary.h rename : gfx/thebes/public/WGLLibrary.h => gfx/thebes/WGLLibrary.h rename : gfx/thebes/src/cairo-gdk-utils.c => gfx/thebes/cairo-gdk-utils.c rename : gfx/thebes/src/cairo-gdk-utils.h => gfx/thebes/cairo-gdk-utils.h rename : gfx/thebes/src/cairo-xlib-utils.c => gfx/thebes/cairo-xlib-utils.c rename : gfx/thebes/src/cairo-xlib-utils.h => gfx/thebes/cairo-xlib-utils.h rename : gfx/thebes/src/genUnicodeScriptData.pl => gfx/thebes/genUnicodeScriptData.pl rename : gfx/thebes/public/gfx3DMatrix.h => gfx/thebes/gfx3DMatrix.h rename : gfx/thebes/src/gfxASurface.cpp => gfx/thebes/gfxASurface.cpp rename : gfx/thebes/public/gfxASurface.h => gfx/thebes/gfxASurface.h rename : gfx/thebes/src/gfxAlphaRecovery.cpp => gfx/thebes/gfxAlphaRecovery.cpp rename : gfx/thebes/public/gfxAlphaRecovery.h => gfx/thebes/gfxAlphaRecovery.h rename : gfx/thebes/src/gfxAndroidPlatform.cpp => gfx/thebes/gfxAndroidPlatform.cpp rename : gfx/thebes/public/gfxAndroidPlatform.h => gfx/thebes/gfxAndroidPlatform.h rename : gfx/thebes/src/gfxAtomList.h => gfx/thebes/gfxAtomList.h rename : gfx/thebes/src/gfxAtoms.cpp => gfx/thebes/gfxAtoms.cpp rename : gfx/thebes/src/gfxAtoms.h => gfx/thebes/gfxAtoms.h rename : gfx/thebes/src/gfxBeOSPlatform.cpp => gfx/thebes/gfxBeOSPlatform.cpp rename : gfx/thebes/public/gfxBeOSPlatform.h => gfx/thebes/gfxBeOSPlatform.h rename : gfx/thebes/src/gfxBeOSSurface.cpp => gfx/thebes/gfxBeOSSurface.cpp rename : gfx/thebes/public/gfxBeOSSurface.h => gfx/thebes/gfxBeOSSurface.h rename : gfx/thebes/public/gfxColor.h => gfx/thebes/gfxColor.h rename : gfx/thebes/src/gfxContext.cpp => gfx/thebes/gfxContext.cpp rename : gfx/thebes/public/gfxContext.h => gfx/thebes/gfxContext.h rename : gfx/thebes/src/gfxCoreTextShaper.cpp => gfx/thebes/gfxCoreTextShaper.cpp rename : gfx/thebes/src/gfxCoreTextShaper.h => gfx/thebes/gfxCoreTextShaper.h rename : gfx/thebes/src/gfxD2DSurface.cpp => gfx/thebes/gfxD2DSurface.cpp rename : gfx/thebes/public/gfxD2DSurface.h => gfx/thebes/gfxD2DSurface.h rename : gfx/thebes/src/gfxDDrawSurface.cpp => gfx/thebes/gfxDDrawSurface.cpp rename : gfx/thebes/public/gfxDDrawSurface.h => gfx/thebes/gfxDDrawSurface.h rename : gfx/thebes/src/gfxDWriteCommon.cpp => gfx/thebes/gfxDWriteCommon.cpp rename : gfx/thebes/src/gfxDWriteCommon.h => gfx/thebes/gfxDWriteCommon.h rename : gfx/thebes/src/gfxDWriteFontList.cpp => gfx/thebes/gfxDWriteFontList.cpp rename : gfx/thebes/src/gfxDWriteFontList.h => gfx/thebes/gfxDWriteFontList.h rename : gfx/thebes/src/gfxDWriteFonts.cpp => gfx/thebes/gfxDWriteFonts.cpp rename : gfx/thebes/public/gfxDWriteFonts.h => gfx/thebes/gfxDWriteFonts.h rename : gfx/thebes/src/gfxDWriteShaper.cpp => gfx/thebes/gfxDWriteShaper.cpp rename : gfx/thebes/src/gfxDWriteShaper.h => gfx/thebes/gfxDWriteShaper.h rename : gfx/thebes/src/gfxDWriteTextAnalysis.cpp => gfx/thebes/gfxDWriteTextAnalysis.cpp rename : gfx/thebes/src/gfxDWriteTextAnalysis.h => gfx/thebes/gfxDWriteTextAnalysis.h rename : gfx/thebes/src/gfxDirectFBSurface.cpp => gfx/thebes/gfxDirectFBSurface.cpp rename : gfx/thebes/public/gfxDirectFBSurface.h => gfx/thebes/gfxDirectFBSurface.h rename : gfx/thebes/src/gfxDllDeps.cpp => gfx/thebes/gfxDllDeps.cpp rename : gfx/thebes/src/gfxFT2FontBase.cpp => gfx/thebes/gfxFT2FontBase.cpp rename : gfx/thebes/public/gfxFT2FontBase.h => gfx/thebes/gfxFT2FontBase.h rename : gfx/thebes/src/gfxFT2FontList.cpp => gfx/thebes/gfxFT2FontList.cpp rename : gfx/thebes/src/gfxFT2FontList.h => gfx/thebes/gfxFT2FontList.h rename : gfx/thebes/src/gfxFT2Fonts.cpp => gfx/thebes/gfxFT2Fonts.cpp rename : gfx/thebes/public/gfxFT2Fonts.h => gfx/thebes/gfxFT2Fonts.h rename : gfx/thebes/src/gfxFT2Utils.cpp => gfx/thebes/gfxFT2Utils.cpp rename : gfx/thebes/src/gfxFT2Utils.h => gfx/thebes/gfxFT2Utils.h rename : gfx/thebes/src/gfxFont.cpp => gfx/thebes/gfxFont.cpp rename : gfx/thebes/public/gfxFont.h => gfx/thebes/gfxFont.h rename : gfx/thebes/public/gfxFontConstants.h => gfx/thebes/gfxFontConstants.h rename : gfx/thebes/src/gfxFontMissingGlyphs.cpp => gfx/thebes/gfxFontMissingGlyphs.cpp rename : gfx/thebes/src/gfxFontMissingGlyphs.h => gfx/thebes/gfxFontMissingGlyphs.h rename : gfx/thebes/src/gfxFontTest.cpp => gfx/thebes/gfxFontTest.cpp rename : gfx/thebes/public/gfxFontTest.h => gfx/thebes/gfxFontTest.h rename : gfx/thebes/src/gfxFontUtils.cpp => gfx/thebes/gfxFontUtils.cpp rename : gfx/thebes/public/gfxFontUtils.h => gfx/thebes/gfxFontUtils.h rename : gfx/thebes/src/gfxFontconfigUtils.cpp => gfx/thebes/gfxFontconfigUtils.cpp rename : gfx/thebes/src/gfxFontconfigUtils.h => gfx/thebes/gfxFontconfigUtils.h rename : gfx/thebes/src/gfxGDIFont.cpp => gfx/thebes/gfxGDIFont.cpp rename : gfx/thebes/src/gfxGDIFont.h => gfx/thebes/gfxGDIFont.h rename : gfx/thebes/src/gfxGDIFontList.cpp => gfx/thebes/gfxGDIFontList.cpp rename : gfx/thebes/src/gfxGDIFontList.h => gfx/thebes/gfxGDIFontList.h rename : gfx/thebes/src/gfxGDIShaper.cpp => gfx/thebes/gfxGDIShaper.cpp rename : gfx/thebes/src/gfxGDIShaper.h => gfx/thebes/gfxGDIShaper.h rename : gfx/thebes/src/gfxGdkNativeRenderer.cpp => gfx/thebes/gfxGdkNativeRenderer.cpp rename : gfx/thebes/public/gfxGdkNativeRenderer.h => gfx/thebes/gfxGdkNativeRenderer.h rename : gfx/thebes/public/gfxGlitzSurface.h => gfx/thebes/gfxGlitzSurface.h rename : gfx/thebes/src/gfxHarfBuzzShaper.cpp => gfx/thebes/gfxHarfBuzzShaper.cpp rename : gfx/thebes/src/gfxHarfBuzzShaper.h => gfx/thebes/gfxHarfBuzzShaper.h rename : gfx/thebes/src/gfxImageSurface.cpp => gfx/thebes/gfxImageSurface.cpp rename : gfx/thebes/public/gfxImageSurface.h => gfx/thebes/gfxImageSurface.h rename : gfx/thebes/src/gfxMacFont.cpp => gfx/thebes/gfxMacFont.cpp rename : gfx/thebes/src/gfxMacFont.h => gfx/thebes/gfxMacFont.h rename : gfx/thebes/src/gfxMacPlatformFontList.h => gfx/thebes/gfxMacPlatformFontList.h rename : gfx/thebes/src/gfxMacPlatformFontList.mm => gfx/thebes/gfxMacPlatformFontList.mm rename : gfx/thebes/src/gfxMatrix.cpp => gfx/thebes/gfxMatrix.cpp rename : gfx/thebes/public/gfxMatrix.h => gfx/thebes/gfxMatrix.h rename : gfx/thebes/src/gfxOS2Fonts.cpp => gfx/thebes/gfxOS2Fonts.cpp rename : gfx/thebes/public/gfxOS2Fonts.h => gfx/thebes/gfxOS2Fonts.h rename : gfx/thebes/src/gfxOS2Platform.cpp => gfx/thebes/gfxOS2Platform.cpp rename : gfx/thebes/public/gfxOS2Platform.h => gfx/thebes/gfxOS2Platform.h rename : gfx/thebes/src/gfxOS2Surface.cpp => gfx/thebes/gfxOS2Surface.cpp rename : gfx/thebes/public/gfxOS2Surface.h => gfx/thebes/gfxOS2Surface.h rename : gfx/thebes/src/gfxPDFSurface.cpp => gfx/thebes/gfxPDFSurface.cpp rename : gfx/thebes/public/gfxPDFSurface.h => gfx/thebes/gfxPDFSurface.h rename : gfx/thebes/src/gfxPSSurface.cpp => gfx/thebes/gfxPSSurface.cpp rename : gfx/thebes/public/gfxPSSurface.h => gfx/thebes/gfxPSSurface.h rename : gfx/thebes/src/gfxPangoFonts.cpp => gfx/thebes/gfxPangoFonts.cpp rename : gfx/thebes/public/gfxPangoFonts.h => gfx/thebes/gfxPangoFonts.h rename : gfx/thebes/src/gfxPath.cpp => gfx/thebes/gfxPath.cpp rename : gfx/thebes/public/gfxPath.h => gfx/thebes/gfxPath.h rename : gfx/thebes/src/gfxPattern.cpp => gfx/thebes/gfxPattern.cpp rename : gfx/thebes/public/gfxPattern.h => gfx/thebes/gfxPattern.h rename : gfx/thebes/src/gfxPlatform.cpp => gfx/thebes/gfxPlatform.cpp rename : gfx/thebes/public/gfxPlatform.h => gfx/thebes/gfxPlatform.h rename : gfx/thebes/src/gfxPlatformFontList.cpp => gfx/thebes/gfxPlatformFontList.cpp rename : gfx/thebes/src/gfxPlatformFontList.h => gfx/thebes/gfxPlatformFontList.h rename : gfx/thebes/src/gfxPlatformGtk.cpp => gfx/thebes/gfxPlatformGtk.cpp rename : gfx/thebes/public/gfxPlatformGtk.h => gfx/thebes/gfxPlatformGtk.h rename : gfx/thebes/src/gfxPlatformMac.cpp => gfx/thebes/gfxPlatformMac.cpp rename : gfx/thebes/public/gfxPlatformMac.h => gfx/thebes/gfxPlatformMac.h rename : gfx/thebes/public/gfxPoint.h => gfx/thebes/gfxPoint.h rename : gfx/thebes/src/gfxQPainterSurface.cpp => gfx/thebes/gfxQPainterSurface.cpp rename : gfx/thebes/public/gfxQPainterSurface.h => gfx/thebes/gfxQPainterSurface.h rename : gfx/thebes/src/gfxQtNativeRenderer.cpp => gfx/thebes/gfxQtNativeRenderer.cpp rename : gfx/thebes/public/gfxQtNativeRenderer.h => gfx/thebes/gfxQtNativeRenderer.h rename : gfx/thebes/src/gfxQtPlatform.cpp => gfx/thebes/gfxQtPlatform.cpp rename : gfx/thebes/public/gfxQtPlatform.h => gfx/thebes/gfxQtPlatform.h rename : gfx/thebes/src/gfxQuartzImageSurface.cpp => gfx/thebes/gfxQuartzImageSurface.cpp rename : gfx/thebes/public/gfxQuartzImageSurface.h => gfx/thebes/gfxQuartzImageSurface.h rename : gfx/thebes/src/gfxQuartzNativeDrawing.cpp => gfx/thebes/gfxQuartzNativeDrawing.cpp rename : gfx/thebes/public/gfxQuartzNativeDrawing.h => gfx/thebes/gfxQuartzNativeDrawing.h rename : gfx/thebes/src/gfxQuartzPDFSurface.cpp => gfx/thebes/gfxQuartzPDFSurface.cpp rename : gfx/thebes/public/gfxQuartzPDFSurface.h => gfx/thebes/gfxQuartzPDFSurface.h rename : gfx/thebes/src/gfxQuartzSurface.cpp => gfx/thebes/gfxQuartzSurface.cpp rename : gfx/thebes/public/gfxQuartzSurface.h => gfx/thebes/gfxQuartzSurface.h rename : gfx/thebes/src/gfxRect.cpp => gfx/thebes/gfxRect.cpp rename : gfx/thebes/public/gfxRect.h => gfx/thebes/gfxRect.h rename : gfx/thebes/src/gfxScriptItemizer.cpp => gfx/thebes/gfxScriptItemizer.cpp rename : gfx/thebes/src/gfxScriptItemizer.h => gfx/thebes/gfxScriptItemizer.h rename : gfx/thebes/src/gfxSharedImageSurface.cpp => gfx/thebes/gfxSharedImageSurface.cpp rename : gfx/thebes/public/gfxSharedImageSurface.h => gfx/thebes/gfxSharedImageSurface.h rename : gfx/thebes/src/gfxSkipChars.cpp => gfx/thebes/gfxSkipChars.cpp rename : gfx/thebes/public/gfxSkipChars.h => gfx/thebes/gfxSkipChars.h rename : gfx/thebes/src/gfxTextRunCache.cpp => gfx/thebes/gfxTextRunCache.cpp rename : gfx/thebes/public/gfxTextRunCache.h => gfx/thebes/gfxTextRunCache.h rename : gfx/thebes/src/gfxTextRunWordCache.cpp => gfx/thebes/gfxTextRunWordCache.cpp rename : gfx/thebes/public/gfxTextRunWordCache.h => gfx/thebes/gfxTextRunWordCache.h rename : gfx/thebes/public/gfxTypes.h => gfx/thebes/gfxTypes.h rename : gfx/thebes/src/gfxUnicodeProperties.cpp => gfx/thebes/gfxUnicodeProperties.cpp rename : gfx/thebes/src/gfxUnicodeProperties.h => gfx/thebes/gfxUnicodeProperties.h rename : gfx/thebes/src/gfxUnicodePropertyData.cpp => gfx/thebes/gfxUnicodePropertyData.cpp rename : gfx/thebes/src/gfxUniscribeShaper.cpp => gfx/thebes/gfxUniscribeShaper.cpp rename : gfx/thebes/src/gfxUniscribeShaper.h => gfx/thebes/gfxUniscribeShaper.h rename : gfx/thebes/src/gfxUserFontSet.cpp => gfx/thebes/gfxUserFontSet.cpp rename : gfx/thebes/public/gfxUserFontSet.h => gfx/thebes/gfxUserFontSet.h rename : gfx/thebes/src/gfxUtils.cpp => gfx/thebes/gfxUtils.cpp rename : gfx/thebes/public/gfxUtils.h => gfx/thebes/gfxUtils.h rename : gfx/thebes/src/gfxWindowsNativeDrawing.cpp => gfx/thebes/gfxWindowsNativeDrawing.cpp rename : gfx/thebes/public/gfxWindowsNativeDrawing.h => gfx/thebes/gfxWindowsNativeDrawing.h rename : gfx/thebes/src/gfxWindowsPlatform.cpp => gfx/thebes/gfxWindowsPlatform.cpp rename : gfx/thebes/public/gfxWindowsPlatform.h => gfx/thebes/gfxWindowsPlatform.h rename : gfx/thebes/src/gfxWindowsSurface.cpp => gfx/thebes/gfxWindowsSurface.cpp rename : gfx/thebes/public/gfxWindowsSurface.h => gfx/thebes/gfxWindowsSurface.h rename : gfx/thebes/src/gfxXlibNativeRenderer.cpp => gfx/thebes/gfxXlibNativeRenderer.cpp rename : gfx/thebes/public/gfxXlibNativeRenderer.h => gfx/thebes/gfxXlibNativeRenderer.h rename : gfx/thebes/src/gfxXlibSurface.cpp => gfx/thebes/gfxXlibSurface.cpp rename : gfx/thebes/public/gfxXlibSurface.h => gfx/thebes/gfxXlibSurface.h rename : gfx/thebes/src/ignorable.x-ccmap => gfx/thebes/ignorable.x-ccmap rename : gfx/thebes/src/nsUnicodeRange.cpp => gfx/thebes/nsUnicodeRange.cpp rename : gfx/thebes/src/nsUnicodeRange.h => gfx/thebes/nsUnicodeRange.h rename : gfx/thebes/src/woff-private.h => gfx/thebes/woff-private.h rename : gfx/thebes/src/woff.c => gfx/thebes/woff.c rename : gfx/thebes/src/woff.h => gfx/thebes/woff.h
1136 lines
35 KiB
C++
1136 lines
35 KiB
C++
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
*
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
* the License. You may obtain a copy of the License at
|
|
* http://www.mozilla.org/MPL/
|
|
*
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
* for the specific language governing rights and limitations under the
|
|
* License.
|
|
*
|
|
* The Original Code is Mozilla Foundation code.
|
|
*
|
|
* The Initial Developer of the Original Code is Mozilla Foundation.
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
|
* the Initial Developer. All Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
* Vladimir Vukicevic <vladimir@pobox.com>
|
|
*
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
* the provisions above, a recipient may use your version of this file under
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
*
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
#include "gfxPlatform.h"
|
|
|
|
#if defined(XP_WIN)
|
|
#include "gfxWindowsPlatform.h"
|
|
#elif defined(XP_MACOSX)
|
|
#include "gfxPlatformMac.h"
|
|
#elif defined(MOZ_WIDGET_GTK2)
|
|
#include "gfxPlatformGtk.h"
|
|
#elif defined(MOZ_WIDGET_QT)
|
|
#include "gfxQtPlatform.h"
|
|
#elif defined(XP_BEOS)
|
|
#include "gfxBeOSPlatform.h"
|
|
#elif defined(XP_OS2)
|
|
#include "gfxOS2Platform.h"
|
|
#elif defined(ANDROID)
|
|
#include "gfxAndroidPlatform.h"
|
|
#endif
|
|
|
|
#include "gfxAtoms.h"
|
|
#include "gfxPlatformFontList.h"
|
|
#include "gfxContext.h"
|
|
#include "gfxImageSurface.h"
|
|
#include "gfxTextRunCache.h"
|
|
#include "gfxTextRunWordCache.h"
|
|
#include "gfxUserFontSet.h"
|
|
|
|
#include "nsUnicodeRange.h"
|
|
#include "nsServiceManagerUtils.h"
|
|
#include "nsTArray.h"
|
|
#include "nsIUGenCategory.h"
|
|
#include "nsUnicharUtilCIID.h"
|
|
#include "nsILocaleService.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
#include "cairo.h"
|
|
#include "qcms.h"
|
|
|
|
#include "plstr.h"
|
|
#include "nsIPrefService.h"
|
|
#include "nsIPrefBranch.h"
|
|
#include "nsIPrefBranch2.h"
|
|
#include "nsIPrefLocalizedString.h"
|
|
#include "nsCRT.h"
|
|
|
|
#include "mozilla/FunctionTimer.h"
|
|
|
|
gfxPlatform *gPlatform = nsnull;
|
|
|
|
PRInt32 gfxPlatform::sDPI = -1;
|
|
|
|
// These two may point to the same profile
|
|
static qcms_profile *gCMSOutputProfile = nsnull;
|
|
static qcms_profile *gCMSsRGBProfile = nsnull;
|
|
|
|
static qcms_transform *gCMSRGBTransform = nsnull;
|
|
static qcms_transform *gCMSInverseRGBTransform = nsnull;
|
|
static qcms_transform *gCMSRGBATransform = nsnull;
|
|
|
|
static PRBool gCMSInitialized = PR_FALSE;
|
|
static eCMSMode gCMSMode = eCMSMode_Off;
|
|
static int gCMSIntent = -2;
|
|
|
|
static const char *CMPrefName = "gfx.color_management.mode";
|
|
static const char *CMPrefNameOld = "gfx.color_management.enabled";
|
|
static const char *CMIntentPrefName = "gfx.color_management.rendering_intent";
|
|
static const char *CMProfilePrefName = "gfx.color_management.display_profile";
|
|
static const char *CMForceSRGBPrefName = "gfx.color_management.force_srgb";
|
|
|
|
static void ShutdownCMS();
|
|
static void MigratePrefs();
|
|
|
|
/* Class to listen for pref changes so that chrome code can dynamically
|
|
force sRGB as an output profile. See Bug #452125. */
|
|
class SRGBOverrideObserver : 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;
|
|
}
|
|
|
|
#define GFX_DOWNLOADABLE_FONTS_ENABLED "gfx.downloadable_fonts.enabled"
|
|
|
|
#define GFX_PREF_HARFBUZZ_LEVEL "gfx.font_rendering.harfbuzz.level"
|
|
#define HARFBUZZ_LEVEL_DEFAULT 0
|
|
|
|
class FontPrefsObserver : public nsIObserver
|
|
{
|
|
public:
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSIOBSERVER
|
|
};
|
|
|
|
NS_IMPL_ISUPPORTS1(FontPrefsObserver, nsIObserver)
|
|
|
|
NS_IMETHODIMP
|
|
FontPrefsObserver::Observe(nsISupports *aSubject,
|
|
const char *aTopic,
|
|
const PRUnichar *someData)
|
|
{
|
|
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(aSubject);
|
|
if (!branch || someData == nsnull) {
|
|
NS_ERROR("font pref observer code broken");
|
|
return NS_ERROR_UNEXPECTED;
|
|
}
|
|
|
|
gfxPlatform::GetPlatform()->FontsPrefsChanged(branch,
|
|
NS_ConvertUTF16toUTF8(someData).get());
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
|
|
|
|
// 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",
|
|
"x-orya",
|
|
"x-telu",
|
|
"x-knda",
|
|
"x-sinh",
|
|
"x-tibt",
|
|
"x-unicode",
|
|
"x-user-def"
|
|
};
|
|
|
|
gfxPlatform::gfxPlatform()
|
|
{
|
|
mUseHarfBuzzLevel = UNINITIALIZED_VALUE;
|
|
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
|
|
}
|
|
|
|
gfxPlatform*
|
|
gfxPlatform::GetPlatform()
|
|
{
|
|
return gPlatform;
|
|
}
|
|
|
|
nsresult
|
|
gfxPlatform::Init()
|
|
{
|
|
NS_ASSERTION(!gPlatform, "Already started???");
|
|
|
|
gfxAtoms::RegisterAtoms();
|
|
|
|
#if defined(XP_WIN)
|
|
gPlatform = new gfxWindowsPlatform;
|
|
#elif defined(XP_MACOSX)
|
|
gPlatform = new gfxPlatformMac;
|
|
#elif defined(MOZ_WIDGET_GTK2)
|
|
gPlatform = new gfxPlatformGtk;
|
|
#elif defined(MOZ_WIDGET_QT)
|
|
gPlatform = new gfxQtPlatform;
|
|
#elif defined(XP_BEOS)
|
|
gPlatform = new gfxBeOSPlatform;
|
|
#elif defined(XP_OS2)
|
|
gPlatform = new gfxOS2Platform;
|
|
#elif defined(ANDROID)
|
|
gPlatform = new gfxAndroidPlatform;
|
|
#endif
|
|
if (!gPlatform)
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
nsresult rv;
|
|
|
|
#if defined(XP_MACOSX) || defined(XP_WIN) // temporary, until this is implemented on others
|
|
rv = gfxPlatformFontList::Init();
|
|
if (NS_FAILED(rv)) {
|
|
NS_ERROR("Could not initialize gfxPlatformFontList");
|
|
Shutdown();
|
|
return rv;
|
|
}
|
|
#endif
|
|
|
|
rv = gfxFontCache::Init();
|
|
if (NS_FAILED(rv)) {
|
|
NS_ERROR("Could not initialize gfxFontCache");
|
|
Shutdown();
|
|
return rv;
|
|
}
|
|
|
|
rv = gfxTextRunWordCache::Init();
|
|
if (NS_FAILED(rv)) {
|
|
NS_ERROR("Could not initialize gfxTextRunWordCache");
|
|
Shutdown();
|
|
return rv;
|
|
}
|
|
|
|
rv = gfxTextRunCache::Init();
|
|
if (NS_FAILED(rv)) {
|
|
NS_ERROR("Could not initialize gfxTextRunCache");
|
|
Shutdown();
|
|
return rv;
|
|
}
|
|
|
|
/* Pref migration hook. */
|
|
MigratePrefs();
|
|
|
|
/* Create and register our CMS Override observer. */
|
|
gPlatform->overrideObserver = new SRGBOverrideObserver();
|
|
FontPrefsObserver *fontPrefObserver = new FontPrefsObserver();
|
|
|
|
nsCOMPtr<nsIPrefBranch2> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
if (prefs) {
|
|
prefs->AddObserver(CMForceSRGBPrefName, gPlatform->overrideObserver, PR_TRUE);
|
|
prefs->AddObserver(GFX_DOWNLOADABLE_FONTS_ENABLED, fontPrefObserver, PR_FALSE);
|
|
prefs->AddObserver("gfx.font_rendering.", fontPrefObserver, PR_FALSE);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
gfxPlatform::Shutdown()
|
|
{
|
|
// These may be called before the corresponding subsystems have actually
|
|
// started up. That's OK, they can handle it.
|
|
gfxTextRunCache::Shutdown();
|
|
gfxTextRunWordCache::Shutdown();
|
|
gfxFontCache::Shutdown();
|
|
gfxFontGroup::Shutdown();
|
|
#if defined(XP_MACOSX) || defined(XP_WIN) // temporary, until this is implemented on others
|
|
gfxPlatformFontList::Shutdown();
|
|
#endif
|
|
|
|
// Free the various non-null transforms and loaded profiles
|
|
ShutdownCMS();
|
|
|
|
/* Unregister our CMS Override callback. */
|
|
nsCOMPtr<nsIPrefBranch2> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
if (prefs)
|
|
prefs->RemoveObserver(CMForceSRGBPrefName, gPlatform->overrideObserver);
|
|
|
|
delete gPlatform;
|
|
gPlatform = nsnull;
|
|
}
|
|
|
|
gfxPlatform::~gfxPlatform()
|
|
{
|
|
// 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.
|
|
//
|
|
// because cairo can assert and thus crash on shutdown, don't do this in release builds
|
|
#if MOZ_TREE_CAIRO && (defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING) || defined(NS_TRACE_MALLOC))
|
|
cairo_debug_reset_static_data();
|
|
#endif
|
|
|
|
#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
|
|
}
|
|
|
|
already_AddRefed<gfxASurface>
|
|
gfxPlatform::OptimizeImage(gfxImageSurface *aSurface,
|
|
gfxASurface::gfxImageFormat format)
|
|
{
|
|
const gfxIntSize& surfaceSize = aSurface->GetSize();
|
|
|
|
#ifdef XP_WIN
|
|
if (gfxWindowsPlatform::GetPlatform()->GetRenderMode() ==
|
|
gfxWindowsPlatform::RENDER_DIRECT2D) {
|
|
return nsnull;
|
|
}
|
|
#endif
|
|
nsRefPtr<gfxASurface> optSurface = CreateOffscreenSurface(surfaceSize, format);
|
|
if (!optSurface || optSurface->CairoStatus() != 0)
|
|
return nsnull;
|
|
|
|
gfxContext tmpCtx(optSurface);
|
|
tmpCtx.SetOperator(gfxContext::OPERATOR_SOURCE);
|
|
tmpCtx.SetSource(aSurface);
|
|
tmpCtx.Paint();
|
|
|
|
gfxASurface *ret = optSurface;
|
|
NS_ADDREF(ret);
|
|
return ret;
|
|
}
|
|
|
|
nsresult
|
|
gfxPlatform::GetFontList(nsIAtom *aLangGroup,
|
|
const nsACString& aGenericFamily,
|
|
nsTArray<nsString>& aListOfFonts)
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
nsresult
|
|
gfxPlatform::UpdateFontList()
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
PRBool
|
|
gfxPlatform::GetBoolPref(const char *aPref, PRBool aDefault)
|
|
{
|
|
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
if (prefs) {
|
|
PRBool allow;
|
|
nsresult rv = prefs->GetBoolPref(aPref, &allow);
|
|
if (NS_SUCCEEDED(rv))
|
|
return allow;
|
|
}
|
|
|
|
return aDefault;
|
|
}
|
|
|
|
PRBool
|
|
gfxPlatform::DownloadableFontsEnabled()
|
|
{
|
|
if (mAllowDownloadableFonts == UNINITIALIZED_VALUE) {
|
|
mAllowDownloadableFonts = GetBoolPref(GFX_DOWNLOADABLE_FONTS_ENABLED, PR_FALSE);
|
|
}
|
|
|
|
return mAllowDownloadableFonts;
|
|
}
|
|
|
|
PRInt8
|
|
gfxPlatform::UseHarfBuzzLevel()
|
|
{
|
|
if (mUseHarfBuzzLevel == UNINITIALIZED_VALUE) {
|
|
mUseHarfBuzzLevel = HARFBUZZ_LEVEL_DEFAULT;
|
|
nsCOMPtr<nsIPrefBranch2> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
if (prefs) {
|
|
PRInt32 level;
|
|
nsresult rv = prefs->GetIntPref(GFX_PREF_HARFBUZZ_LEVEL, &level);
|
|
if (NS_SUCCEEDED(rv)) {
|
|
mUseHarfBuzzLevel = level;
|
|
}
|
|
}
|
|
}
|
|
|
|
return mUseHarfBuzzLevel;
|
|
}
|
|
|
|
gfxFontEntry*
|
|
gfxPlatform::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
|
|
const PRUint8 *aFontData,
|
|
PRUint32 aLength)
|
|
{
|
|
// 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);
|
|
}
|
|
return nsnull;
|
|
}
|
|
|
|
static void
|
|
AppendGenericFontFromPref(nsString& aFonts, nsIAtom *aLangGroup, const char *aGenericName)
|
|
{
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
if (!prefs)
|
|
return;
|
|
|
|
nsCAutoString prefName, langGroupString;
|
|
nsXPIDLCString nameValue, nameListValue;
|
|
|
|
aLangGroup->ToUTF8String(langGroupString);
|
|
|
|
nsCAutoString genericDotLang;
|
|
if (aGenericName) {
|
|
genericDotLang.Assign(aGenericName);
|
|
} else {
|
|
prefName.AssignLiteral("font.default.");
|
|
prefName.Append(langGroupString);
|
|
prefs->GetCharPref(prefName.get(), getter_Copies(genericDotLang));
|
|
}
|
|
|
|
genericDotLang.AppendLiteral(".");
|
|
genericDotLang.Append(langGroupString);
|
|
|
|
// fetch font.name.xxx value
|
|
prefName.AssignLiteral("font.name.");
|
|
prefName.Append(genericDotLang);
|
|
rv = prefs->GetCharPref(prefName.get(), getter_Copies(nameValue));
|
|
if (NS_SUCCEEDED(rv)) {
|
|
if (!aFonts.IsEmpty())
|
|
aFonts.AppendLiteral(", ");
|
|
aFonts.Append(NS_ConvertUTF8toUTF16(nameValue));
|
|
}
|
|
|
|
// fetch font.name-list.xxx value
|
|
prefName.AssignLiteral("font.name-list.");
|
|
prefName.Append(genericDotLang);
|
|
rv = prefs->GetCharPref(prefName.get(), getter_Copies(nameListValue));
|
|
if (NS_SUCCEEDED(rv) && !nameListValue.Equals(nameValue)) {
|
|
if (!aFonts.IsEmpty())
|
|
aFonts.AppendLiteral(", ");
|
|
aFonts.Append(NS_ConvertUTF8toUTF16(nameListValue));
|
|
}
|
|
}
|
|
|
|
void
|
|
gfxPlatform::GetPrefFonts(nsIAtom *aLanguage, nsString& aFonts, PRBool aAppendUnicode)
|
|
{
|
|
aFonts.Truncate();
|
|
|
|
AppendGenericFontFromPref(aFonts, aLanguage, nsnull);
|
|
if (aAppendUnicode)
|
|
AppendGenericFontFromPref(aFonts, gfxAtoms::x_unicode, nsnull);
|
|
}
|
|
|
|
PRBool gfxPlatform::ForEachPrefFont(eFontPrefLang aLangArray[], PRUint32 aLangArrayLen, PrefFontCallback aCallback,
|
|
void *aClosure)
|
|
{
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
if (!prefs)
|
|
return PR_FALSE;
|
|
|
|
PRUint32 i;
|
|
|
|
for (i = 0; i < aLangArrayLen; i++) {
|
|
eFontPrefLang prefLang = aLangArray[i];
|
|
const char *langGroup = GetPrefLangName(prefLang);
|
|
|
|
nsCAutoString prefName;
|
|
nsXPIDLCString nameValue, nameListValue;
|
|
|
|
nsCAutoString genericDotLang;
|
|
prefName.AssignLiteral("font.default.");
|
|
prefName.Append(langGroup);
|
|
prefs->GetCharPref(prefName.get(), getter_Copies(genericDotLang));
|
|
|
|
genericDotLang.AppendLiteral(".");
|
|
genericDotLang.Append(langGroup);
|
|
|
|
// fetch font.name.xxx value
|
|
prefName.AssignLiteral("font.name.");
|
|
prefName.Append(genericDotLang);
|
|
rv = prefs->GetCharPref(prefName.get(), getter_Copies(nameValue));
|
|
if (NS_SUCCEEDED(rv)) {
|
|
if (!aCallback(prefLang, NS_ConvertUTF8toUTF16(nameValue), aClosure))
|
|
return PR_FALSE;
|
|
}
|
|
|
|
// fetch font.name-list.xxx value
|
|
prefName.AssignLiteral("font.name-list.");
|
|
prefName.Append(genericDotLang);
|
|
rv = prefs->GetCharPref(prefName.get(), getter_Copies(nameListValue));
|
|
if (NS_SUCCEEDED(rv) && !nameListValue.Equals(nameValue)) {
|
|
const char kComma = ',';
|
|
const char *p, *p_end;
|
|
nsCAutoString list(nameListValue);
|
|
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 */ ;
|
|
nsCAutoString fontName(Substring(start, p));
|
|
fontName.CompressWhitespace(PR_FALSE, PR_TRUE);
|
|
if (!aCallback(prefLang, NS_ConvertUTF8toUTF16(fontName), aClosure))
|
|
return PR_FALSE;
|
|
p++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return PR_TRUE;
|
|
}
|
|
|
|
eFontPrefLang
|
|
gfxPlatform::GetFontPrefLangFor(const char* aLang)
|
|
{
|
|
if (!aLang || !aLang[0])
|
|
return eFontPrefLang_Others;
|
|
for (PRUint32 i = 0; i < PRUint32(eFontPrefLang_LangCount); ++i) {
|
|
if (!PL_strcasecmp(gPrefLangNames[i], aLang))
|
|
return eFontPrefLang(i);
|
|
}
|
|
return eFontPrefLang_Others;
|
|
}
|
|
|
|
eFontPrefLang
|
|
gfxPlatform::GetFontPrefLangFor(nsIAtom *aLang)
|
|
{
|
|
if (!aLang)
|
|
return eFontPrefLang_Others;
|
|
nsCAutoString lang;
|
|
aLang->ToUTF8String(lang);
|
|
return GetFontPrefLangFor(lang.get());
|
|
}
|
|
|
|
const char*
|
|
gfxPlatform::GetPrefLangName(eFontPrefLang aLang)
|
|
{
|
|
if (PRUint32(aLang) < PRUint32(eFontPrefLang_AllCount))
|
|
return gPrefLangNames[PRUint32(aLang)];
|
|
return nsnull;
|
|
}
|
|
|
|
eFontPrefLang
|
|
gfxPlatform::GetFontPrefLangFor(PRUint8 aUnicodeRange)
|
|
{
|
|
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;
|
|
case kRangeSetCJK: return eFontPrefLang_CJKSet;
|
|
default: return eFontPrefLang_Others;
|
|
}
|
|
}
|
|
|
|
PRBool
|
|
gfxPlatform::IsLangCJK(eFontPrefLang aLang)
|
|
{
|
|
switch (aLang) {
|
|
case eFontPrefLang_Japanese:
|
|
case eFontPrefLang_ChineseTW:
|
|
case eFontPrefLang_ChineseCN:
|
|
case eFontPrefLang_ChineseHK:
|
|
case eFontPrefLang_Korean:
|
|
case eFontPrefLang_CJKSet:
|
|
return PR_TRUE;
|
|
default:
|
|
return PR_FALSE;
|
|
}
|
|
}
|
|
|
|
void
|
|
gfxPlatform::GetLangPrefs(eFontPrefLang aPrefLangs[], PRUint32 &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang)
|
|
{
|
|
if (IsLangCJK(aCharLang)) {
|
|
AppendCJKPrefLangs(aPrefLangs, aLen, aCharLang, aPageLang);
|
|
} else {
|
|
AppendPrefLang(aPrefLangs, aLen, aCharLang);
|
|
}
|
|
|
|
AppendPrefLang(aPrefLangs, aLen, eFontPrefLang_Others);
|
|
}
|
|
|
|
void
|
|
gfxPlatform::AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], PRUint32 &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang)
|
|
{
|
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
|
|
// prefer the lang specified by the page *if* CJK
|
|
if (IsLangCJK(aPageLang)) {
|
|
AppendPrefLang(aPrefLangs, aLen, aPageLang);
|
|
}
|
|
|
|
// if not set up, set up the default CJK order, based on accept lang settings and locale
|
|
if (mCJKPrefLangs.Length() == 0) {
|
|
|
|
// temp array
|
|
eFontPrefLang tempPrefLangs[kMaxLenPrefLangList];
|
|
PRUint32 tempLen = 0;
|
|
|
|
// Add the CJK pref fonts from accept languages, the order should be same order
|
|
nsCAutoString list;
|
|
if (prefs) {
|
|
nsCOMPtr<nsIPrefLocalizedString> prefString;
|
|
nsresult rv =
|
|
prefs->GetComplexValue("intl.accept_languages",
|
|
NS_GET_IID(nsIPrefLocalizedString),
|
|
getter_AddRefs(prefString));
|
|
if (NS_SUCCEEDED(rv) && prefString) {
|
|
nsAutoString temp;
|
|
prefString->ToString(getter_Copies(temp));
|
|
LossyCopyUTF16toASCII(temp, list);
|
|
}
|
|
}
|
|
|
|
if (!list.IsEmpty()) {
|
|
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 */ ;
|
|
nsCAutoString lang(Substring(start, p));
|
|
lang.CompressWhitespace(PR_FALSE, PR_TRUE);
|
|
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);
|
|
|
|
// copy into the cached array
|
|
PRUint32 j;
|
|
for (j = 0; j < tempLen; j++) {
|
|
mCJKPrefLangs.AppendElement(tempPrefLangs[j]);
|
|
}
|
|
}
|
|
|
|
// append in cached CJK langs
|
|
PRUint32 i, numCJKlangs = mCJKPrefLangs.Length();
|
|
|
|
for (i = 0; i < numCJKlangs; i++) {
|
|
AppendPrefLang(aPrefLangs, aLen, (eFontPrefLang) (mCJKPrefLangs[i]));
|
|
}
|
|
|
|
}
|
|
|
|
void
|
|
gfxPlatform::AppendPrefLang(eFontPrefLang aPrefLangs[], PRUint32& aLen, eFontPrefLang aAddLang)
|
|
{
|
|
if (aLen >= kMaxLenPrefLangList) return;
|
|
|
|
// make sure
|
|
PRUint32 i = 0;
|
|
while (i < aLen && aPrefLangs[i] != aAddLang) {
|
|
i++;
|
|
}
|
|
|
|
if (i == aLen) {
|
|
aPrefLangs[aLen] = aAddLang;
|
|
aLen++;
|
|
}
|
|
}
|
|
|
|
eCMSMode
|
|
gfxPlatform::GetCMSMode()
|
|
{
|
|
if (gCMSInitialized == PR_FALSE) {
|
|
gCMSInitialized = PR_TRUE;
|
|
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
if (prefs) {
|
|
PRInt32 mode;
|
|
nsresult rv =
|
|
prefs->GetIntPref(CMPrefName, &mode);
|
|
if (NS_SUCCEEDED(rv) && (mode >= 0) && (mode < eCMSMode_AllCount)) {
|
|
gCMSMode = static_cast<eCMSMode>(mode);
|
|
}
|
|
}
|
|
}
|
|
return gCMSMode;
|
|
}
|
|
|
|
/* Chris Murphy (CM consultant) suggests this as a default in the event that we
|
|
cannot reproduce relative + Black Point Compensation. BPC brings an
|
|
unacceptable performance overhead, so we go with perceptual. */
|
|
#define INTENT_DEFAULT QCMS_INTENT_PERCEPTUAL
|
|
#define INTENT_MIN 0
|
|
#define INTENT_MAX 3
|
|
|
|
PRBool
|
|
gfxPlatform::GetRenderingIntent()
|
|
{
|
|
if (gCMSIntent == -2) {
|
|
|
|
/* Try to query the pref system for a rendering intent. */
|
|
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
if (prefs) {
|
|
PRInt32 pIntent;
|
|
nsresult rv = prefs->GetIntPref(CMIntentPrefName, &pIntent);
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
/* If the pref is within range, use it as an override. */
|
|
if ((pIntent >= INTENT_MIN) && (pIntent <= 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. */
|
|
if (gCMSIntent == -2)
|
|
gCMSIntent = 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 */
|
|
PRUint32 packed = in.Packed(gfxRGBA::PACKED_ABGR);
|
|
qcms_transform_data(transform,
|
|
(PRUint8 *)&packed, (PRUint8 *)&packed,
|
|
1);
|
|
out.~gfxRGBA();
|
|
new (&out) gfxRGBA(packed, gfxRGBA::PACKED_ABGR);
|
|
#else
|
|
/* ARGB puts the bytes in |ARGB| order on big endian */
|
|
PRUint32 packed = in.Packed(gfxRGBA::PACKED_ARGB);
|
|
/* add one to move past the alpha byte */
|
|
qcms_transform_data(transform,
|
|
(PRUint8 *)&packed + 1, (PRUint8 *)&packed + 1,
|
|
1);
|
|
out.~gfxRGBA();
|
|
new (&out) gfxRGBA(packed, gfxRGBA::PACKED_ARGB);
|
|
#endif
|
|
}
|
|
|
|
else if (&out != &in)
|
|
out = in;
|
|
}
|
|
|
|
qcms_profile *
|
|
gfxPlatform::GetPlatformCMSOutputProfile()
|
|
{
|
|
return nsnull;
|
|
}
|
|
|
|
qcms_profile *
|
|
gfxPlatform::GetCMSOutputProfile()
|
|
{
|
|
if (!gCMSOutputProfile) {
|
|
NS_TIME_FUNCTION;
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
if (prefs) {
|
|
|
|
nsresult rv;
|
|
|
|
/* Determine if we're using the internal override to force sRGB as
|
|
an output profile for reftests. See Bug 452125. */
|
|
PRBool hasSRGBOverride, doSRGBOverride;
|
|
rv = prefs->PrefHasUserValue(CMForceSRGBPrefName, &hasSRGBOverride);
|
|
if (NS_SUCCEEDED(rv) && hasSRGBOverride) {
|
|
rv = prefs->GetBoolPref(CMForceSRGBPrefName, &doSRGBOverride);
|
|
if (NS_SUCCEEDED(rv) && doSRGBOverride)
|
|
gCMSOutputProfile = GetCMSsRGBProfile();
|
|
}
|
|
|
|
if (!gCMSOutputProfile) {
|
|
|
|
nsXPIDLCString fname;
|
|
rv = prefs->GetCharPref(CMProfilePrefName,
|
|
getter_Copies(fname));
|
|
if (NS_SUCCEEDED(rv) && !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 = nsnull;
|
|
}
|
|
|
|
if (!gCMSOutputProfile) {
|
|
gCMSOutputProfile = GetCMSsRGBProfile();
|
|
}
|
|
/* Precache the LUT16 Interpolations for the output profile. See
|
|
bug 444661 for details. */
|
|
qcms_profile_precache_output_transform(gCMSOutputProfile);
|
|
}
|
|
|
|
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 nsnull;
|
|
|
|
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 nsnull;
|
|
|
|
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 nsnull;
|
|
|
|
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 = nsnull;
|
|
}
|
|
if (gCMSInverseRGBTransform) {
|
|
qcms_transform_release(gCMSInverseRGBTransform);
|
|
gCMSInverseRGBTransform = nsnull;
|
|
}
|
|
if (gCMSRGBATransform) {
|
|
qcms_transform_release(gCMSRGBATransform);
|
|
gCMSRGBATransform = nsnull;
|
|
}
|
|
if (gCMSOutputProfile) {
|
|
qcms_profile_release(gCMSOutputProfile);
|
|
|
|
// handle the aliased case
|
|
if (gCMSsRGBProfile == gCMSOutputProfile)
|
|
gCMSsRGBProfile = nsnull;
|
|
gCMSOutputProfile = nsnull;
|
|
}
|
|
if (gCMSsRGBProfile) {
|
|
qcms_profile_release(gCMSsRGBProfile);
|
|
gCMSsRGBProfile = nsnull;
|
|
}
|
|
|
|
// Reset the state variables
|
|
gCMSIntent = -2;
|
|
gCMSMode = eCMSMode_Off;
|
|
gCMSInitialized = PR_FALSE;
|
|
}
|
|
|
|
static void MigratePrefs()
|
|
{
|
|
|
|
/* Load the pref service. If we don't get it die quietly since this isn't
|
|
critical code. */
|
|
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
if (!prefs)
|
|
return;
|
|
|
|
/* Migrate from the boolean color_management.enabled pref - we now use
|
|
color_management.mode. */
|
|
PRBool hasOldCMPref;
|
|
nsresult rv =
|
|
prefs->PrefHasUserValue(CMPrefNameOld, &hasOldCMPref);
|
|
if (NS_SUCCEEDED(rv) && (hasOldCMPref == PR_TRUE)) {
|
|
PRBool CMWasEnabled;
|
|
rv = prefs->GetBoolPref(CMPrefNameOld, &CMWasEnabled);
|
|
if (NS_SUCCEEDED(rv) && (CMWasEnabled == PR_TRUE))
|
|
prefs->SetIntPref(CMPrefName, eCMSMode_All);
|
|
prefs->ClearUserPref(CMPrefNameOld);
|
|
}
|
|
|
|
}
|
|
|
|
void
|
|
gfxPlatform::InitDisplayCaps()
|
|
{
|
|
// Fall back to something sane
|
|
gfxPlatform::sDPI = 96;
|
|
}
|
|
|
|
// default SetupClusterBoundaries, based on Unicode properties;
|
|
// platform subclasses may override if they wish
|
|
static nsIUGenCategory* gGenCategory = nsnull;
|
|
|
|
static nsIUGenCategory*
|
|
GetGenCategory()
|
|
{
|
|
if (!gGenCategory) {
|
|
nsresult rv = CallGetService(NS_UNICHARCATEGORY_CONTRACTID, &gGenCategory);
|
|
if (NS_FAILED(rv)) {
|
|
NS_ERROR("Failed to get the Unicode character category service!");
|
|
gGenCategory = nsnull;
|
|
}
|
|
}
|
|
return gGenCategory;
|
|
}
|
|
|
|
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.
|
|
return;
|
|
}
|
|
|
|
nsIUGenCategory* gc = GetGenCategory();
|
|
if (!gc) {
|
|
NS_WARNING("No Unicode category service: cannot determine clusters");
|
|
return;
|
|
}
|
|
|
|
PRUint32 i, length = aTextRun->GetLength();
|
|
for (i = 0; i < length; ++i) {
|
|
PRBool surrogatePair = PR_FALSE;
|
|
PRUint32 ch = aString[i];
|
|
if (NS_IS_HIGH_SURROGATE(ch) &&
|
|
i < length - 1 && NS_IS_LOW_SURROGATE(aString[i+1])) {
|
|
ch = SURROGATE_TO_UCS4(ch, aString[i+1]);
|
|
surrogatePair = PR_TRUE;
|
|
}
|
|
if (i > 0 && gc->Get(ch) == nsIUGenCategory::kMark) {
|
|
gfxTextRun::CompressedGlyph g;
|
|
aTextRun->SetGlyphs(i, g.SetComplex(PR_FALSE, PR_TRUE, 0), nsnull);
|
|
}
|
|
if (surrogatePair) {
|
|
++i;
|
|
gfxTextRun::CompressedGlyph g;
|
|
aTextRun->SetGlyphs(i, g.SetComplex(PR_FALSE, PR_TRUE, 0), nsnull);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
gfxPlatform::FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref)
|
|
{
|
|
NS_ASSERTION(aPref != nsnull, "null preference");
|
|
if (!strcmp(GFX_DOWNLOADABLE_FONTS_ENABLED, aPref)) {
|
|
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
|
|
} else if (!strcmp(GFX_PREF_HARFBUZZ_LEVEL, aPref)) {
|
|
mUseHarfBuzzLevel = UNINITIALIZED_VALUE;
|
|
gfxTextRunWordCache::Flush();
|
|
gfxFontCache::GetCache()->AgeAllGenerations();
|
|
}
|
|
}
|