2006-02-01 02:35:38 +00:00
|
|
|
/* -*- 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):
|
2006-06-10 00:21:05 +00:00
|
|
|
* Stuart Parmenter <stuart@mozilla.com>
|
2006-02-01 02:35:38 +00:00
|
|
|
* Vladimir Vukicevic <vladimir@pobox.com>
|
2006-11-21 06:31:04 +00:00
|
|
|
* Masayuki Nakano <masayuki@d-toybox.com>
|
2007-01-05 15:51:27 +00:00
|
|
|
* Masatoshi Kimura <VYV03354@nifty.ne.jp>
|
2006-02-01 02:35:38 +00:00
|
|
|
*
|
|
|
|
* 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 "gfxWindowsPlatform.h"
|
|
|
|
|
|
|
|
#include "gfxImageSurface.h"
|
|
|
|
#include "gfxWindowsSurface.h"
|
2010-06-09 00:33:13 +00:00
|
|
|
#include "gfxTextRunWordCache.h"
|
2006-02-01 02:35:38 +00:00
|
|
|
|
2006-06-10 00:21:05 +00:00
|
|
|
#include "nsUnicharUtils.h"
|
|
|
|
|
2009-04-04 09:43:42 +00:00
|
|
|
#include "nsIPrefService.h"
|
|
|
|
#include "nsIPrefBranch2.h"
|
2006-06-10 00:21:05 +00:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2009-01-18 20:14:14 +00:00
|
|
|
#include "nsTArray.h"
|
2006-06-10 00:21:05 +00:00
|
|
|
|
2007-01-05 15:51:27 +00:00
|
|
|
#include "nsIWindowsRegKey.h"
|
2008-10-01 03:01:53 +00:00
|
|
|
#include "nsILocalFile.h"
|
|
|
|
#include "plbase64.h"
|
2010-08-28 02:44:37 +00:00
|
|
|
#include "nsIXULRuntime.h"
|
2007-01-05 15:51:27 +00:00
|
|
|
|
2010-08-30 21:45:29 +00:00
|
|
|
#include "nsIGfxInfo.h"
|
|
|
|
|
2009-01-23 06:24:29 +00:00
|
|
|
#ifdef MOZ_FT2_FONTS
|
|
|
|
#include "ft2build.h"
|
|
|
|
#include FT_FREETYPE_H
|
|
|
|
#include "gfxFT2Fonts.h"
|
2010-02-26 06:36:07 +00:00
|
|
|
#include "gfxFT2FontList.h"
|
2009-01-23 06:24:29 +00:00
|
|
|
#include "cairo-ft.h"
|
2009-05-04 17:00:54 +00:00
|
|
|
#include "nsAppDirectoryServiceDefs.h"
|
2009-01-23 06:24:29 +00:00
|
|
|
#else
|
2009-10-07 14:13:40 +00:00
|
|
|
#include "gfxGDIFontList.h"
|
2010-03-15 09:34:25 +00:00
|
|
|
#include "gfxGDIFont.h"
|
2010-02-27 16:05:54 +00:00
|
|
|
#ifdef CAIRO_HAS_DWRITE_FONT
|
2010-02-26 06:36:07 +00:00
|
|
|
#include "gfxDWriteFontList.h"
|
|
|
|
#include "gfxDWriteFonts.h"
|
|
|
|
#include "gfxDWriteCommon.h"
|
|
|
|
#include <dwrite.h>
|
2009-01-23 06:24:29 +00:00
|
|
|
#endif
|
2010-02-27 16:05:54 +00:00
|
|
|
#endif
|
2009-01-23 06:24:29 +00:00
|
|
|
|
2011-02-04 13:41:06 +00:00
|
|
|
#include <shlobj.h>
|
|
|
|
#include <shlwapi.h>
|
2011-01-31 02:15:12 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
#ifdef CAIRO_HAS_D2D_SURFACE
|
|
|
|
#include "gfxD2DSurface.h"
|
2010-06-30 13:52:13 +00:00
|
|
|
|
2010-08-14 06:34:55 +00:00
|
|
|
#include <d3d10_1.h>
|
|
|
|
|
2010-06-30 13:52:13 +00:00
|
|
|
#include "nsIMemoryReporter.h"
|
|
|
|
#include "nsMemory.h"
|
|
|
|
|
|
|
|
class D2DCacheReporter :
|
|
|
|
public nsIMemoryReporter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
D2DCacheReporter()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_IMETHOD GetPath(char **memoryPath) {
|
|
|
|
*memoryPath = strdup("gfx/d2d/surfacecache");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD GetDescription(char **desc) {
|
|
|
|
*desc = strdup("Memory used by Direct2D internal surface cache.");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD GetMemoryUsed(PRInt64 *memoryUsed) {
|
|
|
|
*memoryUsed = cairo_d2d_get_image_surface_cache_usage();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(D2DCacheReporter, nsIMemoryReporter)
|
2010-08-18 03:43:49 +00:00
|
|
|
|
|
|
|
class D2DVRAMReporter :
|
|
|
|
public nsIMemoryReporter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
D2DVRAMReporter()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_IMETHOD GetPath(char **memoryPath) {
|
|
|
|
*memoryPath = strdup("gfx/d2d/surfacevram");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD GetDescription(char **desc) {
|
|
|
|
*desc = strdup("Video memory used by D2D surfaces");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD GetMemoryUsed(PRInt64 *memoryUsed) {
|
2010-08-19 09:35:08 +00:00
|
|
|
cairo_device_t *device =
|
|
|
|
gfxWindowsPlatform::GetPlatform()->GetD2DDevice();
|
|
|
|
if (device) {
|
|
|
|
*memoryUsed = cairo_d2d_get_surface_vram_usage(device);
|
|
|
|
} else {
|
|
|
|
*memoryUsed = 0;
|
|
|
|
}
|
2010-08-18 03:43:49 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(D2DVRAMReporter, nsIMemoryReporter)
|
2010-02-26 06:36:07 +00:00
|
|
|
#endif
|
2009-07-08 23:34:02 +00:00
|
|
|
|
2009-01-23 06:24:29 +00:00
|
|
|
#ifdef WINCE
|
|
|
|
#include <shlwapi.h>
|
|
|
|
#endif
|
|
|
|
|
2008-10-01 03:01:53 +00:00
|
|
|
#include "gfxUserFontSet.h"
|
2007-04-02 19:06:16 +00:00
|
|
|
|
2006-06-10 00:21:05 +00:00
|
|
|
#include <string>
|
2006-02-24 05:15:21 +00:00
|
|
|
|
2010-05-27 05:05:30 +00:00
|
|
|
#define GFX_USE_CLEARTYPE_ALWAYS "gfx.font_rendering.cleartype.always_use_for_content"
|
|
|
|
#define GFX_DOWNLOADABLE_FONTS_USE_CLEARTYPE "gfx.font_rendering.cleartype.use_for_downloadable_fonts"
|
|
|
|
|
2009-01-23 06:24:29 +00:00
|
|
|
#ifdef MOZ_FT2_FONTS
|
|
|
|
static FT_Library gPlatformFTLibrary = NULL;
|
|
|
|
#endif
|
2007-05-30 00:07:03 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
#ifdef CAIRO_HAS_DWRITE_FONT
|
|
|
|
// DirectWrite is not available on all platforms, we need to use the function
|
|
|
|
// pointer.
|
|
|
|
typedef HRESULT (WINAPI*DWriteCreateFactoryFunc)(
|
|
|
|
__in DWRITE_FACTORY_TYPE factoryType,
|
|
|
|
__in REFIID iid,
|
|
|
|
__out IUnknown **factory
|
|
|
|
);
|
|
|
|
#endif
|
2010-08-16 07:15:03 +00:00
|
|
|
|
|
|
|
#ifdef CAIRO_HAS_D2D_SURFACE
|
|
|
|
typedef HRESULT (WINAPI*D3D10CreateDevice1Func)(
|
|
|
|
IDXGIAdapter *pAdapter,
|
|
|
|
D3D10_DRIVER_TYPE DriverType,
|
|
|
|
HMODULE Software,
|
|
|
|
UINT Flags,
|
|
|
|
D3D10_FEATURE_LEVEL1 HardwareLevel,
|
|
|
|
UINT SDKVersion,
|
|
|
|
ID3D10Device1 **ppDevice
|
2010-08-14 06:34:55 +00:00
|
|
|
);
|
|
|
|
#endif
|
2010-02-26 06:36:07 +00:00
|
|
|
|
2008-03-26 21:32:51 +00:00
|
|
|
static __inline void
|
|
|
|
BuildKeyNameFromFontName(nsAString &aName)
|
|
|
|
{
|
|
|
|
if (aName.Length() >= LF_FACESIZE)
|
|
|
|
aName.Truncate(LF_FACESIZE - 1);
|
|
|
|
ToLowerCase(aName);
|
|
|
|
}
|
2008-03-19 00:06:55 +00:00
|
|
|
|
2006-02-01 02:35:38 +00:00
|
|
|
gfxWindowsPlatform::gfxWindowsPlatform()
|
|
|
|
{
|
2009-10-07 14:13:40 +00:00
|
|
|
mPrefFonts.Init(50);
|
2007-08-24 19:41:16 +00:00
|
|
|
|
2010-05-27 05:05:30 +00:00
|
|
|
mUseClearTypeForDownloadableFonts = UNINITIALIZED_VALUE;
|
|
|
|
mUseClearTypeAlways = UNINITIALIZED_VALUE;
|
|
|
|
|
2010-11-08 11:02:27 +00:00
|
|
|
mUsingGDIFonts = PR_FALSE;
|
|
|
|
|
2010-08-26 20:44:53 +00:00
|
|
|
/*
|
|
|
|
* Initialize COM
|
|
|
|
*/
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2010-08-20 01:26:00 +00:00
|
|
|
mScreenDC = GetDC(NULL);
|
|
|
|
|
2009-01-23 06:24:29 +00:00
|
|
|
#ifdef MOZ_FT2_FONTS
|
|
|
|
FT_Init_FreeType(&gPlatformFTLibrary);
|
|
|
|
#endif
|
|
|
|
|
2010-09-15 22:16:09 +00:00
|
|
|
#ifdef CAIRO_HAS_D2D_SURFACE
|
|
|
|
NS_RegisterMemoryReporter(new D2DCacheReporter());
|
|
|
|
NS_RegisterMemoryReporter(new D2DVRAMReporter());
|
|
|
|
mD2DDevice = nsnull;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
UpdateRenderMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxWindowsPlatform::~gfxWindowsPlatform()
|
|
|
|
{
|
|
|
|
::ReleaseDC(NULL, mScreenDC);
|
|
|
|
// not calling FT_Done_FreeType because cairo may still hold references to
|
|
|
|
// these FT_Faces. See bug 458169.
|
|
|
|
#ifdef CAIRO_HAS_D2D_SURFACE
|
|
|
|
if (mD2DDevice) {
|
|
|
|
cairo_release_device(mD2DDevice);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Uninitialize COM
|
|
|
|
*/
|
2010-11-08 11:02:27 +00:00
|
|
|
CoUninitialize();
|
2010-09-15 22:16:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxWindowsPlatform::UpdateRenderMode()
|
|
|
|
{
|
2009-07-08 23:34:02 +00:00
|
|
|
/* Pick the default render mode differently between
|
|
|
|
* desktop, Windows Mobile, and Windows CE.
|
|
|
|
*/
|
|
|
|
#if defined(WINCE_WINDOWS_MOBILE)
|
|
|
|
mRenderMode = RENDER_IMAGE_DDRAW16;
|
|
|
|
#elif defined(WINCE)
|
|
|
|
mRenderMode = RENDER_DDRAW_GL;
|
|
|
|
#else
|
|
|
|
mRenderMode = RENDER_GDI;
|
|
|
|
#endif
|
|
|
|
|
2010-08-14 06:34:55 +00:00
|
|
|
OSVERSIONINFOA versionInfo;
|
|
|
|
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
|
|
|
|
::GetVersionExA(&versionInfo);
|
|
|
|
bool isVistaOrHigher = versionInfo.dwMajorVersion >= 6;
|
2009-10-07 14:13:40 +00:00
|
|
|
|
2010-08-31 00:02:18 +00:00
|
|
|
PRBool safeMode = PR_FALSE;
|
|
|
|
nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
|
|
|
|
if (xr)
|
|
|
|
xr->GetInSafeMode(&safeMode);
|
|
|
|
|
2010-09-15 22:16:09 +00:00
|
|
|
nsCOMPtr<nsIPrefBranch2> pref = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
PRBool preferDirectWrite = PR_FALSE;
|
|
|
|
|
|
|
|
rv = pref->GetBoolPref(
|
|
|
|
"gfx.font_rendering.directwrite.enabled", &preferDirectWrite);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
preferDirectWrite = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mUseDirectWrite = preferDirectWrite;
|
|
|
|
|
2010-06-30 13:52:13 +00:00
|
|
|
#ifdef CAIRO_HAS_D2D_SURFACE
|
2010-08-30 21:45:29 +00:00
|
|
|
PRBool d2dDisabled = PR_FALSE;
|
2010-09-15 22:16:09 +00:00
|
|
|
PRBool d2dForceEnabled = PR_FALSE;
|
2010-08-30 21:45:29 +00:00
|
|
|
PRBool d2dBlocked = PR_FALSE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
|
|
|
|
if (gfxInfo) {
|
|
|
|
PRInt32 status;
|
|
|
|
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT2D, &status))) {
|
2010-10-07 04:40:08 +00:00
|
|
|
if (status != nsIGfxInfo::FEATURE_NO_INFO) {
|
2010-08-30 21:45:29 +00:00
|
|
|
d2dDisabled = PR_TRUE;
|
2010-10-07 04:40:08 +00:00
|
|
|
if (status == nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION ||
|
|
|
|
status == nsIGfxInfo::FEATURE_BLOCKED_DEVICE)
|
|
|
|
{
|
2010-08-30 21:45:29 +00:00
|
|
|
d2dBlocked = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-15 22:16:09 +00:00
|
|
|
rv = pref->GetBoolPref("gfx.direct2d.disabled", &d2dDisabled);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
d2dDisabled = PR_FALSE;
|
|
|
|
rv = pref->GetBoolPref("gfx.direct2d.force-enabled", &d2dForceEnabled);
|
2010-08-28 02:44:37 +00:00
|
|
|
if (NS_FAILED(rv))
|
2010-11-08 11:02:27 +00:00
|
|
|
d2dForceEnabled = PR_FALSE;
|
2010-08-28 02:44:37 +00:00
|
|
|
|
2010-09-15 22:16:09 +00:00
|
|
|
bool tryD2D = !d2dBlocked || d2dForceEnabled;
|
|
|
|
|
2010-11-08 11:02:27 +00:00
|
|
|
// Do not ever try if d2d is explicitly disabled,
|
|
|
|
// or if we're not using DWrite fonts.
|
|
|
|
if (d2dDisabled || mUsingGDIFonts) {
|
2010-09-15 22:16:09 +00:00
|
|
|
tryD2D = false;
|
|
|
|
}
|
2010-08-14 06:34:55 +00:00
|
|
|
|
2010-09-15 22:16:09 +00:00
|
|
|
if (isVistaOrHigher && !safeMode && tryD2D) {
|
|
|
|
VerifyD2DDevice(d2dForceEnabled);
|
|
|
|
if (mD2DDevice) {
|
|
|
|
mRenderMode = RENDER_DIRECT2D;
|
|
|
|
mUseDirectWrite = PR_TRUE;
|
2010-08-14 06:34:55 +00:00
|
|
|
}
|
2010-09-15 22:16:09 +00:00
|
|
|
} else {
|
|
|
|
mD2DDevice = nsnull;
|
2010-08-14 06:34:55 +00:00
|
|
|
}
|
2010-06-30 13:52:13 +00:00
|
|
|
#endif
|
2010-08-14 06:34:55 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
#ifdef CAIRO_HAS_DWRITE_FONT
|
2010-08-14 06:34:55 +00:00
|
|
|
// Enable when it's preffed on -and- we're using Vista or higher. Or when
|
|
|
|
// we're going to use D2D.
|
2010-09-15 22:16:09 +00:00
|
|
|
if (!mDWriteFactory && (mUseDirectWrite && isVistaOrHigher)) {
|
2010-02-26 06:36:07 +00:00
|
|
|
DWriteCreateFactoryFunc createDWriteFactory = (DWriteCreateFactoryFunc)
|
|
|
|
GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory");
|
|
|
|
|
|
|
|
if (createDWriteFactory) {
|
|
|
|
/**
|
|
|
|
* I need a direct pointer to be able to cast to IUnknown**, I also
|
|
|
|
* need to remember to release this because the nsRefPtr will
|
|
|
|
* AddRef it.
|
|
|
|
*/
|
|
|
|
IDWriteFactory *factory;
|
|
|
|
HRESULT hr = createDWriteFactory(
|
|
|
|
DWRITE_FACTORY_TYPE_SHARED,
|
|
|
|
__uuidof(IDWriteFactory),
|
|
|
|
reinterpret_cast<IUnknown**>(&factory));
|
|
|
|
mDWriteFactory = factory;
|
|
|
|
factory->Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2006-02-24 05:15:21 +00:00
|
|
|
}
|
|
|
|
|
2010-09-15 22:16:09 +00:00
|
|
|
void
|
|
|
|
gfxWindowsPlatform::VerifyD2DDevice(PRBool aAttemptForce)
|
2006-02-24 05:15:21 +00:00
|
|
|
{
|
2010-08-10 23:59:51 +00:00
|
|
|
#ifdef CAIRO_HAS_D2D_SURFACE
|
|
|
|
if (mD2DDevice) {
|
2010-09-15 22:16:09 +00:00
|
|
|
ID3D10Device1 *device = cairo_d2d_device_get_device(mD2DDevice);
|
|
|
|
|
|
|
|
if (SUCCEEDED(device->GetDeviceRemovedReason())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mD2DDevice = nsnull;
|
2010-08-10 23:59:51 +00:00
|
|
|
}
|
2010-08-26 20:44:53 +00:00
|
|
|
|
2010-09-15 22:16:09 +00:00
|
|
|
HMODULE d3d10module = LoadLibraryA("d3d10_1.dll");
|
|
|
|
D3D10CreateDevice1Func createD3DDevice = (D3D10CreateDevice1Func)
|
|
|
|
GetProcAddress(d3d10module, "D3D10CreateDevice1");
|
|
|
|
nsRefPtr<ID3D10Device1> device;
|
|
|
|
|
|
|
|
if (createD3DDevice) {
|
|
|
|
// We try 10.0 first even though we prefer 10.1, since we want to
|
|
|
|
// fail as fast as possible if 10.x isn't supported.
|
|
|
|
HRESULT hr = createD3DDevice(
|
|
|
|
NULL,
|
|
|
|
D3D10_DRIVER_TYPE_HARDWARE,
|
|
|
|
NULL,
|
|
|
|
D3D10_CREATE_DEVICE_BGRA_SUPPORT |
|
|
|
|
D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
|
|
|
|
D3D10_FEATURE_LEVEL_10_0,
|
|
|
|
D3D10_1_SDK_VERSION,
|
|
|
|
getter_AddRefs(device));
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
// We have 10.0, let's try 10.1.
|
|
|
|
// XXX - This adds an additional 10-20ms for people who are
|
|
|
|
// getting direct2d. We'd really like to do something more
|
|
|
|
// clever.
|
|
|
|
nsRefPtr<ID3D10Device1> device1;
|
|
|
|
hr = createD3DDevice(
|
|
|
|
NULL,
|
|
|
|
D3D10_DRIVER_TYPE_HARDWARE,
|
|
|
|
NULL,
|
|
|
|
D3D10_CREATE_DEVICE_BGRA_SUPPORT |
|
|
|
|
D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
|
|
|
|
D3D10_FEATURE_LEVEL_10_1,
|
|
|
|
D3D10_1_SDK_VERSION,
|
|
|
|
getter_AddRefs(device1));
|
2010-08-26 20:44:53 +00:00
|
|
|
|
2010-09-15 22:16:09 +00:00
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
device = device1;
|
|
|
|
}
|
2006-02-24 05:15:21 +00:00
|
|
|
|
2010-09-15 22:16:09 +00:00
|
|
|
mD2DDevice = cairo_d2d_create_device_from_d3d10device(device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mD2DDevice && aAttemptForce) {
|
|
|
|
mD2DDevice = cairo_d2d_create_device();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2010-11-08 11:02:27 +00:00
|
|
|
|
2009-10-07 14:13:40 +00:00
|
|
|
gfxPlatformFontList*
|
|
|
|
gfxWindowsPlatform::CreatePlatformFontList()
|
|
|
|
{
|
2010-11-08 11:02:27 +00:00
|
|
|
mUsingGDIFonts = PR_FALSE;
|
|
|
|
gfxPlatformFontList *pfl;
|
2009-10-07 14:13:40 +00:00
|
|
|
#ifdef MOZ_FT2_FONTS
|
2010-11-08 11:02:27 +00:00
|
|
|
pfl = new gfxFT2FontList();
|
2009-10-07 14:13:40 +00:00
|
|
|
#else
|
2010-02-26 06:36:07 +00:00
|
|
|
#ifdef CAIRO_HAS_DWRITE_FONT
|
2010-11-08 11:02:27 +00:00
|
|
|
if (GetDWriteFactory()) {
|
|
|
|
pfl = new gfxDWriteFontList();
|
|
|
|
if (NS_SUCCEEDED(pfl->InitFontList())) {
|
|
|
|
return pfl;
|
|
|
|
}
|
|
|
|
// DWrite font initialization failed! Don't know why this would happen,
|
|
|
|
// but apparently it can - see bug 594865.
|
|
|
|
// So we're going to fall back to GDI fonts & rendering.
|
|
|
|
gfxPlatformFontList::Shutdown();
|
|
|
|
SetRenderMode(RENDER_GDI);
|
2010-02-26 06:36:07 +00:00
|
|
|
}
|
|
|
|
#endif
|
2010-11-08 11:02:27 +00:00
|
|
|
pfl = new gfxGDIFontList();
|
|
|
|
mUsingGDIFonts = PR_TRUE;
|
2009-10-07 14:13:40 +00:00
|
|
|
#endif
|
2010-11-08 11:02:27 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(pfl->InitFontList())) {
|
|
|
|
return pfl;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxPlatformFontList::Shutdown();
|
|
|
|
return nsnull;
|
2009-10-07 14:13:40 +00:00
|
|
|
}
|
2010-02-26 06:36:07 +00:00
|
|
|
|
2006-03-25 00:34:48 +00:00
|
|
|
already_AddRefed<gfxASurface>
|
2007-02-08 20:47:48 +00:00
|
|
|
gfxWindowsPlatform::CreateOffscreenSurface(const gfxIntSize& size,
|
2010-09-16 21:34:53 +00:00
|
|
|
gfxASurface::gfxContentType contentType)
|
2006-02-01 02:35:38 +00:00
|
|
|
{
|
2009-07-08 23:34:02 +00:00
|
|
|
gfxASurface *surf = nsnull;
|
|
|
|
|
|
|
|
#ifdef CAIRO_HAS_WIN32_SURFACE
|
|
|
|
if (mRenderMode == RENDER_GDI)
|
2010-09-16 21:34:53 +00:00
|
|
|
surf = new gfxWindowsSurface(size, gfxASurface::FormatFromContent(contentType));
|
2009-01-15 00:19:39 +00:00
|
|
|
#endif
|
2009-07-08 23:34:02 +00:00
|
|
|
|
2010-02-26 06:36:07 +00:00
|
|
|
#ifdef CAIRO_HAS_D2D_SURFACE
|
|
|
|
if (mRenderMode == RENDER_DIRECT2D)
|
2010-09-16 21:34:53 +00:00
|
|
|
surf = new gfxD2DSurface(size, gfxASurface::FormatFromContent(contentType));
|
2010-02-26 06:36:07 +00:00
|
|
|
#endif
|
|
|
|
|
2009-07-08 23:34:02 +00:00
|
|
|
if (surf == nsnull)
|
2010-09-16 21:34:53 +00:00
|
|
|
surf = new gfxImageSurface(size, gfxASurface::FormatFromContent(contentType));
|
2009-07-08 23:34:02 +00:00
|
|
|
|
2006-03-25 00:34:48 +00:00
|
|
|
NS_IF_ADDREF(surf);
|
2009-07-08 23:34:02 +00:00
|
|
|
|
2006-03-25 00:34:48 +00:00
|
|
|
return surf;
|
2006-02-01 02:35:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2010-02-24 17:57:57 +00:00
|
|
|
gfxWindowsPlatform::GetFontList(nsIAtom *aLangGroup,
|
2006-02-01 02:35:38 +00:00
|
|
|
const nsACString& aGenericFamily,
|
2009-01-18 20:14:14 +00:00
|
|
|
nsTArray<nsString>& aListOfFonts)
|
2006-02-01 02:35:38 +00:00
|
|
|
{
|
2009-10-07 14:13:40 +00:00
|
|
|
gfxPlatformFontList::PlatformFontList()->GetFontList(aLangGroup, aGenericFamily, aListOfFonts);
|
2006-02-24 05:15:21 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-01-05 15:51:27 +00:00
|
|
|
static void
|
|
|
|
RemoveCharsetFromFontSubstitute(nsAString &aName)
|
|
|
|
{
|
|
|
|
PRInt32 comma = aName.FindChar(PRUnichar(','));
|
|
|
|
if (comma >= 0)
|
|
|
|
aName.Truncate(comma);
|
|
|
|
}
|
|
|
|
|
2006-06-15 04:47:23 +00:00
|
|
|
nsresult
|
|
|
|
gfxWindowsPlatform::UpdateFontList()
|
|
|
|
{
|
2009-10-07 14:13:40 +00:00
|
|
|
gfxPlatformFontList::PlatformFontList()->UpdateFontList();
|
2008-03-13 02:36:58 +00:00
|
|
|
|
2006-06-15 04:47:23 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-11-21 06:31:04 +00:00
|
|
|
struct ResolveData {
|
|
|
|
ResolveData(gfxPlatform::FontResolverCallback aCallback,
|
|
|
|
gfxWindowsPlatform *aCaller, const nsAString *aFontName,
|
|
|
|
void *aClosure) :
|
|
|
|
mFoundCount(0), mCallback(aCallback), mCaller(aCaller),
|
|
|
|
mFontName(aFontName), mClosure(aClosure) {}
|
|
|
|
PRUint32 mFoundCount;
|
|
|
|
gfxPlatform::FontResolverCallback mCallback;
|
|
|
|
gfxWindowsPlatform *mCaller;
|
|
|
|
const nsAString *mFontName;
|
|
|
|
void *mClosure;
|
|
|
|
};
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
gfxWindowsPlatform::ResolveFontName(const nsAString& aFontName,
|
|
|
|
FontResolverCallback aCallback,
|
2010-02-26 06:36:07 +00:00
|
|
|
void *aClosure,
|
|
|
|
PRBool& aAborted)
|
2006-11-21 06:31:04 +00:00
|
|
|
{
|
2009-10-07 14:13:40 +00:00
|
|
|
nsAutoString resolvedName;
|
|
|
|
if (!gfxPlatformFontList::PlatformFontList()->
|
|
|
|
ResolveFontName(aFontName, resolvedName)) {
|
2006-11-21 06:31:04 +00:00
|
|
|
aAborted = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-10-07 14:13:40 +00:00
|
|
|
aAborted = !(*aCallback)(resolvedName, aClosure);
|
2006-11-21 06:31:04 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-07 14:13:40 +00:00
|
|
|
nsresult
|
|
|
|
gfxWindowsPlatform::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName)
|
2007-05-29 15:09:23 +00:00
|
|
|
{
|
2009-10-07 14:13:40 +00:00
|
|
|
gfxPlatformFontList::PlatformFontList()->GetStandardFamilyName(aFontName, aFamilyName);
|
|
|
|
return NS_OK;
|
2006-02-01 02:35:38 +00:00
|
|
|
}
|
2007-04-02 19:06:16 +00:00
|
|
|
|
|
|
|
gfxFontGroup *
|
|
|
|
gfxWindowsPlatform::CreateFontGroup(const nsAString &aFamilies,
|
2008-10-01 03:01:53 +00:00
|
|
|
const gfxFontStyle *aStyle,
|
|
|
|
gfxUserFontSet *aUserFontSet)
|
|
|
|
{
|
2009-01-23 06:24:29 +00:00
|
|
|
#ifdef MOZ_FT2_FONTS
|
|
|
|
return new gfxFT2FontGroup(aFamilies, aStyle);
|
|
|
|
#else
|
2010-04-06 20:19:39 +00:00
|
|
|
return new gfxFontGroup(aFamilies, aStyle, aUserFontSet);
|
2009-01-23 06:24:29 +00:00
|
|
|
#endif
|
2008-10-01 03:01:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxFontEntry*
|
2009-01-03 03:21:49 +00:00
|
|
|
gfxWindowsPlatform::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
|
|
|
|
const nsAString& aFontName)
|
2008-10-01 03:01:53 +00:00
|
|
|
{
|
2009-10-07 14:13:40 +00:00
|
|
|
return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aProxyEntry,
|
|
|
|
aFontName);
|
2008-10-01 03:01:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxFontEntry*
|
2008-12-05 23:19:27 +00:00
|
|
|
gfxWindowsPlatform::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
|
2008-10-29 18:09:50 +00:00
|
|
|
const PRUint8 *aFontData, PRUint32 aLength)
|
2008-10-01 03:01:53 +00:00
|
|
|
{
|
2009-10-07 14:13:40 +00:00
|
|
|
return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aProxyEntry,
|
|
|
|
aFontData,
|
|
|
|
aLength);
|
2008-10-01 03:01:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
gfxWindowsPlatform::IsFontFormatSupported(nsIURI *aFontURI, PRUint32 aFormatFlags)
|
|
|
|
{
|
2009-01-13 05:16:58 +00:00
|
|
|
// check for strange format flags
|
|
|
|
NS_ASSERTION(!(aFormatFlags & gfxUserFontSet::FLAG_FORMAT_NOT_USED),
|
|
|
|
"strange font format hint set");
|
|
|
|
|
|
|
|
// accept supported formats
|
2009-09-17 11:03:12 +00:00
|
|
|
if (aFormatFlags & (gfxUserFontSet::FLAG_FORMAT_WOFF |
|
|
|
|
gfxUserFontSet::FLAG_FORMAT_OPENTYPE |
|
2009-01-13 05:16:58 +00:00
|
|
|
gfxUserFontSet::FLAG_FORMAT_TRUETYPE)) {
|
|
|
|
return PR_TRUE;
|
2008-10-01 03:01:53 +00:00
|
|
|
}
|
|
|
|
|
2009-01-13 05:16:58 +00:00
|
|
|
// reject all other formats, known and unknown
|
|
|
|
if (aFormatFlags != 0) {
|
2008-10-01 03:01:53 +00:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2009-01-13 05:16:58 +00:00
|
|
|
// no format hint set, need to look at data
|
2008-10-01 03:01:53 +00:00
|
|
|
return PR_TRUE;
|
2007-04-02 19:06:16 +00:00
|
|
|
}
|
2007-05-30 00:07:03 +00:00
|
|
|
|
2009-10-07 14:13:40 +00:00
|
|
|
gfxFontFamily *
|
2008-03-19 00:06:55 +00:00
|
|
|
gfxWindowsPlatform::FindFontFamily(const nsAString& aName)
|
2007-05-30 00:07:03 +00:00
|
|
|
{
|
2009-10-07 14:13:40 +00:00
|
|
|
return gfxPlatformFontList::PlatformFontList()->FindFamily(aName);
|
2008-03-19 00:06:55 +00:00
|
|
|
}
|
|
|
|
|
2009-10-07 14:13:40 +00:00
|
|
|
gfxFontEntry *
|
2008-03-26 21:32:51 +00:00
|
|
|
gfxWindowsPlatform::FindFontEntry(const nsAString& aName, const gfxFontStyle& aFontStyle)
|
2008-03-19 00:06:55 +00:00
|
|
|
{
|
2009-10-07 14:13:40 +00:00
|
|
|
nsRefPtr<gfxFontFamily> ff = FindFontFamily(aName);
|
2008-03-19 00:06:55 +00:00
|
|
|
if (!ff)
|
|
|
|
return nsnull;
|
|
|
|
|
2009-10-07 14:13:40 +00:00
|
|
|
PRBool aNeedsBold;
|
|
|
|
return ff->FindFontForStyle(aFontStyle, aNeedsBold);
|
2007-05-30 00:07:03 +00:00
|
|
|
}
|
2007-07-23 22:02:17 +00:00
|
|
|
|
2009-04-07 16:02:11 +00:00
|
|
|
qcms_profile*
|
2007-07-23 22:02:17 +00:00
|
|
|
gfxWindowsPlatform::GetPlatformCMSOutputProfile()
|
|
|
|
{
|
2009-01-23 06:24:29 +00:00
|
|
|
#ifndef MOZ_FT2_FONTS
|
2010-01-24 13:58:31 +00:00
|
|
|
WCHAR str[MAX_PATH];
|
|
|
|
DWORD size = MAX_PATH;
|
|
|
|
BOOL res;
|
2007-07-23 22:02:17 +00:00
|
|
|
|
|
|
|
HDC dc = GetDC(nsnull);
|
2010-01-05 23:39:56 +00:00
|
|
|
if (!dc)
|
|
|
|
return nsnull;
|
|
|
|
|
2010-01-24 13:58:31 +00:00
|
|
|
#if _MSC_VER
|
2010-01-05 23:39:56 +00:00
|
|
|
__try {
|
2010-01-24 13:58:31 +00:00
|
|
|
res = GetICMProfileW(dc, &size, (LPWSTR)&str);
|
2010-01-05 23:39:56 +00:00
|
|
|
} __except(GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION) {
|
2010-01-24 13:58:31 +00:00
|
|
|
res = FALSE;
|
2010-01-05 23:39:56 +00:00
|
|
|
}
|
2010-01-24 13:58:31 +00:00
|
|
|
#else
|
|
|
|
res = GetICMProfileW(dc, &size, (LPWSTR)&str);
|
|
|
|
#endif
|
2010-01-05 23:39:56 +00:00
|
|
|
|
2007-07-23 22:02:17 +00:00
|
|
|
ReleaseDC(nsnull, dc);
|
2010-01-24 13:58:31 +00:00
|
|
|
if (!res)
|
|
|
|
return nsnull;
|
2007-07-23 22:02:17 +00:00
|
|
|
|
2009-04-07 16:02:11 +00:00
|
|
|
qcms_profile* profile =
|
|
|
|
qcms_profile_from_path(NS_ConvertUTF16toUTF8(str).get());
|
2007-07-23 22:02:17 +00:00
|
|
|
#ifdef DEBUG_tor
|
|
|
|
if (profile)
|
|
|
|
fprintf(stderr,
|
|
|
|
"ICM profile read from %s successfully\n",
|
|
|
|
NS_ConvertUTF16toUTF8(str).get());
|
|
|
|
#endif
|
|
|
|
return profile;
|
2008-12-03 13:42:03 +00:00
|
|
|
#else
|
|
|
|
return nsnull;
|
|
|
|
#endif
|
2007-07-23 22:02:17 +00:00
|
|
|
}
|
2007-08-24 19:41:16 +00:00
|
|
|
|
|
|
|
PRBool
|
2009-10-07 14:13:40 +00:00
|
|
|
gfxWindowsPlatform::GetPrefFontEntries(const nsCString& aKey, nsTArray<nsRefPtr<gfxFontEntry> > *array)
|
2007-08-24 19:41:16 +00:00
|
|
|
{
|
2008-03-19 00:06:55 +00:00
|
|
|
return mPrefFonts.Get(aKey, array);
|
2007-08-24 19:41:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-10-07 14:13:40 +00:00
|
|
|
gfxWindowsPlatform::SetPrefFontEntries(const nsCString& aKey, nsTArray<nsRefPtr<gfxFontEntry> >& array)
|
2007-08-24 19:41:16 +00:00
|
|
|
{
|
2008-03-19 00:06:55 +00:00
|
|
|
mPrefFonts.Put(aKey, array);
|
2007-08-24 19:41:16 +00:00
|
|
|
}
|
2008-04-04 02:01:22 +00:00
|
|
|
|
2009-01-23 06:24:29 +00:00
|
|
|
#ifdef MOZ_FT2_FONTS
|
|
|
|
FT_Library
|
|
|
|
gfxWindowsPlatform::GetFTLibrary()
|
|
|
|
{
|
|
|
|
return gPlatformFTLibrary;
|
|
|
|
}
|
|
|
|
#endif
|
2009-09-22 12:45:56 +00:00
|
|
|
|
2010-05-27 05:05:30 +00:00
|
|
|
PRBool
|
|
|
|
gfxWindowsPlatform::UseClearTypeForDownloadableFonts()
|
|
|
|
{
|
|
|
|
if (mUseClearTypeForDownloadableFonts == UNINITIALIZED_VALUE) {
|
|
|
|
mUseClearTypeForDownloadableFonts = GetBoolPref(GFX_DOWNLOADABLE_FONTS_USE_CLEARTYPE, PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mUseClearTypeForDownloadableFonts;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
gfxWindowsPlatform::UseClearTypeAlways()
|
|
|
|
{
|
|
|
|
if (mUseClearTypeAlways == UNINITIALIZED_VALUE) {
|
|
|
|
mUseClearTypeAlways = GetBoolPref(GFX_USE_CLEARTYPE_ALWAYS, PR_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mUseClearTypeAlways;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32
|
|
|
|
gfxWindowsPlatform::WindowsOSVersion()
|
|
|
|
{
|
|
|
|
static PRInt32 winVersion = UNINITIALIZED_VALUE;
|
|
|
|
|
|
|
|
OSVERSIONINFO vinfo;
|
|
|
|
|
|
|
|
if (winVersion == UNINITIALIZED_VALUE) {
|
|
|
|
vinfo.dwOSVersionInfoSize = sizeof (vinfo);
|
|
|
|
if (!GetVersionEx(&vinfo)) {
|
|
|
|
winVersion = kWindowsUnknown;
|
|
|
|
} else {
|
|
|
|
winVersion = PRInt32(vinfo.dwMajorVersion << 16) + vinfo.dwMinorVersion;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return winVersion;
|
|
|
|
}
|
|
|
|
|
2011-01-14 12:57:17 +00:00
|
|
|
void
|
2011-01-28 10:35:40 +00:00
|
|
|
gfxWindowsPlatform::GetDLLVersion(const PRUnichar *aDLLPath, nsAString& aVersion)
|
2011-01-14 12:57:17 +00:00
|
|
|
{
|
|
|
|
DWORD versInfoSize, vers[4] = {0};
|
|
|
|
// version info not available case
|
|
|
|
aVersion.Assign(NS_LITERAL_STRING("0.0.0.0"));
|
|
|
|
versInfoSize = GetFileVersionInfoSizeW(aDLLPath, NULL);
|
|
|
|
nsAutoTArray<BYTE,512> versionInfo;
|
|
|
|
|
2011-02-15 02:28:51 +00:00
|
|
|
if (versInfoSize == 0 ||
|
|
|
|
!versionInfo.AppendElements(PRUint32(versInfoSize)))
|
|
|
|
{
|
2011-01-14 12:57:17 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-02-15 02:28:51 +00:00
|
|
|
|
2011-01-28 10:35:40 +00:00
|
|
|
if (!GetFileVersionInfoW(aDLLPath, 0, versInfoSize,
|
2011-02-15 02:28:51 +00:00
|
|
|
LPBYTE(versionInfo.Elements())))
|
|
|
|
{
|
2011-01-14 12:57:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-15 02:28:51 +00:00
|
|
|
UINT len = 0;
|
|
|
|
VS_FIXEDFILEINFO *fileInfo = nsnull;
|
2011-01-14 12:57:17 +00:00
|
|
|
if (!VerQueryValue(LPBYTE(versionInfo.Elements()), TEXT("\\"),
|
2011-02-15 02:28:51 +00:00
|
|
|
(LPVOID *)&fileInfo, &len) ||
|
|
|
|
len == 0 ||
|
|
|
|
fileInfo == nsnull)
|
|
|
|
{
|
2011-01-14 12:57:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD fileVersMS = fileInfo->dwFileVersionMS;
|
|
|
|
DWORD fileVersLS = fileInfo->dwFileVersionLS;
|
|
|
|
|
|
|
|
vers[0] = HIWORD(fileVersMS);
|
|
|
|
vers[1] = LOWORD(fileVersMS);
|
|
|
|
vers[2] = HIWORD(fileVersLS);
|
|
|
|
vers[3] = LOWORD(fileVersLS);
|
|
|
|
|
|
|
|
char buf[256];
|
|
|
|
sprintf(buf, "%d.%d.%d.%d", vers[0], vers[1], vers[2], vers[3]);
|
|
|
|
aVersion.Assign(NS_ConvertUTF8toUTF16(buf));
|
|
|
|
}
|
|
|
|
|
2011-01-31 02:15:12 +00:00
|
|
|
void
|
|
|
|
gfxWindowsPlatform::GetFontCacheSize(nsAString& aSize)
|
|
|
|
{
|
|
|
|
WIN32_FIND_DATAW findFileData;
|
|
|
|
HANDLE file;
|
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
|
|
|
|
aSize.Assign(L"n/a");
|
|
|
|
|
|
|
|
if (FAILED(SHGetFolderPathW(NULL, CSIDL_WINDOWS, NULL, 0, path))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PathAppendW(path,
|
|
|
|
L"ServiceProfiles\\LocalService\\AppData\\Local\\FontCache-*-*.dat");
|
|
|
|
file = FindFirstFileW(path, &findFileData);
|
|
|
|
if (file == INVALID_HANDLE_VALUE) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
WCHAR size[256];
|
|
|
|
|
|
|
|
double sizeMB = (double(findFileData.nFileSizeLow) +
|
|
|
|
findFileData.nFileSizeHigh * (double(MAXDWORD) + 1))
|
|
|
|
/ 1000000.0;
|
2011-02-08 06:02:06 +00:00
|
|
|
swprintf_s(size, sizeof(size), L"%.2f MB", sizeMB);
|
2011-01-31 02:15:12 +00:00
|
|
|
aSize.Assign(size);
|
2011-02-08 06:02:06 +00:00
|
|
|
FindClose(file);
|
2011-01-31 02:15:12 +00:00
|
|
|
}
|
|
|
|
|
2010-05-27 05:05:30 +00:00
|
|
|
void
|
|
|
|
gfxWindowsPlatform::FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref)
|
|
|
|
{
|
2010-06-09 00:33:13 +00:00
|
|
|
PRBool clearTextFontCaches = PR_TRUE;
|
2010-05-27 05:05:30 +00:00
|
|
|
|
|
|
|
gfxPlatform::FontsPrefsChanged(aPrefBranch, aPref);
|
|
|
|
|
|
|
|
if (!aPref) {
|
|
|
|
mUseClearTypeForDownloadableFonts = UNINITIALIZED_VALUE;
|
|
|
|
mUseClearTypeAlways = UNINITIALIZED_VALUE;
|
|
|
|
} else if (!strcmp(GFX_DOWNLOADABLE_FONTS_USE_CLEARTYPE, aPref)) {
|
|
|
|
mUseClearTypeForDownloadableFonts = UNINITIALIZED_VALUE;
|
|
|
|
} else if (!strcmp(GFX_USE_CLEARTYPE_ALWAYS, aPref)) {
|
|
|
|
mUseClearTypeAlways = UNINITIALIZED_VALUE;
|
|
|
|
} else {
|
2010-06-09 00:33:13 +00:00
|
|
|
clearTextFontCaches = PR_FALSE;
|
2010-05-27 05:05:30 +00:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:33:13 +00:00
|
|
|
if (clearTextFontCaches) {
|
2010-05-27 05:05:30 +00:00
|
|
|
gfxFontCache *fc = gfxFontCache::GetCache();
|
2010-06-09 00:33:13 +00:00
|
|
|
if (fc) {
|
|
|
|
fc->Flush();
|
|
|
|
}
|
|
|
|
gfxTextRunWordCache::Flush();
|
2010-05-27 05:05:30 +00:00
|
|
|
}
|
2010-08-14 12:43:27 +00:00
|
|
|
}
|