blob: 8ec2d32d0fc70c0f78994e55d1f185246812e806 [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.com2af2ad92013-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
29 virtual int save(SaveFlags flags = kMatrixClip_SaveFlag) {return 0;}
30 virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
31 SaveFlags flags = kARGB_ClipLayer_SaveFlag) {return 0;}
32 int saveLayerAlpha(const SkRect* bounds, U8CPU alpha,
33 SaveFlags flags = kARGB_ClipLayer_SaveFlag) {return 0;}
34 virtual void restore() {}
35 int getSaveCount() const {return 0;}
36 virtual bool isDrawingToLayer() const {return false;}
37 virtual bool translate(SkScalar dx, SkScalar dy) {return true;}
38 virtual bool scale(SkScalar sx, SkScalar sy) {return true;}
39 virtual bool rotate(SkScalar degrees) {return true;}
40 virtual bool skew(SkScalar sx, SkScalar sy) {return true;}
41 virtual bool concat(const SkMatrix& matrix) {return true;}
42 virtual void setMatrix(const SkMatrix& matrix) {}
43 virtual bool clipRect(const SkRect& rect,
44 SkRegion::Op op = SkRegion::kIntersect_Op,
45 bool doAntiAlias = false) {return true;}
46 virtual bool clipRRect(const SkRRect& rrect,
47 SkRegion::Op op = SkRegion::kIntersect_Op,
48 bool doAntiAlias = false) {return true;}
49 virtual bool clipPath(const SkPath& path,
50 SkRegion::Op op = SkRegion::kIntersect_Op,
51 bool doAntiAlias = false) {return true;}
52 virtual bool clipRegion(const SkRegion& deviceRgn,
53 SkRegion::Op op = SkRegion::kIntersect_Op) {return true;}
54 virtual void clear(SkColor) {}
55 virtual void drawPaint(const SkPaint& paint) {}
56 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
57 const SkPaint& paint) {}
bsalomon@google.com7ce564c2013-10-22 16:54:15 +000058 virtual void drawRect(const SkRect& rect, const SkPaint& paint) {}
edisonn@google.comac03d912013-07-22 15:36:39 +000059 virtual void drawOval(const SkRect& oval, const SkPaint&) {}
60 virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) {}
bsalomon@google.com7ce564c2013-10-22 16:54:15 +000061 virtual void drawPath(const SkPath& path, const SkPaint& paint) {}
edisonn@google.comac03d912013-07-22 15:36:39 +000062 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
63 const SkPaint* paint = NULL) {}
64 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
65 const SkRect& dst,
edisonn@google.com2c817772013-08-16 16:30:02 +000066 const SkPaint* paint,
67 DrawBitmapRectFlags flags) {}
edisonn@google.comac03d912013-07-22 15:36:39 +000068 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
69 const SkPaint* paint = NULL) {}
70 virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
71 const SkRect& dst, const SkPaint* paint = NULL) {}
72 virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
73 const SkPaint* paint = NULL) {}
74 virtual void drawText(const void* text, size_t byteLength, SkScalar x,
75 SkScalar y, const SkPaint& paint) {}
76 virtual void drawPosText(const void* text, size_t byteLength,
77 const SkPoint pos[], const SkPaint& paint) {}
78 virtual void drawPosTextH(const void* text, size_t byteLength,
79 const SkScalar xpos[], SkScalar constY,
80 const SkPaint& paint) {}
81 virtual void drawTextOnPath(const void* text, size_t byteLength,
82 const SkPath& path, const SkMatrix* matrix,
83 const SkPaint& paint) {}
84 virtual void drawPicture(SkPicture& picture) {}
85 virtual void drawVertices(VertexMode vmode, int vertexCount,
86 const SkPoint vertices[], const SkPoint texs[],
87 const SkColor colors[], SkXfermode* xmode,
88 const uint16_t indices[], int indexCount,
89 const SkPaint& paint) {}
90 virtual void drawData(const void* data, size_t length) {}
91 virtual void beginCommentGroup(const char* description) {}
92 virtual void addComment(const char* kywd, const char* value) {}
93 virtual void endCommentGroup() {}
94 virtual SkBounder* setBounder(SkBounder* bounder) {return NULL;}
95 virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) {return NULL;}
96
97protected:
98 virtual SkCanvas* canvasForDrawIter() {return NULL;}
robertphillips@google.com1f2f3382013-08-29 11:54:56 +000099 virtual SkBaseDevice* setDevice(SkBaseDevice* device) {return NULL;}
edisonn@google.comac03d912013-07-22 15:36:39 +0000100
101private:
102 typedef SkCanvas INHERITED;
103};
104
edisonn@google.comcf2cfa12013-08-21 16:31:37 +0000105#endif // SkNulCanvas_DEFINED