blob: 0843911181f353446d8e58526e8d80c77504a890 [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
commit-bot@chromium.org7c9d0f32014-02-21 10:13:32 +000026 static SkEmbossMaskFilter* Create(SkScalar blurSigma, const Light& light) {
27 return SkNEW_ARGS(SkEmbossMaskFilter, (blurSigma, light));
28 }
reed@android.com8a1c16f2008-12-17 15:59:43 +000029
30 // overrides from SkMaskFilter
31 // This method is not exported to java.
reed@google.com30711b72012-12-18 19:18:39 +000032 virtual SkMask::Format getFormat() const SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000033 // This method is not exported to java.
mike@reedtribe.org6b919c32011-04-20 11:17:30 +000034 virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
reed@google.com30711b72012-12-18 19:18:39 +000035 SkIPoint* margin) const SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000036
robertphillips@google.com0bd80fa2013-03-18 17:53:38 +000037 SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;)
djsollen@google.comba28d032012-03-26 17:57:35 +000038 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmbossMaskFilter)
39
reed@android.com8a1c16f2008-12-17 15:59:43 +000040protected:
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000041 SkEmbossMaskFilter(SkReadBuffer&);
42 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000043
commit-bot@chromium.org7c9d0f32014-02-21 10:13:32 +000044#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
45public:
46#endif
47 SkEmbossMaskFilter(SkScalar blurSigma, const Light& light);
48
reed@android.com8a1c16f2008-12-17 15:59:43 +000049private:
50 Light fLight;
robertphillips@google.com7ce661d2013-08-27 16:14:03 +000051 SkScalar fBlurSigma;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000052
reed@android.com8a1c16f2008-12-17 15:59:43 +000053 typedef SkMaskFilter INHERITED;
54};
55
56#endif