blob: 762ab9f76f3c3f2199941e21e87367b9c0446561 [file] [log] [blame]
djsollen@google.com339e79f2013-09-04 17:16:00 +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 SkCanvasStack_DEFINED
9#define SkCanvasStack_DEFINED
10
11#include "SkNWayCanvas.h"
12#include "SkTArray.h"
13
14class SkCanvasStack : public SkNWayCanvas {
15public:
16 SkCanvasStack(int width, int height);
17 virtual ~SkCanvasStack();
18
19 void pushCanvas(SkCanvas* canvas, const SkIPoint& origin);
mtklein36352bf2015-03-25 18:17:31 -070020 void removeAll() override;
djsollen@google.com339e79f2013-09-04 17:16:00 +000021
22 /*
23 * The following add/remove canvas methods are overrides from SkNWayCanvas
24 * that do not make sense in the context of our CanvasStack, but since we
25 * can share most of the other implementation of NWay we override those
26 * methods to be no-ops.
27 */
mtklein36352bf2015-03-25 18:17:31 -070028 void addCanvas(SkCanvas*) override { SkDEBUGFAIL("Invalid Op"); }
29 void removeCanvas(SkCanvas*) override { SkDEBUGFAIL("Invalid Op"); }
djsollen@google.com339e79f2013-09-04 17:16:00 +000030
robertphillips@google.com8f90a892014-02-28 18:19:39 +000031protected:
mtklein36352bf2015-03-25 18:17:31 -070032 void didSetMatrix(const SkMatrix&) override;
commit-bot@chromium.org44c48d02014-03-13 20:03:58 +000033
reed73603f32016-09-20 08:42:38 -070034 void onClipRect(const SkRect&, ClipOp, ClipEdgeStyle) override;
35 void onClipRRect(const SkRRect&, ClipOp, ClipEdgeStyle) override;
36 void onClipPath(const SkPath&, ClipOp, ClipEdgeStyle) override;
37 void onClipRegion(const SkRegion&, ClipOp) override;
djsollen@google.com339e79f2013-09-04 17:16:00 +000038
39private:
40 void clipToZOrderedBounds();
41
42 struct CanvasData {
43 SkIPoint origin;
44 SkRegion requiredClip;
45 };
46
47 SkTArray<CanvasData> fCanvasData;
48
49 typedef SkNWayCanvas INHERITED;
50};
51
52#endif