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