9#if defined(SK_BUILD_FOR_WIN)
18#include <XpsObjectModel.h>
21struct SkXPSDocument final :
public SkDocument {
22 SkTScopedComPtr<IXpsOMObjectFactory> fXpsFactory;
24 std::unique_ptr<SkCanvas> fCanvas;
29 ~SkXPSDocument()
override;
39 SkTScopedComPtr<IXpsOMObjectFactory> xpsFactory)
41 , fXpsFactory(
std::move(xpsFactory))
42 , fDevice(
SkISize{10000, 10000})
45 fUnitsPerMeter.set(kPointsPerMeter, kPointsPerMeter);
47 fPixelsPerMeter.set(pixelsPerMeterScale, pixelsPerMeterScale);
49 fDevice.beginPortfolio(
stream, fXpsFactory.get());
52SkXPSDocument::~SkXPSDocument() {
58 fDevice.beginSheet(fUnitsPerMeter, fPixelsPerMeter, {
width,
height});
63void SkXPSDocument::onEndPage() {
65 fCanvas.reset(
nullptr);
71 (void)fDevice.endPortfolio();
74void SkXPSDocument::onAbort() {}
79 IXpsOMObjectFactory* factoryPtr,
81 SkTScopedComPtr<IXpsOMObjectFactory> factory(SkSafeRefComPtr(factoryPtr));
83 ? sk_make_sp<SkXPSDocument>(
stream, dpi, std::move(factory))
sk_sp< T > sk_ref_sp(T *obj)
#define SkDoubleToScalar(x)
virtual void onClose(SkWStream *)=0
virtual SkCanvas * onBeginPage(SkScalar width, SkScalar height)=0
virtual void onEndPage()=0
SK_API sk_sp< SkDocument > MakeDocument(SkWStream *stream, const Metadata &metadata)