edisonn@google.com | cf2cfa1 | 2013-08-21 16:31:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkNulCanvas_DEFINED |
| 9 | #define SkNulCanvas_DEFINED |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 10 | |
| 11 | #include "SkCanvas.h" |
| 12 | |
edisonn@google.com | 2af2ad9c | 2013-10-11 16:17:44 +0000 | [diff] [blame] | 13 | /** \class SkNulCanvas |
| 14 | * |
| 15 | * Nul Canvas is a canvas that does nothing. It is used to measure the perf of just parsing |
| 16 | * a pdf, without actually rendering anything. |
| 17 | * |
| 18 | */ |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 19 | class SK_API SkNulCanvas : public SkCanvas { |
| 20 | public: |
| 21 | SK_DECLARE_INST_COUNT(SkNulCanvas); |
| 22 | |
| 23 | SkNulCanvas() {} |
robertphillips@google.com | 1f2f338 | 2013-08-29 11:54:56 +0000 | [diff] [blame] | 24 | explicit SkNulCanvas(SkBaseDevice* device) : SkCanvas(device) {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 25 | |
| 26 | explicit SkNulCanvas(const SkBitmap& bitmap) : SkCanvas(bitmap) {} |
| 27 | virtual ~SkNulCanvas() {} |
| 28 | |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 29 | virtual bool isDrawingToLayer() const SK_OVERRIDE {return false;} |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 30 | virtual void clear(SkColor) SK_OVERRIDE {} |
| 31 | virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 32 | virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 33 | const SkPaint& paint) SK_OVERRIDE {} |
| 34 | virtual void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE {} |
| 35 | virtual void drawOval(const SkRect& oval, const SkPaint&) SK_OVERRIDE {} |
| 36 | virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE {} |
| 37 | virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 38 | virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 39 | const SkPaint* paint = NULL) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 40 | virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
| 41 | const SkRect& dst, |
edisonn@google.com | 2c81777 | 2013-08-16 16:30:02 +0000 | [diff] [blame] | 42 | const SkPaint* paint, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 43 | DrawBitmapRectFlags flags) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 44 | virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 45 | const SkPaint* paint = NULL) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 46 | virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 47 | const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 48 | virtual void drawSprite(const SkBitmap& bitmap, int left, int top, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 49 | const SkPaint* paint = NULL) SK_OVERRIDE {} |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 50 | virtual void drawPicture(SkPicture& picture) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 51 | virtual void drawVertices(VertexMode vmode, int vertexCount, |
| 52 | const SkPoint vertices[], const SkPoint texs[], |
| 53 | const SkColor colors[], SkXfermode* xmode, |
| 54 | const uint16_t indices[], int indexCount, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 55 | const SkPaint& paint) SK_OVERRIDE {} |
| 56 | virtual void drawData(const void* data, size_t length) SK_OVERRIDE {} |
| 57 | virtual void beginCommentGroup(const char* description) SK_OVERRIDE {} |
| 58 | virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE {} |
| 59 | virtual void endCommentGroup() SK_OVERRIDE {} |
| 60 | virtual SkBounder* setBounder(SkBounder* bounder) SK_OVERRIDE {return NULL;} |
| 61 | virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE {return NULL;} |
| 62 | |
| 63 | virtual bool isClipEmpty() const SK_OVERRIDE { return false; } |
commit-bot@chromium.org | 5c70cdc | 2014-03-08 03:57:19 +0000 | [diff] [blame] | 64 | #ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 65 | virtual ClipType getClipType() const SK_OVERRIDE { return kRect_ClipType; } |
commit-bot@chromium.org | 5c70cdc | 2014-03-08 03:57:19 +0000 | [diff] [blame] | 66 | #endif |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 67 | virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE { |
| 68 | if (NULL != bounds) { |
skia.committer@gmail.com | 370a899 | 2014-03-01 03:02:09 +0000 | [diff] [blame] | 69 | bounds->setXYWH(0, 0, |
| 70 | SkIntToScalar(this->imageInfo().fWidth), |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 71 | SkIntToScalar(this->imageInfo().fHeight)); |
| 72 | } |
| 73 | return true; |
| 74 | } |
| 75 | virtual bool getClipDeviceBounds(SkIRect* bounds) const SK_OVERRIDE { |
| 76 | if (NULL != bounds) { |
| 77 | bounds->setLargest(); |
| 78 | } |
| 79 | return true; |
| 80 | } |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 81 | |
| 82 | protected: |
| 83 | virtual SkCanvas* canvasForDrawIter() {return NULL;} |
robertphillips@google.com | 1f2f338 | 2013-08-29 11:54:56 +0000 | [diff] [blame] | 84 | virtual SkBaseDevice* setDevice(SkBaseDevice* device) {return NULL;} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 85 | |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 86 | virtual SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint, |
| 87 | SaveFlags flags) SK_OVERRIDE { |
| 88 | this->INHERITED::willSaveLayer(bounds, paint, flags); |
| 89 | return kNoLayer_SaveLayerStrategy; |
| 90 | } |
| 91 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 92 | virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, |
| 93 | SkScalar y, const SkPaint& paint) SK_OVERRIDE {} |
| 94 | virtual void onDrawPosText(const void* text, size_t byteLength, |
| 95 | const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE {} |
| 96 | virtual void onDrawPosTextH(const void* text, size_t byteLength, |
| 97 | const SkScalar xpos[], SkScalar constY, |
| 98 | const SkPaint& paint) SK_OVERRIDE {} |
| 99 | virtual void onDrawTextOnPath(const void* text, size_t byteLength, |
| 100 | const SkPath& path, const SkMatrix* matrix, |
| 101 | const SkPaint& paint) SK_OVERRIDE {} |
| 102 | |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 103 | virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {} |
| 104 | virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {} |
| 105 | virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {} |
| 106 | virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE {} |
| 107 | |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 108 | private: |
| 109 | typedef SkCanvas INHERITED; |
| 110 | }; |
| 111 | |
edisonn@google.com | cf2cfa1 | 2013-08-21 16:31:37 +0000 | [diff] [blame] | 112 | #endif // SkNulCanvas_DEFINED |