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