blob: 1c12a5b88faba60d52a1961152cef9cd9e47d0a8 [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
commit-bot@chromium.org069a55a2014-03-12 15:08:22 +000029 virtual int save(SaveFlags flags = kMatrixClip_SaveFlag) SK_OVERRIDE {return 0;}
30 virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
31 SaveFlags flags = kARGB_ClipLayer_SaveFlag) SK_OVERRIDE {return 0;}
32 int saveLayerAlpha(const SkRect* bounds, U8CPU alpha,
33 SaveFlags flags = kARGB_ClipLayer_SaveFlag) {return 0;}
34 virtual void restore() SK_OVERRIDE {}
35 int getSaveCount() const {return 0;}
robertphillips@google.com8f90a892014-02-28 18:19:39 +000036 virtual bool isDrawingToLayer() const SK_OVERRIDE {return false;}
37 virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE {return true;}
38 virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE {return true;}
39 virtual bool rotate(SkScalar degrees) SK_OVERRIDE {return true;}
40 virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE {return true;}
41 virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE {return true;}
42 virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE {}
43 virtual void clear(SkColor) SK_OVERRIDE {}
44 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000045 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
robertphillips@google.com8f90a892014-02-28 18:19:39 +000046 const SkPaint& paint) SK_OVERRIDE {}
47 virtual void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE {}
48 virtual void drawOval(const SkRect& oval, const SkPaint&) SK_OVERRIDE {}
49 virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE {}
50 virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000051 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000052 const SkPaint* paint = NULL) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000053 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
54 const SkRect& dst,
edisonn@google.com2c817772013-08-16 16:30:02 +000055 const SkPaint* paint,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000056 DrawBitmapRectFlags flags) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000057 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000058 const SkPaint* paint = NULL) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000059 virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000060 const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000061 virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000062 const SkPaint* paint = NULL) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000063 virtual void drawText(const void* text, size_t byteLength, SkScalar x,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000064 SkScalar y, const SkPaint& paint) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000065 virtual void drawPosText(const void* text, size_t byteLength,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000066 const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000067 virtual void drawPosTextH(const void* text, size_t byteLength,
68 const SkScalar xpos[], SkScalar constY,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000069 const SkPaint& paint) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000070 virtual void drawTextOnPath(const void* text, size_t byteLength,
71 const SkPath& path, const SkMatrix* matrix,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000072 const SkPaint& paint) SK_OVERRIDE {}
73 virtual void drawPicture(SkPicture& picture) SK_OVERRIDE {}
edisonn@google.comac03d912013-07-22 15:36:39 +000074 virtual void drawVertices(VertexMode vmode, int vertexCount,
75 const SkPoint vertices[], const SkPoint texs[],
76 const SkColor colors[], SkXfermode* xmode,
77 const uint16_t indices[], int indexCount,
robertphillips@google.com8f90a892014-02-28 18:19:39 +000078 const SkPaint& paint) SK_OVERRIDE {}
79 virtual void drawData(const void* data, size_t length) SK_OVERRIDE {}
80 virtual void beginCommentGroup(const char* description) SK_OVERRIDE {}
81 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE {}
82 virtual void endCommentGroup() SK_OVERRIDE {}
83 virtual SkBounder* setBounder(SkBounder* bounder) SK_OVERRIDE {return NULL;}
84 virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE {return NULL;}
85
86 virtual bool isClipEmpty() const SK_OVERRIDE { return false; }
commit-bot@chromium.org5c70cdc2014-03-08 03:57:19 +000087#ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE
robertphillips@google.com8f90a892014-02-28 18:19:39 +000088 virtual ClipType getClipType() const SK_OVERRIDE { return kRect_ClipType; }
commit-bot@chromium.org5c70cdc2014-03-08 03:57:19 +000089#endif
robertphillips@google.com8f90a892014-02-28 18:19:39 +000090 virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE {
91 if (NULL != bounds) {
skia.committer@gmail.com370a8992014-03-01 03:02:09 +000092 bounds->setXYWH(0, 0,
93 SkIntToScalar(this->imageInfo().fWidth),
robertphillips@google.com8f90a892014-02-28 18:19:39 +000094 SkIntToScalar(this->imageInfo().fHeight));
95 }
96 return true;
97 }
98 virtual bool getClipDeviceBounds(SkIRect* bounds) const SK_OVERRIDE {
99 if (NULL != bounds) {
100 bounds->setLargest();
101 }
102 return true;
103 }
edisonn@google.comac03d912013-07-22 15:36:39 +0000104
105protected:
106 virtual SkCanvas* canvasForDrawIter() {return NULL;}
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000107 virtual SkBaseDevice* setDevice(SkBaseDevice* device) {return NULL;}
edisonn@google.comac03d912013-07-22 15:36:39 +0000108
robertphillips@google.com8f90a892014-02-28 18:19:39 +0000109 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
110 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
111 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
112 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE {}
113
edisonn@google.comac03d912013-07-22 15:36:39 +0000114private:
115 typedef SkCanvas INHERITED;
116};
117
edisonn@google.comcf2cfa12013-08-21 16:31:37 +0000118#endif // SkNulCanvas_DEFINED