blob: b6bd1a164291b47b839f1c621884b8726308805f [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2006 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00003 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00004 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00006 */
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.org6806fe82012-10-12 14:41:39 +000017class SK_API SkEmbossMaskFilter : public SkMaskFilter {
reed@android.com8a1c16f2008-12-17 15:59:43 +000018public:
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
reed2d6ba662015-12-20 20:08:42 -080026 static SkEmbossMaskFilter* Create(SkScalar blurSigma, const Light& light);
reed@android.com8a1c16f2008-12-17 15:59:43 +000027
28 // overrides from SkMaskFilter
29 // This method is not exported to java.
mtklein36352bf2015-03-25 18:17:31 -070030 SkMask::Format getFormat() const override;
reed@android.com8a1c16f2008-12-17 15:59:43 +000031 // This method is not exported to java.
robertphillipse80eb922015-12-17 11:33:12 -080032 bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
33 SkIPoint* margin) const override;
reed@android.com8a1c16f2008-12-17 15:59:43 +000034
commit-bot@chromium.org0f10f7b2014-03-13 18:02:17 +000035 SK_TO_STRING_OVERRIDE()
djsollen@google.comba28d032012-03-26 17:57:35 +000036 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmbossMaskFilter)
37
reed@android.com8a1c16f2008-12-17 15:59:43 +000038protected:
commit-bot@chromium.org7c9d0f32014-02-21 10:13:32 +000039 SkEmbossMaskFilter(SkScalar blurSigma, const Light& light);
mtklein36352bf2015-03-25 18:17:31 -070040 void flatten(SkWriteBuffer&) const override;
commit-bot@chromium.org7c9d0f32014-02-21 10:13:32 +000041
reed@android.com8a1c16f2008-12-17 15:59:43 +000042private:
43 Light fLight;
robertphillips@google.com7ce661d2013-08-27 16:14:03 +000044 SkScalar fBlurSigma;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000045
reed@android.com8a1c16f2008-12-17 15:59:43 +000046 typedef SkMaskFilter INHERITED;
47};
48
49#endif