epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 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.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | #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.org | 74b4619 | 2012-01-28 01:45:11 +0000 | [diff] [blame] | 16 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 17 | 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.org | e1a81d2 | 2013-07-15 22:49:37 +0000 | [diff] [blame] | 20 | class SK_API SkProxyCanvas : public SkCanvas { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 21 | public: |
| 22 | SkProxyCanvas() : fProxy(NULL) {} |
| 23 | SkProxyCanvas(SkCanvas* proxy); |
| 24 | virtual ~SkProxyCanvas(); |
vandebo@chromium.org | 74b4619 | 2012-01-28 01:45:11 +0000 | [diff] [blame] | 25 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 26 | SkCanvas* getProxy() const { return fProxy; } |
| 27 | void setProxy(SkCanvas* proxy); |
vandebo@chromium.org | 74b4619 | 2012-01-28 01:45:11 +0000 | [diff] [blame] | 28 | |
reed@google.com | 2d4297c | 2011-10-06 13:14:12 +0000 | [diff] [blame] | 29 | virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 30 | virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], |
reed@google.com | 2d4297c | 2011-10-06 13:14:12 +0000 | [diff] [blame] | 31 | const SkPaint& paint) SK_OVERRIDE; |
reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 32 | virtual void drawOval(const SkRect&, const SkPaint& paint) SK_OVERRIDE; |
bsalomon@google.com | 7ce564c | 2013-10-22 16:54:15 +0000 | [diff] [blame] | 33 | virtual void drawRect(const SkRect&, const SkPaint& paint) SK_OVERRIDE; |
reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 34 | virtual void drawRRect(const SkRRect&, const SkPaint& paint) SK_OVERRIDE; |
bsalomon@google.com | 7ce564c | 2013-10-22 16:54:15 +0000 | [diff] [blame] | 35 | virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 36 | virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
reed@google.com | 2d4297c | 2011-10-06 13:14:12 +0000 | [diff] [blame] | 37 | const SkPaint* paint = NULL) SK_OVERRIDE; |
reed@google.com | 7112173 | 2012-09-18 15:14:33 +0000 | [diff] [blame] | 38 | virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 39 | const SkRect& dst, const SkPaint* paint, |
| 40 | DrawBitmapRectFlags flags) SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 41 | virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, |
reed@google.com | 2d4297c | 2011-10-06 13:14:12 +0000 | [diff] [blame] | 42 | const SkPaint* paint = NULL) SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 43 | virtual void drawSprite(const SkBitmap& bitmap, int left, int top, |
reed@google.com | 2d4297c | 2011-10-06 13:14:12 +0000 | [diff] [blame] | 44 | const SkPaint* paint = NULL) SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 45 | virtual void drawVertices(VertexMode vmode, int vertexCount, |
| 46 | const SkPoint vertices[], const SkPoint texs[], |
| 47 | const SkColor colors[], SkXfermode* xmode, |
| 48 | const uint16_t indices[], int indexCount, |
reed@google.com | 2d4297c | 2011-10-06 13:14:12 +0000 | [diff] [blame] | 49 | const SkPaint& paint) SK_OVERRIDE; |
| 50 | virtual void drawData(const void* data, size_t length) SK_OVERRIDE; |
reed@android.com | cb60844 | 2009-12-04 21:32:27 +0000 | [diff] [blame] | 51 | |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 52 | virtual void beginCommentGroup(const char* description) SK_OVERRIDE; |
| 53 | virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE; |
| 54 | virtual void endCommentGroup() SK_OVERRIDE; |
| 55 | |
reed@google.com | 2d4297c | 2011-10-06 13:14:12 +0000 | [diff] [blame] | 56 | virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 57 | |
commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 58 | protected: |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 59 | virtual void willSave() SK_OVERRIDE; |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 60 | virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; |
| 61 | virtual void willRestore() SK_OVERRIDE; |
| 62 | |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 63 | virtual void didConcat(const SkMatrix&) SK_OVERRIDE; |
| 64 | virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; |
| 65 | |
commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 66 | virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE; |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 67 | virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
| 68 | const SkPaint&) SK_OVERRIDE; |
| 69 | virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], |
| 70 | const SkPaint&) SK_OVERRIDE; |
| 71 | virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], |
| 72 | SkScalar constY, const SkPaint&) SK_OVERRIDE; |
| 73 | virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, |
| 74 | const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE; |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 75 | virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
| 76 | const SkPaint& paint) SK_OVERRIDE; |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 77 | virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], |
| 78 | const SkPoint texCoords[4], SkXfermode* xmode, |
| 79 | const SkPaint& paint) SK_OVERRIDE; |
| 80 | |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 81 | virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; |
| 82 | virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; |
| 83 | virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; |
| 84 | virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; |
| 85 | |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 86 | virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) SK_OVERRIDE; |
robertphillips | 9b14f26 | 2014-06-04 05:40:44 -0700 | [diff] [blame] | 87 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 88 | private: |
| 89 | SkCanvas* fProxy; |
vandebo@chromium.org | 74b4619 | 2012-01-28 01:45:11 +0000 | [diff] [blame] | 90 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 91 | typedef SkCanvas INHERITED; |
| 92 | }; |
| 93 | |
| 94 | #endif |