180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2011 The Android Open Source Project
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkDrawFilter_DEFINED
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkDrawFilter_DEFINED
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkRefCnt.h"
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkCanvas;
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkPaint;
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/**
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *  Right before something is being draw, filter() is called with the
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *  paint. The filter may modify the paint as it wishes, which will then be
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *  used for the actual drawing. Note: this modification only lasts for the
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *  current draw, as a temporary copy of the paint is used.
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SK_API SkDrawFilter : public SkRefCnt {
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SK_DECLARE_INST_COUNT(SkDrawFilter)
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum Type {
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kPaint_Type,
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kPoint_Type,
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kLine_Type,
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kBitmap_Type,
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kRect_Type,
347839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger        kRRect_Type,
35d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger        kOval_Type,
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kPath_Type,
37363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger        kText_Type,
38363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    };
39363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger
40363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    enum {
41363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger        kTypeCount = kText_Type + 1
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Called with the paint that will be used to draw the specified type.
46363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  The implementation may modify the paint as they wish. If filter()
47363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  returns false, the draw will be skipped.
4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
49363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    virtual bool filter(SkPaint*, Type) = 0;
5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef SkRefCnt INHERITED;
5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
56