epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 4 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | #ifndef SkDrawFilter_DEFINED |
| 11 | #define SkDrawFilter_DEFINED |
| 12 | |
| 13 | #include "SkRefCnt.h" |
| 14 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 15 | class SkCanvas; |
| 16 | class SkPaint; |
| 17 | |
reed@google.com | 4e2b3d3 | 2011-04-07 14:18:59 +0000 | [diff] [blame] | 18 | /** |
fmalita | 61a237e | 2016-01-12 12:14:10 -0800 | [diff] [blame] | 19 | * DEPRECATED - use SkPaintFilterCanvas instead. |
| 20 | * |
reed@google.com | 4e2b3d3 | 2011-04-07 14:18:59 +0000 | [diff] [blame] | 21 | * 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.com | 4200dfe | 2012-10-13 17:13:18 +0000 | [diff] [blame] | 26 | class SK_API SkDrawFilter : public SkRefCnt { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 27 | public: |
| 28 | enum Type { |
| 29 | kPaint_Type, |
| 30 | kPoint_Type, |
| 31 | kLine_Type, |
| 32 | kBitmap_Type, |
| 33 | kRect_Type, |
commit-bot@chromium.org | f2bfd54 | 2013-04-25 15:27:00 +0000 | [diff] [blame] | 34 | kRRect_Type, |
jvanverth@google.com | 46d3d39 | 2013-01-22 13:34:01 +0000 | [diff] [blame] | 35 | kOval_Type, |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 36 | kPath_Type, |
caryclark@google.com | a362237 | 2012-11-06 21:26:13 +0000 | [diff] [blame] | 37 | kText_Type, |
reed@google.com | 971aca7 | 2012-11-26 20:26:54 +0000 | [diff] [blame] | 38 | }; |
caryclark@google.com | a362237 | 2012-11-06 21:26:13 +0000 | [diff] [blame] | 39 | |
reed@google.com | 971aca7 | 2012-11-26 20:26:54 +0000 | [diff] [blame] | 40 | enum { |
kkinnunen | a9baa65 | 2015-03-05 06:33:54 -0800 | [diff] [blame] | 41 | kTypeCount = kText_Type + 1 |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
reed@google.com | 4e2b3d3 | 2011-04-07 14:18:59 +0000 | [diff] [blame] | 44 | /** |
| 45 | * Called with the paint that will be used to draw the specified type. |
reed@google.com | 971aca7 | 2012-11-26 20:26:54 +0000 | [diff] [blame] | 46 | * The implementation may modify the paint as they wish. If filter() |
| 47 | * returns false, the draw will be skipped. |
reed@google.com | 4e2b3d3 | 2011-04-07 14:18:59 +0000 | [diff] [blame] | 48 | */ |
reed@google.com | 971aca7 | 2012-11-26 20:26:54 +0000 | [diff] [blame] | 49 | virtual bool filter(SkPaint*, Type) = 0; |
robertphillips@google.com | 15e9d3e | 2012-06-21 20:25:03 +0000 | [diff] [blame] | 50 | |
| 51 | private: |
| 52 | typedef SkRefCnt INHERITED; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | #endif |