aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkCanvasStack.h
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-04 17:16:00 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-04 17:16:00 +0000
commit339e79fbeabae18a8b9ea094293c7c25eaf9dd68 (patch)
treeeda72fb41ba782e0d4a1b78577ed924423bb3e31 /src/utils/SkCanvasStack.h
parent059a5a339b14b6fe4f942d57387fba7a9e1fea06 (diff)
Add SkCanvasStack and update the Canvas utilities to use it.
BUG= R=reed@google.com Review URL: https://codereview.chromium.org/23865004 git-svn-id: http://skia.googlecode.com/svn/trunk@11081 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils/SkCanvasStack.h')
-rw-r--r--src/utils/SkCanvasStack.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/utils/SkCanvasStack.h b/src/utils/SkCanvasStack.h
new file mode 100644
index 0000000000..2137d308b8
--- /dev/null
+++ b/src/utils/SkCanvasStack.h
@@ -0,0 +1,52 @@
+
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkCanvasStack_DEFINED
+#define SkCanvasStack_DEFINED
+
+#include "SkNWayCanvas.h"
+#include "SkTArray.h"
+
+class SkCanvasStack : public SkNWayCanvas {
+public:
+ SkCanvasStack(int width, int height);
+ virtual ~SkCanvasStack();
+
+ void pushCanvas(SkCanvas* canvas, const SkIPoint& origin);
+ virtual void removeAll() SK_OVERRIDE;
+
+ /*
+ * The following add/remove canvas methods are overrides from SkNWayCanvas
+ * that do not make sense in the context of our CanvasStack, but since we
+ * can share most of the other implementation of NWay we override those
+ * methods to be no-ops.
+ */
+ virtual void addCanvas(SkCanvas*) SK_OVERRIDE { SkASSERT(!"Invalid Op"); }
+ virtual void removeCanvas(SkCanvas*) SK_OVERRIDE { SkASSERT(!"Invalid Op"); }
+
+ virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
+ virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE;
+ virtual bool clipRRect(const SkRRect&, SkRegion::Op, bool) SK_OVERRIDE;
+ virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE;
+ virtual bool clipRegion(const SkRegion& deviceRgn,
+ SkRegion::Op) SK_OVERRIDE;
+
+private:
+ void clipToZOrderedBounds();
+
+ struct CanvasData {
+ SkIPoint origin;
+ SkRegion requiredClip;
+ };
+
+ SkTArray<CanvasData> fCanvasData;
+
+ typedef SkNWayCanvas INHERITED;
+};
+
+#endif