OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SKIA_EXT_VECTOR_PLATFORM_DEVICE_SKIA_H_ | |
6 #define SKIA_EXT_VECTOR_PLATFORM_DEVICE_SKIA_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/logging.h" | |
11 #include "skia/ext/platform_device.h" | |
12 #include "third_party/skia/include/core/SkMatrix.h" | |
13 #include "third_party/skia/include/core/SkRect.h" | |
Lei Zhang
2011/04/06 20:43:56
I think you can forward declare?
vandebo (ex-Chrome)
2011/04/06 22:01:37
Done.
| |
14 #include "third_party/skia/include/core/SkRefCnt.h" | |
15 #include "third_party/skia/include/core/SkTScopedPtr.h" | |
16 #include "third_party/skia/include/pdf/SkPDFDevice.h" | |
17 | |
18 class SkClipStack; | |
19 | |
20 namespace skia { | |
21 | |
22 class BitmapPlatformDevice; | |
23 | |
24 class VectorPlatformDeviceSkiaFactory : public SkDeviceFactory { | |
25 public: | |
26 virtual SkDevice* newDevice(SkCanvas* notUsed, SkBitmap::Config config, | |
27 int width, int height, bool isOpaque, | |
28 bool isForLayer); | |
29 }; | |
30 | |
31 class VectorPlatformDeviceSkia : public PlatformDevice { | |
alokp
2011/04/06 20:36:32
This is consistent with other vector-devices and s
vandebo (ex-Chrome)
2011/04/06 22:01:37
I have to override all the methods to get them to
| |
32 public: | |
33 VectorPlatformDeviceSkia(int width, int height, | |
34 SkPDFDevice::OriginTransform flip); | |
35 | |
36 ~VectorPlatformDeviceSkia(); | |
37 | |
38 SkPDFDevice* PdfDevice() { return pdf_device_.get(); } | |
39 | |
40 // PlatformDevice methods. | |
41 virtual bool IsVectorial(); | |
42 virtual bool IsNativeFontRenderingAllowed(); | |
43 | |
44 virtual PlatformSurface beginPlatformPaint(); | |
45 virtual void endPlatformPaint(); | |
46 | |
47 // SkDevice methods. | |
48 virtual SkDeviceFactory* getDeviceFactory(); | |
49 virtual uint32_t getDeviceCapabilities(); | |
50 | |
51 virtual int width() const; | |
52 virtual int height() const; | |
53 virtual void setMatrixClip(const SkMatrix& matrix, const SkRegion& region, | |
54 const SkClipStack& stack); | |
55 virtual bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap); | |
56 | |
57 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint); | |
58 virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, | |
59 size_t count, const SkPoint[], const SkPaint& paint); | |
60 virtual void drawRect(const SkDraw& draw, const SkRect& rect, | |
61 const SkPaint& paint); | |
62 virtual void drawPath(const SkDraw& draw, const SkPath& path, | |
63 const SkPaint& paint, const SkMatrix* prePathMatrix, | |
64 bool pathIsMutable); | |
65 virtual void drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, | |
66 const SkIRect* srcRectOrNull, const SkMatrix& matrix, | |
67 const SkPaint& paint); | |
68 virtual void drawSprite(const SkDraw& draw, const SkBitmap& bitmap, | |
69 int x, int y, const SkPaint& paint); | |
70 virtual void drawText(const SkDraw& draw, const void* text, size_t len, | |
71 SkScalar x, SkScalar y, const SkPaint& paint); | |
72 virtual void drawPosText(const SkDraw& draw, const void* text, size_t len, | |
73 const SkScalar pos[], SkScalar constY, | |
74 int scalarsPerPos, const SkPaint& paint); | |
75 virtual void drawTextOnPath(const SkDraw& draw, const void* text, size_t len, | |
76 const SkPath& path, const SkMatrix* matrix, | |
77 const SkPaint& paint); | |
78 virtual void drawVertices(const SkDraw& draw, SkCanvas::VertexMode, | |
79 int vertexCount, const SkPoint verts[], | |
80 const SkPoint texs[], const SkColor colors[], | |
81 SkXfermode* xmode, const uint16_t indices[], | |
82 int indexCount, const SkPaint& paint); | |
83 virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y, | |
84 const SkPaint&); | |
85 | |
86 #if defined(OS_WIN) | |
87 virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect); | |
88 #endif | |
89 | |
90 // Our own methods. | |
91 | |
92 // This needs to be called before anything is drawn. | |
93 void setInitialTransform(int xOffset, int yOffset, float scale_factor); | |
94 | |
95 private: | |
96 SkRefPtr<SkPDFDevice> pdf_device_; | |
97 SkMatrix base_transform_; | |
98 SkRefPtr<BitmapPlatformDevice> raster_surface_; | |
99 | |
100 DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceSkia); | |
101 }; | |
102 | |
103 } // namespace skia | |
104 | |
105 #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_SKIA_H_ | |
OLD | NEW |