aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkDrawFilter.h
blob: db5a68519189d7f7ad392f6b215a7c057c0811ea (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
49
50
51
52
53
54
55
56
/*
 * Copyright (C) 2008 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SkDrawFilter_DEFINED
#define SkDrawFilter_DEFINED

#include "SkRefCnt.h"

////////////////// EXPERIMENTAL //////////////////////////

class SkCanvas;
class SkPaint;

/** Right before something is being draw, filter() is called with the
    current canvas and paint. If it returns true, then drawing proceeds
    with the (possibly modified) canvas/paint, and then restore() is called
    to restore the canvas/paint to their state before filter() was called.
    If filter returns false, canvas/paint should not have been changed, and
    restore() will not be called.
*/
class SkDrawFilter : public SkRefCnt {
public:
    enum Type {
        kPaint_Type,
        kPoint_Type,
        kLine_Type,
        kBitmap_Type,
        kRect_Type,
        kPath_Type,
        kText_Type
    };

    /** Return true to allow the draw to continue (with possibly modified
        canvas/paint). If true is returned, then restore() will be called.
    */
    virtual bool filter(SkCanvas*, SkPaint*, Type) = 0;
    /** If filter() returned true, then restore() will be called to restore the
        canvas/paint to their previous states
    */
    virtual void restore(SkCanvas*, SkPaint*, Type) = 0;
};

#endif