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; }
625c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org#ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE
638f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual ClipType getClipType() const SK_OVERRIDE { return kRect_ClipType; }
645c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org#endif
658f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE {
668f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        if (NULL != bounds) {
67370a89980b2d38a6d01903b484bf404d6c48b496skia.committer@gmail.com            bounds->setXYWH(0, 0,
68370a89980b2d38a6d01903b484bf404d6c48b496skia.committer@gmail.com                            SkIntToScalar(this->imageInfo().fWidth),
698f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com                            SkIntToScalar(this->imageInfo().fHeight));
708f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        }
718f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        return true;
728f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    }
738f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual bool getClipDeviceBounds(SkIRect* bounds) const SK_OVERRIDE {
748f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        if (NULL != bounds) {
758f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com            bounds->setLargest();
768f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        }
778f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com        return true;
788f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    }
79ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com
80ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.comprotected:
81ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    virtual SkCanvas* canvasForDrawIter() {return NULL;}
821f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual SkBaseDevice* setDevice(SkBaseDevice* device) {return NULL;}
83ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com
84e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org    virtual SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint,
85e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org                                            SaveFlags flags) SK_OVERRIDE {
86e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org        this->INHERITED::willSaveLayer(bounds, paint, flags);
87e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org        return kNoLayer_SaveLayerStrategy;
88e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org    }
89e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org
90e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com    virtual void onDrawText(const void* text, size_t byteLength, SkScalar x,
91e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                          SkScalar y, const SkPaint& paint) SK_OVERRIDE {}
92e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com    virtual void onDrawPosText(const void* text, size_t byteLength,
93e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                             const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE {}
94e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com    virtual void onDrawPosTextH(const void* text, size_t byteLength,
95e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                              const SkScalar xpos[], SkScalar constY,
96e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                              const SkPaint& paint) SK_OVERRIDE {}
97e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com    virtual void onDrawTextOnPath(const void* text, size_t byteLength,
98e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                                const SkPath& path, const SkMatrix* matrix,
99e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com                                const SkPaint& paint) SK_OVERRIDE {}
100e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com
1018f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
1028f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
1038f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
1048f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com    virtual void onClipRegion(const SkRegion&, SkRegion::Op)  SK_OVERRIDE {}
1058f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com
1069b14f26d0f3a974f3dd626c8354e1db1cfcd322frobertphillips    virtual void onDrawPicture(const SkPicture* picture) SK_OVERRIDE {}
1079b14f26d0f3a974f3dd626c8354e1db1cfcd322frobertphillips
108ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.comprivate:
109ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com    typedef SkCanvas INHERITED;
110ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com};
111ac03d91ee03599eab946a8ad25e33f9fc5f3166eedisonn@google.com
112cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#endif  // SkNulCanvas_DEFINED
113