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

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

Issue 354133002: change gpudevice and pdfdevice to inherit from basedevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkPDFDevice_DEFINED 10 #ifndef SkPDFDevice_DEFINED
11 #define SkPDFDevice_DEFINED 11 #define SkPDFDevice_DEFINED
12 12
13 #include "SkBitmapDevice.h" 13 #include "SkDevice.h"
14 #include "SkBitmap.h" 14 #include "SkBitmap.h"
15 #include "SkCanvas.h" 15 #include "SkCanvas.h"
16 #include "SkPaint.h" 16 #include "SkPaint.h"
17 #include "SkPath.h" 17 #include "SkPath.h"
18 #include "SkPicture.h" 18 #include "SkPicture.h"
19 #include "SkRect.h" 19 #include "SkRect.h"
20 #include "SkRefCnt.h" 20 #include "SkRefCnt.h"
21 #include "SkStream.h" 21 #include "SkStream.h"
22 #include "SkTDArray.h" 22 #include "SkTDArray.h"
23 #include "SkTemplates.h" 23 #include "SkTemplates.h"
(...skipping 14 matching lines...) Expand all
38 38
39 // Private classes. 39 // Private classes.
40 struct ContentEntry; 40 struct ContentEntry;
41 struct GraphicStateEntry; 41 struct GraphicStateEntry;
42 struct NamedDestination; 42 struct NamedDestination;
43 43
44 /** \class SkPDFDevice 44 /** \class SkPDFDevice
45 45
46 The drawing context for the PDF backend. 46 The drawing context for the PDF backend.
47 */ 47 */
48 class SkPDFDevice : public SkBitmapDevice { 48 class SkPDFDevice : public SkBaseDevice {
49 public: 49 public:
50 /** Create a PDF drawing context with the given width and height. 50 /** Create a PDF drawing context with the given width and height.
51 * 72 points/in means letter paper is 612x792. 51 * 72 points/in means letter paper is 612x792.
52 * @param pageSize Page size in points. 52 * @param pageSize Page size in points.
53 * @param contentSize The content size of the page in points. This will be 53 * @param contentSize The content size of the page in points. This will be
54 * combined with the initial transform to determine the drawing area 54 * combined with the initial transform to determine the drawing area
55 * (as reported by the width and height methods). Anything outside 55 * (as reported by the width and height methods). Anything outside
56 * of the drawing area will be clipped. 56 * of the drawing area will be clipped.
57 * @param initialTransform The initial transform to apply to the page. 57 * @param initialTransform The initial transform to apply to the page.
58 * This may be useful to, for example, move the origin in and 58 * This may be useful to, for example, move the origin in and
(...skipping 16 matching lines...) Expand all
75 /** These are called inside the per-device-layer loop for each draw call. 75 /** These are called inside the per-device-layer loop for each draw call.
76 When these are called, we have already applied any saveLayer operations, 76 When these are called, we have already applied any saveLayer operations,
77 and are handling any looping from the paint, and any effects from the 77 and are handling any looping from the paint, and any effects from the
78 DrawFilter. 78 DrawFilter.
79 */ 79 */
80 virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; 80 virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE;
81 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, 81 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode,
82 size_t count, const SkPoint[], 82 size_t count, const SkPoint[],
83 const SkPaint& paint) SK_OVERRIDE; 83 const SkPaint& paint) SK_OVERRIDE;
84 virtual void drawRect(const SkDraw&, const SkRect& r, const SkPaint& paint); 84 virtual void drawRect(const SkDraw&, const SkRect& r, const SkPaint& paint);
85 virtual void drawRRect(const SkDraw&, const SkRRect& rr, 85 virtual void drawOval(const SkDraw&, const SkRect& oval, const SkPaint& pain t) SK_OVERRIDE;
86 const SkPaint& paint) SK_OVERRIDE; 86 virtual void drawRRect(const SkDraw&, const SkRRect& rr, const SkPaint& pain t) SK_OVERRIDE;
87 virtual void drawPath(const SkDraw&, const SkPath& origpath, 87 virtual void drawPath(const SkDraw&, const SkPath& origpath,
88 const SkPaint& paint, const SkMatrix* prePathMatrix, 88 const SkPaint& paint, const SkMatrix* prePathMatrix,
89 bool pathIsMutable) SK_OVERRIDE; 89 bool pathIsMutable) SK_OVERRIDE;
90 virtual void drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, 90 virtual void drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
91 const SkRect* src, const SkRect& dst, 91 const SkRect* src, const SkRect& dst,
92 const SkPaint& paint, 92 const SkPaint& paint,
93 SkCanvas::DrawBitmapRectFlags flags) SK_OVERRIDE ; 93 SkCanvas::DrawBitmapRectFlags flags) SK_OVERRIDE ;
94 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, 94 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
95 const SkMatrix& matrix, const SkPaint&) SK_OVERRIDE; 95 const SkMatrix& matrix, const SkPaint&) SK_OVERRIDE;
96 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, int x, int y, 96 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, int x, int y,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 * intent with better fidelity, but it can make for larger 201 * intent with better fidelity, but it can make for larger
202 * PDF files too, which would use more memory while rendering, 202 * PDF files too, which would use more memory while rendering,
203 * and it would be slower to be processed or sent online or 203 * and it would be slower to be processed or sent online or
204 * to printer. 204 * to printer.
205 */ 205 */
206 void setRasterDpi(SkScalar rasterDpi) { 206 void setRasterDpi(SkScalar rasterDpi) {
207 fRasterDpi = rasterDpi; 207 fRasterDpi = rasterDpi;
208 } 208 }
209 209
210 protected: 210 protected:
211 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE;
211 virtual bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE; 212 virtual bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE;
212 213
213 private: 214 private:
214 // 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
215 // order to get the right access levels without using friend. 216 // order to get the right access levels without using friend.
216 friend class ScopedContentEntry; 217 friend class ScopedContentEntry;
217 218
218 SkISize fPageSize; 219 SkISize fPageSize;
219 SkISize fContentSize; 220 SkISize fContentSize;
220 SkMatrix fInitialTransform; 221 SkMatrix fInitialTransform;
(...skipping 20 matching lines...) Expand all
241 SkAutoTDelete<ContentEntry>* getContentEntries(); 242 SkAutoTDelete<ContentEntry>* getContentEntries();
242 ContentEntry* getLastContentEntry(); 243 ContentEntry* getLastContentEntry();
243 void setLastContentEntry(ContentEntry* contentEntry); 244 void setLastContentEntry(ContentEntry* contentEntry);
244 245
245 // Glyph ids used for each font on this device. 246 // Glyph ids used for each font on this device.
246 SkAutoTDelete<SkPDFGlyphSetMap> fFontGlyphUsage; 247 SkAutoTDelete<SkPDFGlyphSetMap> fFontGlyphUsage;
247 248
248 SkPicture::EncodeBitmap fEncoder; 249 SkPicture::EncodeBitmap fEncoder;
249 SkScalar fRasterDpi; 250 SkScalar fRasterDpi;
250 251
252 SkBitmap fLegacyBitmap;
253
251 SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack, 254 SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack,
252 const SkRegion& existingClipRegion); 255 const SkRegion& existingClipRegion);
253 256
254 // override from SkBaseDevice 257 // override from SkBaseDevice
255 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE; 258 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE;
256 259
257 void init(); 260 void init();
258 void cleanUp(bool clearFontUsage); 261 void cleanUp(bool clearFontUsage);
259 SkPDFFormXObject* createFormXObjectFromDevice(); 262 SkPDFFormXObject* createFormXObjectFromDevice();
260 263
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 bool handlePointAnnotation(const SkPoint* points, size_t count, 319 bool handlePointAnnotation(const SkPoint* points, size_t count,
317 const SkMatrix& matrix, const SkPaint& paint); 320 const SkMatrix& matrix, const SkPaint& paint);
318 SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix); 321 SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix);
319 void handleLinkToURL(SkData* urlData, const SkRect& r, 322 void handleLinkToURL(SkData* urlData, const SkRect& r,
320 const SkMatrix& matrix); 323 const SkMatrix& matrix);
321 void handleLinkToNamedDest(SkData* nameData, const SkRect& r, 324 void handleLinkToNamedDest(SkData* nameData, const SkRect& r,
322 const SkMatrix& matrix); 325 const SkMatrix& matrix);
323 void defineNamedDestination(SkData* nameData, const SkPoint& point, 326 void defineNamedDestination(SkData* nameData, const SkPoint& point,
324 const SkMatrix& matrix); 327 const SkMatrix& matrix);
325 328
326 typedef SkBitmapDevice INHERITED; 329 typedef SkBaseDevice INHERITED;
327 330
328 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to create 331 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to create
329 // an SkPDFDevice 332 // an SkPDFDevice
330 //friend class SkDocument_PDF; 333 //friend class SkDocument_PDF;
331 //friend class SkPDFImageShader; 334 //friend class SkPDFImageShader;
332 }; 335 };
333 336
334 #endif 337 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698