1 
2 /*
3  * Copyright 2011 The Android Open Source Project
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 
10 #ifndef SkDrawFilter_DEFINED
11 #define SkDrawFilter_DEFINED
12 
13 #include "SkRefCnt.h"
14 
15 class SkCanvas;
16 class SkPaint;
17 
18 /**
19  *  Right before something is being draw, filter() is called with the
20  *  paint. The filter may modify the paint as it wishes, which will then be
21  *  used for the actual drawing. Note: this modification only lasts for the
22  *  current draw, as a temporary copy of the paint is used.
23  */
24 class SK_API SkDrawFilter : public SkRefCnt {
25 public:
26     SK_DECLARE_INST_COUNT(SkDrawFilter)
27 
28     enum Type {
29         kPaint_Type,
30         kPoint_Type,
31         kLine_Type,
32         kBitmap_Type,
33         kRect_Type,
34         kRRect_Type,
35         kOval_Type,
36         kPath_Type,
37         kText_Type,
38     };
39 
40     enum {
41         kTypeCount = kText_Type + 1
42     };
43 
44     /**
45      *  Called with the paint that will be used to draw the specified type.
46      *  The implementation may modify the paint as they wish. If filter()
47      *  returns false, the draw will be skipped.
48      */
49     virtual bool filter(SkPaint*, Type) = 0;
50 
51 private:
52     typedef SkRefCnt INHERITED;
53 };
54 
55 #endif
56