reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2008 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 3 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 8 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 9 | #ifndef SkBlurDrawLooper_DEFINED |
| 10 | #define SkBlurDrawLooper_DEFINED |
| 11 | |
| 12 | #include "SkDrawLooper.h" |
| 13 | #include "SkColor.h" |
| 14 | |
| 15 | class SkMaskFilter; |
senorblanco@chromium.org | 4868e6b | 2011-02-18 19:03:01 +0000 | [diff] [blame] | 16 | class SkColorFilter; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 17 | |
| 18 | /** \class SkBlurDrawLooper |
| 19 | This class draws a shadow of the object (possibly offset), and then draws |
| 20 | the original object in its original position. |
| 21 | should there be an option to just draw the shadow/blur layer? webkit? |
| 22 | */ |
ctguil@chromium.org | 7ffb1b2 | 2011-03-15 21:27:08 +0000 | [diff] [blame] | 23 | class SK_API SkBlurDrawLooper : public SkDrawLooper { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 24 | public: |
senorblanco@chromium.org | 038aff6 | 2010-12-06 23:45:58 +0000 | [diff] [blame] | 25 | enum BlurFlags { |
| 26 | kNone_BlurFlag = 0x00, |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 27 | /** |
| 28 | The blur layer's dx/dy/radius aren't affected by the canvas |
senorblanco@chromium.org | 038aff6 | 2010-12-06 23:45:58 +0000 | [diff] [blame] | 29 | transform. |
| 30 | */ |
senorblanco@chromium.org | 4868e6b | 2011-02-18 19:03:01 +0000 | [diff] [blame] | 31 | kIgnoreTransform_BlurFlag = 0x01, |
| 32 | kOverrideColor_BlurFlag = 0x02, |
| 33 | kHighQuality_BlurFlag = 0x04, |
senorblanco@chromium.org | 038aff6 | 2010-12-06 23:45:58 +0000 | [diff] [blame] | 34 | /** mask for all blur flags */ |
senorblanco@chromium.org | 91f489a | 2012-11-29 17:09:27 +0000 | [diff] [blame] | 35 | kAll_BlurFlag = 0x07 |
senorblanco@chromium.org | 038aff6 | 2010-12-06 23:45:58 +0000 | [diff] [blame] | 36 | }; |
| 37 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 38 | SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy, SkColor color, |
senorblanco@chromium.org | 038aff6 | 2010-12-06 23:45:58 +0000 | [diff] [blame] | 39 | uint32_t flags = kNone_BlurFlag); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 40 | virtual ~SkBlurDrawLooper(); |
| 41 | |
| 42 | // overrides from SkDrawLooper |
reed@google.com | 4e2b3d3 | 2011-04-07 14:18:59 +0000 | [diff] [blame] | 43 | virtual void init(SkCanvas*); |
| 44 | virtual bool next(SkCanvas*, SkPaint* paint); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 45 | |
robertphillips@google.com | 4991b8f | 2013-01-28 20:21:59 +0000 | [diff] [blame] | 46 | SK_DEVELOPER_TO_STRING() |
djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 47 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurDrawLooper) |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 48 | |
| 49 | protected: |
| 50 | SkBlurDrawLooper(SkFlattenableReadBuffer&); |
djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 51 | virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 52 | |
| 53 | private: |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 54 | SkMaskFilter* fBlur; |
senorblanco@chromium.org | 4868e6b | 2011-02-18 19:03:01 +0000 | [diff] [blame] | 55 | SkColorFilter* fColorFilter; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 56 | SkScalar fDx, fDy; |
| 57 | SkColor fBlurColor; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 58 | uint32_t fBlurFlags; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 59 | |
| 60 | enum State { |
| 61 | kBeforeEdge, |
| 62 | kAfterEdge, |
| 63 | kDone |
| 64 | }; |
| 65 | State fState; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 66 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 67 | typedef SkDrawLooper INHERITED; |
| 68 | }; |
| 69 | |
| 70 | #endif |