Debian Codegraph @

src/core/SkClipStackDevice.h

raw
1 /*
2 * Copyright 2017 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 SkClipStackDevice_DEFINED
9 #define SkClipStackDevice_DEFINED
10
11 #include "include/core/SkRect.h"
12 #include "include/core/SkRefCnt.h"
13 #include "src/core/SkClipStack.h"
14 #include "src/core/SkDevice.h"
15
16 #include <cstdint>
17
18 class SkPath;
19 class SkRRect;
20 class SkRegion;
21 class SkShader;
22 class SkSurfaceProps;
23 enum class SkClipOp;
24 struct SkImageInfo;
25
26 class SkClipStackDevice : public SkDevice {
27 public:
28 SkClipStackDevice(const SkImageInfo& info, const SkSurfaceProps& props)
29 : SkDevice(info, props)
30 , fClipStack(fStorage, sizeof(fStorage))
31 {}
32
33 SkClipStack& cs() { return fClipStack; }
34 const SkClipStack& cs() const { return fClipStack; }
35
36 void pushClipStack() override;
37 void popClipStack() override;
38
39 void clipRect(const SkRect& rect, SkClipOp, bool aa) override;
40 void clipRRect(const SkRRect& rrect, SkClipOp, bool aa) override;
41 void clipPath(const SkPath& path, SkClipOp, bool aa) override;
42 void clipRegion(const SkRegion& deviceRgn, SkClipOp) override;
43
44 void replaceClip(const SkIRect& rect) override;
45
46 bool isClipAntiAliased() const override;
47 bool isClipWideOpen() const override;
48 bool isClipEmpty() const override;
49 bool isClipRect() const override;
50
51 void android_utils_clipAsRgn(SkRegion*) const override;
52
53 SkIRect devClipBounds() const override;
54
55 private:
56 // empirically determined, adjust as needed to reduce mallocs
57 static constexpr int kPreallocCount = 16;
58
59 void onClipShader(sk_sp<SkShader>) override;
60
61 intptr_t fStorage[kPreallocCount * sizeof(SkClipStack::Element) / sizeof(intptr_t)];
62 SkClipStack fClipStack;
63 };
64
65 #endif