aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-02-22 13:41:39 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-22 19:09:10 +0000
commit242135a402592e4fb40c5aba44cf8d483e68d292 (patch)
tree04f98735331d03ffc00ad9f15c16cf3cc43e59cf
parent2c0349262132d6aa54ac6e8a4295f17c67e25907 (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>
-rw-r--r--gm/reveal.cpp4
-rw-r--r--gn/core.gni1
-rw-r--r--include/core/SkRRect.h34
-rw-r--r--src/core/SkRRect.cpp12
-rw-r--r--src/core/SkRRectPriv.h36
-rw-r--r--src/effects/SkBlurMaskFilter.cpp5
-rw-r--r--src/effects/SkRRectsGaussianEdgeMaskFilter.cpp25
-rw-r--r--src/gpu/GrRenderTargetContext.cpp12
-rw-r--r--src/gpu/SkGpuDevice.cpp4
-rw-r--r--src/gpu/effects/GrRRectBlurEffect.cpp10
-rw-r--r--src/gpu/effects/GrRRectBlurEffect.fp7
-rw-r--r--src/gpu/effects/GrRRectBlurEffect.h1
-rw-r--r--src/gpu/effects/GrRRectEffect.cpp11
-rw-r--r--src/gpu/ops/GrOvalOpFactory.cpp4
-rw-r--r--src/gpu/ops/GrShadowRRectOp.cpp9
-rw-r--r--src/utils/SkDumpCanvas.cpp4
16 files changed, 108 insertions, 71 deletions
diff --git a/gm/reveal.cpp b/gm/reveal.cpp
index eb08a3f8a8..e58807c090 100644
--- a/gm/reveal.cpp
+++ b/gm/reveal.cpp
@@ -12,7 +12,7 @@
#include "SkRRectsGaussianEdgeMaskFilter.h"
#include "SkPath.h"
#include "SkPathOps.h"
-#include "SkRRect.h"
+#include "SkRRectPriv.h"
#include "SkStroke.h"
constexpr int kNumCols = 2;
@@ -61,7 +61,7 @@ public:
SkRect devRect;
ctm.mapRect(&devRect, fRRect.rect());
- SkScalar scaledRad = scales[0] * fRRect.getSimpleRadii().fX;
+ SkScalar scaledRad = scales[0] * SkRRectPriv::GetSimpleRadii(fRRect).fX;
*rr = SkRRect::MakeRectXY(devRect, scaledRad, scaledRad);
return true;
diff --git a/gn/core.gni b/gn/core.gni
index 00f6b73f6c..e73227867c 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -261,6 +261,7 @@ skia_core_sources = [
"$_src/core/SkRemoteGlyphCache.cpp",
"$_src/core/SkResourceCache.cpp",
"$_src/core/SkRRect.cpp",
+ "$_src/core/SkRRectPriv.h",
"$_src/core/SkRTree.h",
"$_src/core/SkRTree.cpp",
"$_src/core/SkRWBuffer.cpp",
diff --git a/include/core/SkRRect.h b/include/core/SkRRect.h
index 798dd47f13..a553191515 100644
--- a/include/core/SkRRect.h
+++ b/include/core/SkRRect.h
@@ -105,23 +105,22 @@ public:
inline bool isRect() const { return kRect_Type == this->getType(); }
inline bool isOval() const { return kOval_Type == this->getType(); }
inline bool isSimple() const { return kSimple_Type == this->getType(); }
- // TODO: should isSimpleCircular & isCircle take a tolerance? This could help
- // instances where the mapping to device space is noisy.
- inline bool isSimpleCircular() const {
- return this->isSimple() && SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].fY);
- }
- inline bool isCircle() const {
- return this->isOval() && SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].fY);
- }
inline bool isNinePatch() const { return kNinePatch_Type == this->getType(); }
inline bool isComplex() const { return kComplex_Type == this->getType(); }
- bool allCornersCircular(SkScalar tolerance = SK_ScalarNearlyZero) const;
-
SkScalar width() const { return fRect.width(); }
SkScalar height() const { return fRect.height(); }
/**
+ * kSimple means that all corners have the same x,y radii. This returns the top/left
+ * corner's radii as representative of all corners. If the RRect is kComplex, then
+ * this still returns that corner's radii, but it is not indicative of the other corners.
+ */
+ SkVector getSimpleRadii() const {
+ return fRadii[0];
+ }
+
+ /**
* Same as default initialized - zero width and height at the origin.
*/
void setEmpty() { *this = SkRRect(); }
@@ -206,18 +205,9 @@ public:
};
const SkRect& rect() const { return fRect; }
- const SkVector& radii(Corner corner) const { return fRadii[corner]; }
+ SkVector radii(Corner corner) const { return fRadii[corner]; }
const SkRect& getBounds() const { return fRect; }
- /**
- * When a rrect is simple, all of its radii are equal. This returns one
- * of those radii. This call requires the rrect to be non-complex.
- */
- const SkVector& getSimpleRadii() const {
- SkASSERT(!this->isComplex());
- return fRadii[0];
- }
-
friend bool operator==(const SkRRect& a, const SkRRect& b) {
return a.fRect == b.fRect && SkScalarsEqual(&a.fRadii[0].fX, &b.fRadii[0].fX, 8);
}
@@ -279,7 +269,6 @@ public:
bool contains(const SkRect& rect) const;
bool isValid() const;
- static bool AreRectAndRadiiValid(const SkRect&, const SkVector[4]);
enum {
kSizeInMemory = 12 * sizeof(SkScalar)
@@ -323,6 +312,8 @@ public:
void dumpHex() const { this->dump(true); }
private:
+ static bool AreRectAndRadiiValid(const SkRect&, const SkVector[4]);
+
SkRRect(const SkRect& rect, const SkVector radii[4], int32_t type)
: fRect(rect)
, fRadii{radii[0], radii[1], radii[2], radii[3]}
@@ -347,6 +338,7 @@ private:
// to access fRadii directly
friend class SkPath;
+ friend class SkRRectPriv;
};
#endif
diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp
index c6a0f0a10d..a8ed7246ef 100644
--- a/src/core/SkRRect.cpp
+++ b/src/core/SkRRect.cpp
@@ -6,7 +6,7 @@
*/
#include <cmath>
-#include "SkRRect.h"
+#include "SkRRectPriv.h"
#include "SkScopeExit.h"
#include "SkBuffer.h"
#include "SkMalloc.h"
@@ -257,11 +257,11 @@ bool SkRRect::checkCornerContainment(SkScalar x, SkScalar y) const {
return dist <= SkScalarSquare(fRadii[index].fX * fRadii[index].fY);
}
-bool SkRRect::allCornersCircular(SkScalar tolerance) const {
- return SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].fY, tolerance) &&
- SkScalarNearlyEqual(fRadii[1].fX, fRadii[1].fY, tolerance) &&
- SkScalarNearlyEqual(fRadii[2].fX, fRadii[2].fY, tolerance) &&
- SkScalarNearlyEqual(fRadii[3].fX, fRadii[3].fY, tolerance);
+bool SkRRectPriv::AllCornersCircular(const SkRRect& rr, SkScalar tolerance) {
+ return SkScalarNearlyEqual(rr.fRadii[0].fX, rr.fRadii[0].fY, tolerance) &&
+ SkScalarNearlyEqual(rr.fRadii[1].fX, rr.fRadii[1].fY, tolerance) &&
+ SkScalarNearlyEqual(rr.fRadii[2].fX, rr.fRadii[2].fY, tolerance) &&
+ SkScalarNearlyEqual(rr.fRadii[3].fX, rr.fRadii[3].fY, tolerance);
}
bool SkRRect::contains(const SkRect& rect) const {
diff --git a/src/core/SkRRectPriv.h b/src/core/SkRRectPriv.h
new file mode 100644
index 0000000000..ea277f7f33
--- /dev/null
+++ b/src/core/SkRRectPriv.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkRRectPriv_DEFINED
+#define SkRRectPriv_DEFINED
+
+#include "SkRRect.h"
+
+class SkRRectPriv {
+public:
+ static bool IsCircle(const SkRRect& rr) {
+ return rr.isOval() && SkScalarNearlyEqual(rr.fRadii[0].fX, rr.fRadii[0].fY);
+ }
+
+ static SkVector GetSimpleRadii(const SkRRect& rr) {
+ SkASSERT(!rr.isComplex());
+ return rr.fRadii[0];
+ }
+
+ static bool IsSimpleCircular(const SkRRect& rr) {
+ return rr.isSimple() && SkScalarNearlyEqual(rr.fRadii[0].fX, rr.fRadii[0].fY);
+ }
+
+ static bool EqualRadii(const SkRRect& rr) {
+ return rr.isRect() || SkRRectPriv::IsCircle(rr) || SkRRectPriv::IsSimpleCircular(rr);
+ }
+
+ static bool AllCornersCircular(const SkRRect& rr, SkScalar tolerance = SK_ScalarNearlyZero);
+};
+
+#endif
+
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 7992d97d78..9d7df43d62 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -10,6 +10,7 @@
#include "SkGpuBlurUtils.h"
#include "SkMaskFilterBase.h"
#include "SkReadBuffer.h"
+#include "SkRRectPriv.h"
#include "SkWriteBuffer.h"
#include "SkMaskFilter.h"
#include "SkRRect.h"
@@ -828,7 +829,7 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
- if (devRRect.isRect() || devRRect.isCircle()) {
+ if (devRRect.isRect() || SkRRectPriv::IsCircle(devRRect)) {
std::unique_ptr<GrFragmentProcessor> fp;
if (devRRect.isRect()) {
SkScalar pad = 3.0f * xformedSigma;
@@ -924,7 +925,7 @@ bool SkBlurMaskFilterImpl::canFilterMaskGPU(const SkRRect& devRRect,
}
// We always do circles and simple circular rrects on the GPU
- if (!devRRect.isCircle() && !devRRect.isSimpleCircular()) {
+ if (!SkRRectPriv::IsCircle(devRRect) && !SkRRectPriv::IsSimpleCircular(devRRect)) {
static const SkScalar kMIN_GPU_BLUR_SIZE = SkIntToScalar(64);
static const SkScalar kMIN_GPU_BLUR_SIGMA = SkIntToScalar(32);
diff --git a/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp b/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp
index 850e440099..856076f5ce 100644
--- a/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp
+++ b/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp
@@ -8,7 +8,7 @@
#include "SkMaskFilterBase.h"
#include "SkRRectsGaussianEdgeMaskFilter.h"
#include "SkReadBuffer.h"
-#include "SkRRect.h"
+#include "SkRRectPriv.h"
#include "SkWriteBuffer.h"
#if SK_SUPPORT_GPU
@@ -66,7 +66,7 @@ static SkScalar compute_rrect_normalized_dist(const SkRRect& rr, const SkPoint&
SkScalar halfH = 0.5f * rr.rect().height();
SkScalar invRad = 1.0f/rad;
- const SkVector& radii = rr.getSimpleRadii();
+ const SkVector& radii = SkRRectPriv::GetSimpleRadii(rr);
SkASSERT(SkScalarNearlyEqual(radii.fX, radii.fY));
switch (rr.getType()) {
@@ -428,8 +428,10 @@ private:
// This is a bit of overkill since fX should equal fY for both round rects but it
// makes the shader code simpler.
pdman.set4f(fRadiiUni,
- first.getSimpleRadii().fX, first.getSimpleRadii().fY,
- second.getSimpleRadii().fX, second.getSimpleRadii().fY);
+ SkRRectPriv::GetSimpleRadii(first).fX,
+ SkRRectPriv::GetSimpleRadii(first).fY,
+ SkRRectPriv::GetSimpleRadii(second).fX,
+ SkRRectPriv::GetSimpleRadii(second).fY);
}
pdman.set1f(fRadiusUni, edgeFP.radius());
@@ -480,12 +482,12 @@ private:
}
static Mode ComputeMode(const SkRRect& rr) {
- if (rr.isCircle()) {
+ if (SkRRectPriv::IsCircle(rr)) {
return kCircle_Mode;
} else if (rr.isRect()) {
return kRect_Mode;
} else {
- SkASSERT(rr.isSimpleCircular());
+ SkASSERT(SkRRectPriv::IsSimpleCircular(rr));
return kSimpleCircular_Mode;
}
}
@@ -548,15 +550,15 @@ sk_sp<SkFlattenable> SkRRectsGaussianEdgeMaskFilterImpl::CreateProc(SkReadBuffer
void SkRRectsGaussianEdgeMaskFilterImpl::flatten(SkWriteBuffer& buf) const {
INHERITED::flatten(buf);
- SkASSERT(fFirst.isRect() || fFirst.isCircle() || fFirst.isSimpleCircular());
+ SkASSERT(SkRRectPriv::EqualRadii(fFirst));
buf.writeRect(fFirst.rect());
- const SkVector& radii1 = fFirst.getSimpleRadii();
+ const SkVector radii1 = SkRRectPriv::GetSimpleRadii(fFirst);
buf.writeScalar(radii1.fX);
buf.writeScalar(radii1.fY);
- SkASSERT(fSecond.isRect() || fSecond.isCircle() || fSecond.isSimpleCircular());
+ SkASSERT(SkRRectPriv::EqualRadii(fSecond));
buf.writeRect(fSecond.rect());
- const SkVector& radii2 = fSecond.getSimpleRadii();
+ const SkVector radii2 = SkRRectPriv::GetSimpleRadii(fSecond);
buf.writeScalar(radii2.fX);
buf.writeScalar(radii2.fY);
@@ -568,8 +570,7 @@ void SkRRectsGaussianEdgeMaskFilterImpl::flatten(SkWriteBuffer& buf) const {
sk_sp<SkMaskFilter> SkRRectsGaussianEdgeMaskFilter::Make(const SkRRect& first,
const SkRRect& second,
SkScalar radius) {
- if ((!first.isRect() && !first.isCircle() && !first.isSimpleCircular()) ||
- (!second.isRect() && !second.isCircle() && !second.isSimpleCircular())) {
+ if (!SkRRectPriv::EqualRadii(first) || !SkRRectPriv::EqualRadii(second)) {
// we only deal with the shapes where the x & y radii are equal
// and the same for all four corners
return nullptr;
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);
}
}
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index c547fa238e..b7c200f41d 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -13,7 +13,7 @@
#include "SkPicture.h"
#include "SkPixelRef.h"
#include "SkRegion.h"
-#include "SkRRect.h"
+#include "SkRRectPriv.h"
#include "SkString.h"
#include "SkTextBlob.h"
#include <stdarg.h>
@@ -44,7 +44,7 @@ static void toString(const SkRRect& rrect, SkString* str) {
if (rrect.isOval()) {
str->append("()");
} else if (rrect.isSimple()) {
- const SkVector& rad = rrect.getSimpleRadii();
+ const SkVector rad = SkRRectPriv::GetSimpleRadii(rrect);
str->appendf("(%g,%g)", rad.x(), rad.y());
} else if (rrect.isComplex()) {
SkVector radii[4] = {