Skia
2D Graphics Library
SkCanvasVirtualEnforcer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 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 SkCanvasVirtualEnforcer_DEFINED
9 #define SkCanvasVirtualEnforcer_DEFINED
10 
11 #include "include/core/SkCanvas.h"
12 
13 // If you would ordinarily want to inherit from Base (eg SkCanvas, SkNWayCanvas), instead
14 // inherit from SkCanvasVirtualEnforcer<Base>, which will make the build fail if you forget
15 // to override one of SkCanvas' key virtual hooks.
16 template <typename Base>
17 class SkCanvasVirtualEnforcer : public Base {
18 public:
19  using Base::Base;
20 
21 protected:
22  void onDrawPaint(const SkPaint& paint) override = 0;
23  void onDrawBehind(const SkPaint&) override {} // make zero after android updates
24  void onDrawRect(const SkRect& rect, const SkPaint& paint) override = 0;
25  void onDrawRRect(const SkRRect& rrect, const SkPaint& paint) override = 0;
26  void onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
27  const SkPaint& paint) override = 0;
28  void onDrawOval(const SkRect& rect, const SkPaint& paint) override = 0;
29  void onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
30  const SkPaint& paint) override = 0;
31  void onDrawPath(const SkPath& path, const SkPaint& paint) override = 0;
32  void onDrawRegion(const SkRegion& region, const SkPaint& paint) override = 0;
33 
34  void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
35  const SkPaint& paint) override = 0;
36 
37  void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
38  const SkPoint texCoords[4], SkBlendMode mode,
39  const SkPaint& paint) override = 0;
40  void onDrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
41  const SkPaint& paint) override = 0;
42 
43 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
44  // This is under active development for Chrome and not used in Android. Hold off on adding
45  // implementations in Android's SkCanvas subclasses until this stabilizes.
46  void onDrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
47  SkCanvas::QuadAAFlags aaFlags, const SkColor4f& color, SkBlendMode mode) override {}
48 #else
49  void onDrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
50  SkCanvas::QuadAAFlags aaFlags, const SkColor4f& color, SkBlendMode mode) override = 0;
51 #endif
52 
53  void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) override = 0;
54  void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override = 0;
55 
56  void onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) override = 0;
57  void onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
58  const SkPaint* paint) override = 0;
59 };
60 
61 #endif
SkTextBlob
Definition: SkTextBlob.h:28
SkPath
Definition: SkPath.h:44
SkCanvasVirtualEnforcer::onDrawPaint
void onDrawPaint(const SkPaint &paint) override=0
SkCanvas.h
SkCanvasVirtualEnforcer::onDrawRRect
void onDrawRRect(const SkRRect &rrect, const SkPaint &paint) override=0
SkCanvasVirtualEnforcer::onDrawTextBlob
void onDrawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint) override=0
SkColor4f
SkBlendMode
SkBlendMode
Blends are operators that take in two colors (source, destination) and return a new color.
Definition: SkBlendMode.h:38
SkCanvasVirtualEnforcer::onDrawOval
void onDrawOval(const SkRect &rect, const SkPaint &paint) override=0
SkCanvasVirtualEnforcer::onDrawDrawable
void onDrawDrawable(SkDrawable *drawable, const SkMatrix *matrix) override=0
SkCanvasVirtualEnforcer
Definition: SkCanvasVirtualEnforcer.h:17
SkCanvasVirtualEnforcer::onDrawDRRect
void onDrawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint) override=0
SkData
SkData holds an immutable data buffer.
Definition: SkData.h:22
SkRRect
Definition: SkRRect.h:31
SkCanvasVirtualEnforcer::onDrawBehind
void onDrawBehind(const SkPaint &) override
Definition: SkCanvasVirtualEnforcer.h:23
SkCanvasVirtualEnforcer::onDrawPath
void onDrawPath(const SkPath &path, const SkPaint &paint) override=0
SkCanvasVirtualEnforcer::onDrawPicture
void onDrawPicture(const SkPicture *picture, const SkMatrix *matrix, const SkPaint *paint) override=0
SkCanvasVirtualEnforcer::onDrawShadowRec
void onDrawShadowRec(const SkPath &, const SkDrawShadowRec &) override=0
SkRegion
Definition: SkRegion.h:23
SkPoint
Definition: SkPoint.h:160
SkPaint
Definition: SkPaint.h:39
SkCanvasVirtualEnforcer::onDrawRegion
void onDrawRegion(const SkRegion &region, const SkPaint &paint) override=0
SkPicture
Definition: SkPicture.h:39
SkDrawable
Base-class for objects that draw into SkCanvas.
Definition: SkDrawable.h:29
SkCanvasVirtualEnforcer::onDrawAnnotation
void onDrawAnnotation(const SkRect &rect, const char key[], SkData *value) override=0
SkScalar
float SkScalar
Definition: SkScalar.h:16
SkCanvasVirtualEnforcer::onDrawPatch
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint &paint) override=0
SkCanvasVirtualEnforcer::onDrawEdgeAAQuad
void onDrawEdgeAAQuad(const SkRect &rect, const SkPoint clip[4], SkCanvas::QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode) override=0
SkMatrix
Definition: SkMatrix.h:48
SkColor
uint32_t SkColor
32-bit ARGB color value, unpremultiplied.
Definition: SkColor.h:35
SkRect
Definition: SkRect.h:572
SkCanvasVirtualEnforcer::onDrawPoints
void onDrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint) override=0
SkCanvas::QuadAAFlags
QuadAAFlags
Experimental.
Definition: SkCanvas.h:1566
SkCanvasVirtualEnforcer::onDrawRect
void onDrawRect(const SkRect &rect, const SkPaint &paint) override=0
SkCanvas::PointMode
PointMode
Definition: SkCanvas.h:1165
SkCanvasVirtualEnforcer::onDrawArc
void onDrawArc(const SkRect &rect, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint) override=0