• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/SkBlurTypes.h"
12 #include "src/core/SkClipStack.h"
13 #include "src/core/SkDevice.h"
14 
15 class SkClipStackDevice : public SkBaseDevice {
16 public:
SkClipStackDevice(const SkImageInfo & info,const SkSurfaceProps & props)17     SkClipStackDevice(const SkImageInfo& info, const SkSurfaceProps& props)
18         : SkBaseDevice(info, props)
19         , fClipStack(fStorage, sizeof(fStorage))
20     {}
21 
cs()22     SkClipStack& cs() { return fClipStack; }
cs()23     const SkClipStack& cs() const { return fClipStack; }
24 
25 protected:
26     void onSave() override;
27     void onRestore() override;
28     void onClipRect(const SkRect& rect, SkClipOp, bool aa) override;
29     void onClipRRect(const SkRRect& rrect, SkClipOp, bool aa) override;
30     void onClipPath(const SkPath& path, SkClipOp, bool aa) override;
31     void onClipShader(sk_sp<SkShader>) override;
32     void onClipRegion(const SkRegion& deviceRgn, SkClipOp) override;
33     void onReplaceClip(const SkIRect& rect) override;
34     bool onClipIsAA() const override;
35     bool onClipIsWideOpen() const override;
36     void onAsRgnClip(SkRegion*) const override;
37     ClipType onGetClipType() const override;
38     SkIRect onDevClipBounds() const override;
39 
drawBlurImage(const SkImage * image,const SkBlurArg & blurArg)40     bool drawBlurImage(const SkImage* image, const SkBlurArg& blurArg) override { return false; }
41 
42 private:
43     enum {
44         kPreallocCount = 16 // empirically determined, adjust as needed to reduce mallocs
45     };
46     intptr_t fStorage[kPreallocCount * sizeof(SkClipStack::Element) / sizeof(intptr_t)];
47     SkClipStack fClipStack;
48 
49     using INHERITED = SkBaseDevice;
50 };
51 
52 #endif
53