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 2006 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 | |
| 8 | #ifndef SkEmbossMaskFilter_DEFINED |
| 9 | #define SkEmbossMaskFilter_DEFINED |
| 10 | |
| 11 | #include "SkMaskFilter.h" |
| 12 | |
| 13 | /** \class SkEmbossMaskFilter |
| 14 | |
| 15 | This mask filter creates a 3D emboss look, by specifying a light and blur amount. |
| 16 | */ |
tfarina@chromium.org | 6806fe8 | 2012-10-12 14:41:39 +0000 | [diff] [blame] | 17 | class SK_API SkEmbossMaskFilter : public SkMaskFilter { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 18 | public: |
| 19 | struct Light { |
| 20 | SkScalar fDirection[3]; // x,y,z |
| 21 | uint16_t fPad; |
| 22 | uint8_t fAmbient; |
| 23 | uint8_t fSpecular; // exponent, 4.4 right now |
| 24 | }; |
| 25 | |
commit-bot@chromium.org | 7c9d0f3 | 2014-02-21 10:13:32 +0000 | [diff] [blame^] | 26 | static SkEmbossMaskFilter* Create(SkScalar blurSigma, const Light& light) { |
| 27 | return SkNEW_ARGS(SkEmbossMaskFilter, (blurSigma, light)); |
| 28 | } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 29 | |
| 30 | // overrides from SkMaskFilter |
| 31 | // This method is not exported to java. |
reed@google.com | 30711b7 | 2012-12-18 19:18:39 +0000 | [diff] [blame] | 32 | virtual SkMask::Format getFormat() const SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 33 | // This method is not exported to java. |
mike@reedtribe.org | 6b919c3 | 2011-04-20 11:17:30 +0000 | [diff] [blame] | 34 | virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, |
reed@google.com | 30711b7 | 2012-12-18 19:18:39 +0000 | [diff] [blame] | 35 | SkIPoint* margin) const SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 36 | |
robertphillips@google.com | 0bd80fa | 2013-03-18 17:53:38 +0000 | [diff] [blame] | 37 | SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;) |
djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 38 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmbossMaskFilter) |
| 39 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 40 | protected: |
commit-bot@chromium.org | 8b0e8ac | 2014-01-30 18:58:24 +0000 | [diff] [blame] | 41 | SkEmbossMaskFilter(SkReadBuffer&); |
| 42 | virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 43 | |
commit-bot@chromium.org | 7c9d0f3 | 2014-02-21 10:13:32 +0000 | [diff] [blame^] | 44 | #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS |
| 45 | public: |
| 46 | #endif |
| 47 | SkEmbossMaskFilter(SkScalar blurSigma, const Light& light); |
| 48 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 49 | private: |
| 50 | Light fLight; |
robertphillips@google.com | 7ce661d | 2013-08-27 16:14:03 +0000 | [diff] [blame] | 51 | SkScalar fBlurSigma; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 52 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 53 | typedef SkMaskFilter INHERITED; |
| 54 | }; |
| 55 | |
| 56 | #endif |