djsollen@google.com | 339e79f | 2013-09-04 17:16:00 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 14 | class SkCanvasStack : public SkNWayCanvas { |
| 15 | public: |
| 16 | SkCanvasStack(int width, int height); |
| 17 | virtual ~SkCanvasStack(); |
| 18 | |
| 19 | void pushCanvas(SkCanvas* canvas, const SkIPoint& origin); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 20 | void removeAll() override; |
djsollen@google.com | 339e79f | 2013-09-04 17:16:00 +0000 | [diff] [blame] | 21 | |
| 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 | */ |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 28 | void addCanvas(SkCanvas*) override { SkDEBUGFAIL("Invalid Op"); } |
| 29 | void removeCanvas(SkCanvas*) override { SkDEBUGFAIL("Invalid Op"); } |
djsollen@google.com | 339e79f | 2013-09-04 17:16:00 +0000 | [diff] [blame] | 30 | |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 31 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 32 | void didSetMatrix(const SkMatrix&) override; |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 33 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 34 | void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; |
| 35 | void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; |
| 36 | void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; |
| 37 | void onClipRegion(const SkRegion&, SkRegion::Op) override; |
djsollen@google.com | 339e79f | 2013-09-04 17:16:00 +0000 | [diff] [blame] | 38 | |
| 39 | private: |
| 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 |