gfx/skia/trunk/include/device/xps/SkXPSDevice.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial