1cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com/*
2cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com * Copyright 2013 Google Inc.
3cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com *
4cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com * Use of this source code is governed by a BSD-style license that can be
5cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com * found in the LICENSE file.
6cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com */
7cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com
8cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#ifndef SkNulCanvas_DEFINED
9cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#define SkNulCanvas_DEFINED
10ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com
11ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com#include "SkCanvas.h"
12ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com
132af2ad9cc0b2c7d911aed2e8d2ac77c0b7d3b5dfedisonn@google.com/** \class SkNulCanvas
142af2ad9cc0b2c7d911aed2e8d2ac77c0b7d3b5dfedisonn@google.com *
152af2ad9cc0b2c7d911aed2e8d2ac77c0b7d3b5dfedisonn@google.com *   Nul Canvas is a canvas that does nothing. It is used to measure the perf of just parsing
162af2ad9cc0b2c7d911aed2e8d2ac77c0b7d3b5dfedisonn@google.com *   a pdf, without actually rendering anything.
172af2ad9cc0b2c7d911aed2e8d2ac77c0b7d3b5dfedisonn@google.com *
182af2ad9cc0b2c7d911aed2e8d2ac77c0b7d3b5dfedisonn@google.com */
19ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.comclass SK_API SkNulCanvas : public SkCanvas {
20ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.compublic:
21ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    SK_DECLARE_INST_COUNT(SkNulCanvas);
22ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com
23ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    SkNulCanvas() {}
241f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    explicit SkNulCanvas(SkBaseDevice* device) : SkCanvas(device) {}
25ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com
26ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    explicit SkNulCanvas(const SkBitmap& bitmap) : SkCanvas(bitmap) {}
27ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    virtual ~SkNulCanvas() {}
28ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com
298f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual bool isDrawingToLayer() const SK_OVERRIDE {return false;}
308f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void clear(SkColor) SK_OVERRIDE {}
318f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE {}
32ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
338f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com                            const SkPaint& paint) SK_OVERRIDE {}
348f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE {}
358f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void drawOval(const SkRect& oval, const SkPaint&) SK_OVERRIDE {}
368f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE {}
378f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE {}
38ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
398f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com                            const SkPaint* paint = NULL) SK_OVERRIDE {}
40ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
41ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com                                      const SkRect& dst,
422c8177767a4b3b6c27c6ac071c8619b557472521edisonn@google.com                                      const SkPaint* paint,
438f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com                                      DrawBitmapRectFlags flags) SK_OVERRIDE {}
44ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
458f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com                                  const SkPaint* paint = NULL) SK_OVERRIDE {}
46ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
478f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com                                const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE {}
48ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
498f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com                            const SkPaint* paint = NULL) SK_OVERRIDE {}
50ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    virtual void drawVertices(VertexMode vmode, int vertexCount,
51ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com                              const SkPoint vertices[], const SkPoint texs[],
52ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com                              const SkColor colors[], SkXfermode* xmode,
53ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com                              const uint16_t indices[], int indexCount,
548f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com                              const SkPaint& paint) SK_OVERRIDE {}
558f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void drawData(const void* data, size_t length) SK_OVERRIDE {}
568f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void beginCommentGroup(const char* description) SK_OVERRIDE {}
578f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE {}
588f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void endCommentGroup() SK_OVERRIDE {}
598f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE {return NULL;}
608f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com
618f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual bool isClipEmpty() const SK_OVERRIDE { return false; }
628f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE {
638f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        if (NULL != bounds) {
64370a89980b2d38a6d01903b484bf404d6c48b496skia.committer@gmail.com            bounds->setXYWH(0, 0,
65e5ea500d4714a7d84de2bf913e81be3b65d2de68reed                            SkIntToScalar(this->imageInfo().width()),
66e5ea500d4714a7d84de2bf913e81be3b65d2de68reed                            SkIntToScalar(this->imageInfo().height()));
678f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        }
688f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        return true;
698f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    }
708f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual bool getClipDeviceBounds(SkIRect* bounds) const SK_OVERRIDE {
718f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        if (NULL != bounds) {
728f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com            bounds->setLargest();
738f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        }
748f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        return true;
758f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    }
76ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com
77ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.comprotected:
78ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    virtual SkCanvas* canvasForDrawIter() {return NULL;}
791f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual SkBaseDevice* setDevice(SkBaseDevice* device) {return NULL;}
80ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com
81e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org    virtual SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint,
82e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org                                            SaveFlags flags) SK_OVERRIDE {
83e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org        this->INHERITED::willSaveLayer(bounds, paint, flags);
84e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org        return kNoLayer_SaveLayerStrategy;
85e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org    }
86e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org
87e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com    virtual void onDrawText(const void* text, size_t byteLength, SkScalar x,
88e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                          SkScalar y, const SkPaint& paint) SK_OVERRIDE {}
89e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com    virtual void onDrawPosText(const void* text, size_t byteLength,
90e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                             const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE {}
91e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com    virtual void onDrawPosTextH(const void* text, size_t byteLength,
92e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                              const SkScalar xpos[], SkScalar constY,
93e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                              const SkPaint& paint) SK_OVERRIDE {}
94e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com    virtual void onDrawTextOnPath(const void* text, size_t byteLength,
95e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                                const SkPath& path, const SkMatrix* matrix,
96e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                                const SkPaint& paint) SK_OVERRIDE {}
97e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com
988f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
998f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
1008f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
1018f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void onClipRegion(const SkRegion&, SkRegion::Op)  SK_OVERRIDE {}
1028f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com
103d5fa1a455aad61f3e99081fe7a9b065cb3b115c6reed    virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) SK_OVERRIDE {}
1049b14f26d0f3a974f3dd626c8354e1db1cfcd322frobertphillips
105ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.comprivate:
106ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    typedef SkCanvas INHERITED;
107ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com};
108ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com
109cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#endif  // SkNulCanvas_DEFINED
110