diff options
author | Mike Reed <reed@google.com> | 2018-02-22 13:41:39 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-22 19:09:10 +0000 |
commit | 242135a402592e4fb40c5aba44cf8d483e68d292 (patch) | |
tree | 04f98735331d03ffc00ad9f15c16cf3cc43e59cf /src/gpu | |
parent | 2c0349262132d6aa54ac6e8a4295f17c67e25907 (diff) |
move some RRect methods into priv
also, return radii by value instead of reference, in possible prep for changing underlying representation
Bug: skia:7649
Change-Id: Iff42a49c53cc48171fc63462be366cc3500b2273
Reviewed-on: https://skia-review.googlesource.com/109385
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrRenderTargetContext.cpp | 12 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 4 | ||||
-rw-r--r-- | src/gpu/effects/GrRRectBlurEffect.cpp | 10 | ||||
-rw-r--r-- | src/gpu/effects/GrRRectBlurEffect.fp | 7 | ||||
-rw-r--r-- | src/gpu/effects/GrRRectBlurEffect.h | 1 | ||||
-rw-r--r-- | src/gpu/effects/GrRRectEffect.cpp | 11 | ||||
-rw-r--r-- | src/gpu/ops/GrOvalOpFactory.cpp | 4 | ||||
-rw-r--r-- | src/gpu/ops/GrShadowRRectOp.cpp | 9 |
8 files changed, 32 insertions, 26 deletions
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 89f0b8ae52..1de4ab8510 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -28,6 +28,7 @@ #include "SkGr.h" #include "SkLatticeIter.h" #include "SkMatrixPriv.h" +#include "SkRRectPriv.h" #include "SkShadowUtils.h" #include "SkSurfacePriv.h" #include "effects/GrRRectEffect.h" @@ -965,7 +966,7 @@ bool GrRenderTargetContext::drawFastShadow(const GrClip& clip, SkRRect rrect; SkRect rect; // we can only handle rects, circles, and rrects with circular corners - bool isRRect = path.isRRect(&rrect) && rrect.isSimpleCircular() && + bool isRRect = path.isRRect(&rrect) && SkRRectPriv::IsSimpleCircular(rrect) && rrect.radii(SkRRect::kUpperLeft_Corner).fX > SK_ScalarNearlyZero; if (!isRRect && path.isOval(&rect) && SkScalarNearlyEqual(rect.width(), rect.height()) && @@ -1014,7 +1015,7 @@ bool GrRenderTargetContext::drawFastShadow(const GrClip& clip, if (rrect.isOval()) { ambientRRect = SkRRect::MakeOval(outsetRect); } else { - SkScalar outsetRad = rrect.getSimpleRadii().fX + ambientPathOutset; + SkScalar outsetRad = SkRRectPriv::GetSimpleRadii(rrect).fX + ambientPathOutset; ambientRRect = SkRRect::MakeRectXY(outsetRect, outsetRad, outsetRad); } @@ -1064,7 +1065,7 @@ bool GrRenderTargetContext::drawFastShadow(const GrClip& clip, SkMatrix shadowTransform; shadowTransform.setScaleTranslate(spotScale, spotScale, spotOffset.fX, spotOffset.fY); rrect.transform(shadowTransform, &spotShadowRRect); - SkScalar spotRadius = spotShadowRRect.getSimpleRadii().fX; + SkScalar spotRadius = SkRRectPriv::GetSimpleRadii(spotShadowRRect).fX; // Compute the insetWidth SkScalar blurOutset = srcSpaceSpotBlur; @@ -1097,7 +1098,7 @@ bool GrRenderTargetContext::drawFastShadow(const GrClip& clip, SkTAbs(spotShadowRRect.rect().fBottom - rrect.rect().fBottom))); } else { - SkScalar dr = spotRadius - rrect.getSimpleRadii().fX; + SkScalar dr = spotRadius - SkRRectPriv::GetSimpleRadii(rrect).fX; SkPoint upperLeftOffset = SkPoint::Make(spotShadowRRect.rect().fLeft - rrect.rect().fLeft + dr, spotShadowRRect.rect().fTop - @@ -1153,7 +1154,8 @@ bool GrRenderTargetContext::drawFilledDRRect(const GrClip& clip, return false; } - if (GrAAType::kCoverage == aaType && inner->isCircle() && outer->isCircle()) { + if (GrAAType::kCoverage == aaType && SkRRectPriv::IsCircle(*inner) + && SkRRectPriv::IsCircle(*outer)) { auto outerR = outer->width() / 2.f; auto innerR = inner->width() / 2.f; auto cx = outer->getBounds().fLeft + outerR; diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index bc5a34b132..1a4538af72 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -32,7 +32,7 @@ #include "SkPathEffect.h" #include "SkPicture.h" #include "SkPictureData.h" -#include "SkRRect.h" +#include "SkRRectPriv.h" #include "SkRasterClip.h" #include "SkReadPixelsRec.h" #include "SkRecord.h" @@ -418,7 +418,7 @@ void SkGpuDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) { SkRRect devRRect; if (rrect.transform(this->ctm(), &devRRect)) { - if (devRRect.allCornersCircular()) { + if (SkRRectPriv::AllCornersCircular(devRRect)) { if (mf->canFilterMaskGPU(devRRect, this->devClipBounds(), this->ctm(), nullptr)) { if (mf->directFilterRRectMaskGPU(this->context(), fRenderTargetContext.get(), std::move(grPaint), this->clip(), this->ctm(), diff --git a/src/gpu/effects/GrRRectBlurEffect.cpp b/src/gpu/effects/GrRRectBlurEffect.cpp index e83ef17605..b307946d0c 100644 --- a/src/gpu/effects/GrRRectBlurEffect.cpp +++ b/src/gpu/effects/GrRRectBlurEffect.cpp @@ -15,10 +15,11 @@ std::unique_ptr<GrFragmentProcessor> GrRRectBlurEffect::Make(GrContext* context, float xformedSigma, const SkRRect& srcRRect, const SkRRect& devRRect) { - SkASSERT(!devRRect.isCircle() && !devRRect.isRect()); // Should've been caught up-stream + SkASSERT(!SkRRectPriv::IsCircle(devRRect) && + !devRRect.isRect()); // Should've been caught up-stream // TODO: loosen this up - if (!devRRect.isSimpleCircular()) { + if (!SkRRectPriv::IsSimpleCircular(devRRect)) { return nullptr; } @@ -44,8 +45,9 @@ std::unique_ptr<GrFragmentProcessor> GrRRectBlurEffect::Make(GrContext* context, return nullptr; } - return std::unique_ptr<GrFragmentProcessor>(new GrRRectBlurEffect( - xformedSigma, devRRect.getBounds(), devRRect.getSimpleRadii().fX, std::move(mask))); + return std::unique_ptr<GrFragmentProcessor>( + new GrRRectBlurEffect(xformedSigma, devRRect.getBounds(), + SkRRectPriv::GetSimpleRadii(devRRect).fX, std::move(mask))); } #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" diff --git a/src/gpu/effects/GrRRectBlurEffect.fp b/src/gpu/effects/GrRRectBlurEffect.fp index 3f817d5331..5015cd07b4 100644 --- a/src/gpu/effects/GrRRectBlurEffect.fp +++ b/src/gpu/effects/GrRRectBlurEffect.fp @@ -22,6 +22,7 @@ uniform half blurRadius; #include "GrStyle.h" #include "SkBlurMaskFilter.h" #include "SkGpuBlurUtils.h" + #include "SkRRectPriv.h" } @class { @@ -108,10 +109,10 @@ uniform half blurRadius; float xformedSigma, const SkRRect& srcRRect, const SkRRect& devRRect) { - SkASSERT(!devRRect.isCircle() && !devRRect.isRect()); // Should've been caught up-stream + SkASSERT(!SkRRectPriv::IsCircle(devRRect) && !devRRect.isRect()); // Should've been caught up-stream // TODO: loosen this up - if (!devRRect.isSimpleCircular()) { + if (!SkRRectPriv::IsSimpleCircular(devRRect)) { return nullptr; } @@ -144,7 +145,7 @@ uniform half blurRadius; return std::unique_ptr<GrFragmentProcessor>( new GrRRectBlurEffect(xformedSigma, devRRect.getBounds(), - devRRect.getSimpleRadii().fX, std::move(mask))); + SkRRectPriv::GetSimpleRadii(devRRect).fX, std::move(mask))); } } diff --git a/src/gpu/effects/GrRRectBlurEffect.h b/src/gpu/effects/GrRRectBlurEffect.h index 3fd6f0c976..7ba02c7dd0 100644 --- a/src/gpu/effects/GrRRectBlurEffect.h +++ b/src/gpu/effects/GrRRectBlurEffect.h @@ -22,6 +22,7 @@ #include "GrStyle.h" #include "SkBlurMaskFilter.h" #include "SkGpuBlurUtils.h" +#include "SkRRectPriv.h" #include "GrFragmentProcessor.h" #include "GrCoordTransform.h" class GrRRectBlurEffect : public GrFragmentProcessor { diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp index c6430abd15..2fb28fd381 100644 --- a/src/gpu/effects/GrRRectEffect.cpp +++ b/src/gpu/effects/GrRRectEffect.cpp @@ -11,7 +11,7 @@ #include "GrFragmentProcessor.h" #include "GrOvalEffect.h" #include "GrShaderCaps.h" -#include "SkRRect.h" +#include "SkRRectPriv.h" #include "SkTLazy.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" @@ -298,8 +298,8 @@ void GLCircularRRectEffect::onSetData(const GrGLSLProgramDataManager& pdman, SkScalar radius = 0; switch (crre.getCircularCornerFlags()) { case CircularRRectEffect::kAll_CornerFlags: - SkASSERT(rrect.isSimpleCircular()); - radius = rrect.getSimpleRadii().fX; + SkASSERT(SkRRectPriv::IsSimpleCircular(rrect)); + radius = SkRRectPriv::GetSimpleRadii(rrect).fX; SkASSERT(radius >= kRadiusMin); rect.inset(radius, radius); break; @@ -680,12 +680,13 @@ std::unique_ptr<GrFragmentProcessor> GrRRectEffect::Make(GrClipEdgeType edgeType } if (rrect.isSimple()) { - if (rrect.getSimpleRadii().fX < kRadiusMin || rrect.getSimpleRadii().fY < kRadiusMin) { + if (SkRRectPriv::GetSimpleRadii(rrect).fX < kRadiusMin || + SkRRectPriv::GetSimpleRadii(rrect).fY < kRadiusMin) { // In this case the corners are extremely close to rectangular and we collapse the // clip to a rectangular clip. return GrConvexPolyEffect::Make(edgeType, rrect.getBounds()); } - if (rrect.getSimpleRadii().fX == rrect.getSimpleRadii().fY) { + if (SkRRectPriv::GetSimpleRadii(rrect).fX == SkRRectPriv::GetSimpleRadii(rrect).fY) { return CircularRRectEffect::Make(edgeType, CircularRRectEffect::kAll_CornerFlags, rrect); } else { diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp index ecaa30d459..b931869d53 100644 --- a/src/gpu/ops/GrOvalOpFactory.cpp +++ b/src/gpu/ops/GrOvalOpFactory.cpp @@ -13,7 +13,7 @@ #include "GrResourceProvider.h" #include "GrShaderCaps.h" #include "GrStyle.h" -#include "SkRRect.h" +#include "SkRRectPriv.h" #include "SkStrokeRec.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLGeometryProcessor.h" @@ -2317,7 +2317,7 @@ static std::unique_ptr<GrDrawOp> make_rrect_op(GrPaint&& paint, SkRect bounds; viewMatrix.mapRect(&bounds, rrectBounds); - SkVector radii = rrect.getSimpleRadii(); + SkVector radii = SkRRectPriv::GetSimpleRadii(rrect); SkScalar xRadius = SkScalarAbs(viewMatrix[SkMatrix::kMScaleX] * radii.fX + viewMatrix[SkMatrix::kMSkewY] * radii.fY); SkScalar yRadius = SkScalarAbs(viewMatrix[SkMatrix::kMSkewX] * radii.fX + diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp index 24bbff48ef..ba96941073 100644 --- a/src/gpu/ops/GrShadowRRectOp.cpp +++ b/src/gpu/ops/GrShadowRRectOp.cpp @@ -8,7 +8,7 @@ #include "GrShadowRRectOp.h" #include "GrDrawOpTest.h" #include "GrOpFlushState.h" -#include "SkRRect.h" +#include "SkRRectPriv.h" #include "effects/GrShadowGeoProc.h" /////////////////////////////////////////////////////////////////////////////// @@ -651,8 +651,7 @@ std::unique_ptr<GrDrawOp> Make(GrColor color, SkScalar insetWidth, SkScalar blurClamp) { // Shadow rrect ops only handle simple circular rrects. - SkASSERT(viewMatrix.isSimilarity() && - (rrect.isSimpleCircular() || rrect.isRect() || rrect.isCircle())); + SkASSERT(viewMatrix.isSimilarity() && SkRRectPriv::EqualRadii(rrect)); // Do any matrix crunching before we reset the draw state for device coords. const SkRect& rrectBounds = rrect.getBounds(); @@ -660,7 +659,7 @@ std::unique_ptr<GrDrawOp> Make(GrColor color, viewMatrix.mapRect(&bounds, rrectBounds); // Map radius and inset. As the matrix is a similarity matrix, this should be isotropic. - SkScalar radius = rrect.getSimpleRadii().fX; + SkScalar radius = SkRRectPriv::GetSimpleRadii(rrect).fX; SkScalar matrixFactor = viewMatrix[SkMatrix::kMScaleX] + viewMatrix[SkMatrix::kMSkewX]; SkScalar scaledRadius = SkScalarAbs(radius*matrixFactor); SkScalar scaledInsetWidth = SkScalarAbs(insetWidth*matrixFactor); @@ -703,7 +702,7 @@ GR_DRAW_OP_TEST_DEFINE(ShadowRRectOp) { do { // This may return a rrect with elliptical corners, which we don't support. rrect = GrTest::TestRRectSimple(random); - } while (!rrect.isSimpleCircular()); + } while (!SkRRectPriv::IsSimpleCircular(rrect)); return GrShadowRRectOp::Make(color, viewMatrix, rrect, blurWidth, insetWidth, blurClamp); } } |