Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: src/pdf/SkPDFDevice.h

Issue 1767713002: SkPDF: PDFDevice use SkTArray<T> rather than SkTDArray<T*> (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkPDFDevice_DEFINED 8 #ifndef SkPDFDevice_DEFINED
9 #define SkPDFDevice_DEFINED 9 #define SkPDFDevice_DEFINED
10 10
11 #include "SkBitmap.h" 11 #include "SkBitmap.h"
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 #include "SkClipStack.h" 13 #include "SkClipStack.h"
14 #include "SkData.h"
14 #include "SkDevice.h" 15 #include "SkDevice.h"
15 #include "SkPaint.h" 16 #include "SkPaint.h"
16 #include "SkPath.h" 17 #include "SkPath.h"
17 #include "SkPicture.h" 18 #include "SkPicture.h"
18 #include "SkRect.h" 19 #include "SkRect.h"
19 #include "SkRefCnt.h" 20 #include "SkRefCnt.h"
20 #include "SkStream.h" 21 #include "SkStream.h"
21 #include "SkTDArray.h" 22 #include "SkTDArray.h"
22 #include "SkTemplates.h" 23 #include "SkTemplates.h"
23 24
24 class SkPDFArray; 25 class SkPDFArray;
25 class SkPDFCanon; 26 class SkPDFCanon;
26 class SkPDFDevice; 27 class SkPDFDevice;
27 class SkPDFDict; 28 class SkPDFDict;
28 class SkPDFFont; 29 class SkPDFFont;
29 class SkPDFFormXObject; 30 class SkPDFFormXObject;
30 class SkPDFGlyphSetMap; 31 class SkPDFGlyphSetMap;
31 class SkPDFGraphicState; 32 class SkPDFGraphicState;
32 class SkPDFObject; 33 class SkPDFObject;
33 class SkPDFShader; 34 class SkPDFShader;
34 class SkPDFStream; 35 class SkPDFStream;
35 class SkRRect; 36 class SkRRect;
36 37
37 // Private classes. 38 // Private classes.
38 struct ContentEntry; 39 struct ContentEntry;
39 struct GraphicStateEntry; 40 struct GraphicStateEntry;
40 struct NamedDestination;
41 struct RectWithData;
42 41
43 /** \class SkPDFDevice 42 /** \class SkPDFDevice
44 43
45 The drawing context for the PDF backend. 44 The drawing context for the PDF backend.
46 */ 45 */
47 class SkPDFDevice final : public SkBaseDevice { 46 class SkPDFDevice final : public SkBaseDevice {
48 public: 47 public:
49 /** Create a PDF drawing context. SkPDFDevice applies a 48 /** Create a PDF drawing context. SkPDFDevice applies a
50 * scale-and-translate transform to move the origin from the 49 * scale-and-translate transform to move the origin from the
51 * bottom left (PDF default) to the top left (Skia default). 50 * bottom left (PDF default) to the top left (Skia default).
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 SkPDFCanon* getCanon() const { return fCanon; } 191 SkPDFCanon* getCanon() const { return fCanon; }
193 192
194 protected: 193 protected:
195 const SkBitmap& onAccessBitmap() override { 194 const SkBitmap& onAccessBitmap() override {
196 return fLegacyBitmap; 195 return fLegacyBitmap;
197 } 196 }
198 197
199 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override; 198 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override;
200 199
201 private: 200 private:
201 struct RectWithData {
202 SkRect rect;
203 sk_sp<const SkData> data;
204 RectWithData(const SkRect& rect, const SkData* data)
205 : rect(rect), data(SkRef(data)) {}
206 };
207
208 struct NamedDestination {
209 sk_sp<const SkData> nameData;
210 SkPoint point;
211 NamedDestination(const SkData* nameData, const SkPoint& point)
212 : nameData(SkRef(nameData)), point(point) {}
213 };
214
202 // TODO(vandebo): push most of SkPDFDevice's state into a core object in 215 // TODO(vandebo): push most of SkPDFDevice's state into a core object in
203 // order to get the right access levels without using friend. 216 // order to get the right access levels without using friend.
204 friend class ScopedContentEntry; 217 friend class ScopedContentEntry;
205 218
206 SkISize fPageSize; 219 SkISize fPageSize;
207 SkISize fContentSize; 220 SkISize fContentSize;
208 SkMatrix fInitialTransform; 221 SkMatrix fInitialTransform;
209 SkClipStack fExistingClipStack; 222 SkClipStack fExistingClipStack;
210 SkRegion fExistingClipRegion; 223 SkRegion fExistingClipRegion;
211 224
212 SkTDArray<RectWithData*> fLinkToURLs; 225 SkTArray<RectWithData> fLinkToURLs;
213 SkTDArray<RectWithData*> fLinkToDestinations; 226 SkTArray<RectWithData> fLinkToDestinations;
214 SkTDArray<NamedDestination*> fNamedDestinations; 227 SkTArray<NamedDestination> fNamedDestinations;
215 228
216 SkTDArray<SkPDFObject*> fGraphicStateResources; 229 SkTDArray<SkPDFObject*> fGraphicStateResources;
217 SkTDArray<SkPDFObject*> fXObjectResources; 230 SkTDArray<SkPDFObject*> fXObjectResources;
218 SkTDArray<SkPDFFont*> fFontResources; 231 SkTDArray<SkPDFFont*> fFontResources;
219 SkTDArray<SkPDFObject*> fShaderResources; 232 SkTDArray<SkPDFObject*> fShaderResources;
220 233
221 SkAutoTDelete<ContentEntry> fContentEntries; 234 SkAutoTDelete<ContentEntry> fContentEntries;
222 ContentEntry* fLastContentEntry; 235 ContentEntry* fLastContentEntry;
223 SkAutoTDelete<ContentEntry> fMarginContentEntries; 236 SkAutoTDelete<ContentEntry> fMarginContentEntries;
224 ContentEntry* fLastMarginContentEntry; 237 ContentEntry* fLastMarginContentEntry;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 323
311 typedef SkBaseDevice INHERITED; 324 typedef SkBaseDevice INHERITED;
312 325
313 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to create 326 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to create
314 // an SkPDFDevice 327 // an SkPDFDevice
315 //friend class SkDocument_PDF; 328 //friend class SkDocument_PDF;
316 //friend class SkPDFImageShader; 329 //friend class SkPDFImageShader;
317 }; 330 };
318 331
319 #endif 332 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698