diff options
author | 2017-01-13 14:37:37 -0500 | |
---|---|---|
committer | 2017-01-13 20:09:02 +0000 | |
commit | 43475ad9dc43c4cbe13d924d8caff8916dcbbc06 (patch) | |
tree | 7d88d02b2e5992771832ee73604ed023ed9361f1 /src/effects | |
parent | d4652ca1b7989af5ef4e81b0de4eba529f804618 (diff) |
Move Android shadow rendering interface to util library.
BUG=skia:6119
Change-Id: I8318cf2758042ffd0c81c5fa74240acbf7bea61f
Reviewed-on: https://skia-review.googlesource.com/6999
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/effects')
-rwxr-xr-x | src/effects/SkShadowMaskFilter.cpp | 2 | ||||
-rwxr-xr-x | src/effects/SkShadowMaskFilter.h | 51 |
2 files changed, 52 insertions, 1 deletions
diff --git a/src/effects/SkShadowMaskFilter.cpp b/src/effects/SkShadowMaskFilter.cpp index f1012f5e0f..61a93b8982 100755 --- a/src/effects/SkShadowMaskFilter.cpp +++ b/src/effects/SkShadowMaskFilter.cpp @@ -234,7 +234,7 @@ bool SkShadowMaskFilterImpl::directFilterRRectMaskGPU(GrContext*, static const float kGeomFactor = 64.0f; SkScalar srcSpaceAmbientRadius = fOccluderHeight * kHeightFactor * kGeomFactor; - const float umbraAlpha = 1.0f / (1.0f + SkTMax(fOccluderHeight * kHeightFactor, 0.0f)); + const float umbraAlpha = (1.0f + SkTMax(fOccluderHeight * kHeightFactor, 0.0f)); const SkScalar ambientOffset = srcSpaceAmbientRadius * umbraAlpha; // For the ambient rrect, we inset the offset rect by half the srcSpaceAmbientRadius diff --git a/src/effects/SkShadowMaskFilter.h b/src/effects/SkShadowMaskFilter.h new file mode 100755 index 0000000000..a85da63db9 --- /dev/null +++ b/src/effects/SkShadowMaskFilter.h @@ -0,0 +1,51 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkShadowMaskFilter_DEFINED +#define SkShadowMaskFilter_DEFINED + +#include "SkMaskFilter.h" + + +/* + * This filter implements a pair of shadows for an occluding object-- one representing + * ambient occlusion, and one representing a displaced shadow from a point light. + */ +class SK_API SkShadowMaskFilter { +public: + enum ShadowFlags { + kNone_ShadowFlag = 0x00, + /** The occluding object is not opaque. Knowing that the occluder is opaque allows + * us to cull shadow geometry behind it and improve performance. */ + kTransparentOccluder_ShadowFlag = 0x01, + /** Use a larger umbra for a darker shadow */ + kLargerUmbra_ShadowFlag = 0x02, + /** Use a Gaussian for the edge function rather than smoothstep */ + kGaussianEdge_ShadowFlag = 0x04, + /** mask for all shadow flags */ + kAll_ShadowFlag = 0x07 + }; + + /** Create a shadow maskfilter. + * @param occluderHeight Height of occluding object off of ground plane. + * @param lightPos Position of the light applied to this object. + * @param lightRadius Radius of the light (light is assumed to be spherical). + * @param ambientAlpha Base opacity of the ambient occlusion shadow. + * @param spotAlpha Base opacity of the displaced spot shadow. + * @param flags Flags to use - defaults to none + * @return The new shadow maskfilter + */ + static sk_sp<SkMaskFilter> Make(SkScalar occluderHeight, const SkPoint3& lightPos, + SkScalar lightRadius, SkScalar ambientAlpha, + SkScalar spotAlpha, uint32_t flags = kNone_ShadowFlag); + + SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() + +private: + SkShadowMaskFilter(); // can't be instantiated +}; +#endif |