1b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com/*
2b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com * Copyright 2011 Google Inc.
3b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com *
4b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com * Use of this source code is governed by a BSD-style license that can be
5b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com * found in the LICENSE file.
6b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com */
7b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
8b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#ifndef SkXPSDevice_DEFINED
9b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#define SkXPSDevice_DEFINED
10b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
11b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkTypes.h"
1247ef4d5d934bba86848aa238efab21f54a160c1ahalcanary
130cbe7ee765cf72f15e6ca10b308676aa077fb3e2halcanary#ifdef SK_BUILD_FOR_WIN
140cbe7ee765cf72f15e6ca10b308676aa077fb3e2halcanary
15b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include <ObjBase.h>
16b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include <XpsObjectModel.h>
17b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
18b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkAutoCoInitialize.h"
191f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com#include "SkBitmapDevice.h"
20b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkBitSet.h"
21b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkCanvas.h"
22b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkColor.h"
23b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkPaint.h"
24b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkPath.h"
25b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkPoint.h"
26b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkShader.h"
27b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkSize.h"
28b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkTArray.h"
29b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkTScopedComPtr.h"
30b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com#include "SkTypeface.h"
31b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
32da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner//#define SK_XPS_USE_DETERMINISTIC_IDS
33da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner
34b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com/** \class SkXPSDevice
35b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
36b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    The drawing context for the XPS backend.
37b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com*/
381f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.comclass SkXPSDevice : public SkBitmapDevice {
39b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.compublic:
40b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SK_API SkXPSDevice();
41b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SK_API virtual ~SkXPSDevice();
42b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
43b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual bool beginPortfolio(SkWStream* outputStream);
44b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    /**
45b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com      @param unitsPerMeter converts geometry units into physical units.
46b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com      @param pixelsPerMeter resolution to use when geometry must be rasterized.
47b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com      @param trimSize final page size in physical units.
48b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com                      The top left of the trim is the origin of physical space.
49b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com      @param mediaBox The size of the physical media in physical units.
50b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com                      The top and left must be less than zero.
51b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com                      The bottom and right must be greater than the trimSize.
52b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com                      The default is to coincide with the trimSize.
53b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com      @param bleedBox The size of the bleed box in physical units.
54b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com                      Must be contained within the mediaBox.
55b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com                      The default is to coincide with the mediaBox.
56b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com      @param artBox The size of the content box in physical units.
57b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com                    Must be contained within the trimSize.
58b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com                    The default is to coincide with the trimSize.
59b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com      @param cropBox The size of the recommended view port in physical units.
60b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com                     Must be contained within the mediaBox.
61b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com                     The default is to coincide with the mediaBox.
62b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com     */
63b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual bool beginSheet(
64b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkVector& unitsPerMeter,
65b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkVector& pixelsPerMeter,
66b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkSize& trimSize,
67b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkRect* mediaBox = NULL,
68b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkRect* bleedBox = NULL,
69b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkRect* artBox = NULL,
70b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkRect* cropBox = NULL);
71b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
72b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual bool endSheet();
73b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual bool endPortfolio();
74b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
75b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.comprotected:
7636352bf5e38f45a70ee4f4fc132a38048d38206dmtklein    void drawPaint(const SkDraw&, const SkPaint& paint) override;
77b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
78b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual void drawPoints(
79b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw&,
80b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        SkCanvas::PointMode mode,
81b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        size_t count, const SkPoint[],
8236352bf5e38f45a70ee4f4fc132a38048d38206dmtklein        const SkPaint& paint) override;
83b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
84b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual void drawRect(
85b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw&,
86b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkRect& r,
8736352bf5e38f45a70ee4f4fc132a38048d38206dmtklein        const SkPaint& paint) override;
88b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
89cac8d01eabd05d11365f56b6af3f30bccb173487scroggo@google.com    virtual void drawRRect(
90cac8d01eabd05d11365f56b6af3f30bccb173487scroggo@google.com        const SkDraw&,
91cac8d01eabd05d11365f56b6af3f30bccb173487scroggo@google.com        const SkRRect&,
9236352bf5e38f45a70ee4f4fc132a38048d38206dmtklein        const SkPaint& paint) override;
93cac8d01eabd05d11365f56b6af3f30bccb173487scroggo@google.com
94b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual void drawPath(
95b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw&,
96b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkPath& platonicPath,
97b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkPaint& paint,
98b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkMatrix* prePathMatrix,
9936352bf5e38f45a70ee4f4fc132a38048d38206dmtklein        bool pathIsMutable) override;
100b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
101b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual void drawBitmap(
102b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw&,
103b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkBitmap& bitmap,
104b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkMatrix& matrix,
10536352bf5e38f45a70ee4f4fc132a38048d38206dmtklein        const SkPaint& paint) override;
106b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
107b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual void drawSprite(
108b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw&,
109b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkBitmap& bitmap,
110b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        int x, int y,
11136352bf5e38f45a70ee4f4fc132a38048d38206dmtklein        const SkPaint& paint) override;
112b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
113b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual void drawText(
114b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw&,
115b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const void* text, size_t len,
116b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        SkScalar x, SkScalar y,
11736352bf5e38f45a70ee4f4fc132a38048d38206dmtklein        const SkPaint& paint) override;
118b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
119b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual void drawPosText(
120b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw&,
121b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const void* text, size_t len,
12205c4a4322e7d4f3417b7df33825bab8603d52051fmalita        const SkScalar pos[], int scalarsPerPos,
12336352bf5e38f45a70ee4f4fc132a38048d38206dmtklein        const SkPoint& offset, const SkPaint& paint) override;
124b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
125b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual void drawVertices(
126b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw&,
127b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        SkCanvas::VertexMode,
128b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        int vertexCount, const SkPoint verts[],
129b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkPoint texs[], const SkColor colors[],
130b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        SkXfermode* xmode,
131b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const uint16_t indices[], int indexCount,
13236352bf5e38f45a70ee4f4fc132a38048d38206dmtklein        const SkPaint& paint) override;
133b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
134b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    virtual void drawDevice(
135b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw&,
1361f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com        SkBaseDevice* device,
137b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        int x, int y,
13836352bf5e38f45a70ee4f4fc132a38048d38206dmtklein        const SkPaint& paint) override;
139b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
140b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.comprivate:
141b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    class TypefaceUse : ::SkNoncopyable {
142b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    public:
143b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        SkFontID typefaceId;
144b5e34e22aa0e019e25f9f913f0e119a9a97e5562commit-bot@chromium.org        int ttcIndex;
145b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        SkStream* fontData;
146b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMFontResource* xpsFont;
147b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        SkBitSet* glyphsUsed;
14874b461961607fa57a150a9282c410ef0cab38764vandebo@chromium.org
149b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        explicit TypefaceUse();
150b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        ~TypefaceUse();
151b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    };
152b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    friend static HRESULT subset_typeface(TypefaceUse* current);
153b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
154b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SkXPSDevice(IXpsOMObjectFactory* xpsFactory);
155b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
156b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SkAutoCoInitialize fAutoCo;
157b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SkTScopedComPtr<IXpsOMObjectFactory> fXpsFactory;
158b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SkTScopedComPtr<IStream> fOutputStream;
159b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SkTScopedComPtr<IXpsOMPackageWriter> fPackageWriter;
160b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
161b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    unsigned int fCurrentPage;
162b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SkTScopedComPtr<IXpsOMCanvas> fCurrentXpsCanvas;
163b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SkSize fCurrentCanvasSize;
164b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SkVector fCurrentUnitsPerMeter;
165b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SkVector fCurrentPixelsPerMeter;
166b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
167b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SkTArray<TypefaceUse, true> fTypefaces;
168b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
169da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner    /** Creates a GUID based id and places it into buffer.
170da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner        buffer should have space for at least GUID_ID_LEN wide characters.
171da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner        The string will always be wchar null terminated.
172da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner        XXXXXXXXsXXXXsXXXXsXXXXsXXXXXXXXXXXX0
173da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner        The string may begin with a digit,
174da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner        and so may not be suitable as a bare resource key.
175da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner     */
176da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner    HRESULT createId(wchar_t* buffer, size_t bufferSize, wchar_t sep = '-');
177da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner#ifdef SK_XPS_USE_DETERMINISTIC_IDS
178da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner    decltype(GUID::Data1) fNextId = 0;
179da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner#endif
180da5a1b8cd80bbea1dfdb474c6917a1f13a0e7f9eBen Wagner
181b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT initXpsDocumentWriter(IXpsOMImageResource* image);
182b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
183b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT createXpsPage(
184b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const XPS_SIZE& pageSize,
185b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMPage** page);
186b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
187b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT createXpsThumbnail(
188b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMPage* page, const unsigned int pageNumber,
189b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMImageResource** image);
190b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
191b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    void internalDrawRect(
192b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw&,
193b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkRect& r,
194b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        bool transformRect,
195b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkPaint& paint);
196b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
197b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT createXpsBrush(
198b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkPaint& skPaint,
199b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMBrush** xpsBrush,
200b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkMatrix* parentTransform = NULL);
201b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
202b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT createXpsSolidColorBrush(
203b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkColor skColor, const SkAlpha alpha,
204b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMBrush** xpsBrush);
205b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
206b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT createXpsImageBrush(
207b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkBitmap& bitmap,
208b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkMatrix& localMatrix,
209b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkShader::TileMode (&xy)[2],
210b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkAlpha alpha,
211b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMTileBrush** xpsBrush);
212b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
213b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT createXpsLinearGradient(
214b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        SkShader::GradientInfo info,
215b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkAlpha alpha,
216b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkMatrix& localMatrix,
217b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMMatrixTransform* xpsMatrixToUse,
218b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMBrush** xpsBrush);
219b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
220b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT createXpsRadialGradient(
221b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        SkShader::GradientInfo info,
222b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkAlpha alpha,
223b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkMatrix& localMatrix,
224b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMMatrixTransform* xpsMatrixToUse,
225b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMBrush** xpsBrush);
226b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
227b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT createXpsGradientStop(
228b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkColor skColor,
229b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkScalar offset,
230b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMGradientStop** xpsGradStop);
231b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
232b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT createXpsTransform(
233b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkMatrix& matrix,
234b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMMatrixTransform ** xpsTransform);
235b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
236b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT createXpsRect(
237b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkRect& rect,
238b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        BOOL stroke, BOOL fill,
239b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMGeometryFigure** xpsRect);
240b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
241b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT createXpsQuad(
242b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkPoint (&points)[4],
243b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        BOOL stroke, BOOL fill,
244b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMGeometryFigure** xpsQuad);
245b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
246b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT CreateTypefaceUse(
247b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkPaint& paint,
248b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        TypefaceUse** fontResource);
249b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
250b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT AddGlyphs(
251b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw& d,
252b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMObjectFactory* xpsFactory,
253b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMCanvas* canvas,
254b5e34e22aa0e019e25f9f913f0e119a9a97e5562commit-bot@chromium.org        TypefaceUse* font,
255b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        LPCWSTR text,
256b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        XPS_GLYPH_INDEX* xpsGlyphs,
257b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        UINT32 xpsGlyphsLen,
258b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        XPS_POINT *origin,
259b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        FLOAT fontSize,
260b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        XPS_STYLE_SIMULATION sims,
261b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkMatrix& transform,
262b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkPaint& paint);
263b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
264b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT addXpsPathGeometry(
265b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMGeometryFigureCollection* figures,
266b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        BOOL stroke, BOOL fill, const SkPath& path);
267b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
268b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT createPath(
269b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMGeometryFigure* figure,
270b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMVisualCollection* visuals,
271b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMPath** path);
272b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
273b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT sideOfClamp(
274b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkRect& leftPoints, const XPS_RECT& left,
275b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMImageResource* imageResource,
276b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMVisualCollection* visuals);
277b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
278b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT cornerOfClamp(
279b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkRect& tlPoints,
280b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkColor color,
281b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMVisualCollection* visuals);
282b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
283b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT clip(
284b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMVisual* xpsVisual,
285b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw& d);
286b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT clipToPath(
287b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMVisual* xpsVisual,
288b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkPath& clipPath,
289b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        XPS_FILL_RULE fillRule);
290b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
291b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT drawInverseWindingPath(
292b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw& d,
293b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkPath& devicePath,
294b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMPath* xpsPath);
295b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
296b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT shadePath(
297b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMPath* shadedPath,
298b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkPaint& shaderPaint,
299b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkMatrix& matrix,
300b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        BOOL* fill, BOOL* stroke);
301b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
302b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    void convertToPpm(
303b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkMaskFilter* filter,
304b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        SkMatrix* matrix,
305b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        SkVector* ppuScale,
306b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkIRect& clip, SkIRect* clipIRect);
307b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
308b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    HRESULT applyMask(
309b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkDraw& d,
310b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkMask& mask,
311b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        const SkVector& ppuScale,
312b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com        IXpsOMPath* shadedPath);
313b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
31436352bf5e38f45a70ee4f4fc132a38048d38206dmtklein    SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
315b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
316b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    // Disable the default copy and assign implementation.
317b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    SkXPSDevice(const SkXPSDevice&);
318b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com    void operator=(const SkXPSDevice&);
319b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
3201f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    typedef SkBitmapDevice INHERITED;
321b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com};
322b29c883fb46ac6099440d82ac57b86d25386daedbungeman@google.com
3230cbe7ee765cf72f15e6ca10b308676aa077fb3e2halcanary#endif  // SK_BUILD_FOR_WIN
3240cbe7ee765cf72f15e6ca10b308676aa077fb3e2halcanary#endif  // SkXPSDevice_DEFINED
325