• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SkDrawFilter_DEFINED
18 #define SkDrawFilter_DEFINED
19 
20 #include "SkRefCnt.h"
21 
22 ////////////////// EXPERIMENTAL //////////////////////////
23 
24 class SkCanvas;
25 class SkPaint;
26 
27 /** Right before something is being draw, filter() is called with the
28     current canvas and paint. If it returns true, then drawing proceeds
29     with the (possibly modified) canvas/paint, and then restore() is called
30     to restore the canvas/paint to their state before filter() was called.
31     If filter returns false, canvas/paint should not have been changed, and
32     restore() will not be called.
33 */
34 class SkDrawFilter : public SkRefCnt {
35 public:
36     enum Type {
37         kPaint_Type,
38         kPoint_Type,
39         kLine_Type,
40         kBitmap_Type,
41         kRect_Type,
42         kPath_Type,
43         kText_Type
44     };
45 
46     /** Return true to allow the draw to continue (with possibly modified
47         canvas/paint). If true is returned, then restore() will be called.
48     */
49     virtual bool filter(SkCanvas*, SkPaint*, Type) = 0;
50     /** If filter() returned true, then restore() will be called to restore the
51         canvas/paint to their previous states
52     */
53     virtual void restore(SkCanvas*, SkPaint*, Type) = 0;
54 };
55 
56 #endif
57