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
10
11#include "SkCanvas.h"
12
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 */
19class SK_API SkNulCanvas : public SkCanvas {
20public:
21    SK_DECLARE_INST_COUNT(SkNulCanvas);
22
23    SkNulCanvas() {}
24    explicit SkNulCanvas(SkBaseDevice* device) : SkCanvas(device) {}
25
26    explicit SkNulCanvas(const SkBitmap& bitmap) : SkCanvas(bitmap) {}
27    virtual ~SkNulCanvas() {}
28
29    virtual bool isDrawingToLayer() const SK_OVERRIDE {return false;}
30    virtual void clear(SkColor) SK_OVERRIDE {}
31    virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE {}
32    virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
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 {}
38    virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
39                            const SkPaint* paint = NULL) SK_OVERRIDE {}
40    virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
41                                      const SkRect& dst,
42                                      const SkPaint* paint,
43                                      DrawBitmapRectFlags flags) SK_OVERRIDE {}
44    virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
45                                  const SkPaint* paint = NULL) SK_OVERRIDE {}
46    virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
47                                const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE {}
48    virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
49                            const SkPaint* paint = NULL) SK_OVERRIDE {}
50    virtual void drawVertices(VertexMode vmode, int vertexCount,
51                              const SkPoint vertices[], const SkPoint texs[],
52                              const SkColor colors[], SkXfermode* xmode,
53                              const uint16_t indices[], int indexCount,
54                              const SkPaint& paint) SK_OVERRIDE {}
55    virtual void drawData(const void* data, size_t length) SK_OVERRIDE {}
56    virtual void beginCommentGroup(const char* description) SK_OVERRIDE {}
57    virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE {}
58    virtual void endCommentGroup() SK_OVERRIDE {}
59    virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE {return NULL;}
60
61    virtual bool isClipEmpty() const SK_OVERRIDE { return false; }
62    virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE {
63        if (NULL != bounds) {
64            bounds->setXYWH(0, 0,
65                            SkIntToScalar(this->imageInfo().width()),
66                            SkIntToScalar(this->imageInfo().height()));
67        }
68        return true;
69    }
70    virtual bool getClipDeviceBounds(SkIRect* bounds) const SK_OVERRIDE {
71        if (NULL != bounds) {
72            bounds->setLargest();
73        }
74        return true;
75    }
76
77protected:
78    virtual SkCanvas* canvasForDrawIter() {return NULL;}
79    virtual SkBaseDevice* setDevice(SkBaseDevice* device) {return NULL;}
80
81    virtual SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint,
82                                            SaveFlags flags) SK_OVERRIDE {
83        this->INHERITED::willSaveLayer(bounds, paint, flags);
84        return kNoLayer_SaveLayerStrategy;
85    }
86
87    virtual void onDrawText(const void* text, size_t byteLength, SkScalar x,
88                          SkScalar y, const SkPaint& paint) SK_OVERRIDE {}
89    virtual void onDrawPosText(const void* text, size_t byteLength,
90                             const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE {}
91    virtual void onDrawPosTextH(const void* text, size_t byteLength,
92                              const SkScalar xpos[], SkScalar constY,
93                              const SkPaint& paint) SK_OVERRIDE {}
94    virtual void onDrawTextOnPath(const void* text, size_t byteLength,
95                                const SkPath& path, const SkMatrix* matrix,
96                                const SkPaint& paint) SK_OVERRIDE {}
97
98    virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
99    virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
100    virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
101    virtual void onClipRegion(const SkRegion&, SkRegion::Op)  SK_OVERRIDE {}
102
103    virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) SK_OVERRIDE {}
104
105private:
106    typedef SkCanvas INHERITED;
107};
108
109#endif  // SkNulCanvas_DEFINED
110