From 5e221e7ca26130393a0527bb9b5155d6685b74ba Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Mon, 6 Feb 2017 09:51:42 -0500 Subject: SkXPS: new document API. Now requires a IXpsOMObjectFactory pointer. This will allow sandboxing to be used in Chromium. (Chrome will create a IXpsOMObjectFactory, then go into sandbox mode, then call SkDocumenent::MakeXPS().) Change-Id: Ic4b48d4b148c44e188d12a9481fb74735546528a Reviewed-on: https://skia-review.googlesource.com/8052 Reviewed-by: Ben Wagner Reviewed-by: Mike Reed Commit-Queue: Hal Canary --- src/xps/SkDocument_XPS_None.cpp | 17 ----------------- src/xps/SkXPSDocument.cpp | 36 ++---------------------------------- src/xps/SkXPSDocument.h | 3 +-- 3 files changed, 3 insertions(+), 53 deletions(-) delete mode 100644 src/xps/SkDocument_XPS_None.cpp (limited to 'src/xps') diff --git a/src/xps/SkDocument_XPS_None.cpp b/src/xps/SkDocument_XPS_None.cpp deleted file mode 100644 index b1c7ed4bcd..0000000000 --- a/src/xps/SkDocument_XPS_None.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "SkTypes.h" -#if !defined(SK_BUILD_FOR_WIN32) - -#include "SkDocument.h" -sk_sp SkDocument::MakeXPS(SkWStream*, SkScalar) { return nullptr; } -sk_sp SkDocument::MakeXPS(const char path[], SkScalar) { - return nullptr; -} - -#endif//!defined(SK_BUILD_FOR_WIN32) diff --git a/src/xps/SkXPSDocument.cpp b/src/xps/SkXPSDocument.cpp index 68672271e8..80dd5eea6a 100644 --- a/src/xps/SkXPSDocument.cpp +++ b/src/xps/SkXPSDocument.cpp @@ -14,10 +14,9 @@ #include "SkHRESULT.h" SkXPSDocument::SkXPSDocument(SkWStream* stream, - void (*doneProc)(SkWStream*, bool), SkScalar dpi, SkTScopedComPtr xpsFactory) - : SkDocument(stream, doneProc) + : SkDocument(stream, nullptr) , fXpsFactory(std::move(xpsFactory)) , fDevice(SkISize{10000, 10000}) { @@ -59,45 +58,14 @@ void SkXPSDocument::onClose(SkWStream*) { void SkXPSDocument::onAbort() {} - -static SkTScopedComPtr make_xps_factory() { - IXpsOMObjectFactory* factory; - HRN(CoCreateInstance(CLSID_XpsOMObjectFactory, - nullptr, - CLSCTX_INPROC_SERVER, - IID_PPV_ARGS(&factory))); - return SkTScopedComPtr(factory); -} - - /////////////////////////////////////////////////////////////////////////////// -// TODO(halcanary, reed): modify the SkDocument API to take a IXpsOMObjectFactory* pointer. -/* sk_sp SkDocument::MakeXPS(SkWStream* stream, IXpsOMObjectFactory* factoryPtr, SkScalar dpi) { SkTScopedComPtr factory(SkSafeRefComPtr(factoryPtr)); return stream && factory - ? sk_make_sp(stream, nullptr, dpi, std::move(factory)) - : nullptr; -} -*/ - -sk_sp SkDocument::MakeXPS(SkWStream* stream, SkScalar dpi) { - auto factory = make_xps_factory(); - return stream && factory - ? sk_make_sp(stream, nullptr, dpi, std::move(factory)) - : nullptr; -} - -sk_sp SkDocument::MakeXPS(const char path[], SkScalar dpi) { - std::unique_ptr stream(new SkFILEWStream(path)); - auto factory = make_xps_factory(); - return stream->isValid() && factory - ? sk_make_sp(stream.release(), - [](SkWStream* s, bool) { delete s; }, - dpi, std::move(factory)) + ? sk_make_sp(stream, dpi, std::move(factory)) : nullptr; } diff --git a/src/xps/SkXPSDocument.h b/src/xps/SkXPSDocument.h index fbaf57b36f..726af8f58f 100644 --- a/src/xps/SkXPSDocument.h +++ b/src/xps/SkXPSDocument.h @@ -20,8 +20,7 @@ class SkXPSDocument final : public SkDocument { public: - SkXPSDocument(SkWStream*, void (*doneProc)(SkWStream*, bool abort), - SkScalar dpi, SkTScopedComPtr); + SkXPSDocument(SkWStream*, SkScalar dpi, SkTScopedComPtr); virtual ~SkXPSDocument(); protected: -- cgit v1.2.3