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/SkRefCnt.h" |
| 14 #include "third_party/skia/include/core/SkTScopedPtr.h" |
| 15 #include "third_party/skia/include/pdf/SkPDFDevice.h" |
| 16 |
| 17 class SkClipStack; |
| 18 struct SkIRect; |
| 19 struct SkRect; |
| 20 |
| 21 namespace skia { |
| 22 |
| 23 class BitmapPlatformDevice; |
| 24 |
| 25 class VectorPlatformDeviceSkiaFactory : public SkDeviceFactory { |
| 26 public: |
| 27 virtual SkDevice* newDevice(SkCanvas* notUsed, SkBitmap::Config config, |
| 28 int width, int height, bool isOpaque, |
| 29 bool isForLayer); |
| 30 }; |
| 31 |
| 32 class VectorPlatformDeviceSkia : public PlatformDevice { |
| 33 public: |
| 34 VectorPlatformDeviceSkia(int width, int height, |
| 35 SkPDFDevice::OriginTransform flip); |
| 36 |
| 37 ~VectorPlatformDeviceSkia(); |
| 38 |
| 39 SkPDFDevice* PdfDevice() { return pdf_device_.get(); } |
| 40 |
| 41 // PlatformDevice methods. |
| 42 virtual bool IsVectorial(); |
| 43 virtual bool IsNativeFontRenderingAllowed(); |
| 44 |
| 45 virtual PlatformSurface BeginPlatformPaint(); |
| 46 virtual void EndPlatformPaint(); |
| 47 |
| 48 // SkDevice methods. |
| 49 virtual SkDeviceFactory* getDeviceFactory(); |
| 50 virtual uint32_t getDeviceCapabilities(); |
| 51 |
| 52 virtual int width() const; |
| 53 virtual int height() const; |
| 54 virtual void setMatrixClip(const SkMatrix& matrix, const SkRegion& region, |
| 55 const SkClipStack& stack); |
| 56 virtual bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap); |
| 57 |
| 58 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint); |
| 59 virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, |
| 60 size_t count, const SkPoint[], const SkPaint& paint); |
| 61 virtual void drawRect(const SkDraw& draw, const SkRect& rect, |
| 62 const SkPaint& paint); |
| 63 virtual void drawPath(const SkDraw& draw, const SkPath& path, |
| 64 const SkPaint& paint, const SkMatrix* prePathMatrix, |
| 65 bool pathIsMutable); |
| 66 virtual void drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, |
| 67 const SkIRect* srcRectOrNull, const SkMatrix& matrix, |
| 68 const SkPaint& paint); |
| 69 virtual void drawSprite(const SkDraw& draw, const SkBitmap& bitmap, |
| 70 int x, int y, const SkPaint& paint); |
| 71 virtual void drawText(const SkDraw& draw, const void* text, size_t len, |
| 72 SkScalar x, SkScalar y, const SkPaint& paint); |
| 73 virtual void drawPosText(const SkDraw& draw, const void* text, size_t len, |
| 74 const SkScalar pos[], SkScalar constY, |
| 75 int scalarsPerPos, const SkPaint& paint); |
| 76 virtual void drawTextOnPath(const SkDraw& draw, const void* text, size_t len, |
| 77 const SkPath& path, const SkMatrix* matrix, |
| 78 const SkPaint& paint); |
| 79 virtual void drawVertices(const SkDraw& draw, SkCanvas::VertexMode, |
| 80 int vertexCount, const SkPoint verts[], |
| 81 const SkPoint texs[], const SkColor colors[], |
| 82 SkXfermode* xmode, const uint16_t indices[], |
| 83 int indexCount, const SkPaint& paint); |
| 84 virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y, |
| 85 const SkPaint&); |
| 86 |
| 87 #if defined(OS_WIN) |
| 88 virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect); |
| 89 #endif |
| 90 |
| 91 // Our own methods. |
| 92 |
| 93 // This needs to be called before anything is drawn. |
| 94 void setInitialTransform(int xOffset, int yOffset, float scale_factor); |
| 95 |
| 96 private: |
| 97 SkRefPtr<SkPDFDevice> pdf_device_; |
| 98 SkMatrix base_transform_; |
| 99 SkRefPtr<BitmapPlatformDevice> raster_surface_; |
| 100 |
| 101 DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceSkia); |
| 102 }; |
| 103 |
| 104 } // namespace skia |
| 105 |
| 106 #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_SKIA_H_ |
OLD | NEW |