Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkCanvasStack.h
Go to the documentation of this file.
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
12#include "include/core/SkM44.h"
20
21#include <memory>
22#include <type_traits>
23
24class SkPath;
25class SkRRect;
26class SkShader;
27enum class SkClipOp;
28struct SkRect;
29
30/**
31 * Like NWayCanvas, in that it forwards all canvas methods to each sub-canvas that is "pushed".
32 *
33 * Unlike NWayCanvas, this takes ownership of each subcanvas, and deletes them when this canvas
34 * is deleted.
35 */
37public:
38 SkCanvasStack(int width, int height);
39 ~SkCanvasStack() override;
40
41 void pushCanvas(std::unique_ptr<SkCanvas>, const SkIPoint& origin);
42 void removeAll() override;
43
44 /*
45 * The following add/remove canvas methods are overrides from SkNWayCanvas
46 * that do not make sense in the context of our CanvasStack, but since we
47 * can share most of the other implementation of NWay we override those
48 * methods to be no-ops.
49 */
50 void addCanvas(SkCanvas*) override { SkDEBUGFAIL("Invalid Op"); }
51 void removeCanvas(SkCanvas*) override { SkDEBUGFAIL("Invalid Op"); }
52
53protected:
54 void didSetM44(const SkM44&) override;
55
56 void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
57 void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
58 void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
60 void onClipRegion(const SkRegion&, SkClipOp) override;
61
62private:
63 void clipToZOrderedBounds();
64
65 struct CanvasData {
66 SkIPoint origin;
67 SkRegion requiredClip;
68 std::unique_ptr<SkCanvas> ownedCanvas;
69
70 static_assert(::sk_is_trivially_relocatable<decltype(origin)>::value);
71 static_assert(::sk_is_trivially_relocatable<decltype(requiredClip)>::value);
72 static_assert(::sk_is_trivially_relocatable<decltype(ownedCanvas)>::value);
73
74 using sk_is_trivially_relocatable = std::true_type;
75 };
76
78
79 using INHERITED = SkNWayCanvas;
80};
81
82#endif
#define SkDEBUGFAIL(message)
Definition SkAssert.h:118
SkClipOp
Definition SkClipOp.h:13
~SkCanvasStack() override
void addCanvas(SkCanvas *) override
void pushCanvas(std::unique_ptr< SkCanvas >, const SkIPoint &origin)
void didSetM44(const SkM44 &) override
void removeAll() override
void onClipRegion(const SkRegion &, SkClipOp) override
void onClipRRect(const SkRRect &, SkClipOp, ClipEdgeStyle) override
void onClipShader(sk_sp< SkShader >, SkClipOp) override
void removeCanvas(SkCanvas *) override
void onClipRect(const SkRect &, SkClipOp, ClipEdgeStyle) override
void onClipPath(const SkPath &, SkClipOp, ClipEdgeStyle) override
Definition SkM44.h:150
int32_t height
int32_t width