Line data Source code
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 "SkClipStack.h"
12 : #include "SkDevice.h"
13 :
14 0 : class SK_API SkClipStackDevice : public SkBaseDevice {
15 : public:
16 0 : SkClipStackDevice(const SkImageInfo& info, const SkSurfaceProps& props)
17 0 : : SkBaseDevice(info, props)
18 0 : , fClipStack(fStorage, sizeof(fStorage))
19 0 : {}
20 :
21 0 : SkClipStack& cs() { return fClipStack; }
22 0 : const SkClipStack& cs() const { return fClipStack; }
23 :
24 : SkIRect devClipBounds() const;
25 :
26 : protected:
27 : void onSave() override;
28 : void onRestore() override;
29 : void onClipRect(const SkRect& rect, SkClipOp, bool aa) override;
30 : void onClipRRect(const SkRRect& rrect, SkClipOp, bool aa) override;
31 : void onClipPath(const SkPath& path, SkClipOp, bool aa) override;
32 : void onClipRegion(const SkRegion& deviceRgn, SkClipOp) override;
33 : void onSetDeviceClipRestriction(SkIRect* mutableClipRestriction) override;
34 : bool onClipIsAA() const override;
35 : void onAsRgnClip(SkRegion*) const override;
36 : ClipType onGetClipType() const override;
37 :
38 : private:
39 : enum {
40 : kPreallocCount = 16 // empirically determined, adjust as needed to reduce mallocs
41 : };
42 : intptr_t fStorage[kPreallocCount * sizeof(SkClipStack::Element) / sizeof(intptr_t)];
43 : SkClipStack fClipStack;
44 :
45 : typedef SkBaseDevice INHERITED;
46 : };
47 :
48 : #endif
|