blob: 2812017b71120f32918d13bdd8f4bdfa2df1576c [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@android.com8a1c16f2008-12-17 15:59:43 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2011 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@android.com8a1c16f2008-12-17 15:59:43 +000010#ifndef SkDrawFilter_DEFINED
11#define SkDrawFilter_DEFINED
12
13#include "SkRefCnt.h"
14
reed@android.com8a1c16f2008-12-17 15:59:43 +000015class SkCanvas;
16class SkPaint;
17
reed@google.com4e2b3d32011-04-07 14:18:59 +000018/**
fmalita61a237e2016-01-12 12:14:10 -080019 * DEPRECATED - use SkPaintFilterCanvas instead.
20 *
reed@google.com4e2b3d32011-04-07 14:18:59 +000021 * Right before something is being draw, filter() is called with the
22 * paint. The filter may modify the paint as it wishes, which will then be
23 * used for the actual drawing. Note: this modification only lasts for the
24 * current draw, as a temporary copy of the paint is used.
25 */
bungeman@google.com4200dfe2012-10-13 17:13:18 +000026class SK_API SkDrawFilter : public SkRefCnt {
reed@android.com8a1c16f2008-12-17 15:59:43 +000027public:
28 enum Type {
29 kPaint_Type,
30 kPoint_Type,
31 kLine_Type,
32 kBitmap_Type,
33 kRect_Type,
commit-bot@chromium.orgf2bfd542013-04-25 15:27:00 +000034 kRRect_Type,
jvanverth@google.com46d3d392013-01-22 13:34:01 +000035 kOval_Type,
reed@android.com8a1c16f2008-12-17 15:59:43 +000036 kPath_Type,
caryclark@google.coma3622372012-11-06 21:26:13 +000037 kText_Type,
reed@google.com971aca72012-11-26 20:26:54 +000038 };
caryclark@google.coma3622372012-11-06 21:26:13 +000039
reed@google.com971aca72012-11-26 20:26:54 +000040 enum {
kkinnunena9baa652015-03-05 06:33:54 -080041 kTypeCount = kText_Type + 1
reed@android.com8a1c16f2008-12-17 15:59:43 +000042 };
43
reed@google.com4e2b3d32011-04-07 14:18:59 +000044 /**
45 * Called with the paint that will be used to draw the specified type.
reed@google.com971aca72012-11-26 20:26:54 +000046 * The implementation may modify the paint as they wish. If filter()
47 * returns false, the draw will be skipped.
reed@google.com4e2b3d32011-04-07 14:18:59 +000048 */
reed@google.com971aca72012-11-26 20:26:54 +000049 virtual bool filter(SkPaint*, Type) = 0;
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +000050
51private:
52 typedef SkRefCnt INHERITED;
reed@android.com8a1c16f2008-12-17 15:59:43 +000053};
54
55#endif