1 
2 /*
3  * Copyright 2011 Google Inc.
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 #ifndef SkNWayCanvas_DEFINED
10 #define SkNWayCanvas_DEFINED
11 
12 #include "SkCanvas.h"
13 
14 class SK_API SkNWayCanvas : public SkCanvas {
15 public:
16     SkNWayCanvas(int width, int height);
17     virtual ~SkNWayCanvas();
18 
19     virtual void addCanvas(SkCanvas*);
20     virtual void removeCanvas(SkCanvas*);
21     virtual void removeAll();
22 
23     ///////////////////////////////////////////////////////////////////////////
24     // These are forwarded to the N canvases we're referencing
25 
26     SkDrawFilter* setDrawFilter(SkDrawFilter*) override;
27 
28     void beginCommentGroup(const char* description) override;
29     void addComment(const char* kywd, const char* value) override;
30     void endCommentGroup() override;
31 
32 protected:
33     SkTDArray<SkCanvas*> fList;
34 
35     void willSave() override;
36     SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) override;
37     void willRestore() override;
38 
39     void didConcat(const SkMatrix&) override;
40     void didSetMatrix(const SkMatrix&) override;
41 
42     void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
43     virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
44                             const SkPaint&) override;
45     virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
46                                const SkPaint&) override;
47     virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
48                                 SkScalar constY, const SkPaint&) override;
49     virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
50                                   const SkMatrix* matrix, const SkPaint&) override;
51     virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
52                                 const SkPaint& paint) override;
53     virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
54                              const SkPoint texCoords[4], SkXfermode* xmode,
55                              const SkPaint& paint) override;
56 
57     void onDrawPaint(const SkPaint&) override;
58     void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
59     void onDrawRect(const SkRect&, const SkPaint&) override;
60     void onDrawOval(const SkRect&, const SkPaint&) override;
61     void onDrawRRect(const SkRRect&, const SkPaint&) override;
62     void onDrawPath(const SkPath&, const SkPaint&) override;
63     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
64     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
65                           DrawBitmapRectFlags flags) override;
66     void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
67     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
68                          const SkPaint*) override;
69     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
70                           const SkPaint*) override;
71     void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override;
72     void onDrawVertices(VertexMode vmode, int vertexCount,
73                               const SkPoint vertices[], const SkPoint texs[],
74                               const SkColor colors[], SkXfermode* xmode,
75                               const uint16_t indices[], int indexCount,
76                               const SkPaint&) override;
77 
78     void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
79     void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
80     void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;
81     void onClipRegion(const SkRegion&, SkRegion::Op) override;
82 
83     void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
84 
85     class Iter;
86 
87 private:
88     typedef SkCanvas INHERITED;
89 };
90 
91 
92 #endif
93