blob: f2befad34442c04fc61ee9419d8301cc687d686c [file] [log] [blame]
edisonn@google.comcf2cfa12013-08-21 16:31:37 +00001/*
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.comac03d912013-07-22 15:36:39 +000010
11#include "SkCanvas.h"
12
edisonn@google.com2af2ad9c2013-10-11 16:17:44 +000013/** \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.comac03d912013-07-22 15:36:39 +000019class SK_API SkNulCanvas : public SkCanvas {
20public:
21 SK_DECLARE_INST_COUNT(SkNulCanvas);
22
23 SkNulCanvas() {}
robertphillips@google.com1f2f3382013-08-29 11:54:56 +000024 explicit SkNulCanvas(SkBaseDevice* device) : SkCanvas(device) {}
edisonn@google.comac03d912013-07-22 15:36:39 +000025
26 explicit SkNulCanvas(const SkBitmap& bitmap) : SkCanvas(bitmap) {}
27 virtual ~SkNulCanvas() {}
28
robertphillips@google.com8f90a892014-02-28 18:19:39 +000029 virtual bool isDrawingToLayer() const SK_OVERRIDE {return false;}
robertphillips@google.com8f90a892014-02-28 18:19:39 +000030 virtual void clear(SkColor) SK_OVERRIDE {}
31 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000032 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
robertphillips@google.com8f90a892014-02-28 18:19:39 +000033 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.comac03d912013-07-22 15:36:39 +000038 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000039 const SkPaint* paint = NULL) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000040 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
41 const SkRect& dst,
edisonn@google.com2c817772013-08-16 16:30:02 +000042 const SkPaint* paint,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000043 DrawBitmapRectFlags flags) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000044 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000045 const SkPaint* paint = NULL) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000046 virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000047 const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000048 virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000049 const SkPaint* paint = NULL) SK_OVERRIDE {}
robertphillips@google.com8f90a892014-02-28 18:19:39 +000050 virtual void drawPicture(SkPicture& picture) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000051 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.com8f90a892014-02-28 18:19:39 +000055 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.org5c70cdc2014-03-08 03:57:19 +000064#ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE
robertphillips@google.com8f90a892014-02-28 18:19:39 +000065 virtual ClipType getClipType() const SK_OVERRIDE { return kRect_ClipType; }
commit-bot@chromium.org5c70cdc2014-03-08 03:57:19 +000066#endif
robertphillips@google.com8f90a892014-02-28 18:19:39 +000067 virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE {
68 if (NULL != bounds) {
skia.committer@gmail.com370a8992014-03-01 03:02:09 +000069 bounds->setXYWH(0, 0,
70 SkIntToScalar(this->imageInfo().fWidth),
robertphillips@google.com8f90a892014-02-28 18:19:39 +000071 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.comac03d912013-07-22 15:36:39 +000081
82protected:
83 virtual SkCanvas* canvasForDrawIter() {return NULL;}
robertphillips@google.com1f2f3382013-08-29 11:54:56 +000084 virtual SkBaseDevice* setDevice(SkBaseDevice* device) {return NULL;}
edisonn@google.comac03d912013-07-22 15:36:39 +000085
commit-bot@chromium.orge54a23f2014-03-12 20:21:48 +000086 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.come0d9ce82014-04-23 04:00:17 +000092 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.com8f90a892014-02-28 18:19:39 +0000103 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.comac03d912013-07-22 15:36:39 +0000108private:
109 typedef SkCanvas INHERITED;
110};
111
edisonn@google.comcf2cfa12013-08-21 16:31:37 +0000112#endif // SkNulCanvas_DEFINED