diff options
author | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-27 21:30:50 +0000 |
---|---|---|
committer | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-27 21:30:50 +0000 |
commit | 591255037d2c94fbde4977776ffd1e1b3fc76be7 (patch) | |
tree | 8731b222ff01dd4b02f88f1371f13ac4545e2044 /skia | |
parent | 578de9c1e4e17bb58a01ed04014489260c7f064a (diff) | |
download | chromium_src-591255037d2c94fbde4977776ffd1e1b3fc76be7.zip chromium_src-591255037d2c94fbde4977776ffd1e1b3fc76be7.tar.gz chromium_src-591255037d2c94fbde4977776ffd1e1b3fc76be7.tar.bz2 |
Add DirectWrite keepalive every 10mins
On a 10 minute timer, directly use some DirectWrite APIs that cause
work across the ALPC port. This is attempting to fix occasional drops, on
the theory that the font server is reaping old unused connections.
(This will probably need to be merged to 37)
R=cpu@chromium.org, jam@chromium.org, bungeman@google.com
TBR=darin@chromium.org
BUG=377932,383542
Review URL: https://codereview.chromium.org/330913011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280410 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r-- | skia/ext/directwrite_keepalive_win.cc | 32 | ||||
-rw-r--r-- | skia/ext/directwrite_keepalive_win.h | 15 | ||||
-rw-r--r-- | skia/skia_chrome.gypi | 8 |
3 files changed, 55 insertions, 0 deletions
diff --git a/skia/ext/directwrite_keepalive_win.cc b/skia/ext/directwrite_keepalive_win.cc new file mode 100644 index 0000000..46e0b30 --- /dev/null +++ b/skia/ext/directwrite_keepalive_win.cc @@ -0,0 +1,32 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "skia/ext/directwrite_keepalive_win.h" + +#include "base/logging.h" +#include "skia/ext/refptr.h" +#include "third_party/skia/include/core/SkTypeface.h" +#include "third_party/skia/include/ports/SkFontMgr.h" +#include "third_party/skia/src/ports/SkTypeface_win_dw.h" + +void SkiaDirectWriteKeepalive(SkFontMgr* fontmgr) { + // We can't use a simple SkPaint similar to sandbox warmup here because we + // need to avoid hitting any of Skia's caches to make sure we actually keep + // the connection alive. See crbug.com/377932 for more details. + skia::RefPtr<SkTypeface> typeface = + skia::AdoptRef(fontmgr->legacyCreateTypeface("Arial", 0)); + DWriteFontTypeface* dwrite_typeface = + reinterpret_cast<DWriteFontTypeface*>(typeface.get()); + // Cycle through all 65536 to avoid hitting the in-process dwrite.dll cache. + static uint16_t glyph_id = 0; + glyph_id += 1; + DWRITE_GLYPH_METRICS gm; + HRESULT hr = dwrite_typeface->fDWriteFontFace->GetDesignGlyphMetrics( + &glyph_id, 1, &gm); + // If this check fails, we were unable to retrieve metrics from the + // DirectWrite service, because the ALPC port has been dropped. In this + // case, we will be unable to retrieve metrics or glyphs, so we might as + // well crash. + CHECK(SUCCEEDED(hr)); +} diff --git a/skia/ext/directwrite_keepalive_win.h b/skia/ext/directwrite_keepalive_win.h new file mode 100644 index 0000000..5de2075 --- /dev/null +++ b/skia/ext/directwrite_keepalive_win.h @@ -0,0 +1,15 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SKIA_EXT_DIRECTWRITE_KEEPALIVE_WIN_H_ +#define SKIA_EXT_DIRECTWRITE_KEEPALIVE_WIN_H_ + +#include "third_party/skia/include/core/SkTypes.h" + +class SkFontMgr; + +// Sends a command to the Font Cache Service to avoid being dropped. +void SK_API SkiaDirectWriteKeepalive(SkFontMgr* fontmgr); + +#endif // SKIA_EXT_DIRECTWRITE_KEEPALIVE_WIN_H_ diff --git a/skia/skia_chrome.gypi b/skia/skia_chrome.gypi index 32f5ca0..e48ef04 100644 --- a/skia/skia_chrome.gypi +++ b/skia/skia_chrome.gypi @@ -36,6 +36,8 @@ 'ext/bitmap_platform_device_win.h', 'ext/convolver.cc', 'ext/convolver.h', + 'ext/directwrite_keepalive_win.cc', + 'ext/directwrite_keepalive_win.h', 'ext/event_tracer_impl.cc', 'ext/event_tracer_impl.h', 'ext/fontmgr_default_win.cc', @@ -115,6 +117,12 @@ 'ext/bitmap_platform_device_skia.cc', ], }], + ['OS=="win"', { + 'include_dirs': [ + '../third_party/skia/include/utils/win', + '../third_party/skia/src/utils/win', + ], + }], ], 'target_conditions': [ |