Remove system call in DW for default font.

The last user of the GDI default font in DW is
onMatchFamilyStyleCharacter and it doesn't appear to actually need
to use it. This change removes a system call, making things a bit
faster, as well as eliminating a call blocked in the sandbox.

BUG=chromium:459056

Review URL: https://codereview.chromium.org/1107283003
This commit is contained in:
bungeman 2015-04-29 08:15:31 -07:00 committed by Commit bot
parent 9e43cabaa1
commit c64239a466
2 changed files with 12 additions and 27 deletions

View File

@ -88,10 +88,10 @@ protected:
int count = SkMin32(fm->countFamilies(), MAX_FAMILIES);
for (int i = 0; i < count; ++i) {
SkString fname;
fm->getFamilyName(i, &fname);
SkString familyName;
fm->getFamilyName(i, &familyName);
paint.setTypeface(NULL);
(void)drawString(canvas, fname, 20, y, paint);
(void)drawString(canvas, familyName, 20, y, paint);
SkScalar x = 220;
@ -106,10 +106,10 @@ protected:
x = drawString(canvas, sname, x, y, paint) + 20;
// check to see that we get different glyphs in japanese and chinese
x = drawCharacter(canvas, 0x5203, x, y, paint, fm, fName.c_str(), &zh, 1, fs);
x = drawCharacter(canvas, 0x5203, x, y, paint, fm, fName.c_str(), &ja, 1, fs);
x = drawCharacter(canvas, 0x5203, x, y, paint, fm, familyName.c_str(), &zh, 1, fs);
x = drawCharacter(canvas, 0x5203, x, y, paint, fm, familyName.c_str(), &ja, 1, fs);
// check that emoji characters are found
x = drawCharacter(canvas, 0x1f601, x, y, paint, fm, fName.c_str(), NULL, 0, fs);
x = drawCharacter(canvas, 0x1f601, x, y, paint, fm, familyName.c_str(), NULL,0, fs);
}
y += 24;
}

View File

@ -629,21 +629,6 @@ protected:
SkTypeface* fResolvedTypeface;
};
static HRESULT getDefaultFontFamilyName(SkSMallocWCHAR* name) {
NONCLIENTMETRICSW metrics;
metrics.cbSize = sizeof(metrics);
if (0 == SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0)) {
return E_UNEXPECTED;
}
size_t len = wcsnlen_s(metrics.lfMessageFont.lfFaceName, LF_FACESIZE) + 1;
if (0 != wcsncpy_s(name->reset(len), len, metrics.lfMessageFont.lfFaceName, _TRUNCATE)) {
return E_UNEXPECTED;
}
return S_OK;
}
class FontFallbackSource : public IDWriteTextAnalysisSource {
public:
FontFallbackSource(const WCHAR* string, UINT32 length, const WCHAR* locale,
@ -750,11 +735,11 @@ SkTypeface* SkFontMgr_DirectWrite::onMatchFamilyStyleCharacter(const char family
{
const DWriteStyle dwStyle(style);
SkSMallocWCHAR dwFamilyName;
if (NULL == familyName) {
HRN(getDefaultFontFamilyName(&dwFamilyName));
} else {
HRN(sk_cstring_to_wchar(familyName, &dwFamilyName));
const WCHAR* dwFamilyName = NULL;
SkSMallocWCHAR dwFamilyNameLocal;
if (familyName) {
HRN(sk_cstring_to_wchar(familyName, &dwFamilyNameLocal));
dwFamilyName = dwFamilyNameLocal;
}
WCHAR str[16];
@ -816,7 +801,7 @@ SkTypeface* SkFontMgr_DirectWrite::onMatchFamilyStyleCharacter(const char family
#endif
SkTScopedComPtr<IDWriteTextFormat> fallbackFormat;
HRNM(fFactory->CreateTextFormat(dwFamilyName,
HRNM(fFactory->CreateTextFormat(dwFamilyName ? dwFamilyName : L"",
fFontCollection.get(),
dwStyle.fWeight,
dwStyle.fSlant,