• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef SkProxyCanvas_DEFINED
2 #define SkProxyCanvas_DEFINED
3 
4 #include "SkCanvas.h"
5 
6 /** This class overrides all virtual methods on SkCanvas, and redirects them
7     to a "proxy", another SkCanvas instance. It can be the basis for
8     intercepting (and possibly modifying) calls to a canvas.
9 
10     There must be a proxy installed before the proxycanvas can be used (i.e.
11     before its virtual methods can be called).
12  */
13 class SkProxyCanvas : public SkCanvas {
14 public:
SkProxyCanvas()15     SkProxyCanvas() : fProxy(NULL) {}
16     SkProxyCanvas(SkCanvas* proxy);
17     virtual ~SkProxyCanvas();
18 
getProxy()19     SkCanvas*   getProxy() const { return fProxy; }
20     void        setProxy(SkCanvas* proxy);
21 
22     // overrides from SkCanvas
23 
24     virtual bool getViewport(SkIPoint* size) const;
25     virtual bool setViewport(int x, int y);
26 
27     virtual SkDevice* setBitmapDevice(const SkBitmap& bitmap);
28 
29     virtual int save(SaveFlags flags = kMatrixClip_SaveFlag);
30     virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
31                           SaveFlags flags = kARGB_ClipLayer_SaveFlag);
32     virtual void restore();
33 
34     virtual bool translate(SkScalar dx, SkScalar dy);
35     virtual bool scale(SkScalar sx, SkScalar sy);
36     virtual bool rotate(SkScalar degrees);
37     virtual bool skew(SkScalar sx, SkScalar sy);
38     virtual bool concat(const SkMatrix& matrix);
39     virtual void setMatrix(const SkMatrix& matrix);
40 
41     virtual bool clipRect(const SkRect& rect,
42                           SkRegion::Op op = SkRegion::kIntersect_Op);
43     virtual bool clipPath(const SkPath& path,
44                           SkRegion::Op op = SkRegion::kIntersect_Op);
45     virtual bool clipRegion(const SkRegion& deviceRgn,
46                             SkRegion::Op op = SkRegion::kIntersect_Op);
47 
48     virtual void drawPaint(const SkPaint& paint);
49     virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
50                             const SkPaint& paint);
51     virtual void drawRect(const SkRect& rect, const SkPaint& paint);
52     virtual void drawPath(const SkPath& path, const SkPaint& paint);
53     virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
54                             const SkPaint* paint = NULL);
55     virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
56                                 const SkRect& dst, const SkPaint* paint = NULL);
57     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
58                                   const SkPaint* paint = NULL);
59     virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
60                             const SkPaint* paint = NULL);
61     virtual void drawText(const void* text, size_t byteLength, SkScalar x,
62                           SkScalar y, const SkPaint& paint);
63     virtual void drawPosText(const void* text, size_t byteLength,
64                              const SkPoint pos[], const SkPaint& paint);
65     virtual void drawPosTextH(const void* text, size_t byteLength,
66                               const SkScalar xpos[], SkScalar constY,
67                               const SkPaint& paint);
68     virtual void drawTextOnPath(const void* text, size_t byteLength,
69                                 const SkPath& path, const SkMatrix* matrix,
70                                 const SkPaint& paint);
71     virtual void drawPicture(SkPicture&);
72     virtual void drawShape(SkShape*);
73     virtual void drawVertices(VertexMode vmode, int vertexCount,
74                               const SkPoint vertices[], const SkPoint texs[],
75                               const SkColor colors[], SkXfermode* xmode,
76                               const uint16_t indices[], int indexCount,
77                               const SkPaint& paint);
78 
79     virtual SkBounder* setBounder(SkBounder* bounder);
80     virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter);
81 
82     virtual SkDevice* createDevice(SkBitmap::Config, int width, int height,
83                                    bool isOpaque, bool isForLayer);
84 
85 private:
86     SkCanvas*   fProxy;
87 
88     typedef SkCanvas INHERITED;
89 };
90 
91 #endif
92