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