diff options
author | Jim Van Verth <jvanverth@google.com> | 2017-01-30 13:11:45 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-30 18:44:38 +0000 |
commit | efe3dedbb3493b738abdb56041b093245e4e8711 (patch) | |
tree | 5f38ba81ebc59b48e4888a6e5779e6dbc049c5ad /src/effects/shadows | |
parent | 08c5ec71303aa58d6f081914f3e868fa5cce9f4c (diff) |
Change shadow tessellators to use SkColor and move to util.
BUG=skia:6119
Change-Id: I4c4a8933c663ccc057596318a06c538175b9f16b
Reviewed-on: https://skia-review.googlesource.com/7726
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src/effects/shadows')
-rwxr-xr-x | src/effects/shadows/SkAmbientShadowMaskFilter.cpp | 36 | ||||
-rwxr-xr-x | src/effects/shadows/SkSpotShadowMaskFilter.cpp | 37 |
2 files changed, 8 insertions, 65 deletions
diff --git a/src/effects/shadows/SkAmbientShadowMaskFilter.cpp b/src/effects/shadows/SkAmbientShadowMaskFilter.cpp index 0672020bcf..9db75c5acb 100755 --- a/src/effects/shadows/SkAmbientShadowMaskFilter.cpp +++ b/src/effects/shadows/SkAmbientShadowMaskFilter.cpp @@ -17,8 +17,6 @@ #include "GrStyle.h" #include "GrTexture.h" #include "GrTextureProxy.h" -#include "effects/GrBlurredEdgeFragmentProcessor.h" -#include "effects/GrShadowTessellator.h" #include "SkStrokeRec.h" #endif @@ -164,41 +162,21 @@ bool SkAmbientShadowMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texPr return false; } -#ifdef SUPPORT_FAST_PATH // if circle // TODO: switch to SkScalarNearlyEqual when either oval renderer is updated or we // have our own GeometryProc. if (path.isOval(nullptr) && path.getBounds().width() == path.getBounds().height()) { SkRRect rrect = SkRRect::MakeOval(path.getBounds()); - return this->directFilterRRectMaskGPU(nullptr, drawContext, std::move(paint), clip, + return this->directFilterRRectMaskGPU(nullptr, rtContext, std::move(paint), clip, SkMatrix::I(), strokeRec, rrect, rrect); } else if (path.isRect(nullptr)) { SkRRect rrect = SkRRect::MakeRect(path.getBounds()); - return this->directFilterRRectMaskGPU(nullptr, drawContext, std::move(paint), clip, + return this->directFilterRRectMaskGPU(nullptr, rtContext, std::move(paint), clip, SkMatrix::I(), strokeRec, rrect, rrect); } -#endif - - SkScalar radius = fOccluderHeight * kHeightFactor * kGeomFactor; - SkScalar umbraAlpha = SkScalarInvert((1.0f+SkTMax(fOccluderHeight * kHeightFactor, 0.0f))); - // umbraColor is the interior value, penumbraColor the exterior value. - // umbraAlpha is the factor that is linearly interpolated from outside to inside, and - // then "blurred" by the GrBlurredEdgeFP. It is then multiplied by fAmbientAlpha to get - // the final alpha. - GrColor umbraColor = GrColorPackRGBA(0, 0, umbraAlpha*255.9999f, fAmbientAlpha*255.9999f); - GrColor penumbraColor = GrColorPackRGBA(0, 0, 0, fAmbientAlpha*255.9999f); - - GrAmbientShadowTessellator tess(path, radius, umbraColor, penumbraColor, - SkToBool(fFlags & SkShadowFlags::kTransparentOccluder_ShadowFlag)); - sk_sp<GrFragmentProcessor> edgeFP = GrBlurredEdgeFP::Make(GrBlurredEdgeFP::kGaussian_Mode); - paint.addColorFragmentProcessor(std::move(edgeFP)); - - rtContext->drawVertices(clip, std::move(paint), SkMatrix::I(), kTriangles_GrPrimitiveType, - tess.vertexCount(), tess.positions(), nullptr, - tess.colors(), tess.indices(), tess.indexCount()); - - return true; + // TODO + return false; } bool SkAmbientShadowMaskFilterImpl::directFilterRRectMaskGPU(GrContext*, @@ -209,10 +187,6 @@ bool SkAmbientShadowMaskFilterImpl::directFilterRRectMaskGPU(GrContext*, const SkStrokeRec& strokeRec, const SkRRect& rrect, const SkRRect& devRRect) const { -#ifndef SUPPORT_FAST_PATH - return false; -#endif - // It's likely the caller has already done these checks, but we have to be sure. // TODO: support analytic blurring of general rrect @@ -246,7 +220,7 @@ bool SkAmbientShadowMaskFilterImpl::directFilterRRectMaskGPU(GrContext*, if (fAmbientAlpha > 0.0f) { SkScalar srcSpaceAmbientRadius = fOccluderHeight * kHeightFactor * kGeomFactor; const float umbraAlpha = (1.0f + SkTMax(fOccluderHeight * kHeightFactor, 0.0f)); - const SkScalar ambientOffset = srcSpaceAmbientRadius * umbraAlpha; + const SkScalar ambientOffset = srcSpaceAmbientRadius / umbraAlpha; // For the ambient rrect, we inset the offset rect by half the srcSpaceAmbientRadius // to get our stroke shape. diff --git a/src/effects/shadows/SkSpotShadowMaskFilter.cpp b/src/effects/shadows/SkSpotShadowMaskFilter.cpp index 7a1f3117eb..99a03db091 100755 --- a/src/effects/shadows/SkSpotShadowMaskFilter.cpp +++ b/src/effects/shadows/SkSpotShadowMaskFilter.cpp @@ -17,8 +17,6 @@ #include "GrStyle.h" #include "GrTexture.h" #include "GrTextureProxy.h" -#include "effects/GrBlurredEdgeFragmentProcessor.h" -#include "effects/GrShadowTessellator.h" #include "SkStrokeRec.h" #endif @@ -181,45 +179,20 @@ bool SkSpotShadowMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvi return false; } -#ifdef SUPPORT_FAST_PATH // if circle // TODO: switch to SkScalarNearlyEqual when either oval renderer is updated or we // have our own GeometryProc. if (path.isOval(nullptr) && path.getBounds().width() == path.getBounds().height()) { SkRRect rrect = SkRRect::MakeOval(path.getBounds()); - return this->directFilterRRectMaskGPU(nullptr, drawContext, std::move(paint), clip, + return this->directFilterRRectMaskGPU(nullptr, rtContext, std::move(paint), clip, SkMatrix::I(), strokeRec, rrect, rrect); } else if (path.isRect(nullptr)) { SkRRect rrect = SkRRect::MakeRect(path.getBounds()); - return this->directFilterRRectMaskGPU(nullptr, drawContext, std::move(paint), clip, + return this->directFilterRRectMaskGPU(nullptr, rtContext, std::move(paint), clip, SkMatrix::I(), strokeRec, rrect, rrect); } -#endif - - float zRatio = SkTPin(fOccluderHeight / (fLightPos.fZ - fOccluderHeight), 0.0f, 0.95f); - - SkScalar radius = fLightRadius * zRatio; - - // Compute the scale and translation for the spot shadow. - const SkScalar scale = fLightPos.fZ / (fLightPos.fZ - fOccluderHeight); - - SkPoint center = SkPoint::Make(path.getBounds().centerX(), path.getBounds().centerY()); - const SkVector spotOffset = SkVector::Make(zRatio*(center.fX - fLightPos.fX), - zRatio*(center.fY - fLightPos.fY)); - - GrColor umbraColor = GrColorPackRGBA(0, 0, 255, fSpotAlpha*255.9999f); - GrColor penumbraColor = GrColorPackRGBA(0, 0, 0, fSpotAlpha*255.9999f); - GrSpotShadowTessellator tess(path, scale, spotOffset, radius, umbraColor, penumbraColor, - SkToBool(fFlags & SkShadowFlags::kTransparentOccluder_ShadowFlag)); - - sk_sp<GrFragmentProcessor> edgeFP = GrBlurredEdgeFP::Make(GrBlurredEdgeFP::kGaussian_Mode); - paint.addColorFragmentProcessor(std::move(edgeFP)); - rtContext->drawVertices(clip, std::move(paint), SkMatrix::I(), kTriangles_GrPrimitiveType, - tess.vertexCount(), tess.positions(), nullptr, - tess.colors(), tess.indices(), tess.indexCount()); - - return true; + return false; } bool SkSpotShadowMaskFilterImpl::directFilterRRectMaskGPU(GrContext*, @@ -230,10 +203,6 @@ bool SkSpotShadowMaskFilterImpl::directFilterRRectMaskGPU(GrContext*, const SkStrokeRec& strokeRec, const SkRRect& rrect, const SkRRect& devRRect) const { -#ifndef SUPPORT_FAST_PATH - return false; -#endif - // It's likely the caller has already done these checks, but we have to be sure. // TODO: support analytic blurring of general rrect |