blob: 6e2e8e0a4fe61568752c0cb616f836d6ab60292a [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 bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
30 virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
31 virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
32 virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE;
33 virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
34 virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
vandebo@chromium.org74b46192012-01-28 01:45:11 +000035
reed@google.com2d4297c2011-10-06 13:14:12 +000036 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000037 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
reed@google.com2d4297c2011-10-06 13:14:12 +000038 const SkPaint& paint) SK_OVERRIDE;
reed@google.com4ed0fb72012-12-12 20:48:18 +000039 virtual void drawOval(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
bsalomon@google.com7ce564c2013-10-22 16:54:15 +000040 virtual void drawRect(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
reed@google.com4ed0fb72012-12-12 20:48:18 +000041 virtual void drawRRect(const SkRRect&, const SkPaint& paint) SK_OVERRIDE;
bsalomon@google.com7ce564c2013-10-22 16:54:15 +000042 virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000043 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
reed@google.com2d4297c2011-10-06 13:14:12 +000044 const SkPaint* paint = NULL) SK_OVERRIDE;
reed@google.com71121732012-09-18 15:14:33 +000045 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +000046 const SkRect& dst, const SkPaint* paint,
47 DrawBitmapRectFlags flags) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000048 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
reed@google.com2d4297c2011-10-06 13:14:12 +000049 const SkPaint* paint = NULL) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000050 virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
reed@google.com2d4297c2011-10-06 13:14:12 +000051 const SkPaint* paint = NULL) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000052 virtual void drawText(const void* text, size_t byteLength, SkScalar x,
reed@google.com2d4297c2011-10-06 13:14:12 +000053 SkScalar y, const SkPaint& paint) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000054 virtual void drawPosText(const void* text, size_t byteLength,
reed@google.com2d4297c2011-10-06 13:14:12 +000055 const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000056 virtual void drawPosTextH(const void* text, size_t byteLength,
57 const SkScalar xpos[], SkScalar constY,
reed@google.com2d4297c2011-10-06 13:14:12 +000058 const SkPaint& paint) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000059 virtual void drawTextOnPath(const void* text, size_t byteLength,
60 const SkPath& path, const SkMatrix* matrix,
reed@google.com2d4297c2011-10-06 13:14:12 +000061 const SkPaint& paint) SK_OVERRIDE;
62 virtual void drawPicture(SkPicture&) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000063 virtual void drawVertices(VertexMode vmode, int vertexCount,
64 const SkPoint vertices[], const SkPoint texs[],
65 const SkColor colors[], SkXfermode* xmode,
66 const uint16_t indices[], int indexCount,
reed@google.com2d4297c2011-10-06 13:14:12 +000067 const SkPaint& paint) SK_OVERRIDE;
68 virtual void drawData(const void* data, size_t length) SK_OVERRIDE;
reed@android.comcb608442009-12-04 21:32:27 +000069
robertphillips@google.com0a4805e2013-05-29 13:24:23 +000070 virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
71 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
72 virtual void endCommentGroup() SK_OVERRIDE;
73
reed@google.com2d4297c2011-10-06 13:14:12 +000074 virtual SkBounder* setBounder(SkBounder* bounder) SK_OVERRIDE;
75 virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000076
commit-bot@chromium.orgab582732014-02-21 12:20:45 +000077protected:
commit-bot@chromium.orge54a23f2014-03-12 20:21:48 +000078 virtual void willSave(SaveFlags) SK_OVERRIDE;
79 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
80 virtual void willRestore() SK_OVERRIDE;
81
commit-bot@chromium.orgab582732014-02-21 12:20:45 +000082 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
83
robertphillips@google.com8f90a892014-02-28 18:19:39 +000084 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
85 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
86 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
87 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
88
reed@android.com8a1c16f2008-12-17 15:59:43 +000089private:
90 SkCanvas* fProxy;
vandebo@chromium.org74b46192012-01-28 01:45:11 +000091
reed@android.com8a1c16f2008-12-17 15:59:43 +000092 typedef SkCanvas INHERITED;
93};
94
95#endif