blob: 89bb5c8921c0cbf3fc47ef16ce50c92f75e493ae [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
Mike Reed80747ef2018-01-23 15:29:32 -050011#include "SkMaskFilterBase.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000012
13/** \class SkEmbossMaskFilter
14
15 This mask filter creates a 3D emboss look, by specifying a light and blur amount.
16*/
Mike Reed80747ef2018-01-23 15:29:32 -050017class SK_API SkEmbossMaskFilter : public SkMaskFilterBase {
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
reedefdfd512016-04-04 10:02:58 -070026 static sk_sp<SkMaskFilter> Make(SkScalar blurSigma, const Light& light);
Ben Wagner63fd7602017-10-09 15:45:33 -040027
reed@android.com8a1c16f2008-12-17 15:59:43 +000028 // 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