aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkCanvasVirtualEnforcer.h
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2018-03-09 13:40:31 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-09 19:43:41 +0000
commit37886ce8cd7ff7ab9ac7f6440bd31abfd39955e5 (patch)
treeef2f462295f5f214e75bf431d2aede181e8d31aa /include/core/SkCanvasVirtualEnforcer.h
parente5daecd5c3d6a62cff065266cc40e5373bc5a473 (diff)
Shim to enforce that canvas virtuals are overridden
Change-Id: Iad70d449bbc43195baefd70d20c41996a8435e6e Reviewed-on: https://skia-review.googlesource.com/113320 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'include/core/SkCanvasVirtualEnforcer.h')
-rw-r--r--include/core/SkCanvasVirtualEnforcer.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/include/core/SkCanvasVirtualEnforcer.h b/include/core/SkCanvasVirtualEnforcer.h
new file mode 100644
index 0000000000..1999802170
--- /dev/null
+++ b/include/core/SkCanvasVirtualEnforcer.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkCanvasVirtualEnforcer_DEFINED
+#define SkCanvasVirtualEnforcer_DEFINED
+
+#include "SkCanvas.h"
+
+// If you would ordinarily want to inherit from Base (eg SkCanvas, SkNWayCanvas), instead
+// inherit from SkCanvasVirtualEnforcer<Base>, which will make the build fail if you forget
+// to override one of SkCanvas' key virtual hooks.
+template <typename Base>
+class SkCanvasVirtualEnforcer : public Base {
+public:
+ using Base::Base;
+
+protected:
+ void onDrawPaint(const SkPaint& paint) override = 0;
+ void onDrawRect(const SkRect& rect, const SkPaint& paint) override = 0;
+ void onDrawRRect(const SkRRect& rrect, const SkPaint& paint) override = 0;
+ void onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
+ const SkPaint& paint) override = 0;
+ void onDrawOval(const SkRect& rect, const SkPaint& paint) override = 0;
+ void onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
+ const SkPaint& paint) override = 0;
+ void onDrawPath(const SkPath& path, const SkPaint& paint) override = 0;
+ void onDrawRegion(const SkRegion& region, const SkPaint& paint) override = 0;
+
+ void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint& paint) override = 0;
+ void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
+ const SkPaint& paint) override = 0;
+ void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
+ SkScalar constY, const SkPaint& paint) override = 0;
+ void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
+ const SkMatrix* matrix, const SkPaint& paint) override = 0;
+ void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
+ const SkRect* cullRect, const SkPaint& paint) override = 0;
+ void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
+ const SkPaint& paint) override = 0;
+
+ void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
+ const SkPoint texCoords[4], SkBlendMode mode,
+ const SkPaint& paint) override = 0;
+ void onDrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
+ const SkPaint& paint) override = 0;
+ void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
+ const SkPaint& paint) override = 0;
+
+ void onDrawImage(const SkImage* image, SkScalar dx, SkScalar dy,
+ const SkPaint* paint) override = 0;
+ void onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
+ const SkPaint* paint, SkCanvas::SrcRectConstraint constraint) override = 0;
+ void onDrawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
+ const SkPaint* paint) override = 0;
+ void onDrawImageLattice(const SkImage* image, const SkCanvas::Lattice& lattice,
+ const SkRect& dst, const SkPaint* paint) override = 0;
+
+ void onDrawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy,
+ const SkPaint* paint) override = 0;
+ void onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
+ const SkPaint* paint,
+ SkCanvas::SrcRectConstraint constraint) override = 0;
+ void onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst,
+ const SkPaint* paint) override = 0;
+ void onDrawBitmapLattice(const SkBitmap& bitmap, const SkCanvas::Lattice& lattice,
+ const SkRect& dst, const SkPaint* paint) override = 0;
+
+ void onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect rect[],
+ const SkColor colors[], int count, SkBlendMode mode, const SkRect* cull,
+ const SkPaint* paint) override = 0;
+
+ void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) override = 0;
+ void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override = 0;
+
+ void onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) override = 0;
+ void onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
+ const SkPaint* paint) override = 0;
+};
+
+#endif