blob: de0f6297d4304f6c5c8756804fdd89ecdf7e4fe7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkClipStackDevice_DEFINED
#define SkClipStackDevice_DEFINED
#include "SkClipStack.h"
#include "SkDevice.h"
class SK_API SkClipStackDevice : public SkBaseDevice {
public:
SkClipStackDevice(const SkImageInfo& info, const SkSurfaceProps& props)
: SkBaseDevice(info, props)
, fClipStack(fStorage, sizeof(fStorage))
{}
SkClipStack& cs() { return fClipStack; }
const SkClipStack& cs() const { return fClipStack; }
SkIRect devClipBounds() const;
protected:
void onSave() override;
void onRestore() override;
void onClipRect(const SkRect& rect, SkClipOp, bool aa) override;
void onClipRRect(const SkRRect& rrect, SkClipOp, bool aa) override;
void onClipPath(const SkPath& path, SkClipOp, bool aa) override;
void onClipRegion(const SkRegion& deviceRgn, SkClipOp) override;
void onSetDeviceClipRestriction(SkIRect* mutableClipRestriction) override;
bool onClipIsAA() const override;
void onAsRgnClip(SkRegion*) const override;
ClipType onGetClipType() const override;
private:
enum {
kPreallocCount = 16 // empirically determined, adjust as needed to reduce mallocs
};
intptr_t fStorage[kPreallocCount * sizeof(SkClipStack::Element) / sizeof(intptr_t)];
SkClipStack fClipStack;
typedef SkBaseDevice INHERITED;
};
#endif
|