blob: ba2fed49321cdab30c4d497d5505a382c6948e98 [file] [log] [blame]
djsollen@google.com339e79f2013-09-04 17:16:00 +00001
2/*
3 * Copyright 2013 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 SkCanvasStack_DEFINED
10#define SkCanvasStack_DEFINED
11
12#include "SkNWayCanvas.h"
13#include "SkTArray.h"
14
15class SkCanvasStack : public SkNWayCanvas {
16public:
17 SkCanvasStack(int width, int height);
18 virtual ~SkCanvasStack();
19
20 void pushCanvas(SkCanvas* canvas, const SkIPoint& origin);
21 virtual void removeAll() SK_OVERRIDE;
22
23 /*
24 * The following add/remove canvas methods are overrides from SkNWayCanvas
25 * that do not make sense in the context of our CanvasStack, but since we
26 * can share most of the other implementation of NWay we override those
27 * methods to be no-ops.
28 */
djsollen@google.com19bcf6e2013-09-04 17:35:39 +000029 virtual void addCanvas(SkCanvas*) SK_OVERRIDE { SkDEBUGFAIL("Invalid Op"); }
30 virtual void removeCanvas(SkCanvas*) SK_OVERRIDE { SkDEBUGFAIL("Invalid Op"); }
djsollen@google.com339e79f2013-09-04 17:16:00 +000031
32 virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
robertphillips@google.com8f90a892014-02-28 18:19:39 +000033
34protected:
35 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
36 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
37 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
38 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
djsollen@google.com339e79f2013-09-04 17:16:00 +000039
40private:
41 void clipToZOrderedBounds();
42
43 struct CanvasData {
44 SkIPoint origin;
45 SkRegion requiredClip;
46 };
47
48 SkTArray<CanvasData> fCanvasData;
49
50 typedef SkNWayCanvas INHERITED;
51};
52
53#endif