blob: 472ea3b2a91c897f787b9bbf590cc523ef4a6667 [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;}
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.comac03d912013-07-22 15:36:39 +000038 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
robertphillips@google.com8f90a892014-02-28 18:19:39 +000039 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.comac03d912013-07-22 15:36:39 +000044 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
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 drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
47 const SkRect& dst,
edisonn@google.com2c817772013-08-16 16:30:02 +000048 const SkPaint* paint,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000049 DrawBitmapRectFlags flags) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000050 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000051 const SkPaint* paint = NULL) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000052 virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000053 const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000054 virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000055 const SkPaint* paint = NULL) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000056 virtual void drawText(const void* text, size_t byteLength, SkScalar x,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000057 SkScalar y, const SkPaint& paint) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000058 virtual void drawPosText(const void* text, size_t byteLength,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000059 const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000060 virtual void drawPosTextH(const void* text, size_t byteLength,
61 const SkScalar xpos[], SkScalar constY,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000062 const SkPaint& paint) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000063 virtual void drawTextOnPath(const void* text, size_t byteLength,
64 const SkPath& path, const SkMatrix* matrix,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000065 const SkPaint& paint) SK_OVERRIDE {}
66 virtual void drawPicture(SkPicture& picture) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000067 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.com8f90a892014-02-28 18:19:39 +000071 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.org5c70cdc2014-03-08 03:57:19 +000080#ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE
robertphillips@google.com8f90a892014-02-28 18:19:39 +000081 virtual ClipType getClipType() const SK_OVERRIDE { return kRect_ClipType; }
commit-bot@chromium.org5c70cdc2014-03-08 03:57:19 +000082#endif
robertphillips@google.com8f90a892014-02-28 18:19:39 +000083 virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE {
84 if (NULL != bounds) {
skia.committer@gmail.com370a8992014-03-01 03:02:09 +000085 bounds->setXYWH(0, 0,
86 SkIntToScalar(this->imageInfo().fWidth),
robertphillips@google.com8f90a892014-02-28 18:19:39 +000087 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.comac03d912013-07-22 15:36:39 +000097
98protected:
99 virtual SkCanvas* canvasForDrawIter() {return NULL;}
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000100 virtual SkBaseDevice* setDevice(SkBaseDevice* device) {return NULL;}
edisonn@google.comac03d912013-07-22 15:36:39 +0000101
commit-bot@chromium.orge54a23f2014-03-12 20:21:48 +0000102 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.com8f90a892014-02-28 18:19:39 +0000108 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.comac03d912013-07-22 15:36:39 +0000113private:
114 typedef SkCanvas INHERITED;
115};
116
edisonn@google.comcf2cfa12013-08-21 16:31:37 +0000117#endif // SkNulCanvas_DEFINED