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;} |
| 30 | virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE {return true;} |
| 31 | virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE {return true;} |
| 32 | virtual bool rotate(SkScalar degrees) SK_OVERRIDE {return true;} |
| 33 | virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE {return true;} |
| 34 | virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE {return true;} |
| 35 | virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE {} |
| 36 | virtual void clear(SkColor) SK_OVERRIDE {} |
| 37 | virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 38 | virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 39 | const SkPaint& paint) SK_OVERRIDE {} |
| 40 | virtual void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE {} |
| 41 | virtual void drawOval(const SkRect& oval, const SkPaint&) SK_OVERRIDE {} |
| 42 | virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE {} |
| 43 | virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 44 | virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
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 drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
| 47 | const SkRect& dst, |
edisonn@google.com | 2c81777 | 2013-08-16 16:30:02 +0000 | [diff] [blame] | 48 | const SkPaint* paint, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 49 | DrawBitmapRectFlags flags) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 50 | virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 51 | const SkPaint* paint = NULL) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 52 | virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 53 | const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 54 | virtual void drawSprite(const SkBitmap& bitmap, int left, int top, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 55 | const SkPaint* paint = NULL) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 56 | virtual void drawText(const void* text, size_t byteLength, SkScalar x, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 57 | SkScalar y, const SkPaint& paint) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 58 | virtual void drawPosText(const void* text, size_t byteLength, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 59 | const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 60 | virtual void drawPosTextH(const void* text, size_t byteLength, |
| 61 | const SkScalar xpos[], SkScalar constY, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 62 | const SkPaint& paint) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 63 | virtual void drawTextOnPath(const void* text, size_t byteLength, |
| 64 | const SkPath& path, const SkMatrix* matrix, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 65 | const SkPaint& paint) SK_OVERRIDE {} |
| 66 | virtual void drawPicture(SkPicture& picture) SK_OVERRIDE {} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 67 | virtual void drawVertices(VertexMode vmode, int vertexCount, |
| 68 | const SkPoint vertices[], const SkPoint texs[], |
| 69 | const SkColor colors[], SkXfermode* xmode, |
| 70 | const uint16_t indices[], int indexCount, |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 71 | const SkPaint& paint) SK_OVERRIDE {} |
| 72 | virtual void drawData(const void* data, size_t length) SK_OVERRIDE {} |
| 73 | virtual void beginCommentGroup(const char* description) SK_OVERRIDE {} |
| 74 | virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE {} |
| 75 | virtual void endCommentGroup() SK_OVERRIDE {} |
| 76 | virtual SkBounder* setBounder(SkBounder* bounder) SK_OVERRIDE {return NULL;} |
| 77 | virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE {return NULL;} |
| 78 | |
| 79 | virtual bool isClipEmpty() const SK_OVERRIDE { return false; } |
commit-bot@chromium.org | 5c70cdc | 2014-03-08 03:57:19 +0000 | [diff] [blame] | 80 | #ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 81 | virtual ClipType getClipType() const SK_OVERRIDE { return kRect_ClipType; } |
commit-bot@chromium.org | 5c70cdc | 2014-03-08 03:57:19 +0000 | [diff] [blame] | 82 | #endif |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 83 | virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE { |
| 84 | if (NULL != bounds) { |
skia.committer@gmail.com | 370a899 | 2014-03-01 03:02:09 +0000 | [diff] [blame] | 85 | bounds->setXYWH(0, 0, |
| 86 | SkIntToScalar(this->imageInfo().fWidth), |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 87 | SkIntToScalar(this->imageInfo().fHeight)); |
| 88 | } |
| 89 | return true; |
| 90 | } |
| 91 | virtual bool getClipDeviceBounds(SkIRect* bounds) const SK_OVERRIDE { |
| 92 | if (NULL != bounds) { |
| 93 | bounds->setLargest(); |
| 94 | } |
| 95 | return true; |
| 96 | } |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 97 | |
| 98 | protected: |
| 99 | virtual SkCanvas* canvasForDrawIter() {return NULL;} |
robertphillips@google.com | 1f2f338 | 2013-08-29 11:54:56 +0000 | [diff] [blame] | 100 | virtual SkBaseDevice* setDevice(SkBaseDevice* device) {return NULL;} |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 101 | |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame^] | 102 | virtual SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint, |
| 103 | SaveFlags flags) SK_OVERRIDE { |
| 104 | this->INHERITED::willSaveLayer(bounds, paint, flags); |
| 105 | return kNoLayer_SaveLayerStrategy; |
| 106 | } |
| 107 | |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 108 | virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {} |
| 109 | virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {} |
| 110 | virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {} |
| 111 | virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE {} |
| 112 | |
edisonn@google.com | ac03d91 | 2013-07-22 15:36:39 +0000 | [diff] [blame] | 113 | private: |
| 114 | typedef SkCanvas INHERITED; |
| 115 | }; |
| 116 | |
edisonn@google.com | cf2cfa1 | 2013-08-21 16:31:37 +0000 | [diff] [blame] | 117 | #endif // SkNulCanvas_DEFINED |