diff options
-rw-r--r-- | include/core/SkRect.h | 15 | ||||
-rwxr-xr-x | src/gpu/GrBitmapTextContext.cpp | 2 | ||||
-rwxr-xr-x | src/gpu/GrDistanceFieldTextContext.cpp | 2 |
3 files changed, 15 insertions, 4 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h index c8fc7c65c8..d249aee8d0 100644 --- a/include/core/SkRect.h +++ b/include/core/SkRect.h @@ -702,8 +702,19 @@ struct SK_API SkRect { void join(const SkRect& r) { this->join(r.fLeft, r.fTop, r.fRight, r.fBottom); } - // alias for join() - void growToInclude(const SkRect& r) { this->join(r); } + + void joinNonEmptyArg(const SkRect& r) { + SkASSERT(!r.isEmpty()); + // if we are empty, just assign + if (fLeft >= fRight || fTop >= fBottom) { + *this = r; + } else { + fLeft = SkMinScalar(fLeft, r.left()); + fTop = SkMinScalar(fTop, r.top()); + fRight = SkMaxScalar(fRight, r.right()); + fBottom = SkMaxScalar(fBottom, r.bottom()); + } + } /** * Grow the rect to include the specified (x,y). After this call, the diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp index 422a7e0179..c9cdf2c23f 100755 --- a/src/gpu/GrBitmapTextContext.cpp +++ b/src/gpu/GrBitmapTextContext.cpp @@ -575,7 +575,7 @@ HAS_ATLAS: r.fRight = SkFixedToFloat(vx + width); r.fBottom = SkFixedToFloat(vy + height); - fVertexBounds.growToInclude(r); + fVertexBounds.joinNonEmptyArg(r); size_t vertSize = useColorVerts ? (2 * sizeof(SkPoint) + sizeof(GrColor)) : (2 * sizeof(SkPoint)); diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp index 07e9a2e21d..b565dd63f8 100755 --- a/src/gpu/GrDistanceFieldTextContext.cpp +++ b/src/gpu/GrDistanceFieldTextContext.cpp @@ -411,7 +411,7 @@ HAS_ATLAS: r.fRight = sx + width; r.fBottom = sy + height; - fVertexBounds.growToInclude(r); + fVertexBounds.joinNonEmptyArg(r); size_t vertSize = fUseLCDText ? (2 * sizeof(SkPoint)) : (2 * sizeof(SkPoint) + sizeof(GrColor)); |