aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--docs/SkRect_Reference.bmh101
-rw-r--r--include/core/SkRect.h51
-rw-r--r--src/core/SkRectPriv.h7
-rw-r--r--src/gpu/GrDistanceFieldGenFromVector.cpp3
-rw-r--r--src/gpu/ops/GrAAHairLinePathRenderer.cpp3
-rw-r--r--src/gpu/ops/GrDrawAtlasOp.cpp8
-rw-r--r--tests/GrShapeTest.cpp5
-rw-r--r--tests/RectTest.cpp5
-rw-r--r--tools/debugger/SkDrawCommand.cpp3
9 files changed, 25 insertions, 161 deletions
diff --git a/docs/SkRect_Reference.bmh b/docs/SkRect_Reference.bmh
index 19bfecd05e..ddebdb104f 100644
--- a/docs/SkRect_Reference.bmh
+++ b/docs/SkRect_Reference.bmh
@@ -56,7 +56,6 @@ integer input cannot convert to SkScalar without loss of precision.
# contains() # Returns true if points are equal or inside. ##
# dump() # Sends text representation using floats to standard output. ##
# dumpHex # Sends text representation using hexadecimal to standard output. ##
-# growToInclude # Sets to union of bounds and one or more Points. ##
# height # Returns span in y. ##
# inset() # Moves the sides symmetrically about the center. ##
# intersect() # Sets to shared area; returns true if not empty. ##
@@ -1736,106 +1735,6 @@ sorted: 10, 0, 55, 100
# ------------------------------------------------------------------------------
-#Method void growToInclude(SkPoint pt)
-
-Grows Rect to include (pt.fX, pt.fY), modifying it so that:
-
-#Formula
-fLeft <= pt.fX <= fRight && fTop <= pt.fY <= fBottom
-##
-.
-
-If Rect is inverted, then Rect will preserve the top left, and the result
-will not be inverted.
-
-#Param pt Point to include ##
-
-#Example
- SkRect rect = { 1, 1, 0, 0 };
- rect.growToInclude( { 42, 24 } );
- SkDebugf("rect: %g, %g, %g, %g ", rect.left(), rect.top(), rect.right(), rect.bottom());
- SkDebugf("isEmpty: %s\n", rect.isEmpty() ? "true" : "false");
-#StdOut
-rect: 1, 1, 42, 24 isEmpty: false
-##
-##
-
-#SeeAlso join
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void growToInclude(const SkPoint pts[], int count)
-
-For each of count Point in pts, grows Rect to include (pt.fX, pt.fY), modifying
-it so that:
-#Formula
-fLeft <= pt.fX <= fRight && fTop <= pt.fY <= fBottom
-##
-.
-
-If Rect is inverted, then Rect will contain bounds of
-Points after one or more calls. In this case, Rect is empty after first call.
-
-#Param pts Point array ##
-#Param count number of points in array ##
-
-#Example
- SkPoint pts[] = { { 30, 50 }, { 40, 50 }, { 30, 60 } };
- SkRect rect = { pts[0].fX, pts[0].fY, pts[0].fX, pts[0].fY };
- rect.growToInclude( pts[1] );
- rect.growToInclude( pts[2] );
- SkDebugf("rect: %g, %g, %g, %g ", rect.left(), rect.top(), rect.right(), rect.bottom());
-#StdOut
-rect: 30, 50, 40, 60
-##
-##
-
-#SeeAlso join
-
-##
-
-# ------------------------------------------------------------------------------
-
-#Method void growToInclude(const SkPoint pts[], size_t stride, int count)
-
-For each of count Point in pts, grows Rect to include (pt.fX, pt.fY), modifying
-it so that:
-#Formula
-fLeft <= pt.fX <= fRight && fTop <= pt.fY <= fBottom
-##
-.
-
-Point may be followed with other data in each array element. stride is number
-of bytes in element; the interval to skip to advance from one Point to
-the next.
-
-If Rect is inverted, then Rect will contain bounds of
-Points after one or more calls. In this case, Rect is empty after first call.
-
-#Param pts array of elements beginning with Point ##
-#Param stride size of pts elements in 32-bit words; zero or greater ##
-#Param count number of elements in array ##
-
-#Bug 7142 ##
-#Example
- SkPoint3 pts[] = { { 30, 50, -1 }, { 40, 50, -1 }, { 30, 60, -1 } };
- SkRect rect = { 1, 1, 0, 0 };
- rect.growToInclude((SkPoint* ) &pts[0].fX, sizeof(SkPoint3), SK_ARRAY_COUNT(pts));
- SkDebugf("rect: %g, %g, %g, %g ", rect.left(), rect.top(), rect.right(), rect.bottom());
-#StdOut
-#Volatile
-rect: 30, 50, 40, 60
-##
-##
-
-#SeeAlso join
-
-##
-
-# ------------------------------------------------------------------------------
-
#Method bool contains(const SkRect& r) const
Returns true if Rect contains r.
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index dcb8615350..a9d73be235 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -1411,57 +1411,6 @@ public:
fBottom = SkMaxScalar(fBottom, r.bottom());
}
- /** Grows SkRect to include (pt.fX, pt.fY), modifying it so that:
- fLeft <= pt.fX <= fRight && fTop <= pt.fY <= fBottom.
-
- If SkRect is inverted, then SkRect will contain bounds of
- points after one or more calls. In this case, SkRect is empty after first call.
-
- @param pt SkPoint to include
- */
- void growToInclude(SkPoint pt) {
- fLeft = SkMinScalar(pt.fX, fLeft);
- fRight = SkMaxScalar(pt.fX, fRight);
- fTop = SkMinScalar(pt.fY, fTop);
- fBottom = SkMaxScalar(pt.fY, fBottom);
- }
-
- /** For each of count SkPoint in pts, grows SkRect to include (pt.fX, pt.fY), modifying
- it so that: fLeft <= pt.fX <= fRight && fTop <= pt.fY <= fBottom.
-
- If SkRect is inverted, then SkRect will contain bounds of
- points after one or more calls. In this case, SkRect is empty after first call.
-
- @param pts SkPoint array
- @param count number of points in array
- */
- void growToInclude(const SkPoint pts[], int count) {
- this->growToInclude(pts, sizeof(SkPoint), count);
- }
-
- /** For each of count SkPoint in pts, grows SkRect to include (pt.fX, pt.fY), modifying
- it so that: fLeft <= pt.fX <= fRight && fTop <= pt.fY <= fBottom.
-
- SkPoint may be followed with other data in each array element. stride is number
- of bytes in element; the interval to skip to advance from one SkPoint to
- the next.
-
- If SkRect is inverted, then SkRect will contain bounds of
- points after one or more calls. In this case, SkRect is empty after first call.
-
- @param pts array of elements beginning with SkPoint
- @param stride size of pts elements in 32-bit words; zero or greater
- @param count number of elements in array
- */
- void growToInclude(const SkPoint pts[], size_t stride, int count) {
- SkASSERT(count >= 0);
- SkASSERT(stride >= sizeof(SkPoint));
- const SkPoint* end = (const SkPoint*)((intptr_t)pts + count * stride);
- for (; pts < end; pts = (const SkPoint*)((intptr_t)pts + stride)) {
- this->growToInclude(*pts);
- }
- }
-
/** Returns true if SkRect contains r.
Returns false if SkRect is empty or r is empty.
diff --git a/src/core/SkRectPriv.h b/src/core/SkRectPriv.h
index 422037f4a1..01d184dce6 100644
--- a/src/core/SkRectPriv.h
+++ b/src/core/SkRectPriv.h
@@ -42,6 +42,13 @@ public:
static SkIRect MakeILargestInverted() {
return { SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32 };
}
+
+ static void GrowToInclude(SkRect* r, const SkPoint& pt) {
+ r->fLeft = SkMinScalar(pt.fX, r->fLeft);
+ r->fRight = SkMaxScalar(pt.fX, r->fRight);
+ r->fTop = SkMinScalar(pt.fY, r->fTop);
+ r->fBottom = SkMaxScalar(pt.fY, r->fBottom);
+ }
};
diff --git a/src/gpu/GrDistanceFieldGenFromVector.cpp b/src/gpu/GrDistanceFieldGenFromVector.cpp
index fdaeaf2964..efea0fca8c 100644
--- a/src/gpu/GrDistanceFieldGenFromVector.cpp
+++ b/src/gpu/GrDistanceFieldGenFromVector.cpp
@@ -15,6 +15,7 @@
#include "SkMatrix.h"
#include "SkPathOps.h"
#include "SkPointPriv.h"
+#include "SkRectPriv.h"
/**
* If a scanline (a row of texel) cross from the kRight_SegSide
@@ -275,7 +276,7 @@ void PathSegment::init() {
t.fX = _P1mP0.x() * t.x();
t.fY = _P1mP0.y() * t.y();
const SkPoint m = fPts[0] + t;
- fBoundingBox.growToInclude(&m, 1);
+ SkRectPriv::GrowToInclude(&fBoundingBox, m);
const double p1x = fPts[1].x();
const double p1y = fPts[1].y();
diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
index 1502b80a50..2342982943 100644
--- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
@@ -21,6 +21,7 @@
#include "SkMatrixPriv.h"
#include "SkPoint3.h"
#include "SkPointPriv.h"
+#include "SkRectPriv.h"
#include "SkStroke.h"
#include "SkTemplates.h"
#include "effects/GrBezierEffect.h"
@@ -750,7 +751,7 @@ bool check_bounds(const SkMatrix& viewMatrix, const SkRect& devBounds, void* ver
actualBounds.set(pos.fX, pos.fY, pos.fX, pos.fY);
first = false;
} else {
- actualBounds.growToInclude(pos);
+ SkRectPriv::GrowToInclude(&actualBounds, pos);
}
}
if (!first) {
diff --git a/src/gpu/ops/GrDrawAtlasOp.cpp b/src/gpu/ops/GrDrawAtlasOp.cpp
index 2c6f162c64..fa948b753d 100644
--- a/src/gpu/ops/GrDrawAtlasOp.cpp
+++ b/src/gpu/ops/GrDrawAtlasOp.cpp
@@ -82,25 +82,25 @@ GrDrawAtlasOp::GrDrawAtlasOp(const Helper::MakeArgs& helperArgs, GrColor color,
*(reinterpret_cast<SkPoint*>(currVertex)) = strip[0];
*(reinterpret_cast<SkPoint*>(currVertex + texOffset)) =
SkPoint::Make(currRect.fLeft, currRect.fTop);
- bounds.growToInclude(strip[0]);
+ SkRectPriv::GrowToInclude(&bounds, strip[0]);
currVertex += vertexStride;
*(reinterpret_cast<SkPoint*>(currVertex)) = strip[1];
*(reinterpret_cast<SkPoint*>(currVertex + texOffset)) =
SkPoint::Make(currRect.fLeft, currRect.fBottom);
- bounds.growToInclude(strip[1]);
+ SkRectPriv::GrowToInclude(&bounds, strip[1]);
currVertex += vertexStride;
*(reinterpret_cast<SkPoint*>(currVertex)) = strip[2];
*(reinterpret_cast<SkPoint*>(currVertex + texOffset)) =
SkPoint::Make(currRect.fRight, currRect.fTop);
- bounds.growToInclude(strip[2]);
+ SkRectPriv::GrowToInclude(&bounds, strip[2]);
currVertex += vertexStride;
*(reinterpret_cast<SkPoint*>(currVertex)) = strip[3];
*(reinterpret_cast<SkPoint*>(currVertex + texOffset)) =
SkPoint::Make(currRect.fRight, currRect.fBottom);
- bounds.growToInclude(strip[3]);
+ SkRectPriv::GrowToInclude(&bounds, strip[3]);
currVertex += vertexStride;
}
diff --git a/tests/GrShapeTest.cpp b/tests/GrShapeTest.cpp
index 261a7d2500..ae75f1c886 100644
--- a/tests/GrShapeTest.cpp
+++ b/tests/GrShapeTest.cpp
@@ -14,6 +14,7 @@
#include "SkDashPathEffect.h"
#include "SkPath.h"
#include "SkPathOps.h"
+#include "SkRectPriv.h"
#include "SkSurface.h"
#include "SkClipOpPriv.h"
@@ -1207,8 +1208,8 @@ void test_unknown_path_effect(skiatest::Reporter* reporter, const Geo& geo) {
}
void computeFastBounds(SkRect* dst, const SkRect& src) const override {
*dst = src;
- dst->growToInclude({0, 0});
- dst->growToInclude({100, 100});
+ SkRectPriv::GrowToInclude(dst, {0, 0});
+ SkRectPriv::GrowToInclude(dst, {100, 100});
}
static sk_sp<SkPathEffect> Make() { return sk_sp<SkPathEffect>(new AddLineTosPathEffect); }
Factory getFactory() const override { return nullptr; }
diff --git a/tests/RectTest.cpp b/tests/RectTest.cpp
index 820586c3c6..ae54f4b779 100644
--- a/tests/RectTest.cpp
+++ b/tests/RectTest.cpp
@@ -88,3 +88,8 @@ DEF_TEST(Rect, reporter) {
test_stroke_width_clipping(reporter);
test_skbug4406(reporter);
}
+
+DEF_TEST(Rect_grow, reporter) {
+ test_stroke_width_clipping(reporter);
+ test_skbug4406(reporter);
+}
diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp
index 0c0d7ac0a0..34189fa6a4 100644
--- a/tools/debugger/SkDrawCommand.cpp
+++ b/tools/debugger/SkDrawCommand.cpp
@@ -21,6 +21,7 @@
#include "SkPathEffect.h"
#include "SkPicture.h"
#include "SkReadBuffer.h"
+#include "SkRectPriv.h"
#include "SkTextBlob.h"
#include "SkTextBlobRunIterator.h"
#include "SkTHash.h"
@@ -2741,7 +2742,7 @@ bool SkDrawPointsCommand::render(SkCanvas* canvas) const {
bounds.setEmpty();
for (unsigned int i = 0; i < fCount; ++i) {
- bounds.growToInclude(fPts[i]);
+ SkRectPriv::GrowToInclude(&bounds, fPts[i]);
}
xlate_and_scale_to_bounds(canvas, bounds);