blob: 383e532fbfca4d849f959dadbadc9cbf961248e5 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
reed@android.com8a1c16f2008-12-17 15:59:43 +00008#ifndef SkProxyCanvas_DEFINED
9#define SkProxyCanvas_DEFINED
10
11#include "SkCanvas.h"
12
13/** This class overrides all virtual methods on SkCanvas, and redirects them
14 to a "proxy", another SkCanvas instance. It can be the basis for
15 intercepting (and possibly modifying) calls to a canvas.
vandebo@chromium.org74b46192012-01-28 01:45:11 +000016
reed@android.com8a1c16f2008-12-17 15:59:43 +000017 There must be a proxy installed before the proxycanvas can be used (i.e.
18 before its virtual methods can be called).
19 */
commit-bot@chromium.orge1a81d22013-07-15 22:49:37 +000020class SK_API SkProxyCanvas : public SkCanvas {
reed@android.com8a1c16f2008-12-17 15:59:43 +000021public:
22 SkProxyCanvas() : fProxy(NULL) {}
23 SkProxyCanvas(SkCanvas* proxy);
24 virtual ~SkProxyCanvas();
vandebo@chromium.org74b46192012-01-28 01:45:11 +000025
reed@android.com8a1c16f2008-12-17 15:59:43 +000026 SkCanvas* getProxy() const { return fProxy; }
27 void setProxy(SkCanvas* proxy);
vandebo@chromium.org74b46192012-01-28 01:45:11 +000028
reed@google.com2d4297c2011-10-06 13:14:12 +000029 virtual int save(SaveFlags flags = kMatrixClip_SaveFlag) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000030 virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
reed@google.com2d4297c2011-10-06 13:14:12 +000031 SaveFlags flags = kARGB_ClipLayer_SaveFlag) SK_OVERRIDE;
32 virtual void restore() SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000033
reed@google.com2d4297c2011-10-06 13:14:12 +000034 virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
35 virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
36 virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
37 virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE;
38 virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
39 virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
vandebo@chromium.org74b46192012-01-28 01:45:11 +000040
reed@google.com071eef92011-10-12 11:52:53 +000041 virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE;
reed@google.com4ed0fb72012-12-12 20:48:18 +000042 virtual bool clipRRect(const SkRRect&, SkRegion::Op, bool) SK_OVERRIDE;
reed@google.com071eef92011-10-12 11:52:53 +000043 virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000044 virtual bool clipRegion(const SkRegion& deviceRgn,
reed@google.com2d4297c2011-10-06 13:14:12 +000045 SkRegion::Op op = SkRegion::kIntersect_Op) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000046
reed@google.com2d4297c2011-10-06 13:14:12 +000047 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000048 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
reed@google.com2d4297c2011-10-06 13:14:12 +000049 const SkPaint& paint) SK_OVERRIDE;
reed@google.com4ed0fb72012-12-12 20:48:18 +000050 virtual void drawOval(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
robertphillips@google.comc2cc1db2013-10-17 17:34:20 +000051 virtual void drawRect(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
reed@google.com4ed0fb72012-12-12 20:48:18 +000052 virtual void drawRRect(const SkRRect&, const SkPaint& paint) SK_OVERRIDE;
robertphillips@google.comc2cc1db2013-10-17 17:34:20 +000053 virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000054 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
reed@google.com2d4297c2011-10-06 13:14:12 +000055 const SkPaint* paint = NULL) SK_OVERRIDE;
reed@google.com71121732012-09-18 15:14:33 +000056 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +000057 const SkRect& dst, const SkPaint* paint,
58 DrawBitmapRectFlags flags) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000059 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
reed@google.com2d4297c2011-10-06 13:14:12 +000060 const SkPaint* paint = NULL) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000061 virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
reed@google.com2d4297c2011-10-06 13:14:12 +000062 const SkPaint* paint = NULL) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000063 virtual void drawText(const void* text, size_t byteLength, SkScalar x,
reed@google.com2d4297c2011-10-06 13:14:12 +000064 SkScalar y, const SkPaint& paint) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000065 virtual void drawPosText(const void* text, size_t byteLength,
reed@google.com2d4297c2011-10-06 13:14:12 +000066 const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000067 virtual void drawPosTextH(const void* text, size_t byteLength,
68 const SkScalar xpos[], SkScalar constY,
reed@google.com2d4297c2011-10-06 13:14:12 +000069 const SkPaint& paint) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000070 virtual void drawTextOnPath(const void* text, size_t byteLength,
71 const SkPath& path, const SkMatrix* matrix,
reed@google.com2d4297c2011-10-06 13:14:12 +000072 const SkPaint& paint) SK_OVERRIDE;
73 virtual void drawPicture(SkPicture&) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000074 virtual void drawVertices(VertexMode vmode, int vertexCount,
75 const SkPoint vertices[], const SkPoint texs[],
76 const SkColor colors[], SkXfermode* xmode,
77 const uint16_t indices[], int indexCount,
reed@google.com2d4297c2011-10-06 13:14:12 +000078 const SkPaint& paint) SK_OVERRIDE;
79 virtual void drawData(const void* data, size_t length) SK_OVERRIDE;
reed@android.comcb608442009-12-04 21:32:27 +000080
robertphillips@google.com0a4805e2013-05-29 13:24:23 +000081 virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
82 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
83 virtual void endCommentGroup() SK_OVERRIDE;
84
reed@google.com2d4297c2011-10-06 13:14:12 +000085 virtual SkBounder* setBounder(SkBounder* bounder) SK_OVERRIDE;
86 virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000087
reed@android.com8a1c16f2008-12-17 15:59:43 +000088private:
89 SkCanvas* fProxy;
vandebo@chromium.org74b46192012-01-28 01:45:11 +000090
reed@android.com8a1c16f2008-12-17 15:59:43 +000091 typedef SkCanvas INHERITED;
92};
93
94#endif