From 38e7c98c23710e512b81882411d5bfe8307e52f3 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sat, 6 May 2017 19:24:24 -0400 Subject: [PATCH] fixes for XPS --- include/core/SkDocument.h | 8 ++++++++ src/xps/SkXPSDocument.cpp | 31 ++++++++++++------------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/include/core/SkDocument.h b/include/core/SkDocument.h index 6594511..55ab086 100644 --- a/include/core/SkDocument.h +++ b/include/core/SkDocument.h @@ -170,6 +170,14 @@ public: static sk_sp MakeXPS(SkWStream* stream, IXpsOMObjectFactory* xpsFactory, SkScalar dpi = SK_ScalarDefaultRasterDPI); + static sk_sp MakeXPS(SkWStream* stream, + SkScalar dpi = SK_ScalarDefaultRasterDPI); +#else + // DEPRECATED; TODO(mattleibow): we should remove this function. + static sk_sp MakeXPS(SkWStream* stream, + SkScalar dpi = SK_ScalarDefaultRasterDPI) { + return nullptr; + } #endif // DEPRECATED; TODO(halcanary): remove this function after Chromium switches to new API. static sk_sp MakeXPS(SkWStream*) { return nullptr; } diff --git a/src/xps/SkXPSDocument.cpp b/src/xps/SkXPSDocument.cpp index 319b332..23aa695 100644 --- a/src/xps/SkXPSDocument.cpp +++ b/src/xps/SkXPSDocument.cpp @@ -60,30 +60,23 @@ void SkXPSDocument::onAbort() {} /////////////////////////////////////////////////////////////////////////////// -// UWP Mobile does not support XPS, but Desktop does -static inline bool xps_available() { -#ifdef SK_BUILD_FOR_WINRT - static bool available = []{ - SkTScopedComPtr factory; - auto hr = CoCreateInstance( - CLSID_XpsOMObjectFactory, - nullptr, - CLSCTX_INPROC_SERVER, - IID_PPV_ARGS(&factory)); - return SUCCEEDED(hr); - }(); - return available; -#else - return true; -#endif +sk_sp SkDocument::MakeXPS(SkWStream* stream, + SkScalar dpi) { + SkTScopedComPtr factory; + auto hr = CoCreateInstance( + CLSID_XpsOMObjectFactory, + nullptr, + CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(&factory)); + if (!SUCCEEDED(hr)) { + return nullptr; + } + return SkDocument::MakeXPS (stream, factory, dpi); } sk_sp SkDocument::MakeXPS(SkWStream* stream, IXpsOMObjectFactory* factoryPtr, SkScalar dpi) { - if (!xps_available()) { - return nullptr; - } SkTScopedComPtr factory(SkSafeRefComPtr(factoryPtr)); return stream && factory ? sk_make_sp(stream, dpi, std::move(factory)) -- 2.7.4